ScummVM API documentation
dgMeshEffectSolidTree.h
1 /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
2  *
3  * This software is provided 'as-is', without any express or implied
4  * warranty. In no event will the authors be held liable for any damages
5  * arising from the use of this software.
6  *
7  * Permission is granted to anyone to use this software for any purpose,
8  * including commercial applications, and to alter it and redistribute it
9  * freely, subject to the following restrictions:
10  *
11  * 1. The origin of this software must not be misrepresented; you must not
12  * claim that you wrote the original software. If you use this software
13  * in a product, an acknowledgment in the product documentation would be
14  * appreciated but is not required.
15  *
16  * 2. Altered source versions must be plainly marked as such, and must not be
17  * misrepresented as being the original software.
18  *
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 
22 #ifndef __dgMeshEffectSolidTree_H__
23 #define __dgMeshEffectSolidTree_H__
24 
25 #include "hpl1/engine/libraries/newton/core/dg.h"
26 
27 class dgMeshEffect;
28 class dgMeshTreeCSGFace;
30 
32 public:
33  DG_CLASS_ALLOCATOR(allocator)
34 
35  enum dgPlaneType {
36  m_divider = 1,
37  m_empty,
38  m_solid,
39  };
40 
41  dgMeshEffectSolidTree(dgPlaneType type);
42  dgMeshEffectSolidTree(const dgMeshEffect &mesh, dgEdge *const face);
43  dgMeshEffectSolidTree(const dgHugeVector &plane, dgMemoryAllocator *const allocator);
45 
46  dgHugeVector BuildPlane(const dgMeshEffect &mesh, dgEdge *const face) const;
47  void AddFace(const dgMeshEffect &mesh, dgEdge *const face);
48 
49  dgPlaneType GetPointSide(const dgHugeVector &point) const;
50  dgPlaneType GetFaceSide(const dgMeshTreeCSGFace *const face) const;
51 
52  dgPlaneType m_planeType;
53  dgMeshEffectSolidTree *m_back;
54  dgMeshEffectSolidTree *m_front;
55  dgHugeVector m_plane;
56 };
57 
58 class dgMeshTreeCSGFace : public dgList<dgHugeVector>, public dgRefCounter {
59 public:
60  dgMeshTreeCSGFace(const dgMeshEffect &mesh, dgEdge *const face);
61  dgMeshTreeCSGFace(dgMemoryAllocator *const allocator, dgInt32 count, const dgHugeVector *const points);
62 
63  void Clip(const dgHugeVector &plane, dgMeshTreeCSGFace **leftOut, dgMeshTreeCSGFace **rightOut);
64  void MergeMissingVertex(const dgMeshTreeCSGFace *const face);
65  bool IsPointOnEdge(const dgHugeVector &p0, const dgHugeVector &p1, const dgHugeVector &q) const;
66  bool CheckFaceArea(dgInt32 count, const dgHugeVector *const points) const;
67  dgInt32 RemoveDuplicates(dgInt32 count, dgHugeVector *const points) const;
68 
69  dgHugeVector FaceNormal() const;
70 
71  bool CheckConvex(const dgHugeVector &normal) const;
72 
73 #ifdef _DEBUG
74  dgMatrix DebugMatrix() const;
75  void Trace(const dgMatrix &matrix) const;
76 #endif
77 
78  dgMeshEffectSolidTree::dgPlaneType m_side;
79 };
80 
81 #endif
Definition: dgGoogol.h:77
Definition: dgRefCounter.h:25
Definition: dgPolyhedra.h:61
Definition: dgList.h:33
Definition: dgMeshEffect.h:78
Definition: dgMatrix.h:41
Definition: dgMemory.h:80
Definition: dgMeshEffectSolidTree.h:58
Definition: dgMeshEffectSolidTree.h:31