PxTriangle.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12 
13 
14 #ifndef PX_PHYSICS_GEOMUTILS_PX_TRIANGLE
15 #define PX_PHYSICS_GEOMUTILS_PX_TRIANGLE
16 
21 #include "foundation/PxVec3.h"
22 
23 #ifndef PX_DOXYGEN
24 namespace physx
25 {
26 #endif
27 
32 {
33  public:
38 
46  PX_FORCE_INLINE PxTriangle(const PxVec3& p0, const PxVec3& p1, const PxVec3& p2)
47  {
48  verts[0] = p0;
49  verts[1] = p1;
50  verts[2] = p2;
51  }
52 
59  {
60  verts[0] = triangle.verts[0];
61  verts[1] = triangle.verts[1];
62  verts[2] = triangle.verts[2];
63  }
64 
69 
73  PxVec3 verts[3];
74 
80  PX_FORCE_INLINE void normal(PxVec3& _normal) const
81  {
82  _normal = (verts[1]-verts[0]).cross(verts[2]-verts[0]);
83  _normal.normalize();
84  }
85 
91 #ifdef __SPU__
92  void denormalizedNormal(PxVec3& _normal) const
93 #else
94  PX_FORCE_INLINE void denormalizedNormal(PxVec3& _normal) const
95 #endif
96  {
97  _normal = (verts[1]-verts[0]).cross(verts[2]-verts[0]);
98  }
99 
105  PX_FORCE_INLINE PxReal area() const
106  {
107  const PxVec3& p0 = verts[0];
108  const PxVec3& p1 = verts[1];
109  const PxVec3& p2 = verts[2];
110  return ((p0 - p1).cross(p0 - p2)).magnitude() * 0.5f;
111  }
112 
113 };
114 
115 
116 #ifndef PX_DOXYGEN
117 }
118 #endif
119 
121 #endif


Copyright © 2008-2015 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com