HomeWildfire Games

Cache the model-animation bounds more efficiently.

Description

Cache the model-animation bounds more efficiently.

To render models, we need to know the maximum bounds it takes over the course of an animation. This depends only on the ModelDef and the AnimationDef (and thus the SkeletonDef).
Currently, we recompute this data for each model, which is inefficient.
Caching it in ModelDef is faster, particularly avoiding lag spikes at game start on some maps.
The animations are referred by a unique ID to avoid pointer-related issues. I would have preferred weak_ptr, but that cannot be stably hashed for now.

While at it, switch to unique_ptr/vectors.

Differential Revision: https://code.wildfiregames.com/D2967

Event Timeline

vladislavbelov added inline comments.
/ps/trunk/source/graphics/ModelDef.cpp
50

Code logic duplication, put in const u32 animationIndex = anim ? anim->m_UID : 0.

53

The same.

62

The same.

/ps/trunk/source/graphics/SkeletonAnimDef.h
99

Bad code, shouldn't be exposed to header. Also doesn't follow CC.

wraitii marked 4 inline comments as done.May 5 2021, 4:40 PM