PxMeshScale.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_NX_MESHSCALE
15 #define PX_PHYSICS_NX_MESHSCALE
16 
21 #include "foundation/PxMat33.h"
22 
23 #ifndef PX_DOXYGEN
24 namespace physx
25 {
26 #endif
27 
38 {
39 //= ATTENTION! =====================================================================================
40 // Changing the data layout of this class breaks the binary serialization format. See comments for
41 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
42 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
43 // accordingly.
44 //==================================================================================================
45 public:
50  {
51  }
52 
56  explicit PX_CUDA_CALLABLE PX_FORCE_INLINE PxMeshScale(PxReal r): scale(r), rotation(PxIdentity)
57  {
58  }
59 
64  {
65  PX_ASSERT(r.isUnit());
66  scale = s;
67  rotation = r;
68  }
69 
70 
74  PX_CUDA_CALLABLE PX_FORCE_INLINE bool isIdentity() const
75  {
76  return (scale.x == 1.0f && scale.y == 1.0f && scale.z == 1.0f);
77  }
78 
83  {
84  return PxMeshScale(PxVec3(1.0f/scale.x, 1.0f/scale.y, 1.0f/scale.z), rotation);
85  }
86 
92  {
93  return PxMeshScale(1.0f);
94  }
95 
100  {
101  PxMat33 rot(rotation);
102  PxMat33 trans = rot.getTranspose();
103  trans.column0 *= scale[0];
104  trans.column1 *= scale[1];
105  trans.column2 *= scale[2];
106  return trans * rot;
107  }
108 
109 
110  PxVec3 transform(const PxVec3& v) const
111  {
112  return rotation.rotateInv(scale.multiply(rotation.rotate(v)));
113  }
114 
117 
118 
119 };
120 
121 #ifndef PX_DOXYGEN
122 } // namespace physx
123 #endif
124 
126 #endif


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