Skip to content
Snippets Groups Projects
Commit cdcc0cb2 authored by Felix de las Pozas's avatar Felix de las Pozas
Browse files

Small camera animation code cleanup.

parent 111ba292
No related branches found
No related tags found
No related merge requests found
...@@ -121,12 +121,12 @@ namespace neurotessmesh ...@@ -121,12 +121,12 @@ namespace neurotessmesh
const auto position = _boundingBox.center(); const auto position = _boundingBox.center();
const auto radius = _boundingBox.radius( ) / FOV; const auto radius = _boundingBox.radius( ) / FOV;
animate(position, radius); animateCamera(position, radius);
} }
void Scene::cameraPosition(const Eigen::Vector3f &position, const float radius, const Eigen::Matrix3f &rotation) void Scene::cameraPosition(const Eigen::Vector3f &position, const float radius, const Eigen::Matrix3f &rotation)
{ {
animatePosition(position, radius, rotation, true); animateCamera(position, radius, rotation, true);
} }
nlgeometry::AxisAlignedBoundingBox Scene::computeBoundingBox( nlgeometry::AxisAlignedBoundingBox Scene::computeBoundingBox(
...@@ -355,7 +355,7 @@ namespace neurotessmesh ...@@ -355,7 +355,7 @@ namespace neurotessmesh
mode( Scene::EDITION ); mode( Scene::EDITION );
std::vector< unsigned int >indices = { id_ }; std::vector< unsigned int >indices = { id_ };
auto aabb = computeBoundingBox( indices ); auto aabb = computeBoundingBox( indices );
animate(aabb.center(), aabb.radius( ) / sin( _camera->camera()->fieldOfView())); animateCamera(aabb.center(), aabb.radius( ) / sin( _camera->camera()->fieldOfView()));
} }
else else
_editNeuron = nullptr; _editNeuron = nullptr;
...@@ -366,7 +366,7 @@ namespace neurotessmesh ...@@ -366,7 +366,7 @@ namespace neurotessmesh
unsigned int Scene::numEditMorphologyNeurites( void ) const unsigned int Scene::numEditMorphologyNeurites( void ) const
{ {
if ( _editNeuron ) if ( _editNeuron )
return ( unsigned int )_editNeuron->morphology( )->neurites( ).size( ); return static_cast<unsigned int>(_editNeuron->morphology( )->neurites( ).size( ));
return 0; return 0;
} }
...@@ -445,21 +445,15 @@ namespace neurotessmesh ...@@ -445,21 +445,15 @@ namespace neurotessmesh
if ( indices_.size( ) > 0 ) if ( indices_.size( ) > 0 )
{ {
auto aabb = computeBoundingBox( indices_ ); auto aabb = computeBoundingBox( indices_ );
animate( aabb.center( ), aabb.radius( ) / sin( _camera->camera()->fieldOfView())); animateCamera( aabb.center( ), aabb.radius( ) / sin( _camera->camera()->fieldOfView()));
} }
else else
{ {
animate( _boundingBox.center( ), _boundingBox.radius( ) / sin( _camera->camera()->fieldOfView())); animateCamera( _boundingBox.center( ), _boundingBox.radius( ) / sin( _camera->camera()->fieldOfView()));
} }
} }
void Scene::animate(const Eigen::Vector3f &position, const float radius) void Scene::animateCamera(const Eigen::Vector3f &position, const float radius, const Eigen::Matrix3f &rotation,
{
const auto rotation = Eigen::Matrix3f::Zero();
animatePosition(position, radius, rotation, false);
}
void Scene::animatePosition(const Eigen::Vector3f &position, const float radius, const Eigen::Matrix3f &rotation,
bool rotAnimation) bool rotAnimation)
{ {
if(_camera->isAniming()) if(_camera->isAniming())
...@@ -469,8 +463,7 @@ namespace neurotessmesh ...@@ -469,8 +463,7 @@ namespace neurotessmesh
} }
constexpr float CAMERA_ANIMATION_DURATION = 2.f; constexpr float CAMERA_ANIMATION_DURATION = 2.f;
const auto rotInterpolation = rotAnimation ? reto::CameraAnimation::LINEAR : reto::CameraAnimation::NONE;
auto rotInterpolation = rotAnimation ? reto::CameraAnimation::LINEAR : reto::CameraAnimation::NONE;
_animation = new reto::CameraAnimation(reto::CameraAnimation::LINEAR, _animation = new reto::CameraAnimation(reto::CameraAnimation::LINEAR,
rotInterpolation, rotInterpolation,
...@@ -487,5 +480,4 @@ namespace neurotessmesh ...@@ -487,5 +480,4 @@ namespace neurotessmesh
_camera->startAnim(_animation); _camera->startAnim(_animation);
} }
} }
...@@ -215,19 +215,17 @@ namespace neurotessmesh ...@@ -215,19 +215,17 @@ namespace neurotessmesh
NEUROTESSMESH_API NEUROTESSMESH_API
void focusOnIndices( const std::vector< unsigned int >& indices_ ); void focusOnIndices( const std::vector< unsigned int >& indices_ );
protected: protected:
/** \brief Animates the camera to the given position and radius.
* \param[in] position Focus position.
* \param[in] radius Aperture radius.
*
*/
void animate(const Eigen::Vector3f &position, const float radius);
/** \brief Animates the camera to the given position, radius and rotation. /** \brief Animates the camera to the given position, radius and rotation.
* \param[in] position Focus position. * \param[in] position Focus position.
* \param[in] radius Aperture radius. * \param[in] radius Aperture radius.
* \param[in] rotation Camera rotation matrix. * \param[in] rotation Camera rotation matrix.
* \param[in] rotAnimation true to animate rotation and false otherwise.
*
*/ */
void animatePosition(const Eigen::Vector3f &position, const float radius, const Eigen::Matrix3f &rotation, bool rotAnimation); void animateCamera(const Eigen::Vector3f &position,
const float radius,
const Eigen::Matrix3f &rotation = Eigen::Matrix3f::Zero(),
bool rotAnimation = false);
//! Scene mode //! Scene mode
TSceneMode _mode; TSceneMode _mode;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment