I’m trying to optimize memory churning in a debug physics view that I’m creating (see this post and playgound.
In a memory allocation snapshot when PhysicsBodies are still active, a loop that synchronizes the debug mesh visualization with the physics body’s position and rotation, I use
const btq = this.#havokPlugin._hknp.HP_Body_GetQTransform(bidTuple);
// we could assign btq objects directly,
// but copying using fromArray *might* avoid continuous object creation
dm.position.fromArray(btq[1][0]);
dm.rotationQuaternion.fromArray(btq[1][1]);
It looks like HP_Body_GetQTransform() is internally allocating on each call either the btq array itself or the arrays within it.
Is there a way to retrieve a body’s position and rotation from the Havok Engine itself without any new allocations? If I can get the pairing of BodyId to position and rotation, I could accomodate retrieving in bulk.