Menu

#329 CAnimatedMesh getMeshForCurrentFrame cache patch

open
nobody
patch (6)
5
2026-01-23
2026-01-21
viwrap
No

A fix I made for my fork of Irrlicht back in 2021 that avoids animating a mesh twice per frame, of course the cached mesh is discarded when setMesh is called. This should also make a mesh remain consistent if a frame only does rendering and no animation at all.

1 Attachments

Discussion

  • viwrap

    viwrap - 2026-01-21

    i have to stress that this fix is for CAnimatedMeshSceneNode since I seem to have gotten the class name wrong both on the ticket name and patch filename... it's late.

     

    Last edit: viwrap 2026-01-21
  • Michael Zeilfelder

    The problem is if you have 2 nodes using the same mesh but different animations. Then one node suddenly has the wrong animation now. The only way we could cache would be having a frame cache which keeps copies of animated meshes around. Which might be a good idea, but a bit more work. Well, with current animation system at least.

    Note that avoiding double animation if you only gota single instance (or all instances on same frame) is already done for skinned meshes in CSkinnedMesh::animateMesh which checks if the frame changed. Sadly still risks getting animated twice in the above mentioned case, but at least the results stay correct. CAnimatedMeshMD2::updateInterpolationBuffer has a similar check. Didn't check for other formats.

    Still annoying that we have one case where it's animated twice just to get the boundingbox, but I don't have a solution for that right now. What I would do is probably create a mesh copy for each node. Not that much more expensive and then the double animations go away again (at least for those 2 formats).

     
  • viwrap

    viwrap - 2026-01-23

    damn, does that mean animating a mesh involves acutally applying modifications to the underlying mesh resource?

     
  • Michael Zeilfelder

    Yeah, nodes don't make mesh copies for the animations. You can make copies and pass them to nodes, but meshes are indeed modified while they get animated. The unmodified base mesh is only encoded in the weights (for skinned meshes) - and those don't change.

     

Log in to post a comment.