Made XplicitNgine secret instance of DataModel
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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; i<n; i++) {
|
||||
contact[i].surface.mode = dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
|
||||
contact[i].surface.mode = dContactBounce | dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
|
||||
|
||||
// Define contact surface properties
|
||||
contact[i].surface.mu = 0.5;
|
||||
|
||||
contact[i].surface.bounce = 0.5; //Elasticity
|
||||
contact[i].surface.mu = 0.3F; //Friction
|
||||
contact[i].surface.slip1 = 0.0;
|
||||
contact[i].surface.slip2 = 0.0;
|
||||
contact[i].surface.soft_erp = 0.8;
|
||||
contact[i].surface.soft_cfm = 0.01;
|
||||
contact[i].surface.soft_erp = 0.8F;
|
||||
contact[i].surface.soft_cfm = 0.01F;
|
||||
|
||||
// Create joints
|
||||
dJointID c = dJointCreateContact(
|
||||
@@ -119,22 +123,22 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
||||
dGeomSetBody(partInstance->physGeom[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);
|
||||
}
|
||||
Reference in New Issue
Block a user