diff --git a/applications/gui2/src/views/camera3d.cpp b/applications/gui2/src/views/camera3d.cpp index 542fb0e26f28450619f4d5522a1ebc170ff7e48e..06e6e2400433ae81d1ad6a70e4ecc1c824868f17 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 47132b8c356e236b90cbe9d8ebe39e473c7b0a71..b5dda23c2efec1f9ba78a1ffdf6ed021b8a250bd 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 };