Moderators: Sascha Willems, walaber
void dgBroadPhaseCollision::UpdatePairs (dgBody* const body0, dgSortArray::dgListNode* const srcnode, dgInt32 axisX, dgInt32 threadIndex) const
{
// dgFloat32 val;
// dgBody* body1;
if (!body0->m_collision->IsType (dgCollision::dgCollisionNull_RTTI)) {
dgFloat32 val = body0->m_maxAABB[axisX];
dgCollidingPairCollector& contactPair = *((dgWorld*)this);
for (dgSortArray::dgListNode* node = srcnode; node && (node->GetInfo().m_key < val); node = node->GetNext() ) {
dgBody* const body1 = node->GetInfo().m_body;
if (!body1->m_collision->IsType (dgCollision::dgCollisionNull_RTTI)) {
_ASSERTE (body0 != body1);
if (OverlapTest(body0, body1)) {
contactPair.AddPair(body0, body1, threadIndex);
}
}
}
}
}
void dgBroadPhaseCellPairsWorkerThread::ThreadExecute()
{
dgInt32 step = m_step;
dgInt32 count = m_count;
dgBroadPhaseCollision& broadPhase = *m_world;
for (dgInt32 i = 0; i < count; i += step) {
if(m_pairs[i].m_cell_B) {
broadPhase.UpdatePairs (*m_pairs[i].m_cell_A, *m_pairs[i].m_cell_B, m_threadIndex);
} else {
m_pairs[i].m_cell_A->UpdateAutoPair(m_world, m_threadIndex);
}
}
}
DEMO_GRAVITY = -9.8
// 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);
}
rvangaal wrote:A frozen object though seem to NEVER go to sleep! This is why the AABB keeps getting called.
rvangaal wrote:A point though; in the documentation (Wiki) for NewtonBodySetFreezeState, it states:
"If some other body collide or is connected to a frozen body,
the entire island become dynamic again, but only while they are connected to an non-frozen body.
When they lose the contact they become frozen again."
rvangaal wrote:- is it by design that a frozen body never goes to sleep? (if so, why?)
int IslandCallBack(const NewtonWorld* const newtonWorld, const void* islandHandle, int bodyCount)
{
dVector minP(1.0e10f, 1.0e10f, 1.0e10f, 0.0f);
dVector maxP(-1.0e10f, -1.0e10f, -1.0e10f, 0.0f);
for (int i = 0; i < bodyCount; i ++) {}
NewtonBody* const body = NewtonIslandGetBody (island, i);
//check if this body si of special interst, for example teh bod is a car
if (IsSpecialBody(body)) {
return 1;
}
dVector p0;
dVector p1;
NewtonIslandGetBodyAABB (island, i, &p0.m_x, &p1.m_x);
for (int j = 0; j < 3; j ++) {
minP[j] = GetMin (minP[j], p0[j]);
maxP[j] = GetMax (minP[j], p1[j]);
}
}
return CameraFrustrumCheck (minP, maxP);
}
Julio Jerez wrote:No a frozeen body sodul aloway be forced sleep, and only be dynamica if it is in contact with anoeth active body.
teh momen eteh frozzen body loas it conetion to any active body it will that body and all oteh frozen body it is in contact with will stop being simulatete.
Like I say this is a special feature that may no be what you want.
for example say a cone in lifted on the air, because it si frozzen it will not move,
say you hit it, then teh collison life teh cone even higher, by nwi the cone is not torchig anthing so it will be supended in th air.
So is the preformanace acceptable now?
void dgBodyMasterList::AttachConstraint(dgConstraint* const constraint, dgBody* const body0, dgBody* const srcbody1)
{
_ASSERTE (body0);
dgBody* body1 = srcbody1;
if (!body1) {
body1 = body0->GetWorld()->GetSentinelBody();
constraint->m_isUnilateral = true;
}
_ASSERTE (body1);
constraint->m_body0 = body0;
constraint->m_body1 = body1;
constraint->m_link0 = body0->m_masterNode->GetInfo().AddJoint (constraint, body1);
constraint->m_link1 = body1->m_masterNode->GetInfo().AddJoint (constraint, body0);
// note this is in observation (to prevent bodies from not going to sleep inside triggers
// body0->m_equilibrium = body0->m_invMass.m_w ? false : true;
// body1->m_equilibrium = body1->m_invMass.m_w ? false : true;
body0->Unfreeze();
body1->Unfreeze();
m_constraintCount = m_constraintCount + 1;
}
Users browsing this forum: No registered users and 2 guests