Split track animation with physical or graphical objects
This commit is contained in:
parent
510d221fbc
commit
359c468604
@ -70,8 +70,15 @@ ThreeDAnimation::~ThreeDAnimation()
|
||||
// ----------------------------------------------------------------------------
|
||||
/** 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 scale = m_object->getScale();
|
||||
|
||||
|
@ -68,13 +68,12 @@ private:
|
||||
*/
|
||||
bool m_important_animation;
|
||||
|
||||
|
||||
public:
|
||||
ThreeDAnimation(const XMLNode &node, TrackObject* object);
|
||||
virtual ~ThreeDAnimation();
|
||||
virtual void update(float dt) {}
|
||||
// ------------------------------------------------------------------------
|
||||
void updateWithWorldTicks();
|
||||
void updateWithWorldTicks(bool with_physics);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if a collision with this object should
|
||||
* trigger a rescue. */
|
||||
|
@ -530,6 +530,7 @@ void TrackObject::updateGraphics(float dt)
|
||||
{
|
||||
if (m_presentation) m_presentation->updateGraphics(dt);
|
||||
if (m_physical_object) m_physical_object->updateGraphics(dt);
|
||||
if (m_animator) m_animator->updateWithWorldTicks(false/*has_physics*/);
|
||||
} // update
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -540,7 +541,7 @@ void TrackObject::update(float dt)
|
||||
{
|
||||
if (m_presentation) m_presentation->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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user