are you try to wake up two sleep bodies form a joint callback?
by design that's not going to work. in Newton 300 the only call back the gets call for all bodies is Force an true call back.
The force and toque callback is like eh hard beat of a body,
you can do something like
- Code: Select all
// add force and torque to rigid body
void PhysicsApplyGravityForce (const NewtonBody* body, dFloat timestep, int threadIndex)
{
dFloat Ixx;
dFloat Iyy;
dFloat Izz;
dFloat mass;
NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
dVector force (0.0f, mass * DEMO_GRAVITY, 0.0f);
NewtonBodySetForce (body, &force.m_x);
...
// check soemn logic
NewtonBodySetSleepState(body, state ? 1 : 0);
}
A more elegant way to do that is using the new functionality of core 300, by can add a CustomControllerManager
in core 300 these are sub system that control how sub grop of object that share the same proprety are manipulated
basicall you make a class derived from CustomControllerBase
and you add a Manager of type
- Code: Select all
MyWakeController: public CustomControllerBase
{
virtual void PreUpdate (dFloat timestep, int threadIndex)
{
NewtonBodySetSleepState(m_body, 1);
}
virtual void PostUpdate (dFloat timestep, int threadIndex) {}
}
class MyWakupManager: public CustomControllerManager<CustomTriggerController>
{
public:
NEWTON_API MyWakupManager(NewtonWorld* const world);
NEWTON_API virtual ~MyWakupManagerr();
virtual void PostUpdate(dFloat timestep)
{
// bypass the entire Post Update call by not calling the base class
}
virtual void Debug () const {};
NEWTON_API virtual CustomWakeController* CreateTrigger (NetwonBodyt* body);
};
then by adding the bodies that you want to be in no sleeping state to the manager then the will be wake up on the pre Update call
I like the Controller mangers new functionality of Newton because it offer an nom intrusive way to costomize object functionality.
by making multiple controller, for example trigger managarer, rag doll manager, player manager, mouse picked manager, etc bodies can have multiply functionalities
for example a body, can be on a Trigger Volume, and Vortex Volume, being picked, and under Gravity all at the same time
and the manage will handle the transparently, by operating on those bodes as there are part the mamanger with having to code that fuintionality on the body or on the user date that own that controller.