Now I'm with a really strange question.
This is the whole code of the callback. Let's me say that everything is fine, no problem at all.
Pay attention to
- Code: Select all
dVector omega.
Can you believe that if I DECLARE it my airlift car disappears?
Yes, that's right, I don't make anything with it, if I declare, my airlift disappears.
But, I found a even strange solution:
Declare it after the line
- Code: Select all
nWorld = NewtonBodyGetWorld (body);
Someone can explain me that? Is a Newton bug or a compiler bug?
I'm using the old Dev-C++ .
- Code: Select all
void applyGenericForce (const NewtonBody* body, dFloat timestep, int thread)
{
dFloat mass;
dFloat Ixx;
dFloat Iyy;
dFloat Izz;
NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
dVector force (0.0f, mass * GRAVITY, 0.0f);
// Calculate lifter
NewtonWorld * nWorld;
dFloat liftForce;
dFloat liftHeight;
dFloat normal;
int faceHit;
dVector shipPosit;
dVector shipDownward;
dVector torque;
dVector omega; //<<<<<<<<<-----------------------------------------------------------
dMatrix bodyMatrix;
NewtonCollision * shipCol;
RayCastInfo info (body);
nWorld = NewtonBodyGetWorld (body);
if (mass == 1500.0f && ship.lifter == true) // Isso significa que é a nave
{
NewtonBodyGetMatrix (body, &bodyMatrix[0][0]);
shipCol = NewtonBodyGetCollision (body);
// ship lifter
shipPosit = bodyMatrix.m_posit + dVector(0,1.0,0);
shipDownward = bodyMatrix.TransformVector (dVector (0,-1,0));
NewtonWorldRayCast (nWorld, &shipPosit[0], &shipDownward[0], RayCastInfo::RayCast, &info, NULL);
liftHeight = info.parametro;
liftForce = ship.liftPower * (1/liftHeight + 0.1);
// ship thruster
dVector thrust (0.0f, 0.0f, 1.0f);
thrust = thrust.Scale(ship.thruster);
thrust = bodyMatrix.TransformVector(thrust);
force.m_x = thrust.m_x;
force.m_z = thrust.m_z;
force.m_y = force.m_y + liftForce;
// ship steering
dVector steer (0.0f, 1.0f, 0.0f);
steer = steer.Scale(ship.steer);
steer = bodyMatrix.TransformVector(steer);
torque = steer;
}
NewtonBodySetForce (body, &force.m_x);
NewtonBodySetTorque (body, &torque.m_x);
}