diff --git a/lib/hkStubs/CMakeLists.txt b/lib/hkStubs/CMakeLists.txt index 7225d9bc..03cac14c 100644 --- a/lib/hkStubs/CMakeLists.txt +++ b/lib/hkStubs/CMakeLists.txt @@ -30,6 +30,8 @@ add_library(hkStubs OBJECT Havok/Common/Base/Math/SweptTransform/hkSweptTransform.h Havok/Common/Base/Math/SweptTransform/hkSweptTransformf.h Havok/Common/Base/Math/SweptTransform/hkSweptTransformfUtil.h + Havok/Common/Base/Math/Vector/hkFourTransposedPoints.h + Havok/Common/Base/Math/Vector/hkFourTransposedPointsf.h Havok/Common/Base/Math/Vector/hkSimdFloat32.h Havok/Common/Base/Math/Vector/hkSimdReal.h Havok/Common/Base/Math/Vector/hkVector4.h @@ -119,6 +121,7 @@ add_library(hkStubs OBJECT Havok/Physics2012/Collide/Shape/Convex/Box/hkpBoxShape.h Havok/Physics2012/Collide/Shape/Convex/Capsule/hkpCapsuleShape.h Havok/Physics2012/Collide/Shape/Convex/ConvexTransform/hkpConvexTransformShape.h + Havok/Physics2012/Collide/Shape/Convex/ConvexVertices/hkpConvexVerticesShape.h Havok/Physics2012/Collide/Shape/Convex/Cylinder/hkpCylinderShape.h Havok/Physics2012/Collide/Shape/Convex/Sphere/hkpSphereShape.h Havok/Physics2012/Collide/Shape/HeightField/hkpHeightFieldShape.h diff --git a/lib/hkStubs/Havok/Common/Base/Math/Vector/hkFourTransposedPoints.h b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkFourTransposedPoints.h new file mode 100644 index 00000000..91c45101 --- /dev/null +++ b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkFourTransposedPoints.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +using hkFourTransposedPoints = hkFourTransposedPointsf; diff --git a/lib/hkStubs/Havok/Common/Base/Math/Vector/hkFourTransposedPointsf.h b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkFourTransposedPointsf.h new file mode 100644 index 00000000..cc922407 --- /dev/null +++ b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkFourTransposedPointsf.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +class hkFourTransposedPointsf { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkFourTransposedPointsf) + HK_DECLARE_REFLECTION() + + hkFourTransposedPointsf() { + for (auto& vertex : m_vertices) + vertex.setZero(); + } + + hkVector4f m_vertices[3]; +}; diff --git a/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/ConvexVertices/hkpConvexVerticesShape.h b/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/ConvexVertices/hkpConvexVerticesShape.h new file mode 100644 index 00000000..4a3a9db2 --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/ConvexVertices/hkpConvexVerticesShape.h @@ -0,0 +1,81 @@ +#pragma once + +#include +#include +#include + +struct hkStridedVertices; +class hkpConvexVerticesConnectivity; + +class hkpConvexVerticesShape : public hkpConvexShape { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkpConvexVerticesShape) + HK_DECLARE_REFLECTION() + HKCD_DECLARE_SHAPE_TYPE(hkcdShapeType::CONVEX_VERTICES) + + struct BuildConfig { + BuildConfig(); + + hkBool m_createConnectivity; + hkBool m_shrinkByConvexRadius; + hkBool m_useOptimizedShrinking; + hkReal m_convexRadius; + int m_maxVertices; + hkReal m_maxRelativeShrink; + hkReal m_maxShrinkingVerticesDisplacement; + hkReal m_maxCosAngleForBevelPlanes; + }; + + explicit hkpConvexVerticesShape(const hkStridedVertices& vertices, + const BuildConfig& config = BuildConfig()); + + hkpConvexVerticesShape(const hkStridedVertices& vertsIn, + const hkArray& planeEquations, + hkReal radius = hkConvexShapeDefaultRadius); + + hkpConvexVerticesShape(hkFourTransposedPoints* rotatedVertices, int numVertices, + hkVector4* planes, int numPlanes, const hkAabb& aabb, + hkReal radius = hkConvexShapeDefaultRadius); + + explicit hkpConvexVerticesShape(hkReal radius = hkConvexShapeDefaultRadius); + + explicit hkpConvexVerticesShape(hkFinishLoadedObjectFlag flag); + + ~hkpConvexVerticesShape() override; + + void getOriginalVertices(hkArray& vertices) const; + const hkArray& getPlaneEquations() const; + void setPlaneEquations(const hkArray& planes); + void setRadiusUnchecked(hkReal radius) { m_radius = radius; } + void transformVerticesAndPlaneEquations(const hkTransform& t); + void copyVertexData(const hkReal* vertexIn, int byteStriding, int numVertices); + + const hkpConvexVerticesConnectivity* getConnectivity() const { return m_connectivity; } + void setConnectivity(const hkpConvexVerticesConnectivity* connect, bool sort = true); + + void getFirstVertex(hkVector4& v) const override; + void getSupportingVertex(hkVector4Parameter direction, + hkcdVertex& supportingVertexOut) const override; + void convertVertexIdsToVertices(const hkpVertexId* ids, int numIds, + hkcdVertex* verticesOut) const override; + + void getCentre(hkVector4& centreOut) const override; + int getNumCollisionSpheres() const override { return m_numVertices; } + const hkSphere* getCollisionSpheres(hkSphere* sphereBuffer) const override; + void getAabb(const hkTransform& localToWorld, hkReal tolerance, hkAabb& out) const override; + hkBool castRay(const hkpShapeRayCastInput& input, + hkpShapeRayCastOutput& results) const override; + + hkVector4 m_aabbHalfExtents; + hkVector4 m_aabbCenter; + + hkArray m_rotatedVertices; + hkInt32 m_numVertices; + + hkBool m_useSpuBuffer; + mutable hkArray m_planeEquations; + mutable const hkpConvexVerticesConnectivity* m_connectivity; + +protected: + void sortPlanes(); +};