Made anchoring togglable in play mode
This commit is contained in:
@@ -29,7 +29,6 @@ public:
|
|||||||
//Variables
|
//Variables
|
||||||
Color3 color;
|
Color3 color;
|
||||||
bool canCollide;
|
bool canCollide;
|
||||||
bool anchored;
|
|
||||||
dBodyID physBody;
|
dBodyID physBody;
|
||||||
dGeomID physGeom[3];
|
dGeomID physGeom[3];
|
||||||
|
|
||||||
@@ -54,6 +53,8 @@ public:
|
|||||||
void setShape(Enum::Shape::Value shape);
|
void setShape(Enum::Shape::Value shape);
|
||||||
void setChanged();
|
void setChanged();
|
||||||
void setSurface(int face, Enum::SurfaceType::Value surface);
|
void setSurface(int face, Enum::SurfaceType::Value surface);
|
||||||
|
void setAnchored(bool anchored);
|
||||||
|
bool isAnchored();
|
||||||
float getMass();
|
float getMass();
|
||||||
|
|
||||||
//Collision
|
//Collision
|
||||||
@@ -64,6 +65,7 @@ public:
|
|||||||
virtual std::vector<PROPGRIDITEM> getProperties();
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
private:
|
private:
|
||||||
|
bool anchored;
|
||||||
Vector3 position;
|
Vector3 position;
|
||||||
Vector3 size;
|
Vector3 size;
|
||||||
Vector3 velocity;
|
Vector3 velocity;
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ void Application::onInit() {
|
|||||||
test->setPosition(Vector3(0,0,0));
|
test->setPosition(Vector3(0,0,0));
|
||||||
test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(0),toRadians(0)));
|
test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(0),toRadians(0)));
|
||||||
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
||||||
test->anchored = true;
|
test->setAnchored(true);
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->setParent(_dataModel->getWorkspace());
|
test->setParent(_dataModel->getWorkspace());
|
||||||
|
|||||||
@@ -425,8 +425,7 @@ bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
|
|||||||
}
|
}
|
||||||
if(anchoredNode)
|
if(anchoredNode)
|
||||||
{
|
{
|
||||||
printf("AAAAAAAAAAAAAAAAAAAA %s\n", anchoredNode->value());
|
test->setAnchored(stricmp(anchoredNode->value(), "true") == 0);
|
||||||
test->anchored = stricmp(anchoredNode->value(), "true") == 0;
|
|
||||||
}
|
}
|
||||||
test->setSize(Vector3(sizeX,sizeY+_modY,sizeZ));
|
test->setSize(Vector3(sizeX,sizeY+_modY,sizeZ));
|
||||||
test->setName(newName);
|
test->setName(newName);
|
||||||
|
|||||||
@@ -230,9 +230,20 @@ void PartInstance::setPosition(Vector3 pos)
|
|||||||
{
|
{
|
||||||
position = pos;
|
position = pos;
|
||||||
setCFrame(CoordinateFrame(cFrame.rotation, pos));
|
setCFrame(CoordinateFrame(cFrame.rotation, pos));
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PartInstance::setAnchored(bool anchored)
|
||||||
|
{
|
||||||
|
this->anchored = anchored;
|
||||||
|
g_dataModel->getEngine()->deleteBody(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PartInstance::isAnchored()
|
||||||
|
{
|
||||||
|
return this->anchored;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CoordinateFrame PartInstance::getCFrame()
|
CoordinateFrame PartInstance::getCFrame()
|
||||||
{
|
{
|
||||||
return cFrame;
|
return cFrame;
|
||||||
@@ -359,7 +370,7 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
|
|||||||
}
|
}
|
||||||
else if(strcmp(item->lpszPropName, "Anchored") == 0)
|
else if(strcmp(item->lpszPropName, "Anchored") == 0)
|
||||||
{
|
{
|
||||||
anchored= item->lpCurValue == TRUE;
|
setAnchored(item->lpCurValue == TRUE);
|
||||||
}
|
}
|
||||||
else if(strcmp(item->lpszPropName, "Offset") == 0)
|
else if(strcmp(item->lpszPropName, "Offset") == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -141,11 +141,11 @@ void XplicitNgine::createBody(PartInstance* partInstance, float stepSize)
|
|||||||
|
|
||||||
//printf("[XplicitNgine] Created Body for PartInstance\n");
|
//printf("[XplicitNgine] Created Body for PartInstance\n");
|
||||||
|
|
||||||
if(!partInstance->anchored)
|
if(!partInstance->isAnchored())
|
||||||
dGeomSetBody(partInstance->physGeom[0], partInstance->physBody);
|
dGeomSetBody(partInstance->physGeom[0], partInstance->physBody);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(!partInstance->anchored)
|
if(!partInstance->isAnchored())
|
||||||
{
|
{
|
||||||
const dReal* physPosition = dBodyGetPosition(partInstance->physBody);
|
const dReal* physPosition = dBodyGetPosition(partInstance->physBody);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user