rayxuln / spine-runtime-for-godot

This project is a module for godot that allows it to load/play Spine skeleton animation.
MIT License
93 stars 22 forks source link

Code optimization #8

Closed scottkunkel closed 4 years ago

scottkunkel commented 4 years ago

Code optimization results in twice the fps when running 20 objects. Results may vary.

Initial draw in gen_mesh turns out to be not needed. Editor and runtime functionality not influenced by it.

Array.pushback performs a resize every time which is expensive. Exchanged for one resize and directly set the value at a specific place.

Two expensive operations can still be improved: Ref<ArrayMesh> array_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); drops fps by half array_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, as); is also expensive