eugene.litvinov Posted May 5, 2011 Posted May 5, 2011 We use Body::getNumContacts() in our update() function to determine, how much contacts have our physical object. This is working with non physical objects fine, but when our physical object contact with other physical objects, then Body::getNumContacts() always return 0. How can we determine it? Thanks
ulf.schroeter Posted May 5, 2011 Posted May 5, 2011 We use Body::getNumContacts() in our update() function to determine, how much contacts have our physical object. This is working with non physical objects fine, but when our physical object contact with other physical objects, then Body::getNumContacts() always return 0. How can we determine it? Thanks Maybe doing it in world::flush() instead of world::update(). See updated UNIGINE programming documentation for details
eugene.litvinov Posted May 6, 2011 Author Posted May 6, 2011 Maybe doing it in world::flush() instead of world::update(). See updated UNIGINE programming documentation for details Sorry, I confuse, I used flush(). I try to use update() instead of flush(), but result the same: count of contacts is zero for physical_objects - physical_objects contact, and more than zero for physical_objects - static_object contact.
frustum Posted May 13, 2011 Posted May 13, 2011 Use contact callbacks instead of querying number of contacts manually. Two bodies share single contact and this contact can belong to any body from this pair. Body contact callback function receives second body reference. You should check contacts from both bodies in callback function.
eugene.litvinov Posted May 17, 2011 Author Posted May 17, 2011 In our current task we don't need know about contacted bodies, we only need to know, number of contacts > 0 or equal to 0, but we need know about it in flush() method for some "active" object. Yours profiler show dynamic contacts in real-time, maybe you can add ability to detect count of dynamic contacts to Body::getNumContacts() or to other function? Why this function register only static contacts? Thanks.
manguste Posted July 26, 2011 Posted July 26, 2011 In our current task we don't need know about contacted bodies, we only need to know, number of contacts > 0 or equal to 0, but we need know about it in flush() method for some "active" object. Yours profiler show dynamic contacts in real-time, maybe you can add ability to detect count of dynamic contacts to Body::getNumContacts() or to other function? Why this function register only static contacts? Thanks. Try using setContactCallback() for you purpose. It will give the same result, i.e. indicate if a body has any contacts. getNumContacts() returns only those contacts that are solved by the current body during physics simulation. Otherwise, if each body registered the contact it would have required twice as many calculations and double-checking what body is solving the contact, which is bad from the performance point of view.
Recommended Posts