Merge pull request #92 from Vulpovile/feature/physics_sleep

Physics improvement and optimization
This commit is contained in:
Vulpovile
2022-10-05 14:36:00 -07:00
committed by GitHub
4 changed files with 9 additions and 9 deletions

View File

@@ -81,7 +81,7 @@
SuppressStartupBanner="true" SuppressStartupBanner="true"
ProgramDatabaseFile=".\Release/Blocks3D.pdb" ProgramDatabaseFile=".\Release/Blocks3D.pdb"
SubSystem="2" SubSystem="2"
StackReserveSize="8388608" StackReserveSize="16777216"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
@@ -180,7 +180,7 @@
GenerateDebugInformation="true" GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/Blocks3D.pdb" ProgramDatabaseFile=".\Debug/Blocks3D.pdb"
SubSystem="1" SubSystem="1"
StackReserveSize="8388608" StackReserveSize="16777216"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool

View File

@@ -346,9 +346,9 @@ void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
p->setParent(NULL); p->setParent(NULL);
delete p; delete p;
} }
for(int i = 0; i < 10; i++) for(int i = 0; i < 4; i++)
{ {
_dataModel->getEngine()->step(0.05F); _dataModel->getEngine()->step(0.03F);
} }
onLogic(); onLogic();

View File

@@ -259,7 +259,6 @@ void PartInstance::setCFrameNoSync(CoordinateFrame coordinateFrame)
{ {
cFrame = coordinateFrame; cFrame = coordinateFrame;
position = coordinateFrame.translation; position = coordinateFrame.translation;
changed = true;
} }
bool PartInstance::collides(PartInstance * part) bool PartInstance::collides(PartInstance * part)

View File

@@ -15,7 +15,7 @@ XplicitNgine::XplicitNgine()
physSpace = dHashSpaceCreate(0); physSpace = dHashSpaceCreate(0);
contactgroup = dJointGroupCreate(0); contactgroup = dJointGroupCreate(0);
dWorldSetGravity(physWorld, 0, -0.5, 0); dWorldSetGravity(physWorld, 0, -9.8, 0);
dWorldSetAutoDisableFlag(physWorld, 1); dWorldSetAutoDisableFlag(physWorld, 1);
dWorldSetAutoDisableLinearThreshold(physWorld, 0.05F); dWorldSetAutoDisableLinearThreshold(physWorld, 0.05F);
dWorldSetAutoDisableAngularThreshold(physWorld, 0.05F); dWorldSetAutoDisableAngularThreshold(physWorld, 0.05F);
@@ -141,7 +141,7 @@ void XplicitNgine::createBody(PartInstance* partInstance)
} }
dMass mass; dMass mass;
mass.setBox(partSize.x, partSize.y, partSize.z, 0.7F); mass.setBox(sqrt(partSize.x*2), sqrt(partSize.y*2), sqrt(partSize.z*2), 0.7F);
dBodySetMass(partInstance->physBody, &mass); dBodySetMass(partInstance->physBody, &mass);
// Debug output // Debug output
@@ -198,8 +198,9 @@ void XplicitNgine::step(float stepSize)
{ {
dJointGroupEmpty(contactgroup); dJointGroupEmpty(contactgroup);
dSpaceCollide (physSpace,0,&collisionCallback); dSpaceCollide (physSpace,0,&collisionCallback);
//dWorldQuickStep(physWorld, stepSize); dWorldQuickStep(physWorld, stepSize);
dWorldStepFast1(physWorld, stepSize, 20); //dWorldStepFast1(physWorld, stepSize*2, 100);
//dWorldStep(physWorld, stepSize);
} }
void XplicitNgine::updateBody(PartInstance *partInstance, CoordinateFrame * cFrame) void XplicitNgine::updateBody(PartInstance *partInstance, CoordinateFrame * cFrame)