From 8b2e8b88f87645f53f03c029d4a680331abbcde0 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Wed, 22 Jul 2020 12:43:54 +0300 Subject: [PATCH] Fix for render camera motion --- applications/gui2/src/views/camera3d.cpp | 14 ++++++++++++++ applications/gui2/src/views/camera3d.hpp | 2 ++ 2 files changed, 16 insertions(+) diff --git a/applications/gui2/src/views/camera3d.cpp b/applications/gui2/src/views/camera3d.cpp index 542fb0e26..06e6e2400 100644 --- a/applications/gui2/src/views/camera3d.cpp +++ b/applications/gui2/src/views/camera3d.cpp @@ -112,11 +112,25 @@ Eigen::Matrix4d CameraView3D::getUpdatedPose() { return t.matrix() * rotmat_; } +void CameraView3D::processAnimation() { + Eigen::Vector3d diff; + diff[0] = neye_[0] - eye_[0]; + diff[1] = neye_[1] - eye_[1]; + diff[2] = neye_[2] - eye_[2]; + + // Only update pose if there is enough motion + if (diff.norm() > 0.01) { + pose_up_to_date_.clear(); + } +} + void CameraView3D::draw(NVGcontext* ctx) { double now = glfwGetTime(); delta_ = now - ftime_; ftime_ = now; + processAnimation(); + // poll from ctrl_ or send on event instead? if (!pose_up_to_date_.test_and_set()) { ctrl_->sendPose(getUpdatedPose()); diff --git a/applications/gui2/src/views/camera3d.hpp b/applications/gui2/src/views/camera3d.hpp index 47132b8c3..b5dda23c2 100644 --- a/applications/gui2/src/views/camera3d.hpp +++ b/applications/gui2/src/views/camera3d.hpp @@ -41,6 +41,8 @@ protected: std::atomic_flag pose_up_to_date_; + void processAnimation(); + public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; -- GitLab