NvBlastExtTriangleProcessor.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
27 
28 
29 #ifndef NVBLASTEXTTRIANGLEPROCESSOR_H
30 #define NVBLASTEXTTRIANGLEPROCESSOR_H
31 
32 #include <PxVec2.h>
33 #include <PxVec3.h>
34 #include <vector>
35 #include <algorithm>
36 
37 using namespace physx;
38 
39 
40 namespace Nv
41 {
42 namespace Blast
43 {
44 
49 {
50  PxVec3 points[3];
51  TrPrcTriangle(PxVec3 a = PxVec3(0.0f), PxVec3 b = PxVec3(0.0f), PxVec3 c = PxVec3(0.0f))
52  {
53  points[0] = a;
54  points[1] = b;
55  points[2] = c;
56  }
57 
59  {
60  points[0] = b.points[0];
61  points[1] = b.points[1];
62  points[2] = b.points[2];
63  return *this;
64  }
65 
67  {
68  points[0] = b.points[0];
69  points[1] = b.points[1];
70  points[2] = b.points[2];
71  }
72  PxVec3 getNormal() const
73  {
74  return (points[1] - points[0]).cross(points[2] - points[0]);
75  }
76 };
77 
82 {
83  PxVec2 points[3];
84  TrPrcTriangle2d(PxVec2 a = PxVec2(0.0f), PxVec2 b = PxVec2(0.0f), PxVec2 c = PxVec2(0.0f))
85  {
86  points[0] = a;
87  points[1] = b;
88  points[2] = c;
89  }
90 
92  {
93  points[0] = b.points[0];
94  points[1] = b.points[1];
95  points[2] = b.points[2];
96  return *this;
97  }
98 
100  {
101  points[0] = b.points[0];
102  points[1] = b.points[1];
103  points[2] = b.points[2];
104  }
105 };
106 
108 {
109  public:
112 
113 
124  uint32_t getTriangleIntersection(TrPrcTriangle& a, TrPrcTriangle2d& aProjected, TrPrcTriangle& b, PxVec3& centroid,
125  std::vector<PxVec3>& intersectionBuffer, PxVec3 normal);
126 
133  bool triangleBoundingBoxIntersection(TrPrcTriangle2d& a, TrPrcTriangle2d& b);
134 
135 
142  uint32_t isPointInside(const PxVec2& point, const TrPrcTriangle2d& triangle);
143 
153  uint32_t getSegmentIntersection(const PxVec2& s1, const PxVec2& e1, const PxVec2& s2, const PxVec2& e2, PxF32& t1);
154 
158  void sortToCCW(std::vector<PxVec3>& points, PxVec3& normal);
159 
166  void buildConvexHull(std::vector<PxVec3>& points, std::vector<PxVec3>& convexHull, const PxVec3& normal);
167 };
168 
169 } // namespace Blast
170 } // namespace Nv
171 
172 
173 #endif // NVBLASTEXTTRIANGLEPROCESSOR_H
Definition: NvBlastExtApexSharedParts.h:34
PxVec3 getNormal() const
Definition: NvBlastExtTriangleProcessor.h:72
TrPrcTriangle2d(const TrPrcTriangle2d &b)
Definition: NvBlastExtTriangleProcessor.h:99
NV_INLINE float normal(const float a[3], float r[3])
Definition: NvBlastMath.h:93
~TriangleProcessor()
Definition: NvBlastExtTriangleProcessor.h:111
PxVec2 points[3]
Definition: NvBlastExtTriangleProcessor.h:83
Definition: NvBlastExtTriangleProcessor.h:48
Definition: NvBlastExtTriangleProcessor.h:107
TriangleProcessor()
Definition: NvBlastExtTriangleProcessor.h:110
Definition: NvBlastExtTriangleProcessor.h:81
TrPrcTriangle2d(PxVec2 a=PxVec2(0.0f), PxVec2 b=PxVec2(0.0f), PxVec2 c=PxVec2(0.0f))
Definition: NvBlastExtTriangleProcessor.h:84
TrPrcTriangle & operator=(const TrPrcTriangle &b)
Definition: NvBlastExtTriangleProcessor.h:58
PxVec3 points[3]
Definition: NvBlastExtTriangleProcessor.h:50
TrPrcTriangle2d operator=(const TrPrcTriangle2d &b)
Definition: NvBlastExtTriangleProcessor.h:91
TrPrcTriangle(const TrPrcTriangle &b)
Definition: NvBlastExtTriangleProcessor.h:66
TrPrcTriangle(PxVec3 a=PxVec3(0.0f), PxVec3 b=PxVec3(0.0f), PxVec3 c=PxVec3(0.0f))
Definition: NvBlastExtTriangleProcessor.h:51
Definition: NvBlastArray.h:37