From 2cd2d9dc69ca2da025b8a5a350f57fe343998650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Tue, 1 Feb 2022 16:49:05 +0100 Subject: [PATCH] Havok: Add hkpPlaneShape --- lib/hkStubs/CMakeLists.txt | 2 + .../Shape/HeightField/Plane/hkpPlaneShape.h | 36 +++++++++++++++++ .../Shape/HeightField/hkpHeightFieldShape.h | 40 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/Plane/hkpPlaneShape.h create mode 100644 lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/hkpHeightFieldShape.h diff --git a/lib/hkStubs/CMakeLists.txt b/lib/hkStubs/CMakeLists.txt index 9f36a461..d4cb5892 100644 --- a/lib/hkStubs/CMakeLists.txt +++ b/lib/hkStubs/CMakeLists.txt @@ -115,7 +115,9 @@ 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/HeightField/hkpHeightFieldShape.h Havok/Physics2012/Collide/Shape/HeightField/hkpSphereRepShape.h + Havok/Physics2012/Collide/Shape/HeightField/Plane/hkpPlaneShape.h Havok/Physics2012/Collide/Shape/Query/hkpRayShapeCollectionFilter.h Havok/Physics2012/Collide/Shape/Query/hkpShapeRayCastInput.h Havok/Physics2012/Collide/Util/Welding/hkpWeldingUtility.h diff --git a/lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/Plane/hkpPlaneShape.h b/lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/Plane/hkpPlaneShape.h new file mode 100644 index 00000000..135528ee --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/Plane/hkpPlaneShape.h @@ -0,0 +1,36 @@ +#pragma once + +#include + +class hkpPlaneShape : public hkpHeightFieldShape { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkpPlaneShape) + HK_DECLARE_REFLECTION() + HKCD_DECLARE_SHAPE_TYPE(hkcdShapeType::PLANE) + + hkpPlaneShape(const hkVector4& plane, const hkAabb& aabb); + + hkpPlaneShape(const hkVector4& direction, const hkVector4& center, + const hkVector4& halfExtents); + + explicit hkpPlaneShape(hkFinishLoadedObjectFlag flag); + + const hkVector4& getPlane() const { return m_plane; } + const hkVector4& getAabbCenter() const { return m_aabbCenter; } + const hkVector4& getAabbHalfExtents() const { return m_aabbHalfExtents; } + + void getAabb(const hkTransform& localToWorld, hkReal tolerance, hkAabb& out) const override; + hkBool castRay(const hkpShapeRayCastInput& input, + hkpShapeRayCastOutput& results) const override; + void castRayWithCollector(const hkpShapeRayCastInput& input, const hkpCdBody& cdBody, + hkpRayHitCollector& collector) const override; + void castSphere(const hkpSphereCastInput& input, const hkpCdBody& cdBody, + hkpRayHitCollector& collector) const override; + void collideSpheres(const CollideSpheresInput& input, + SphereCollisionOutput* outputArray) const override; + +protected: + hkVector4 m_plane; + hkVector4 m_aabbCenter; + hkVector4 m_aabbHalfExtents; +}; diff --git a/lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/hkpHeightFieldShape.h b/lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/hkpHeightFieldShape.h new file mode 100644 index 00000000..753fef20 --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/hkpHeightFieldShape.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include + +class hkpHeightFieldShape : public hkpShape { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkpHeightFieldShape) + HK_DECLARE_REFLECTION() + HKCD_DECLARE_SHAPE_TYPE(hkcdShapeType::HEIGHT_FIELD); + + struct CollideSpheresInput { + HK_DECLARE_CLASS_ALLOCATOR(CollideSpheresInput) + + hkSphere* m_spheres; + int m_numSpheres; + hkReal m_tolerance; + }; + + using SphereCollisionOutput = hkVector4; + + struct hkpSphereCastInput : public hkpShapeRayCastInput { + HK_DECLARE_CLASS_ALLOCATOR(hkpSphereCastInput) + + hkReal m_radius; + hkReal m_maxExtraPenetration; + }; + + explicit hkpHeightFieldShape(ShapeType type) : hkpShape(type) {} + + explicit hkpHeightFieldShape(hkFinishLoadedObjectFlag flag) : hkpShape(flag) { + setType(HKCD_SHAPE_TYPE_FROM_CLASS(hkpHeightFieldShape)); + } + + virtual void collideSpheres(const CollideSpheresInput& input, + SphereCollisionOutput* outputArray) const = 0; + virtual void castSphere(const hkpSphereCastInput& input, const hkpCdBody& cdBody, + hkpRayHitCollector& collector) const = 0; +};