MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / buildBox

Method buildBox

Engine/source/collision/polytope.cpp:48–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46// Box should be axis aligned in the transform space provided.
47
48void Polytope::buildBox(const MatrixF& transform,const Box3F& box)
49{
50 // Box is assumed to be axis aligned in the source space.
51 // Transform into geometry space
52 Point3F xvec,yvec,zvec,min;
53 transform.getColumn(0,&xvec);
54 xvec *= box.len_x();
55 transform.getColumn(1,&yvec);
56 yvec *= box.len_y();
57 transform.getColumn(2,&zvec);
58 zvec *= box.len_z();
59 transform.mulP(box.minExtents,&min);
60
61 // Initial vertices
62 mVertexList.setSize(8);
63 mVertexList[0].point = min;
64 mVertexList[1].point = min + yvec;
65 mVertexList[2].point = min + xvec + yvec;
66 mVertexList[3].point = min + xvec;
67 mVertexList[4].point = mVertexList[0].point + zvec;
68 mVertexList[5].point = mVertexList[1].point + zvec;
69 mVertexList[6].point = mVertexList[2].point + zvec;
70 mVertexList[7].point = mVertexList[3].point + zvec;
71 S32 i;
72 for (i = 0; i < 8; i++)
73 mVertexList[i].side = 0;
74
75 // Initial faces
76 mFaceList.setSize(6);
77 for (S32 f = 0; f < 6; f++) {
78 Face& face = mFaceList[f];
79 face.original = true;
80 face.vertex = 0;
81 }
82
83 mFaceList[0].plane.set(mVertexList[0].point,xvec);
84 mFaceList[0].plane.invert();
85 mFaceList[1].plane.set(mVertexList[2].point,yvec);
86 mFaceList[2].plane.set(mVertexList[2].point,xvec);
87 mFaceList[3].plane.set(mVertexList[0].point,yvec);
88 mFaceList[3].plane.invert();
89 mFaceList[4].plane.set(mVertexList[0].point,zvec);
90 mFaceList[4].plane.invert();
91 mFaceList[5].plane.set(mVertexList[4].point,zvec);
92
93 // Initial edges
94 mEdgeList.setSize(12);
95 Edge* edge = mEdgeList.begin();
96 S32 nextEdge = 0;
97 for (i = 0; i < 4; i++) {
98 S32 n = (i == 3)? 0: i + 1;
99 S32 p = (i == 0)? 3: i - 1;
100 edge->vertex[0] = i;
101 edge->vertex[1] = n;
102 edge->face[0] = i;
103 edge->face[1] = 4;
104 edge->next = ++nextEdge;
105 edge++;

Callers 7

findGroundContactMethod · 0.45
findCollisionMethod · 0.45
onAddMethod · 0.45
findGroundContactMethod · 0.45
findCollisionMethod · 0.45
updatePosMethod · 0.45
_moveMethod · 0.45

Calls 10

getColumnMethod · 0.80
mulPMethod · 0.80
len_xMethod · 0.45
len_yMethod · 0.45
len_zMethod · 0.45
setSizeMethod · 0.45
setMethod · 0.45
invertMethod · 0.45
beginMethod · 0.45
lastMethod · 0.45

Tested by

no test coverage detected