diff --git a/Blocks3D.vcproj b/Blocks3D.vcproj index ed1e501..806210b 100644 --- a/Blocks3D.vcproj +++ b/Blocks3D.vcproj @@ -631,6 +631,14 @@ + + + + - - - - + + + + - - - - +#include "DatamodelV2/Instance.h" #include "DatamodelV2/PartInstance.h" -class XplicitNgine +class XplicitNgine : Instance { public: XplicitNgine(); diff --git a/src/source/Application.cpp b/src/source/Application.cpp index fb8ec39..a3e5341 100644 --- a/src/source/Application.cpp +++ b/src/source/Application.cpp @@ -188,9 +188,6 @@ void Application::onInit() { _dataModel->setName("undefined"); _dataModel->font = g_fntdominant; g_dataModel = _dataModel; - - _xplicitNgine = new XplicitNgine(); - g_xplicitNgine = _xplicitNgine; #ifdef LEGACY_LOAD_G3DFUN_LEVEL // Anchored this baseplate for XplicitNgine tests @@ -305,7 +302,7 @@ void Application::onLogic() { for(size_t i = 0; i < _dataModel->getWorkspace()->partObjects.size(); i++) { PartInstance* partInstance = _dataModel->getWorkspace()->partObjects[i]; - _xplicitNgine->createBody(partInstance); + _dataModel->getEngine()->createBody(partInstance); } } diff --git a/src/source/DataModelV2/DataModelInstance.cpp b/src/source/DataModelV2/DataModelInstance.cpp index 989bc9c..a3cfa20 100644 --- a/src/source/DataModelV2/DataModelInstance.cpp +++ b/src/source/DataModelV2/DataModelInstance.cpp @@ -33,7 +33,21 @@ DataModelInstance::DataModelInstance(void) _loadedFileName="..//skooter.rbxm"; listicon = 5; running = false; + xplicitNgine = NULL; + resetEngine(); +} +void DataModelInstance::resetEngine() +{ + if(xplicitNgine != NULL) + delete xplicitNgine; + xplicitNgine = new XplicitNgine(); + g_xplicitNgine = xplicitNgine; +} + +XplicitNgine * DataModelInstance::getEngine() +{ + return xplicitNgine; } void DataModelInstance::toggleRun() @@ -47,6 +61,7 @@ bool DataModelInstance::isRunning() DataModelInstance::~DataModelInstance(void) { + delete xplicitNgine; } #ifdef _DEBUG @@ -448,6 +463,7 @@ bool DataModelInstance::load(const char* filename, bool clearObjects) std::string hname = sfilename.substr(begin); std::string tname = hname.substr(0, hname.length() - 5); name = tname; + resetEngine(); return true; } else diff --git a/src/source/XplicitNgine/XplicitNgine.cpp b/src/source/XplicitNgine/XplicitNgine.cpp index 4f4cc01..98a86fd 100644 --- a/src/source/XplicitNgine/XplicitNgine.cpp +++ b/src/source/XplicitNgine/XplicitNgine.cpp @@ -16,6 +16,8 @@ XplicitNgine::XplicitNgine() contactgroup = dJointGroupCreate(0); dWorldSetGravity(physWorld, 0, -0.5, 0); + + this->name = "PhysicsService"; //dGeomID ground_geom = dCreatePlane(physSpace, 0, 1, 0, 0); } @@ -41,14 +43,16 @@ void collisionCallback(void *data, dGeomID o1, dGeomID o2) n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact)); if (n > 0) { for (i=0; iphysGeom[0], partInstance->physBody); } else { - if(partInstance->anchored) - return; - - const dReal* physPosition = dBodyGetPosition(partInstance->physBody); - - // TODO: Rotation code - // Probably should be done AFTER we get physics KINDA working!!! - const dReal* physRotation = dGeomGetRotation(partInstance->physGeom[0]); - //partInstance->setPosition(Vector3(physPosition[0], physPosition[1], physPosition[2])); - partInstance->setCFrame(CoordinateFrame( - Matrix3(physRotation[0],physRotation[1],physRotation[2], - physRotation[4],physRotation[5],physRotation[6], - physRotation[8],physRotation[9],physRotation[10]), - Vector3(physPosition[0], physPosition[1], physPosition[2]))); + if(!partInstance->anchored) + { + const dReal* physPosition = dBodyGetPosition(partInstance->physBody); + + // TODO: Rotation code + // Probably should be done AFTER we get physics KINDA working!!! + const dReal* physRotation = dGeomGetRotation(partInstance->physGeom[0]); + //partInstance->setPosition(Vector3(physPosition[0], physPosition[1], physPosition[2])); + partInstance->setCFrame(CoordinateFrame( + Matrix3(physRotation[0],physRotation[1],physRotation[2], + physRotation[4],physRotation[5],physRotation[6], + physRotation[8],physRotation[9],physRotation[10]), + Vector3(physPosition[0], physPosition[1], physPosition[2]))); + } } - dWorldQuickStep(physWorld,0.05); + dWorldQuickStep(physWorld,0.05F); dJointGroupEmpty(contactgroup); } \ No newline at end of file