Split track animation with physical or graphical objects

This commit is contained in:
Benau 2018-10-12 00:55:37 +08:00
parent 510d221fbc
commit 359c468604
3 changed files with 11 additions and 4 deletions

View File

@ -70,8 +70,15 @@ ThreeDAnimation::~ThreeDAnimation()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Updates position and rotation of this model. Called once per time step. /** Updates position and rotation of this model. Called once per time step.
*/ */
void ThreeDAnimation::updateWithWorldTicks() void ThreeDAnimation::updateWithWorldTicks(bool has_physics)
{ {
const bool track_object_with_physics =
m_object->getPhysicalObject() != nullptr;
if ((has_physics && !track_object_with_physics) ||
(!has_physics && track_object_with_physics))
return;
Vec3 xyz = m_object->getPosition(); Vec3 xyz = m_object->getPosition();
Vec3 scale = m_object->getScale(); Vec3 scale = m_object->getScale();

View File

@ -68,13 +68,12 @@ private:
*/ */
bool m_important_animation; bool m_important_animation;
public: public:
ThreeDAnimation(const XMLNode &node, TrackObject* object); ThreeDAnimation(const XMLNode &node, TrackObject* object);
virtual ~ThreeDAnimation(); virtual ~ThreeDAnimation();
virtual void update(float dt) {} virtual void update(float dt) {}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void updateWithWorldTicks(); void updateWithWorldTicks(bool with_physics);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns true if a collision with this object should /** Returns true if a collision with this object should
* trigger a rescue. */ * trigger a rescue. */

View File

@ -530,6 +530,7 @@ void TrackObject::updateGraphics(float dt)
{ {
if (m_presentation) m_presentation->updateGraphics(dt); if (m_presentation) m_presentation->updateGraphics(dt);
if (m_physical_object) m_physical_object->updateGraphics(dt); if (m_physical_object) m_physical_object->updateGraphics(dt);
if (m_animator) m_animator->updateWithWorldTicks(false/*has_physics*/);
} // update } // update
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -540,7 +541,7 @@ void TrackObject::update(float dt)
{ {
if (m_presentation) m_presentation->update(dt); if (m_presentation) m_presentation->update(dt);
if (m_physical_object) m_physical_object->update(dt); if (m_physical_object) m_physical_object->update(dt);
if (m_animator) m_animator->updateWithWorldTicks(); if (m_animator) m_animator->updateWithWorldTicks(true/*has_physics*/);
} // update } // update
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------