mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +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
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue