3
\$\begingroup\$

The problem is how many times the matrices representing the bones (for animation and rendering) of an entity get calculated.

If i have these components:

  • Position
  • Skeleton (holds matrices for bones)
  • Physics
  • Animation

When the physics get's updated, the position is changed to move the entity. This sends a message, that position has changed. The skeleton takes note and updates the matrices for the changed position (and potentially rotation). The animations are then updated in a separate system, the skeleton then gets updated and changed again. So essentially the matrices are being updated twice (unnecessarily) instead of just once.

Am i going about this the wrong way? Is this just the price of having everything disjoint?

\$\endgroup\$
1
\$\begingroup\$

The question really revolves around whether to process events right away or delay them until it is a system's turn. This is a case where you would use the latter.

Instead of updating the animation's matrix right after an event, instead mark in your animation system that a change has occurred and needs to be processed for that node. Then only during the Animation system's turn, run a computation update across those nodes which were marked dirty earlier. This allows for the skeleton to be modified multiple times in multiple places ahead of the animation system update, and the animation system to only update its relevant data once, for example, right before rendering happens.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.