afritz1 / OpenTESArena

Open-source re-implementation of The Elder Scrolls: Arena.
MIT License
915 stars 68 forks source link

Entity animation refactor #186

Closed afritz1 closed 3 years ago

afritz1 commented 3 years ago

Changed from a slightly-monolithic EntityAnimationData pattern to a shared + unique pattern with EntityAnimationDefinition and EntityAnimationInstance.

Realized during this that the EntityManager shouldn't be returning Entity pointers at all because Entity::setPosition() can cause their chunk coordinate to change which could make the entity instance move around in memory and cause the entity pointer to become dangling. So in the near future: add some EntityRef wrapper like the texture manager.

afritz1 commented 3 years ago

Did a little bit of testing with an address sanitizer turned on in GCC but it didn't catch the problem with Entity::setPosition() being before the animInst updating, so that's a little unsettling. Anyway, merging this in now and should do the entity ref stuff soon.