Fix crashes

This commit is contained in:
Vulpovile
2022-10-06 06:15:05 -07:00
parent b01f5765b1
commit 15dc340a10
3 changed files with 23 additions and 23 deletions

View File

@@ -49,16 +49,12 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="2" Optimization="2"
InlineFunctionExpansion="2" InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="&quot;.\src\include&quot;" AdditionalIncludeDirectories="&quot;.\src\include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
StringPooling="true" StringPooling="true"
RuntimeLibrary="2" RuntimeLibrary="2"
EnableFunctionLevelLinking="true" EnableFunctionLevelLinking="true"
FloatingPointModel="0"
PrecompiledHeaderFile=".\Release/Blocks3D.pch" PrecompiledHeaderFile=".\Release/Blocks3D.pch"
AssemblerListingLocation=".\Release/" AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/" ObjectFile=".\Release/"
@@ -86,11 +82,6 @@
ProgramDatabaseFile=".\Release/Blocks3D.pdb" ProgramDatabaseFile=".\Release/Blocks3D.pdb"
SubSystem="2" SubSystem="2"
StackReserveSize="16777216" StackReserveSize="16777216"
Driver="0"
OptimizeReferences="2"
EnableCOMDATFolding="2"
OptimizeForWindows98="2"
LinkTimeCodeGeneration="1"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
@@ -748,10 +739,6 @@
RelativePath=".\src\include\ToolEnum.h" RelativePath=".\src\include\ToolEnum.h"
> >
</File> </File>
<File
RelativePath=".\src\include\versioning.h"
>
</File>
<File <File
RelativePath=".\src\include\VS2005CompatShim.h" RelativePath=".\src\include\VS2005CompatShim.h"
> >

View File

@@ -117,7 +117,10 @@ void PartInstance::setSurface(int face, Enum::SurfaceType::Value surface)
void PartInstance::setParent(Instance* prnt) void PartInstance::setParent(Instance* prnt)
{ {
g_dataModel->getEngine()->deleteBody(this); if(this->physBody != NULL)
{
g_dataModel->getEngine()->deleteBody(this);
}
Instance * cparent = getParent(); Instance * cparent = getParent();
while(cparent != NULL) while(cparent != NULL)
{ {
@@ -202,8 +205,11 @@ void PartInstance::setSize(Vector3 newSize)
size = Vector3(sizex, sizey, sizez); size = Vector3(sizex, sizey, sizez);
g_dataModel->getEngine()->deleteBody(this); if(this->physBody != NULL)
g_dataModel->getEngine()->createBody(this); {
g_dataModel->getEngine()->deleteBody(this);
g_dataModel->getEngine()->createBody(this);
}
} }
Vector3 PartInstance::getSize() Vector3 PartInstance::getSize()
{ {
@@ -224,8 +230,11 @@ void PartInstance::setShape(Enum::Shape::Value shape)
this->shape = shape; this->shape = shape;
this->setSize(this->getSize()); this->setSize(this->getSize());
} }
g_dataModel->getEngine()->deleteBody(this); if(this->physBody != NULL)
g_dataModel->getEngine()->createBody(this); {
g_dataModel->getEngine()->deleteBody(this);
g_dataModel->getEngine()->createBody(this);
}
changed = true; changed = true;
} }
@@ -238,8 +247,11 @@ void PartInstance::setPosition(Vector3 pos)
void PartInstance::setAnchored(bool anchored) void PartInstance::setAnchored(bool anchored)
{ {
this->anchored = anchored; this->anchored = anchored;
g_dataModel->getEngine()->deleteBody(this); if(this->physBody != NULL)
g_dataModel->getEngine()->createBody(this); {
g_dataModel->getEngine()->deleteBody(this);
g_dataModel->getEngine()->createBody(this);
}
} }
bool PartInstance::isAnchored() bool PartInstance::isAnchored()

View File

@@ -11,6 +11,7 @@
XplicitNgine::XplicitNgine() XplicitNgine::XplicitNgine()
{ {
physWorld = dWorldCreate(); physWorld = dWorldCreate();
physSpace = dHashSpaceCreate(0); physSpace = dHashSpaceCreate(0);
contactgroup = dJointGroupCreate(0); contactgroup = dJointGroupCreate(0);
@@ -19,7 +20,7 @@ XplicitNgine::XplicitNgine()
dWorldSetAutoDisableFlag(physWorld, 1); dWorldSetAutoDisableFlag(physWorld, 1);
dWorldSetAutoDisableLinearThreshold(physWorld, 0.5F); dWorldSetAutoDisableLinearThreshold(physWorld, 0.5F);
dWorldSetAutoDisableAngularThreshold(physWorld, 0.5F); dWorldSetAutoDisableAngularThreshold(physWorld, 0.5F);
dWorldSetAutoDisableSteps(physWorld, 40); dWorldSetAutoDisableSteps(physWorld, 20);
this->name = "PhysicsService"; this->name = "PhysicsService";
//dGeomID ground_geom = dCreatePlane(physSpace, 0, 1, 0, 0); //dGeomID ground_geom = dCreatePlane(physSpace, 0, 1, 0, 0);
@@ -39,6 +40,7 @@ void collisionCallback(void *data, dGeomID o1, dGeomID o2)
dBodyID b1 = dGeomGetBody(o1); dBodyID b1 = dGeomGetBody(o1);
dBodyID b2 = dGeomGetBody(o2); dBodyID b2 = dGeomGetBody(o2);
if (b1 && b2 && dAreConnected(b1, b2)) if (b1 && b2 && dAreConnected(b1, b2))
return; return;
@@ -170,7 +172,6 @@ void XplicitNgine::createBody(PartInstance* partInstance)
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};
dGeomSetRotation(partInstance->physGeom[0], rotation); dGeomSetRotation(partInstance->physGeom[0], rotation);
dBodySetRotation(partInstance->physBody, rotation); dBodySetRotation(partInstance->physBody, rotation);