aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/common/include/ApexMath.h
diff options
context:
space:
mode:
authorgit perforce import user <a@b>2016-10-25 12:29:14 -0600
committerSheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees>2016-10-25 18:56:37 -0500
commit3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch)
treefa6485c169e50d7415a651bf838f5bcd0fd3bfbd /APEX_1.4/common/include/ApexMath.h
downloadphysx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz
physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip
Initial commit:
PhysX 3.4.0 Update @ 21294896 APEX 1.4.0 Update @ 21275617 [CL 21300167]
Diffstat (limited to 'APEX_1.4/common/include/ApexMath.h')
-rw-r--r--APEX_1.4/common/include/ApexMath.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/APEX_1.4/common/include/ApexMath.h b/APEX_1.4/common/include/ApexMath.h
new file mode 100644
index 00000000..19d4af4c
--- /dev/null
+++ b/APEX_1.4/common/include/ApexMath.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
+ * and proprietary rights in and to this software, related documentation
+ * and any modifications thereto. Any use, reproduction, disclosure or
+ * distribution of this software and related documentation without an express
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
+ */
+
+
+#ifndef APEX_MATH_H
+#define APEX_MATH_H
+
+#include "PxMat44.h"
+#include "PsMathUtils.h"
+
+#include "PsVecMath.h"
+namespace nvidia
+{
+
+#define APEX_ALIGN_UP(offset, alignment) (((offset) + (alignment)-1) & ~((alignment)-1))
+
+/**
+ * computes weight * _origin + (1.0f - weight) * _target
+ */
+PX_INLINE PxMat44 interpolateMatrix(float weight, const PxMat44& _origin, const PxMat44& _target)
+{
+ // target: normalize, save scale, transform to quat
+ PxMat33 target(_target.column0.getXYZ(),
+ _target.column1.getXYZ(),
+ _target.column2.getXYZ());
+ PxVec3 axis0 = target.column0;
+ PxVec3 axis1 = target.column1;
+ PxVec3 axis2 = target.column2;
+ const PxVec4 targetScale(axis0.normalize(), axis1.normalize(), axis2.normalize(), 1.0f);
+ target.column0 = axis0;
+ target.column1 = axis1;
+ target.column2 = axis2;
+ const PxQuat targetQ = PxQuat(target);
+
+ // origin: normalize, save scale, transform to quat
+ PxMat33 origin(_origin.column0.getXYZ(),
+ _origin.column1.getXYZ(),
+ _origin.column2.getXYZ());
+ const PxVec4 originScale(axis0.normalize(), axis1.normalize(), axis2.normalize(), 1.0f);
+ origin.column0 = axis0;
+ origin.column1 = axis1;
+ origin.column2 = axis2;
+ const PxQuat originQ = PxQuat(origin);
+
+ // interpolate
+ PxQuat relativeQ = physx::shdfnd::slerp(1.0f - weight, originQ, targetQ);
+ PxMat44 relative(relativeQ);
+ relative.setPosition(weight * _origin.getPosition() + (1.0f - weight) * _target.getPosition());
+
+ PxMat44 _relative = relative;
+ const PxVec4 scale = weight * originScale + (1.0f - weight) * targetScale;
+ _relative.scale(scale);
+
+ return _relative;
+}
+
+bool operator != (const PxMat44& a, const PxMat44& b);
+
+}
+
+
+#endif // APEX_MATH_H