Havok PhysicsBody.shape identity

In Havok, it appears that the PhysicsShape that you set on a PhysicsBody is not the same object if you read it back. That’s a bit confusing itself, but even more so is that isTrigger on the returned object is wrong. I wasted a good hour on that today, since I was making decisions on how to initialize objects based on whether they were a trigger or not.

Here’s an illustrative PG. The console output at this point in time is:

trigger shapes are not-equal
triggerBody.shape.isTrigger false

Is this working as intended? Cheers!

Ok, I found another curious thing, that may be related (or maybe not).

I get collision callbacks between my character and a trigger. The TRIGGER_ENTERED always fires, but the COLLISION_STARTED sometimes also fires when I update the character’s position (with disabledPreStep off, of course). I updated the playground to make this behavior apparent, too. Just click the mouse to update the sphere’s position randomly.

Hello!

getShape indeed returns a new object every time it is called: https://github.com/BabylonJS/Babylon.js/blob/1d039a781a1d7a0b2c361817ce1cfcea88174274/packages/dev/core/src/Physics/v2/Plugins/havokPlugin.ts#L666, but they refer to the same underlying Havok object, so if you compare their _pluginData[0] property (it’s a array with one member), it is the same: PhysicsShape identity 2 | Babylon.js Playground (babylonjs.com)

About the collision event firing, I’m not sure about why this behavior is happening, let me tag @eoin to check :slight_smile:

Got it. So, since the newly instantiated getShape object doesn’t expose the correct value of isTrigger, should that getter property be removed? Otherwise it’s going to confuse a lot more people than just me. :sweat_smile:

The collision event thing is a bug, nice catch! Will get it fixed in the next plugin version.

1 Like