diff --git a/lib/hkStubs/Havok/Geometry/Collide/Shapes/hkcdShape.h b/lib/hkStubs/Havok/Geometry/Collide/Shapes/hkcdShape.h index 95154c21..f2809444 100644 --- a/lib/hkStubs/Havok/Geometry/Collide/Shapes/hkcdShape.h +++ b/lib/hkStubs/Havok/Geometry/Collide/Shapes/hkcdShape.h @@ -91,6 +91,9 @@ public: explicit hkcdShape(hkFinishLoadedObjectFlag flag); + HK_FORCE_INLINE hkcdShape::ShapeType getType() const { return m_type; } + HK_FORCE_INLINE void setType(ShapeType newType) { m_type = newType; } + hkEnum m_type; hkEnum m_dispatchType; hkUint8 m_bitsPerKey; diff --git a/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/Capsule/hkpCapsuleShape.h b/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/Capsule/hkpCapsuleShape.h index 1cc21fea..d46634f2 100644 --- a/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/Capsule/hkpCapsuleShape.h +++ b/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/Capsule/hkpCapsuleShape.h @@ -1,10 +1,59 @@ #pragma once #include -#include +#include -class hkpCapsuleShape : public hkpShape { +class hkpCapsuleShape : public hkpConvexShape { public: + HK_DECLARE_CLASS_ALLOCATOR(hkpCapsuleShape) + HKCD_DECLARE_SHAPE_TYPE(hkcdShapeType::CAPSULE) + + enum RayHitType { + HIT_CAP0, + HIT_CAP1, + HIT_BODY, + }; + + hkpCapsuleShape() = default; hkpCapsuleShape(const hkVector4& vertexA, const hkVector4& vertexB, hkReal radius); + explicit hkpCapsuleShape(hkFinishLoadedObjectFlag flag); virtual ~hkpCapsuleShape(); + + HK_FORCE_INLINE void getSupportingVertex(hkVector4Parameter direction, + hkcdVertex& supportingVertexOut) const override; + + HK_FORCE_INLINE void convertVertexIdsToVertices(const hkpVertexId* ids, int numIds, + hkcdVertex* verticesOut) const override; + + HK_FORCE_INLINE void getCentre(hkVector4& centreOut) const override; + HK_FORCE_INLINE int getNumCollisionSpheres() const override; + 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; + + inline const hkVector4* getVertices() const; + + HK_FORCE_INLINE const hkVector4& getVertex(int i) const; + template + HK_FORCE_INLINE const hkVector4& getVertex() const; + + HK_FORCE_INLINE void setVertex(int i, const hkVector4& position); + template + HK_FORCE_INLINE void setVertex(hkVector4Parameter position); + + void getFirstVertex(hkVector4& v) const override; + + static void closestPointLineSeg(const hkVector4& A, const hkVector4& B, const hkVector4& B2, + hkVector4& pt); + static void closestInfLineSegInfLineSeg(const hkVector4& A, const hkVector4& dA, + const hkVector4& B, const hkVector4& dB, + hkReal& distSquared, hkReal& t, hkReal& u, hkVector4& p, + hkVector4& q); + +protected: + // The line's first point. + hkVector4 m_vertexA; + // The line's second point. + hkVector4 m_vertexB; }; diff --git a/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/hkpConvexShape.h b/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/hkpConvexShape.h index ad2e7be1..a9dfa55a 100644 --- a/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/hkpConvexShape.h +++ b/lib/hkStubs/Havok/Physics2012/Collide/Shape/Convex/hkpConvexShape.h @@ -1,6 +1,58 @@ #pragma once +#include +#include #include -// TODO -class hkpConvexShape {}; +class hkpConvexShape : public hkpSphereRepShape { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkpConvexShape) + HKCD_DECLARE_SHAPE_TYPE(hkcdShapeType::CONVEX) + + using VertexId = hkpVertexId; + + enum WeldResult { + WELD_RESULT_REJECT_CONTACT_POINT, + WELD_RESULT_ACCEPT_CONTACT_POINT_MODIFIED, + WELD_RESULT_ACCEPT_CONTACT_POINT_UNMODIFIED + }; + + HK_FORCE_INLINE hkpConvexShape() = default; + hkpConvexShape(hkFinishLoadedObjectFlag flag); + + void getCentre(hkVector4& centreOut) const override; + int weldContactPoint(hkpVertexId* featurePoints, hkUint8& numFeaturePoints, + hkVector4& contactPointWs, const hkTransform* thisObjTransform, + const hkpConvexShape* collidingShape, + const hkTransform* collidingTransform, + hkVector4& separatingNormalInOut) const override; + void castRayWithCollector(const hkpShapeRayCastInput& input, const hkpCdBody& cdBody, + hkpRayHitCollector& collector) const override; + virtual void getFirstVertex(hkVector4& v) const = 0; + bool isConvex() const override { return true; } + hkReal getMaximumProjection(const hkVector4& direction) const override; + virtual int getSize() const { return 0; } + + inline const hkReal& getRadius() const; + inline void setRadius(hkReal radius); + inline void setRadiusUnchecked(hkReal radius); + +protected: + inline hkpConvexShape(ShapeType type, hkReal radius) : hkpSphereRepShape(type) { + m_radius = radius; + } + + hkReal m_radius; +}; + +inline const hkReal& hkpConvexShape::getRadius() const { + return m_radius; +} + +inline void hkpConvexShape::setRadius(hkReal radius) { + setRadiusUnchecked(radius); +} + +inline void hkpConvexShape::setRadiusUnchecked(hkReal radius) { + m_radius = radius; +} diff --git a/lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/hkpSphereRepShape.h b/lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/hkpSphereRepShape.h index ab1d7dd9..9be52264 100644 --- a/lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/hkpSphereRepShape.h +++ b/lib/hkStubs/Havok/Physics2012/Collide/Shape/HeightField/hkpSphereRepShape.h @@ -1,6 +1,16 @@ #pragma once +#include #include -// TODO -class hkpSphereRepShape {}; +class hkpSphereRepShape : public hkpShape { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkpSphereRepShape) + HKCD_DECLARE_SHAPE_TYPE(hkcdShapeType::SPHERE_REP) + + HK_FORCE_INLINE hkpSphereRepShape() = default; + explicit hkpSphereRepShape(ShapeType type) : hkpShape(type) {} + explicit hkpSphereRepShape(hkFinishLoadedObjectFlag flag) : hkpShape(flag) { + setType(HKCD_SHAPE_TYPE_FROM_CLASS(hkpSphereRepShape)); + } +};