Fixed removing anchored parts when sleeping
This commit is contained in:
@@ -15,5 +15,5 @@ public:
|
|||||||
void step(float stepSize);
|
void step(float stepSize);
|
||||||
void createBody(PartInstance* partInstance);
|
void createBody(PartInstance* partInstance);
|
||||||
void deleteBody(PartInstance* partInstance);
|
void deleteBody(PartInstance* partInstance);
|
||||||
void updateBody(PartInstance* partInstance, CoordinateFrame * cFrame);
|
void updateBody(PartInstance* partInstance);
|
||||||
};
|
};
|
||||||
@@ -254,8 +254,8 @@ CoordinateFrame PartInstance::getCFrame()
|
|||||||
}
|
}
|
||||||
void PartInstance::setCFrame(CoordinateFrame coordinateFrame)
|
void PartInstance::setCFrame(CoordinateFrame coordinateFrame)
|
||||||
{
|
{
|
||||||
g_dataModel->getEngine()->updateBody(this, &coordinateFrame);
|
|
||||||
setCFrameNoSync(coordinateFrame);
|
setCFrameNoSync(coordinateFrame);
|
||||||
|
g_dataModel->getEngine()->updateBody(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartInstance::setCFrameNoSync(CoordinateFrame coordinateFrame)
|
void PartInstance::setCFrameNoSync(CoordinateFrame coordinateFrame)
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ XplicitNgine::XplicitNgine()
|
|||||||
|
|
||||||
dWorldSetGravity(physWorld, 0, -9.8F, 0);
|
dWorldSetGravity(physWorld, 0, -9.8F, 0);
|
||||||
dWorldSetAutoDisableFlag(physWorld, 1);
|
dWorldSetAutoDisableFlag(physWorld, 1);
|
||||||
dWorldSetAutoDisableLinearThreshold(physWorld, 0.05F);
|
dWorldSetAutoDisableLinearThreshold(physWorld, 0.5F);
|
||||||
dWorldSetAutoDisableAngularThreshold(physWorld, 0.05F);
|
dWorldSetAutoDisableAngularThreshold(physWorld, 0.5F);
|
||||||
dWorldSetAutoDisableSteps(physWorld, 40);
|
dWorldSetAutoDisableSteps(physWorld, 40);
|
||||||
|
|
||||||
this->name = "PhysicsService";
|
this->name = "PhysicsService";
|
||||||
@@ -75,11 +75,15 @@ void XplicitNgine::deleteBody(PartInstance* partInstance)
|
|||||||
if(partInstance->physBody != NULL)
|
if(partInstance->physBody != NULL)
|
||||||
{
|
{
|
||||||
dBodyEnable(partInstance->physBody);
|
dBodyEnable(partInstance->physBody);
|
||||||
if(partInstance->isAnchored())
|
|
||||||
dGeomSetBody(partInstance->physGeom[0], partInstance->physBody);
|
|
||||||
dGeomEnable(partInstance->physGeom[0]);
|
dGeomEnable(partInstance->physGeom[0]);
|
||||||
//createBody(partInstance);
|
if(partInstance->isAnchored())
|
||||||
//step(0.5F);
|
{
|
||||||
|
dGeomSetBody(partInstance->physGeom[0], partInstance->physBody);
|
||||||
|
dGeomEnable(partInstance->physGeom[0]);
|
||||||
|
updateBody(partInstance);
|
||||||
|
step(0.03F);
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < dBodyGetNumJoints(partInstance->physBody); i++) {
|
for(int i = 0; i < dBodyGetNumJoints(partInstance->physBody); i++) {
|
||||||
dBodyID b1 = dJointGetBody(dBodyGetJoint(partInstance->physBody, i), 0);
|
dBodyID b1 = dJointGetBody(dBodyGetJoint(partInstance->physBody, i), 0);
|
||||||
dBodyID b2 = dJointGetBody(dBodyGetJoint(partInstance->physBody, i), 1);
|
dBodyID b2 = dJointGetBody(dBodyGetJoint(partInstance->physBody, i), 1);
|
||||||
@@ -205,11 +209,11 @@ void XplicitNgine::step(float stepSize)
|
|||||||
//dWorldStep(physWorld, stepSize);
|
//dWorldStep(physWorld, stepSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XplicitNgine::updateBody(PartInstance *partInstance, CoordinateFrame * cFrame)
|
void XplicitNgine::updateBody(PartInstance *partInstance)
|
||||||
{
|
{
|
||||||
if(partInstance->physBody != NULL)
|
if(partInstance->physBody != NULL)
|
||||||
{
|
{
|
||||||
Vector3 position = cFrame->translation;
|
Vector3 position = partInstance->getCFrame().translation;
|
||||||
|
|
||||||
dBodySetPosition(partInstance->physBody,
|
dBodySetPosition(partInstance->physBody,
|
||||||
position[0],
|
position[0],
|
||||||
@@ -219,7 +223,7 @@ void XplicitNgine::updateBody(PartInstance *partInstance, CoordinateFrame * cFra
|
|||||||
dBodyEnable(partInstance->physBody);
|
dBodyEnable(partInstance->physBody);
|
||||||
dGeomEnable(partInstance->physGeom[0]);
|
dGeomEnable(partInstance->physGeom[0]);
|
||||||
|
|
||||||
Matrix3 g3dRot = cFrame->rotation;
|
Matrix3 g3dRot = partInstance->getCFrame().rotation;
|
||||||
float rotation [12] = { g3dRot[0][0], g3dRot[0][1], g3dRot[0][2], 0,
|
float rotation [12] = { g3dRot[0][0], g3dRot[0][1], g3dRot[0][2], 0,
|
||||||
g3dRot[1][0], g3dRot[1][1], g3dRot[1][2], 0,
|
g3dRot[1][0], g3dRot[1][1], g3dRot[1][2], 0,
|
||||||
g3dRot[2][0], g3dRot[2][1], g3dRot[2][2], 0};
|
g3dRot[2][0], g3dRot[2][1], g3dRot[2][2], 0};
|
||||||
|
|||||||
Reference in New Issue
Block a user