Torque3D Documentation / _generateds / decomposePoly.h

decomposePoly.h

Engine/source/math/util/decomposePoly.h

More...

Classes:

Detailed Description

 1
 2#ifndef DECOMPOSE_POLY_H
 3#define DECOMPOSE_POLY_H
 4
 5#include "core/util/tVector.h"
 6#include "math/mathTypes.h"
 7#include "math/mPoint3.h"
 8
 9struct twoIndices{
10   U8 i1, i2;
11
12public:
13   twoIndices();
14   twoIndices(U8 a, U8 b);
15   bool operator==(const twoIndices&) const;
16};
17
18inline bool twoIndices::operator==(const twoIndices& _test) const
19{
20   return ((i1 == _test.i1) && (i2 == _test.i2) || (i1 == _test.i2) && (i2 == _test.i1));
21}
22
23
24class decompTri
25{
26private:
27
28   U8 mVertIdx[3];
29
30public:
31
32   decompTri();
33   void setVert(U8 val, U8 idx);
34   U8 getVert(U8 idx);
35   twoIndices getOtherVerts(U8 idx);
36   void orderVerts();
37};
38
39class decompPoly
40{
41private:
42
43   Vector<Point3F>      mVertList;
44   Vector<twoIndices>   mEdgeList;
45   Vector<U8>           mInsideVerts;
46   Vector<decompTri>    mTris;
47
48   decompTri            mTestTri;
49
50protected:
51
52   void initEdgeList();
53   bool sameSide(Point3F &p1, Point3F &p2, Point3F &l1, Point3F &l2);
54   bool isInside(decompTri &tri, U8 vertIdx);
55   U8 leftmost();
56   U8 rightmost();
57   U8 uppermost();
58   U8 lowermost();
59   twoIndices findEdges(U8 idx, bool &notUnique);
60   decompTri formTriFromEdges(U8 idx1, U8 idx2);
61   twoIndices leftmostInsideVerts(U8 idx1, U8 idx2);
62   twoIndices rightmostInsideVerts(U8 idx1, U8 idx2);
63   twoIndices uppermostInsideVerts(U8 idx1, U8 idx2);
64   twoIndices lowermostInsideVerts(U8 idx1, U8 idx2);
65   void findPointsInside();
66   void addRemoveEdge(U8 idx1, U8 idx2);
67   bool isVertInEdgeList(U8 idx);
68
69public:
70
71   void addVert(Point3F &newVert);
72   Point3F getVert(U8 idx);
73   void newPoly();
74   U8 getNumVerts() { return mVertList.size(); }
75   U32 getNumTris() { return mTris.size(); }
76   U8 getTriIdx(U32 tri, U8 idx);
77   bool checkEdgeLength(F32 len);
78   bool decompose();
79
80};
81
82#endif
83