From 33810ab0ae32d9626eb702b3238717056190ecd0 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Sun, 26 Jul 2020 13:44:29 +0300
Subject: [PATCH] Attempt to simplify pch

---
 components/codecs/include/ftl/codecs/channels.hpp       | 2 +-
 components/codecs/include/ftl/codecs/codecs.hpp         | 2 +-
 components/codecs/include/ftl/codecs/packet.hpp         | 2 +-
 components/common/cpp/CMakeLists.txt                    | 2 --
 components/operators/src/poser.cpp                      | 2 +-
 components/renderers/cpp/src/CUDARender.cpp             | 4 ++--
 components/streams/src/builder.cpp                      | 2 --
 components/streams/src/renderers/screen_render.cpp      | 6 +++++-
 components/structures/CMakeLists.txt                    | 2 --
 components/structures/include/ftl/data/messages.hpp     | 2 +-
 components/structures/include/ftl/data/new_frameset.hpp | 2 +-
 components/structures/src/frameset.cpp                  | 1 -
 12 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/components/codecs/include/ftl/codecs/channels.hpp b/components/codecs/include/ftl/codecs/channels.hpp
index 17197c31b..71c97dc9f 100644
--- a/components/codecs/include/ftl/codecs/channels.hpp
+++ b/components/codecs/include/ftl/codecs/channels.hpp
@@ -2,7 +2,7 @@
 #define _FTL_RGBD_CHANNELS_HPP_
 
 #include <bitset>
-#include <ftl/utility/msgpack.hpp>
+#include <msgpack.hpp>
 
 namespace ftl {
 namespace codecs {
diff --git a/components/codecs/include/ftl/codecs/codecs.hpp b/components/codecs/include/ftl/codecs/codecs.hpp
index ad49ef6e0..68d4591e6 100644
--- a/components/codecs/include/ftl/codecs/codecs.hpp
+++ b/components/codecs/include/ftl/codecs/codecs.hpp
@@ -2,7 +2,7 @@
 #define _FTL_CODECS_BITRATES_HPP_
 
 #include <cstdint>
-#include <ftl/utility/msgpack.hpp>
+#include <msgpack.hpp>
 
 namespace ftl {
 namespace codecs {
diff --git a/components/codecs/include/ftl/codecs/packet.hpp b/components/codecs/include/ftl/codecs/packet.hpp
index f19ffcba2..02d0af71f 100644
--- a/components/codecs/include/ftl/codecs/packet.hpp
+++ b/components/codecs/include/ftl/codecs/packet.hpp
@@ -5,7 +5,7 @@
 #include <vector>
 #include <ftl/codecs/codecs.hpp>
 #include <ftl/codecs/channels.hpp>
-#include <ftl/utility/msgpack.hpp>
+#include <msgpack.hpp>
 
 namespace ftl {
 namespace codecs {
diff --git a/components/common/cpp/CMakeLists.txt b/components/common/cpp/CMakeLists.txt
index f129316c3..71715801d 100644
--- a/components/common/cpp/CMakeLists.txt
+++ b/components/common/cpp/CMakeLists.txt
@@ -30,8 +30,6 @@ target_include_directories(ftlcommon PUBLIC
 target_link_libraries(ftlcommon Threads::Threads Eigen3::Eigen ${OS_LIBS} ${OpenCV_LIBS} ${URIPARSER_LIBRARIES} ${CUDA_LIBRARIES})
 
 target_precompile_headers(ftlcommon
-	PRIVATE include/ftl/utility/msgpack.hpp
-	PRIVATE include/ftl/utility/msgpack_optional.hpp
 	PRIVATE include/ftl/cuda_common.hpp
 	PRIVATE include/loguru.hpp
 )
diff --git a/components/operators/src/poser.cpp b/components/operators/src/poser.cpp
index 32948ac4a..2f8a166cf 100644
--- a/components/operators/src/poser.cpp
+++ b/components/operators/src/poser.cpp
@@ -113,7 +113,7 @@ bool Poser::apply(ftl::rgbd::FrameSet &in, ftl::rgbd::FrameSet &out, cudaStream_
         auto p = pose_db__.find(pose_ident);
         if (p != pose_db__.end()) {
 			(*p).second.locked = config()->value("locked",false);
-            in.pose = (config()->value("inverse",false)) ? (*p).second.pose.inverse() : (*p).second.pose;
+            in.cast<ftl::rgbd::Frame>().setPose() = (config()->value("inverse",false)) ? (*p).second.pose.inverse() : (*p).second.pose;
         } else {
             LOG(WARNING) << "Pose not found: " << pose_ident;
         }
diff --git a/components/renderers/cpp/src/CUDARender.cpp b/components/renderers/cpp/src/CUDARender.cpp
index c72d3dace..b3d07ac29 100644
--- a/components/renderers/cpp/src/CUDARender.cpp
+++ b/components/renderers/cpp/src/CUDARender.cpp
@@ -647,7 +647,7 @@ bool CUDARender::submit(ftl::data::FrameSet *in, Channels<0> chans, const Eigen:
 	bool success = true;
 
 	try {
-		_renderPass1(in->pose);
+		_renderPass1(t);
 		//cudaSafeCall(cudaStreamSynchronize(stream_));
 	} catch (const ftl::exception &e) {
 		LOG(ERROR) << "Exception in render: " << e.what();
@@ -657,7 +657,7 @@ bool CUDARender::submit(ftl::data::FrameSet *in, Channels<0> chans, const Eigen:
 	auto &s = sets_.emplace_back();
 	s.fs = in;
 	s.channels = chans;
-	s.transform = in->pose;
+	s.transform = t;
 
 	last_frame_ = scene_->timestamp();
 	scene_ = nullptr;
diff --git a/components/streams/src/builder.cpp b/components/streams/src/builder.cpp
index f4fc8b6a4..486823cad 100644
--- a/components/streams/src/builder.cpp
+++ b/components/streams/src/builder.cpp
@@ -104,7 +104,6 @@ std::shared_ptr<ftl::data::FrameSet> LocalBuilder::_allocate(int64_t timestamp)
 	newf->count = size_;
 	newf->mask = 0xFF;
 	newf->clearFlags();
-	newf->pose.setIdentity();
 	return newf;
 }
 
@@ -423,7 +422,6 @@ std::shared_ptr<ftl::data::FrameSet> ForeignBuilder::_addFrameset(int64_t timest
 	newf->count = 0;
 	newf->mask = 0;
 	newf->clearFlags();
-	newf->pose.setIdentity();  // Deprecated?
 
 	// Insertion sort by timestamp
 	for (auto i=framesets_.begin(); i!=framesets_.end(); i++) {
diff --git a/components/streams/src/renderers/screen_render.cpp b/components/streams/src/renderers/screen_render.cpp
index c60bd7047..d06d57f7f 100644
--- a/components/streams/src/renderers/screen_render.cpp
+++ b/components/streams/src/renderers/screen_render.cpp
@@ -133,10 +133,14 @@ bool ScreenRender::retrieve(ftl::data::Frame &frame_out) {
 			for (auto &s : sets) {
 				if (s->frameset() == my_id_) continue;  // Skip self
 
+				Eigen::Matrix4d pose;
+				pose.setIdentity();
+				if (s->hasChannel(Channel::Pose)) pose = s->cast<ftl::rgbd::Frame>().getPose();
+
 				if (!data_only) renderer_->submit(
 					s.get(),
 					ftl::codecs::Channels<0>(ftl::codecs::Channel::Colour),
-					s->pose);
+					pose);
 			}
 
 			if (!data_only) renderer_->render();
diff --git a/components/structures/CMakeLists.txt b/components/structures/CMakeLists.txt
index 95cd7ba29..c291ee7e2 100644
--- a/components/structures/CMakeLists.txt
+++ b/components/structures/CMakeLists.txt
@@ -7,8 +7,6 @@ target_include_directories(ftldata PUBLIC
 target_link_libraries(ftldata ftlcommon Eigen3::Eigen ftlcodecs)
 
 target_precompile_headers(ftldata
-	PRIVATE ../common/cpp/include/ftl/utility/msgpack.hpp
-	PRIVATE ../common/cpp/include/ftl/utility/msgpack_optional.hpp
 	PRIVATE ../common/cpp/include/ftl/cuda_common.hpp
 	PRIVATE ../common/cpp/include/loguru.hpp
 	PRIVATE include/ftl/data/new_frame.hpp
diff --git a/components/structures/include/ftl/data/messages.hpp b/components/structures/include/ftl/data/messages.hpp
index f4e9ba27e..9f90263fd 100644
--- a/components/structures/include/ftl/data/messages.hpp
+++ b/components/structures/include/ftl/data/messages.hpp
@@ -1,7 +1,7 @@
 #ifndef _FTL_DATA_MESSAGES_HPP_
 #define _FTL_DATA_MESSAGES_HPP_
 
-#include <ftl/utility/msgpack.hpp>
+#include <msgpack.hpp>
 
 namespace ftl {
 namespace data {
diff --git a/components/structures/include/ftl/data/new_frameset.hpp b/components/structures/include/ftl/data/new_frameset.hpp
index 368456f20..096a02c2f 100644
--- a/components/structures/include/ftl/data/new_frameset.hpp
+++ b/components/structures/include/ftl/data/new_frameset.hpp
@@ -45,7 +45,7 @@ class FrameSet : public ftl::data::Frame {
 	std::atomic<int> flush_count;		// How many channels have been flushed
 	SHARED_MUTEX smtx;
 
-	Eigen::Matrix4d pose;  // Set to identity by default.
+	//Eigen::Matrix4d pose;  // Set to identity by default.
 
 	inline int64_t localTimestamp() const { return timestamp() + originClockDelta; }
 
diff --git a/components/structures/src/frameset.cpp b/components/structures/src/frameset.cpp
index d804c68d0..4d4cbc88b 100644
--- a/components/structures/src/frameset.cpp
+++ b/components/structures/src/frameset.cpp
@@ -50,7 +50,6 @@ void ftl::data::FrameSet::moveTo(ftl::data::FrameSet &fs) {
 	fs.count = static_cast<int>(count);
 	fs.flags_ = (int)flags_;
 	fs.mask = static_cast<unsigned int>(mask);
-	fs.pose = pose;
 	fs.frames = std::move(frames);
 
 	count = 0;
-- 
GitLab