lo-th / phy

Physics for three. Game engine
https://lo-th.github.io/phy/
MIT License
521 stars 44 forks source link

phy.add contact callback is called for all contacts when using Havok #15

Open fatbatman opened 1 year ago

fatbatman commented 1 year ago

phy.add({ type:'contact', b1:obj1.name, b2:'obj2.name, callback: someCallback })

In Havok someCallback is called for all collisions involving obj1, not just those involving obj2 but arg.hit is always false.

Phsyx works as expected

Rapier, seems to always have arg.hit == true

Also, including all details of the contact in the collision callback argument is probably needed in most real world uses - body1, body2, position, velocity etc

fatbatman commented 1 year ago

Are there any work arounds for this?

lo-th commented 1 year ago

yep i will make demo about that and standardize the process for all engine

brandon-lb commented 1 year ago

Actually, for me Havok worker "Character" example never calls any trigger. You can verify this by adding console logs to showContact and triggerContact and switching between PhysX and Havok.

brandon-lb commented 1 year ago

By the way, I actually want to get a list of all items that are colliding with a given mesh. Any idea the best way to do that?

brandon-lb commented 1 year ago

Sorry to pile on, but I also noticed both the point and normal arrays on a hit are always [0,0,0] as well.

fatbatman commented 1 year ago

What's the recommended way to access the underlying physics engine so I can register a contact listeners directly as a workaround for now?

lo-th commented 1 year ago

contact is add to havok trigger is not constant ? i search why collision return need more research but is in good way

fatbatman commented 1 year ago

It work better In the latest version with Havok - arg.hit is set correctly

I noticed b1, b2 must be in a specific order though

phy.add({ type:'contact', b1:'box1', b2:'sensor1', callback: trigContact}) //is called and arg.hit is set correctly phy.add({ type:'contact', b1:'box2', b2:'sensor1', callback: trigContact}) //is called and arg.hit is set correctly

//This behaves differently: phy.add({ type:'contact', b1:'sensor1', b2:'box1', callback: trigContact}) //is called and arg.hit is set correctly phy.add({ type:'contact', b1:'sensor1', b2:'box2', callback: trigContact}) //# IS NEVER CALLED #

contact point and normal information still isn't present.

Some way of register for all contacts of a given object using a wildcard would be useful.

fatbatman commented 1 year ago

Using Havok contact events don't get triggered after registering more than about ~146.
This in a scene with about 160 rigid bodies in total.

lo-th commented 1 year ago

mm ok i can increase contact

fatbatman commented 1 year ago

Is it possible to have wildcard for all contacts from an objects? as currently I have to register an object, e.g. a bullet, against all possible targets.
Also an ability to remove the contact.

lo-th commented 1 year ago

problem is with worker i have to limite message and return array i will think about that

fatbatman commented 1 year ago

I see you increased the number of contacts that can be supported.
This means it lasts longer, but then runs out as old ones never get cleaned up. However, I can remove the contacts based on their name, but it means I need to store a mapping of those contact pairs relevant to each body.