Havok: Add various classes that are used by hkpCollisionFilter

This commit is contained in:
Léo Lam 2021-12-22 00:54:46 +01:00
parent 6b3799a354
commit 9c3687584b
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
21 changed files with 738 additions and 10 deletions

View File

@ -10,6 +10,8 @@ add_library(hkStubs OBJECT
Havok/Common/Base/Math/hkMath.h
Havok/Common/Base/Math/Vector/hkVector4.h
Havok/Common/Base/Math/Vector/hkVector4f.h
Havok/Common/Base/Math/Vector/hkVector4Comparison.h
Havok/Common/Base/Math/Vector/hkVector4fComparison.h
Havok/Common/Base/Memory/Allocator/hkMemoryAllocator.h
Havok/Common/Base/Memory/Allocator/Lifo/hkLifoAllocator.h
@ -27,6 +29,14 @@ add_library(hkStubs OBJECT
Havok/Common/Base/Types/hkRefPtr.h
Havok/Common/Base/Types/Geometry/Aabb/hkAabb.h
Havok/Geometry/Collide/Shapes/hkcdShape.h
Havok/Physics2012/Collide/Agent/hkpCollisionInput.h
Havok/Physics2012/Collide/Agent/Collidable/hkpCdBody.h
Havok/Physics2012/Collide/Agent/Collidable/hkpCollidable.h
Havok/Physics2012/Collide/Agent/Collidable/hkpCollidableQualityType.h
Havok/Physics2012/Collide/BroadPhase/hkpBroadPhaseHandle.h
Havok/Physics2012/Collide/BroadPhase/hkpTypedBroadPhaseHandle.h
Havok/Physics2012/Collide/Filter/hkpCollidableCollidableFilter.h
Havok/Physics2012/Collide/Filter/hkpCollisionFilter.cpp
Havok/Physics2012/Collide/Filter/hkpCollisionFilter.h
@ -35,12 +45,15 @@ add_library(hkStubs OBJECT
Havok/Physics2012/Collide/Filter/hkpShapeCollectionFilter.h
Havok/Physics2012/Collide/Filter/Group/hkpGroupFilter.cpp
Havok/Physics2012/Collide/Filter/Group/hkpGroupFilter.h
Havok/Physics2012/Collide/Query/CastUtil/hkpWorldRayCastInput.h
Havok/Physics2012/Collide/Shape/hkpShape.h
Havok/Physics2012/Collide/Shape/hkpShapeBase.h
Havok/Physics2012/Collide/Shape/hkpShapeContainer.h
Havok/Physics2012/Collide/Shape/Convex/hkpConvexShape.h
Havok/Physics2012/Collide/Shape/Convex/Capsule/hkpCapsuleShape.h
Havok/Physics2012/Collide/Shape/HeightField/hkpSphereRepShape.h
Havok/Physics2012/Collide/Shape/Query/hkpRayShapeCollectionFilter.h
Havok/Physics2012/Collide/Shape/Query/hkpShapeRayCastInput.h
Havok/Physics2012/Dynamics/Entity/hkpEntity.h
Havok/Physics2012/Dynamics/Entity/hkpRigidBody.h

View File

@ -1,5 +1,3 @@
#pragma once
#include <Havok/Common/Base/Math/Vector/hkVector4f.h>
using hkVector4 = hkVector4f;

View File

@ -0,0 +1,3 @@
#pragma once
#include <Havok/Common/Base/Math/Vector/hkVector4fComparison.h>

View File

@ -0,0 +1,9 @@
#pragma once
// FIXME: incomplete
class hkVector4fComparison {
public:
HK_DECLARE_CLASS_ALLOCATOR(hkVector4fComparison)
hkUint32 m_mask;
};

View File

@ -2,4 +2,15 @@
#include <Havok/Common/Base/Types/hkBaseTypes.h>
class hkVector4f;
using hkVector4fParameter = const hkVector4f&;
class hkVector4fComparison;
using hkVector4fComparisonParameter = const hkVector4fComparison&;
#include <Havok/Common/Base/Math/Vector/hkVector4.h>
#include <Havok/Common/Base/Math/Vector/hkVector4Comparison.h>
using hkVector4 = hkVector4f;
using hkVector4Parameter = const hkVector4f&;
using hkVector4Comparison = hkVector4fComparison;
using hkVector4ComparisonParameter = hkVector4fComparisonParameter;

View File

@ -1,7 +1,6 @@
#pragma once
#include <Havok/Common/Base/Math/Vector/hkVector4.h>
#include <Havok/Common/Base/Memory/Router/hkMemoryRouter.h>
#include <Havok/Common/Base/hkBase.h>
/// Axis aligned bounding box
// FIXME: incomplete

View File

@ -91,6 +91,9 @@ private:
char m_bool;
};
using hkBool32 = hkUint32;
using hkBoolLL = hkUint64;
/// For storing an enum with a particular storage size when specifying the underlying type of the
/// enum is not an option.
template <typename Enum, typename Storage>
@ -176,6 +179,11 @@ inline bool operator!=(hkResultEnum e, hkResult r) {
return r.m_enum != e;
}
struct hkFinishLoadedObjectFlag {
class hkFinishLoadedObjectFlag {
public:
int m_finishing = 0;
};
HK_FORCE_INLINE hkLong hkGetByteOffset(const void* base, const void* pntr) {
return hkLong(pntr) - hkLong(base);
}

View File

@ -0,0 +1,100 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
struct hkcdShapeType {
HK_DECLARE_CLASS_ALLOCATOR(hkcdShapeType)
enum ShapeTypeEnum {
SPHERE = 0, ///< hkpSphereShape type.
CYLINDER = 1, ///< hkpCylinderShape type.
TRIANGLE = 2, ///< hkpTriangleShape type.
BOX = 3, ///< hkpBoxShape type.
CAPSULE = 4, ///< hkpCapsuleShape type.
CONVEX_VERTICES = 5, ///< hkpConvexVerticesShape type.
TRI_SAMPLED_HEIGHT_FIELD_COLLECTION = 6, ///< hkpTriSampledHeightFieldCollection type.
TRI_SAMPLED_HEIGHT_FIELD_BV_TREE = 7, ///< hkpTriSampledHeightFieldBvTreeShape type.
LIST = 8, ///< hkpListShape type.
MOPP = 9, ///< hkpMoppBvTreeShape type.
CONVEX_TRANSLATE = 10, ///< hkpConvexTranslateShape type.
CONVEX_TRANSFORM = 11, ///< hkpConvexTransformShape type.
SAMPLED_HEIGHT_FIELD = 12, ///< hkpSampledHeightFieldShape type.
EXTENDED_MESH = 13, ///< hkpExtendedMeshShape type.
TRANSFORM = 14, ///< hkpTransformShape type.
COMPRESSED_MESH = 15, ///< hkpCompressedMeshShape type.
STATIC_COMPOUND = 16, ///< hkpStaticCompoundShape type.
BV_COMPRESSED_MESH = 17, ///< hkpBvCompressedMeshShape type.
/// All shapes which inherit from hkpShapeCollection have this as an alternate type.
COLLECTION = 18,
USER0 = 19, ///< Custom user type.
USER1 = 20, ///< Custom user type.
USER2 = 21, ///< Custom user type.
/// All shapes which inherit from hkpBvTreeShape have this as an alternate type.
BV_TREE = 22,
/// All shapes which inherit from hkpConvexShape have this as an alternate type.
CONVEX = 23,
CONVEX_PIECE = 24, ///< DEPRECATED - hkpConvexPieceShape type.
MULTI_SPHERE = 25, ///< DEPRECATED - hkpMultiSphereShape type.
CONVEX_LIST = 26, ///< DEPRECATED - hkpConvexListShape.
TRIANGLE_COLLECTION = 27, ///< A shape collection which only returns triangles as child
///< shapes, e.g., hkpMeshShape.
HEIGHT_FIELD = 28, ///< hkpHeightFieldShape type.
SPHERE_REP = 29, ///< hkpSphereRepShape type.
BV = 30, ///< hkpBvShape type.
PLANE = 31, ///< hkpPlaneShape type.
PHANTOM_CALLBACK = 32, ///< hkpPhantomCallbackShape type.
MULTI_RAY = 33, ///< hkpMultiRayShape type.
INVALID = 34, ///< Invalid shape
FIRST_SHAPE_TYPE = SPHERE, ///< The first real shape.
MAX_SPU_SHAPE_TYPE = USER2 + 1, ///< Last SPU support shape type.
MAX_PPU_SHAPE_TYPE = INVALID + 1, ///< The end of the shape type list.
ALL_SHAPE_TYPES = -1, ///< All shapes flag, used by the hkpCollisionDispatcher.
};
};
struct hkcdShapeDispatchType {
HK_DECLARE_CLASS_ALLOCATOR(hkcdShapeDispatchType)
enum ShapeDispatchTypeEnum {
CONVEX_IMPLICIT,
CONVEX,
HEIGHT_FIELD,
COMPOSITE,
USER,
NUM_DISPATCH_TYPES,
};
};
struct hkcdShapeInfoCodecType {
HK_DECLARE_CLASS_ALLOCATOR(hkcdShapeInfoCodecType)
enum ShapeInfoCodecTypeEnum {
NULL_CODEC = 0,
UFM358 = 1,
MAX_NUM_CODECS = 16,
};
};
class hkcdShape : public hkReferencedObject {
public:
HK_DECLARE_CLASS_ALLOCATOR(hkcdShape)
using ShapeType = hkcdShapeType::ShapeTypeEnum;
using DispatchType = hkcdShapeDispatchType::ShapeDispatchTypeEnum;
using ShapeInfoCodecType = hkcdShapeInfoCodecType::ShapeInfoCodecTypeEnum;
HK_FORCE_INLINE explicit hkcdShape(ShapeType shapeType)
: m_type(shapeType), m_dispatchType(hkcdShapeDispatchType::USER), m_bitsPerKey(0),
m_shapeInfoCodecType(hkcdShapeInfoCodecType::NULL_CODEC) {}
explicit hkcdShape(hkFinishLoadedObjectFlag flag);
hkEnum<ShapeType, hkUint8> m_type;
hkEnum<DispatchType, hkUint8> m_dispatchType;
hkUint8 m_bitsPerKey;
hkEnum<ShapeInfoCodecType, hkUint8> m_shapeInfoCodecType;
};
#define HKCD_DECLARE_SHAPE_TYPE(shapeType) enum { THIS_SHAPE_TYPE = (shapeType) };
#define HKCD_SHAPE_TYPE_FROM_CLASS(ShapeClass) (hkcdShape::ShapeType) ShapeClass::THIS_SHAPE_TYPE

View File

@ -0,0 +1,127 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
#include <Havok/Physics2012/Collide/Shape/hkpShape.h>
class hkMotionState;
class hkTransform;
class hkpCollidable;
class hkpCdBody {
public:
HK_DECLARE_CLASS_ALLOCATOR(hkpCdBody)
friend class hkpCollidable;
HK_FORCE_INLINE hkpCdBody() {}
HK_FORCE_INLINE hkpCdBody(const hkpShape* shape, const hkMotionState* motionState);
HK_FORCE_INLINE hkpCdBody(const hkpShape* shape, const hkTransform* t);
HK_FORCE_INLINE hkpCdBody(const hkpCdBody& body) = delete;
HK_FORCE_INLINE const hkTransform& getTransform() const;
HK_FORCE_INLINE const hkpShape* getShape() const;
HK_FORCE_INLINE const hkpCollidable* getRootCollidable() const;
HK_FORCE_INLINE hkpShapeKey getShapeKey() const;
HK_FORCE_INLINE hkpShapeKey getTopLevelShapeKey() const;
HK_FORCE_INLINE const hkpCdBody* getParent() const;
// Internal functions, for collision agents.
explicit HK_FORCE_INLINE hkpCdBody(const hkpCdBody* parent);
HK_FORCE_INLINE hkpCdBody(const hkpCdBody* parent, const hkMotionState* ms);
HK_FORCE_INLINE hkpCdBody(const hkpCdBody* parent, const hkTransform* t);
HK_FORCE_INLINE void setShape(const hkpShape* shape, hkpShapeKey key);
HK_FORCE_INLINE const hkMotionState* getMotionState() const;
HK_FORCE_INLINE void setMotionState(const hkMotionState* state);
HK_FORCE_INLINE void setTransform(const hkTransform* t);
const hkpShape* m_shape;
hkpShapeKey m_shapeKey;
private:
// hkTransform or hkMotionState.
const void* m_motion;
public:
const hkpCdBody* m_parent;
};
inline hkpCdBody::hkpCdBody(const hkpShape* shape, const hkMotionState* motionState) {
m_shape = shape;
setMotionState(motionState);
m_parent = nullptr;
m_shapeKey = HK_INVALID_SHAPE_KEY;
}
inline hkpCdBody::hkpCdBody(const hkpShape* shape, const hkTransform* t) {
m_shape = shape;
setTransform(t);
m_parent = nullptr;
m_shapeKey = HK_INVALID_SHAPE_KEY;
}
inline const hkTransform& hkpCdBody::getTransform() const {
return *static_cast<const hkTransform*>(m_motion);
}
inline const hkpShape* hkpCdBody::getShape() const {
return m_shape;
}
inline const hkpCollidable* hkpCdBody::getRootCollidable() const {
const hkpCdBody* body = this;
while (body->m_parent) {
body = body->m_parent;
}
return reinterpret_cast<const hkpCollidable*>(body);
}
inline hkpShapeKey hkpCdBody::getShapeKey() const {
return m_shapeKey;
}
inline hkpShapeKey hkpCdBody::getTopLevelShapeKey() const {
const hkpCdBody* body = this;
const hkpCdBody* top = body;
while (body->m_parent) {
top = body;
body = body->m_parent;
}
return top->m_shapeKey;
}
inline const hkpCdBody* hkpCdBody::getParent() const {
return m_parent;
}
inline hkpCdBody::hkpCdBody(const hkpCdBody* parent) {
m_parent = parent;
m_motion = parent->m_motion;
}
inline hkpCdBody::hkpCdBody(const hkpCdBody* parent, const hkMotionState* ms) {
m_parent = parent;
setMotionState(ms);
}
inline hkpCdBody::hkpCdBody(const hkpCdBody* parent, const hkTransform* t) {
m_parent = parent;
setTransform(t);
}
inline void hkpCdBody::setShape(const hkpShape* shape, hkpShapeKey key) {
m_shape = shape;
m_shapeKey = key;
}
inline const hkMotionState* hkpCdBody::getMotionState() const {
return static_cast<const hkMotionState*>(m_motion);
}
inline void hkpCdBody::setMotionState(const hkMotionState* state) {
m_motion = state;
}
inline void hkpCdBody::setTransform(const hkTransform* t) {
m_motion = t;
}

View File

@ -0,0 +1,157 @@
#pragma once
#include <Havok/Physics2012/Collide/Agent/Collidable/hkpCdBody.h>
#include <Havok/Physics2012/Collide/BroadPhase/hkpTypedBroadPhaseHandle.h>
class hkAabbUint32;
class hkpCollidable : public hkpCdBody {
public:
HK_DECLARE_CLASS_ALLOCATOR(hkpCollidable)
struct BoundingVolumeData {
HK_DECLARE_CLASS_ALLOCATOR(hkpCollidable::BoundingVolumeData)
BoundingVolumeData();
explicit inline BoundingVolumeData(hkFinishLoadedObjectFlag flag);
HK_FORCE_INLINE bool hasAllocations() const;
void deallocate();
void allocate(int numChildShapes);
HK_FORCE_INLINE void invalidate() {
m_min[0] = 1;
m_max[0] = 0;
}
HK_FORCE_INLINE bool isValid() const { return m_min[0] <= m_max[0]; }
hkUint32 m_min[3];
hkUint8 m_expansionMin[3];
hkUint8 m_expansionShift;
hkUint32 m_max[3];
hkUint8 m_expansionMax[3];
hkUint8 m_padding;
hkUint16 m_numChildShapeAabbs;
hkUint16 m_capacityChildShapeAabbs;
hkAabbUint32* m_childShapeAabbs;
hkpShapeKey* m_childShapeKeys;
};
enum ForceCollideOntoPpuReasons {
FORCE_PPU_USER_REQUEST = 1,
FORCE_PPU_SHAPE_REQUEST = 2,
FORCE_PPU_MODIFIER_REQUEST = 4,
FORCE_PPU_SHAPE_UNCHECKED = 8,
};
explicit hkpCollidable(hkFinishLoadedObjectFlag flag);
inline hkpCollidable(const hkpShape* shape, const hkTransform* t, int type = 0);
inline hkpCollidable(const hkpShape* shape, const hkMotionState* ms, int type = 0);
inline ~hkpCollidable();
inline void setShape(const hkpShape* shape);
inline void* getOwner() const;
inline void setOwner(void* owner);
inline hkpCollidableQualityType getQualityType() const;
inline void setQualityType(hkpCollidableQualityType type);
inline hkReal getAllowedPenetrationDepth() const;
inline void setAllowedPenetrationDepth(hkReal val);
inline hkUint32 getCollisionFilterInfo() const;
inline void setCollisionFilterInfo(hkUint32 info);
inline int getType() const;
protected:
hkInt8 m_ownerOffset;
public:
hkUint8 m_forceCollideOntoPpu;
hkUint16 m_shapeSizeOnSpu;
hkpTypedBroadPhaseHandle m_broadPhaseHandle;
BoundingVolumeData m_boundingVolumeData;
hkReal m_allowedPenetrationDepth;
};
inline hkpCollidable::hkpCollidable(hkFinishLoadedObjectFlag flag)
: m_broadPhaseHandle(flag), m_boundingVolumeData(flag) {
if (flag.m_finishing) {
m_broadPhaseHandle.setOwner(this);
}
}
inline hkpCollidable::hkpCollidable(const hkpShape* shape, const hkTransform* t, int type)
: hkpCdBody(shape, t), m_ownerOffset(0), m_broadPhaseHandle(type),
m_allowedPenetrationDepth(hkReal(-1)) {
m_broadPhaseHandle.setOwner(this);
m_forceCollideOntoPpu = hkpCollidable::FORCE_PPU_SHAPE_UNCHECKED;
m_shapeSizeOnSpu = 0;
}
inline hkpCollidable::hkpCollidable(const hkpShape* shape, const hkMotionState* ms, int type)
: hkpCdBody(shape, ms), m_ownerOffset(0), m_broadPhaseHandle(type),
m_allowedPenetrationDepth(hkReal(-1)) {
m_broadPhaseHandle.setOwner(this);
m_forceCollideOntoPpu = hkpCollidable::FORCE_PPU_SHAPE_UNCHECKED;
m_shapeSizeOnSpu = 0;
}
inline hkpCollidable::~hkpCollidable() {}
inline void hkpCollidable::setShape(const hkpShape* shape) {
m_shape = shape;
}
inline void* hkpCollidable::getOwner() const {
return const_cast<char*>(reinterpret_cast<const char*>(this) + m_ownerOffset);
}
inline void hkpCollidable::setOwner(void* owner) {
auto ownerOffset = int(hkGetByteOffset(this, owner));
m_ownerOffset = static_cast<hkInt8>(ownerOffset);
}
inline hkpCollidableQualityType hkpCollidable::getQualityType() const {
return hkpCollidableQualityType(m_broadPhaseHandle.m_objectQualityType);
}
inline void hkpCollidable::setQualityType(hkpCollidableQualityType type) {
m_broadPhaseHandle.m_objectQualityType = type;
}
inline hkReal hkpCollidable::getAllowedPenetrationDepth() const {
return m_allowedPenetrationDepth;
}
inline void hkpCollidable::setAllowedPenetrationDepth(hkReal val) {
m_allowedPenetrationDepth = val;
}
inline hkUint32 hkpCollidable::getCollisionFilterInfo() const {
return m_broadPhaseHandle.m_collisionFilterInfo;
}
inline void hkpCollidable::setCollisionFilterInfo(hkUint32 info) {
m_broadPhaseHandle.m_collisionFilterInfo = info;
}
inline int hkpCollidable::getType() const {
return m_broadPhaseHandle.getType();
}
inline hkpCollidable::BoundingVolumeData::BoundingVolumeData(hkFinishLoadedObjectFlag flag) {
if (flag.m_finishing) {
m_numChildShapeAabbs = 0;
m_capacityChildShapeAabbs = 0;
m_childShapeAabbs = nullptr;
m_childShapeKeys = nullptr;
invalidate();
}
}
inline bool hkpCollidable::BoundingVolumeData::hasAllocations() const {
return m_childShapeAabbs != nullptr;
}

View File

@ -0,0 +1,16 @@
#pragma once
enum hkpCollidableQualityType {
HK_COLLIDABLE_QUALITY_INVALID = -1,
HK_COLLIDABLE_QUALITY_FIXED = 0,
HK_COLLIDABLE_QUALITY_KEYFRAMED,
HK_COLLIDABLE_QUALITY_DEBRIS,
HK_COLLIDABLE_QUALITY_DEBRIS_SIMPLE_TOI,
HK_COLLIDABLE_QUALITY_MOVING,
HK_COLLIDABLE_QUALITY_CRITICAL,
HK_COLLIDABLE_QUALITY_BULLET,
HK_COLLIDABLE_QUALITY_USER,
HK_COLLIDABLE_QUALITY_CHARACTER,
HK_COLLIDABLE_QUALITY_KEYFRAMED_REPORTING,
HK_COLLIDABLE_QUALITY_MAX
};

View File

@ -0,0 +1,30 @@
#pragma once
#include <Havok/Common/Base/Math/Vector/hkVector4.h>
#include <Havok/Common/Base/Memory/Router/hkMemoryRouter.h>
#include <Havok/Common/Base/Types/hkBaseTypes.h>
class hkpCollisionDispatcher;
class hkpCollisionFilter;
class hkpConvexListFilter;
struct hkpCollisionInput {
HK_DECLARE_CLASS_ALLOCATOR(hkpCollisionInput)
struct Aabb32Info {
HK_DECLARE_CLASS_ALLOCATOR(hkpCollisionInput::Aabb32Info)
hkVector4 m_bitOffsetLow;
hkVector4 m_bitOffsetHigh;
hkVector4 m_bitScale;
};
hkpCollisionDispatcher* m_dispatcher;
hkBool32 m_weldClosestPoints;
hkBool32 m_forceAcceptContactPoints = false;
hkReal m_tolerance;
const hkpCollisionFilter* m_filter;
const hkpConvexListFilter* m_convexListFilter;
mutable hkBool32 m_createPredictiveAgents;
Aabb32Info m_aabb32Info;
};

View File

@ -0,0 +1,13 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
class hkpBroadPhaseHandle {
public:
HK_DECLARE_CLASS_ALLOCATOR(hkpBroadPhaseHandle)
hkpBroadPhaseHandle() : m_id(0) {}
explicit hkpBroadPhaseHandle(hkFinishLoadedObjectFlag flag) {}
hkUint32 m_id;
};

View File

@ -0,0 +1,63 @@
#pragma once
#include <Havok/Physics2012/Collide/Agent/Collidable/hkpCollidableQualityType.h>
#include <Havok/Physics2012/Collide/BroadPhase/hkpBroadPhaseHandle.h>
class hkpTypedBroadPhaseHandle : public hkpBroadPhaseHandle {
public:
HK_DECLARE_CLASS_ALLOCATOR(hkpTypedBroadPhaseHandle)
explicit hkpTypedBroadPhaseHandle(hkFinishLoadedObjectFlag flag) : hkpBroadPhaseHandle(flag) {}
HK_FORCE_INLINE explicit hkpTypedBroadPhaseHandle(int type);
HK_FORCE_INLINE hkpTypedBroadPhaseHandle(void* owner, int type);
/// See hkpWorldObject::BroadPhaseType.
HK_FORCE_INLINE int getType() const;
HK_FORCE_INLINE void* getOwner() const;
HK_FORCE_INLINE void setOwner(void* o);
protected:
friend class hkpBroadPhaseBorder;
inline void setType(int type);
static constexpr int OFFSET_INVALID = 127;
hkInt8 m_type;
hkInt8 m_ownerOffset;
public:
hkInt8 m_objectQualityType;
hkUint32 m_collisionFilterInfo;
};
inline hkpTypedBroadPhaseHandle::hkpTypedBroadPhaseHandle(int type) {
m_type = static_cast<hkInt8>(type);
m_collisionFilterInfo = 0;
m_objectQualityType = HK_COLLIDABLE_QUALITY_INVALID;
m_ownerOffset = OFFSET_INVALID;
}
inline hkpTypedBroadPhaseHandle::hkpTypedBroadPhaseHandle(void* owner, int type) {
m_type = static_cast<hkInt8>(type);
m_collisionFilterInfo = 0;
m_objectQualityType = HK_COLLIDABLE_QUALITY_INVALID;
setOwner(owner);
}
inline int hkpTypedBroadPhaseHandle::getType() const {
return m_type;
}
inline void* hkpTypedBroadPhaseHandle::getOwner() const {
return const_cast<char*>(reinterpret_cast<const char*>(this) + m_ownerOffset);
}
inline void hkpTypedBroadPhaseHandle::setOwner(void* o) {
auto offset = int(hkGetByteOffset(this, o));
m_ownerOffset = static_cast<hkInt8>(offset);
}
inline void hkpTypedBroadPhaseHandle::setType(int type) {
m_type = static_cast<hkInt8>(type);
}

View File

@ -1,4 +1,10 @@
#include <Havok/Physics2012/Collide/Agent/Collidable/hkpCdBody.h>
#include <Havok/Physics2012/Collide/Agent/Collidable/hkpCollidable.h>
#include <Havok/Physics2012/Collide/Agent/hkpCollisionInput.h>
#include <Havok/Physics2012/Collide/Filter/Group/hkpGroupFilter.h>
#include <Havok/Physics2012/Collide/Query/CastUtil/hkpWorldRayCastInput.h>
#include <Havok/Physics2012/Collide/Shape/Query/hkpShapeRayCastInput.h>
#include <Havok/Physics2012/Collide/Shape/hkpShapeContainer.h>
hkpGroupFilter::hkpGroupFilter() {
m_type = HK_FILTER_GROUP;

View File

@ -0,0 +1,13 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
struct hkpWorldRayCastInput {
HK_DECLARE_CLASS_ALLOCATOR(hkpWorldRayCastInput)
hkVector4 m_from;
hkVector4 m_to;
hkBool m_enableShapeCollectionFilter = false;
hkUint32 m_filterInfo = 0;
hkUlong m_userData = 0;
};

View File

@ -0,0 +1,17 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
class hkpCollidable;
class hkpRayShapeCollectionFilter;
struct hkpShapeRayCastInput {
HK_DECLARE_CLASS_ALLOCATOR(hkpShapeRayCastInput)
hkVector4 m_from;
hkVector4 m_to;
hkUint32 m_filterInfo = 0;
const hkpRayShapeCollectionFilter* m_rayShapeCollectionFilter = nullptr;
const hkpCollidable* m_collidable = nullptr;
hkUlong m_userData = 0;
};

View File

@ -1,9 +1,13 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
#include <Havok/Physics2012/Collide/Shape/hkpShapeBase.h>
// FIXME: incomplete. Also this should be inheriting from hkpBase
class hkpShape : public hkReferencedObject {
#define HK_INVALID_SHAPE_KEY 0xffffffff
#define HK_INVALID_VERTEX_ID 0xffff
// FIXME: incomplete.
class hkpShape : public hkpShapeBase {
public:
virtual ~hkpShape();

View File

@ -1,8 +1,91 @@
#pragma once
#include <Havok/Common/Base/Types/hkBaseTypes.h>
#include <Havok/Common/Base/hkBase.h>
#include <Havok/Geometry/Collide/Shapes/hkcdShape.h>
using hkpVertexId = hkUint16;
using hkpShapeKey = hkUint32;
// FIXME: hkpShapeBase
class hkAabb;
class hkSphere;
class hkTransform;
class hkcdVertex;
class hkpCdBody;
class hkpRayHitCollector;
class hkpShapeRayBundleCastInput;
class hkpShapeRayBundleCastOutput;
class hkpShapeRayCastInput;
class hkpShapeRayCastOutput;
/// Base interface for all physics shapes.
class hkpShapeBase : public hkcdShape {
public:
HK_DECLARE_CLASS_ALLOCATOR(hkpShapeBase)
HKCD_DECLARE_SHAPE_TYPE(hkcdShapeType::INVALID)
HK_FORCE_INLINE explicit hkpShapeBase(ShapeType type) : hkcdShape(type) {}
explicit hkpShapeBase(hkFinishLoadedObjectFlag flag);
/// Returns true if the shape is a hkpConvexShape.
virtual bool isConvex() const { return false; }
/// Returns true if the shape is a hkpBvTreeShape.
HK_FORCE_INLINE bool isBvTree() const;
/// Returns true if the shape is a hkpShapeCollection.
HK_FORCE_INLINE bool isCollection() const;
virtual void getAabb(const hkTransform& localToWorld, hkReal tolerance, hkAabb& aabbOut) const;
virtual hkBool castRay(const hkpShapeRayCastInput& input, hkpShapeRayCastOutput& output) const;
virtual void castRayWithCollector(const hkpShapeRayCastInput& input, const hkpCdBody& cdBody,
hkpRayHitCollector& collector) const;
virtual hkVector4Comparison castRayBundle(const hkpShapeRayBundleCastInput& input,
hkpShapeRayBundleCastOutput& output,
hkVector4ComparisonParameter mask) const;
virtual void getSupportingVertex(hkVector4Parameter direction,
hkcdVertex& supportingVertexOut) const;
virtual void convertVertexIdsToVertices(const hkpVertexId* ids, int numIds,
hkcdVertex* vertexArrayOut) const;
virtual void getCentre(hkVector4& centreOut) const;
virtual int getNumCollisionSpheres() const;
virtual const hkSphere* getCollisionSpheres(hkSphere* sphereBuffer) const;
virtual int weldContactPoint(hkpVertexId* featurePoints, hkUint8& numFeaturePoints,
hkVector4& contactPointWs, const hkTransform* thisObjTransform,
const class hkpConvexShape* collidingConvexShape,
const hkTransform* collidingTransform,
hkVector4& separatingNormalInOut) const;
};
inline bool hkpShapeBase::isBvTree() const {
switch (m_type) {
case hkcdShapeType::BV_TREE:
case hkcdShapeType::MOPP:
case hkcdShapeType::STATIC_COMPOUND:
case hkcdShapeType::BV_COMPRESSED_MESH:
case hkcdShapeType::TRI_SAMPLED_HEIGHT_FIELD_BV_TREE:
return true;
default:
return false;
}
}
inline bool hkpShapeBase::isCollection() const {
switch (m_type) {
case hkcdShapeType::COLLECTION:
case hkcdShapeType::LIST:
case hkcdShapeType::EXTENDED_MESH:
case hkcdShapeType::TRI_SAMPLED_HEIGHT_FIELD_COLLECTION:
return true;
default:
return false;
}
}

View File

@ -0,0 +1,58 @@
#pragma once
#include <Havok/Common/Base/hkBase.h>
#include <Havok/Physics2012/Collide/Shape/hkpShape.h>
class hkpShapeBuffer;
class hkpShapeContainer {
public:
HK_DECLARE_CLASS_ALLOCATOR(hkpShapeContainer)
enum ReferencePolicy {
REFERENCE_POLICY_IGNORE,
REFERENCE_POLICY_INCREMENT,
};
virtual ~hkpShapeContainer() = default;
virtual int getNumChildShapes() const;
virtual hkpShapeKey getFirstKey() const = 0;
virtual hkpShapeKey getNextKey(hkpShapeKey oldKey) const = 0;
virtual hkUint32 getCollisionFilterInfo(hkpShapeKey key) const;
virtual const hkpShape* getChildShape(hkpShapeKey key, hkpShapeBuffer& buffer) const = 0;
virtual bool isWeldingEnabled() const { return true; }
};
class hkpSingleShapeContainer : public hkpShapeContainer {
public:
explicit hkpSingleShapeContainer(const hkpShape* s,
ReferencePolicy ref = REFERENCE_POLICY_INCREMENT)
: m_childShape(s) {
if (ref == REFERENCE_POLICY_INCREMENT) {
m_childShape->addReference();
}
}
HK_DECLARE_CLASS_ALLOCATOR(hkpSingleShapeContainer)
explicit hkpSingleShapeContainer(hkFinishLoadedObjectFlag) {}
~hkpSingleShapeContainer() override {
if (m_childShape) {
m_childShape->removeReference();
}
}
int getNumChildShapes() const override { return 1; }
hkpShapeKey getFirstKey() const override { return 0; }
hkpShapeKey getNextKey(hkpShapeKey oldKey) const override { return HK_INVALID_SHAPE_KEY; }
const hkpShape* getChildShape(hkpShapeKey key, hkpShapeBuffer& buffer) const override;
const hkpShape* getChild() const { return m_childShape; }
const hkpShape* operator->() const { return m_childShape; }
protected:
const hkpShape* m_childShape;
};

View File

@ -1,6 +1,6 @@
#pragma once
#include <Havok/Common/Base/Math/Vector/hkVector4.h>
#include <Havok/Common/Base/hkBase.h>
#include <math/seadVector.h>
#include <prim/seadTypedBitFlag.h>
#include <thread/seadAtomic.h>