RavEngine
Loading...
Searching...
No Matches
PxMeshScale.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_MESH_SCALE_H
30#define PX_MESH_SCALE_H
35#include "common/PxPhysXCommonConfig.h"
36#include "foundation/PxMat33.h"
37#include "foundation/PxAssert.h"
38
41#define PX_MESH_SCALE_MIN 1e-6f
42
45#define PX_MESH_SCALE_MAX 1e6f
46
47#if !PX_DOXYGEN
48namespace physx
49{
50#endif
51
69{
70//= ATTENTION! =====================================================================================
71// Changing the data layout of this class breaks the binary serialization format. See comments for
72// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
73// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
74// accordingly.
75//==================================================================================================
76public:
80 PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(): scale(1.0f), rotation(PxIdentity)
81 {
82 }
83
87 explicit PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(PxReal r): scale(r), rotation(PxIdentity)
88 {
89 }
90
94 PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(const PxVec3& s)
95 {
96 scale = s;
97 rotation = PxQuat(PxIdentity);
98 }
99
103 PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(const PxVec3& s, const PxQuat& r)
104 {
105 PX_ASSERT(r.isUnit());
106 scale = s;
107 rotation = r;
108 }
109
113 PX_CUDA_CALLABLE PX_FORCE_INLINE bool isIdentity() const
114 {
115 return (scale.x == 1.0f && scale.y == 1.0f && scale.z == 1.0f);
116 }
117
121 PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale getInverse() const
122 {
123 return PxMeshScale(PxVec3(1.0f/scale.x, 1.0f/scale.y, 1.0f/scale.z), rotation);
124 }
125
129 PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33 toMat33() const
130 {
131 PxMat33 rot(rotation);
132 PxMat33 trans = rot.getTranspose();
133 trans.column0 *= scale[0];
134 trans.column1 *= scale[1];
135 trans.column2 *= scale[2];
136 return trans * rot;
137 }
138
142 PX_CUDA_CALLABLE PX_FORCE_INLINE bool hasNegativeDeterminant() const
143 {
144 return (scale.x * scale.y * scale.z < 0.0f);
145 }
146
147 PxVec3 transform(const PxVec3& v) const
148 {
150 }
151
152 bool isValidForTriangleMesh() const
153 {
154 PxVec3 absXYZ = scale.abs();
155 return (absXYZ.maxElement() <= PX_MESH_SCALE_MAX) && (absXYZ.minElement() >= PX_MESH_SCALE_MIN);
156 }
157
158 bool isValidForConvexMesh() const
159 {
161 }
162
165};
166
167#if !PX_DOXYGEN
168} // namespace physx
169#endif
170
172#endif
3x3 matrix class
Definition PxMat33.h:91
A class expressing a nonuniform scaling transformation.
Definition PxMeshScale.h:69
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(PxReal r)
Constructor from scalar.
Definition PxMeshScale.h:87
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isIdentity() const
Returns true if the scaling is an identity transformation.
Definition PxMeshScale.h:113
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale getInverse() const
Returns the inverse of this scaling transformation.
Definition PxMeshScale.h:121
PxQuat rotation
The orientation of the scaling axes.
Definition PxMeshScale.h:164
PX_CUDA_CALLABLE PX_FORCE_INLINE bool hasNegativeDeterminant() const
Returns true if combination of negative scale components will cause the triangle normal to flip....
Definition PxMeshScale.h:142
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(const PxVec3 &s, const PxQuat &r)
Constructor to initialize to arbitrary scaling.
Definition PxMeshScale.h:103
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale()
Constructor initializes to identity scale.
Definition PxMeshScale.h:80
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(const PxVec3 &s)
Constructor to initialize to arbitrary scale and identity scale rotation.
Definition PxMeshScale.h:94
PxVec3 scale
A nonuniform scaling.
Definition PxMeshScale.h:163
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33 toMat33() const
Converts this transformation to a 3x3 matrix representation.
Definition PxMeshScale.h:129
This is a quaternion class. For more information on quaternion mathematics consult a mathematics sour...
Definition PxQuat.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3 rotate(const PxVec3 &v) const
Definition PxQuat.h:287
PX_CUDA_CALLABLE bool isUnit() const
returns true if finite and magnitude is close to unit
Definition PxQuat.h:132
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3 rotateInv(const PxVec3 &v) const
Definition PxQuat.h:301
3 Element vector class.
Definition PxVec3.h:50
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 multiply(const PxVec3 &a) const
a[i] * b[i], for all i.
Definition PxVec3.h:336
PX_CUDA_CALLABLE PX_FORCE_INLINE float minElement() const
returns MIN(x, y, z);
Definition PxVec3.h:352
PX_CUDA_CALLABLE PX_FORCE_INLINE float maxElement() const
returns MAX(x, y, z);
Definition PxVec3.h:368
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 abs() const
returns absolute values of components;
Definition PxVec3.h:376
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
#define PX_MESH_SCALE_MIN
Minimum allowed absolute magnitude for each of mesh scale's components (x,y,z).
Definition PxMeshScale.h:41
#define PX_MESH_SCALE_MAX
Maximum allowed absolute magnitude for each of mesh scale's components (x,y,z).
Definition PxMeshScale.h:45
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39