mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
Improves logical checks for the default value so it's more sane and stable
Allows creation of polyhedrons via constructor with a origin and vector format, allowing to have default polyhedron values on triggers and physical zones
This commit is contained in:
parent
68ae0ca96d
commit
a0f8b29da7
5 changed files with 63 additions and 2 deletions
|
|
@ -114,6 +114,13 @@ PhysicalZone::PhysicalZone()
|
||||||
force_mag = 0.0f;
|
force_mag = 0.0f;
|
||||||
orient_force = false;
|
orient_force = false;
|
||||||
fade_amt = 1.0f;
|
fade_amt = 1.0f;
|
||||||
|
|
||||||
|
//Default up a basic square
|
||||||
|
Point3F vecs[3] = { Point3F(1.0, 0.0, 0.0),
|
||||||
|
Point3F(0.0, -1.0, 0.0),
|
||||||
|
Point3F(0.0, 0.0, 1.0) };
|
||||||
|
|
||||||
|
mPolyhedron = Polyhedron(Point3F(-0.5, 0.5, 0.0), vecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicalZone::~PhysicalZone()
|
PhysicalZone::~PhysicalZone()
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,13 @@ Trigger::Trigger()
|
||||||
mTripOnce = false;
|
mTripOnce = false;
|
||||||
mTrippedBy = 0xFFFFFFFF;
|
mTrippedBy = 0xFFFFFFFF;
|
||||||
mTripCondition = "";
|
mTripCondition = "";
|
||||||
|
|
||||||
|
//Default up a basic square
|
||||||
|
Point3F vecs[3] = { Point3F(1.0, 0.0, 0.0),
|
||||||
|
Point3F(0.0, -1.0, 0.0),
|
||||||
|
Point3F(0.0, 0.0, 1.0) };
|
||||||
|
|
||||||
|
mTriggerPolyhedron = Polyhedron(Point3F(-0.5, 0.5, 0.0), vecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
Trigger::~Trigger()
|
Trigger::~Trigger()
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ void SimObject::writeFields(Stream &stream, U32 tabStop)
|
||||||
|
|
||||||
//If the field hasn't been changed from the default value, then don't bother writing it out
|
//If the field hasn't been changed from the default value, then don't bother writing it out
|
||||||
const char* defaultValueCheck = defaultObject->getDataField(f->pFieldname, array);
|
const char* defaultValueCheck = defaultObject->getDataField(f->pFieldname, array);
|
||||||
if (defaultValueCheck != '\0' && dStricmp(defaultValueCheck, valCopy) == 0)
|
if (defaultValueCheck && defaultValueCheck[0] != '\0' && dStricmp(defaultValueCheck, valCopy) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
val = valCopy;
|
val = valCopy;
|
||||||
|
|
|
||||||
|
|
@ -307,6 +307,53 @@ struct PolyhedronImpl : public Base
|
||||||
this->mEdgeList = edges;
|
this->mEdgeList = edges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PolyhedronImpl(Point3F origin, Point3F vecs[3])
|
||||||
|
{
|
||||||
|
// This setup goes against conventions for Polyhedrons in that it a) sets up
|
||||||
|
// edges with CCW instead of CW order for face[0] and that it b) lets plane
|
||||||
|
// normals face outwards rather than inwards.
|
||||||
|
|
||||||
|
mPointList.setSize(8);
|
||||||
|
mPointList[0] = origin;
|
||||||
|
mPointList[1] = origin + vecs[0];
|
||||||
|
mPointList[2] = origin + vecs[1];
|
||||||
|
mPointList[3] = origin + vecs[2];
|
||||||
|
mPointList[4] = origin + vecs[0] + vecs[1];
|
||||||
|
mPointList[5] = origin + vecs[0] + vecs[2];
|
||||||
|
mPointList[6] = origin + vecs[1] + vecs[2];
|
||||||
|
mPointList[7] = origin + vecs[0] + vecs[1] + vecs[2];
|
||||||
|
|
||||||
|
Point3F normal;
|
||||||
|
mPlaneList.setSize(6);
|
||||||
|
|
||||||
|
mCross(vecs[2], vecs[0], &normal);
|
||||||
|
mPlaneList[0].set(origin, normal);
|
||||||
|
mCross(vecs[0], vecs[1], &normal);
|
||||||
|
mPlaneList[1].set(origin, normal);
|
||||||
|
mCross(vecs[1], vecs[2], &normal);
|
||||||
|
mPlaneList[2].set(origin, normal);
|
||||||
|
mCross(vecs[1], vecs[0], &normal);
|
||||||
|
mPlaneList[3].set(mPointList[7], normal);
|
||||||
|
mCross(vecs[2], vecs[1], &normal);
|
||||||
|
mPlaneList[4].set(mPointList[7], normal);
|
||||||
|
mCross(vecs[0], vecs[2], &normal);
|
||||||
|
mPlaneList[5].set(mPointList[7], normal);
|
||||||
|
|
||||||
|
mEdgeList.setSize(12);
|
||||||
|
mEdgeList[0].vertex[0] = 0; mEdgeList[0].vertex[1] = 1; mEdgeList[0].face[0] = 0; mEdgeList[0].face[1] = 1;
|
||||||
|
mEdgeList[1].vertex[0] = 1; mEdgeList[1].vertex[1] = 5; mEdgeList[1].face[0] = 0; mEdgeList[1].face[1] = 4;
|
||||||
|
mEdgeList[2].vertex[0] = 5; mEdgeList[2].vertex[1] = 3; mEdgeList[2].face[0] = 0; mEdgeList[2].face[1] = 3;
|
||||||
|
mEdgeList[3].vertex[0] = 3; mEdgeList[3].vertex[1] = 0; mEdgeList[3].face[0] = 0; mEdgeList[3].face[1] = 2;
|
||||||
|
mEdgeList[4].vertex[0] = 3; mEdgeList[4].vertex[1] = 6; mEdgeList[4].face[0] = 3; mEdgeList[4].face[1] = 2;
|
||||||
|
mEdgeList[5].vertex[0] = 6; mEdgeList[5].vertex[1] = 2; mEdgeList[5].face[0] = 2; mEdgeList[5].face[1] = 5;
|
||||||
|
mEdgeList[6].vertex[0] = 2; mEdgeList[6].vertex[1] = 0; mEdgeList[6].face[0] = 2; mEdgeList[6].face[1] = 1;
|
||||||
|
mEdgeList[7].vertex[0] = 1; mEdgeList[7].vertex[1] = 4; mEdgeList[7].face[0] = 4; mEdgeList[7].face[1] = 1;
|
||||||
|
mEdgeList[8].vertex[0] = 4; mEdgeList[8].vertex[1] = 2; mEdgeList[8].face[0] = 1; mEdgeList[8].face[1] = 5;
|
||||||
|
mEdgeList[9].vertex[0] = 4; mEdgeList[9].vertex[1] = 7; mEdgeList[9].face[0] = 4; mEdgeList[9].face[1] = 5;
|
||||||
|
mEdgeList[10].vertex[0] = 5; mEdgeList[10].vertex[1] = 7; mEdgeList[10].face[0] = 3; mEdgeList[10].face[1] = 4;
|
||||||
|
mEdgeList[11].vertex[0] = 7; mEdgeList[11].vertex[1] = 6; mEdgeList[11].face[0] = 3; mEdgeList[11].face[1] = 5;
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the AABB around the polyhedron.
|
/// Return the AABB around the polyhedron.
|
||||||
Box3F getBounds() const
|
Box3F getBounds() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -729,7 +729,7 @@ ImplementEnumType(_TamlFormatMode,
|
||||||
{
|
{
|
||||||
//If the field hasn't been changed from the default value, then don't bother writing it out
|
//If the field hasn't been changed from the default value, then don't bother writing it out
|
||||||
const char* fieldData = defaultObject->getDataField(fieldName, indexBuffer);
|
const char* fieldData = defaultObject->getDataField(fieldName, indexBuffer);
|
||||||
if (fieldData != '\0' && dStricmp(fieldData, pFieldValue) == 0)
|
if (fieldData && fieldData[0] != '\0' && dStricmp(fieldData, pFieldValue) == 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue