diff --git a/Engine/source/T3D/physicalZone.cpp b/Engine/source/T3D/physicalZone.cpp index f3028ee45..9603a4f34 100644 --- a/Engine/source/T3D/physicalZone.cpp +++ b/Engine/source/T3D/physicalZone.cpp @@ -114,6 +114,13 @@ PhysicalZone::PhysicalZone() force_mag = 0.0f; orient_force = false; 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() diff --git a/Engine/source/T3D/trigger.cpp b/Engine/source/T3D/trigger.cpp index 1d075d7c3..bcf85810b 100644 --- a/Engine/source/T3D/trigger.cpp +++ b/Engine/source/T3D/trigger.cpp @@ -173,6 +173,13 @@ Trigger::Trigger() mTripOnce = false; mTrippedBy = 0xFFFFFFFF; 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() diff --git a/Engine/source/console/simObject.cpp b/Engine/source/console/simObject.cpp index 3552f4dd1..e76263fc7 100644 --- a/Engine/source/console/simObject.cpp +++ b/Engine/source/console/simObject.cpp @@ -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 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; val = valCopy; diff --git a/Engine/source/math/mPolyhedron.h b/Engine/source/math/mPolyhedron.h index 4496b219c..e43a0822f 100644 --- a/Engine/source/math/mPolyhedron.h +++ b/Engine/source/math/mPolyhedron.h @@ -307,6 +307,53 @@ struct PolyhedronImpl : public Base 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. Box3F getBounds() const { diff --git a/Engine/source/persistence/taml/taml.cpp b/Engine/source/persistence/taml/taml.cpp index 5200dcf28..a623ba8b1 100644 --- a/Engine/source/persistence/taml/taml.cpp +++ b/Engine/source/persistence/taml/taml.cpp @@ -729,7 +729,7 @@ ImplementEnumType(_TamlFormatMode, { //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); - if (fieldData != '\0' && dStricmp(fieldData, pFieldValue) == 0) + if (fieldData && fieldData[0] != '\0' && dStricmp(fieldData, pFieldValue) == 0) continue; }