Havok: Fix hkpCapsuleShape class layout

This commit is contained in:
Léo Lam 2021-12-31 17:47:16 +01:00
parent 0a82a40bc3
commit 75a270118a
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
4 changed files with 120 additions and 6 deletions

View File

@ -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<ShapeType, hkUint8> m_type;
hkEnum<DispatchType, hkUint8> m_dispatchType;
hkUint8 m_bitsPerKey;

View File

@ -1,10 +1,59 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
#include <Havok/Physics2012/Collide/Shape/hkpShape.h>
#include <Havok/Physics2012/Collide/Shape/Convex/hkpConvexShape.h>
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 <int I>
HK_FORCE_INLINE const hkVector4& getVertex() const;
HK_FORCE_INLINE void setVertex(int i, const hkVector4& position);
template <int I>
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;
};

View File

@ -1,6 +1,58 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
#include <Havok/Physics2012/Collide/Shape/HeightField/hkpSphereRepShape.h>
#include <Havok/Physics2012/Collide/Shape/hkpShape.h>
// 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;
}

View File

@ -1,6 +1,16 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
#include <Havok/Physics2012/Collide/Shape/hkpShape.h>
// 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));
}
};