Moderators: Sascha Willems, Thomas
aitzolmuelas wrote:The solution I came up with is basically to have actual trigger events/callbacks from within the physics engine itself. This was possible for almost no cost by using the 'valid' flag in the persistent contact pair (true when the shapes collide, not just the broadphase AABBs): when the flag changes value (which the engine checks anyway) if any of the colliding bodies is marked as trigger (this had to be added) then send the appropriate message/callback.
Basically it was possible that a joint was send to be deleted while it contact active flag was true.
This could happen if the pair was no seen by the brad phase and the contact was never validated.
class CustomTriggerController: public CustomControllerBase
{
public:
CUSTOM_JOINTS_API CustomTriggerController();
CUSTOM_JOINTS_API ~CustomTriggerController();
CUSTOM_JOINTS_API void Init (NewtonCollision* const convexShape, const dMatrix& matrix, void* const userData);
CUSTOM_JOINTS_API virtual void PreUpdate(dFloat timestep, int threadIndex);
CUSTOM_JOINTS_API virtual void PostUpdate(dFloat timestep, int threadIndex);
private:
dTree<NewtonBody*,NewtonBody*> m_manifest;
friend class CustomTriggerManager;
};
where do you get the idea of the triggers only having room for 32 objects.
dTree<NewtonBody*,NewtonBody*> m_manifest;
but it would still have to implement the same logic
what is does no has is the we to identify the a graph node as a trigger.
this may no be necessary if each objet can validate it contacts each time the change their transform
at the moment there are too many structure to maintain
Julio Jerez wrote:Basically it was possible that a joint was send to be deleted while it contact active flag was true.
This could happen if the pair was no seen by the brad phase and the contact was never validated.
basically the contact garbage collector, has to simple invalidate the joint and delay it destruction, and that fixed the bug, no need for the call back
void MyThiggerManager::OnDestroyBody (NewtonBody* const body)
{
// body was delete inside a trigger, do what you need to do here
....
//call base class callback
CustomTriggerManager::OnDestroyBody (body);
}
void dgWorld::DestroyBody(dgBody* const body)
{
for (dgListenerList::dgListNode* node = m_postListener.GetLast(); node; node = node->GetPrev()) {
dgListener& listener = node->GetInfo();
if (listener.m_onBodyDestroy) {
listener.m_onBodyDestroy (this, node, body);
}
}
for (dgListenerList::dgListNode* node = m_preListener.GetLast(); node; node = node->GetPrev()) {
dgListener& listener = node->GetInfo();
if (listener.m_onBodyDestroy) {
listener.m_onBodyDestroy (this, node, body);
}
}
Users browsing this forum: No registered users and 4 guests