From 9b35b6236828076a443b1c0544129c7aecaba5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Thu, 3 Mar 2022 14:35:48 +0100 Subject: [PATCH] Add more Havok prereqs for ContactListener --- lib/hkStubs/CMakeLists.txt | 8 ++ .../Common/Base/Object/hkReferencedObject.cpp | 2 +- .../Common/Base/Object/hkReferencedObject.h | 4 +- .../Havok/Common/Base/Types/hkBaseTypes.h | 5 + .../ContactMgr/hkpContactMgrFactory.h | 15 +++ .../Dynamics/Collide/hkpDynamicsContactMgr.h | 1 - .../Collide/hkpSimpleConstraintContactMgr.h | 112 ++++++++++++++++++ .../Atom/hkpModifierConstraintAtom.h | 28 +++++ .../Atom/hkpSimpleContactConstraintAtom.h | 47 ++++++++ .../Atom/hkpSimpleContactConstraintAtomUtil.h | 33 ++++++ .../Contact/hkpContactPointProperties.h | 2 +- .../Constraint/Contact/hkpDynamicsCpidMgr.h | 29 +++++ .../Contact/hkpSimpleContactConstraintData.h | 72 +++++++++++ .../Dynamics/World/hkpSimulationIsland.h | 2 +- .../hkpSimpleContactConstraintDataInfo.h | 39 ++++++ 15 files changed, 394 insertions(+), 5 deletions(-) create mode 100644 lib/hkStubs/Havok/Physics2012/Collide/Dispatch/ContactMgr/hkpContactMgrFactory.h create mode 100644 lib/hkStubs/Havok/Physics2012/Dynamics/Collide/hkpSimpleConstraintContactMgr.h create mode 100644 lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpModifierConstraintAtom.h create mode 100644 lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpSimpleContactConstraintAtom.h create mode 100644 lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpSimpleContactConstraintAtomUtil.h create mode 100644 lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpDynamicsCpidMgr.h create mode 100644 lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpSimpleContactConstraintData.h create mode 100644 lib/hkStubs/Havok/Physics2012/Internal/Solver/Contact/hkpSimpleContactConstraintDataInfo.h diff --git a/lib/hkStubs/CMakeLists.txt b/lib/hkStubs/CMakeLists.txt index 3f5d23bb..41685a64 100644 --- a/lib/hkStubs/CMakeLists.txt +++ b/lib/hkStubs/CMakeLists.txt @@ -99,6 +99,7 @@ add_library(hkStubs OBJECT Havok/Physics2012/Collide/BroadPhase/hkpBroadPhaseHandle.h Havok/Physics2012/Collide/BroadPhase/hkpTypedBroadPhaseHandle.h Havok/Physics2012/Collide/Dispatch/hkpCollisionDispatcher.h + Havok/Physics2012/Collide/Dispatch/ContactMgr/hkpContactMgrFactory.h Havok/Physics2012/Collide/Filter/hkpCollidableCollidableFilter.h Havok/Physics2012/Collide/Filter/hkpCollisionFilter.cpp Havok/Physics2012/Collide/Filter/hkpCollisionFilter.h @@ -136,6 +137,7 @@ add_library(hkStubs OBJECT Havok/Physics2012/Dynamics/Action/hkpAction.h Havok/Physics2012/Dynamics/Collide/hkpDynamicsContactMgr.h Havok/Physics2012/Dynamics/Collide/hkpResponseModifier.h + Havok/Physics2012/Dynamics/Collide/hkpSimpleConstraintContactMgr.h Havok/Physics2012/Dynamics/Collide/ContactListener/hkpCollisionEvent.h Havok/Physics2012/Dynamics/Collide/ContactListener/hkpContactListener.h Havok/Physics2012/Dynamics/Collide/ContactListener/hkpContactPointEvent.h @@ -143,7 +145,12 @@ add_library(hkStubs OBJECT Havok/Physics2012/Dynamics/Common/hkpProperty.h Havok/Physics2012/Dynamics/Constraint/hkpConstraintInstance.h Havok/Physics2012/Dynamics/Constraint/hkpConstraintOwner.h + Havok/Physics2012/Dynamics/Constraint/Atom/hkpModifierConstraintAtom.h + Havok/Physics2012/Dynamics/Constraint/Atom/hkpSimpleContactConstraintAtom.h + Havok/Physics2012/Dynamics/Constraint/Atom/hkpSimpleContactConstraintAtomUtil.h Havok/Physics2012/Dynamics/Constraint/Contact/hkpContactPointProperties.h + Havok/Physics2012/Dynamics/Constraint/Contact/hkpDynamicsCpidMgr.h + Havok/Physics2012/Dynamics/Constraint/Contact/hkpSimpleContactConstraintData.h Havok/Physics2012/Dynamics/Entity/hkpEntity.h Havok/Physics2012/Dynamics/Entity/hkpRigidBody.h Havok/Physics2012/Dynamics/Entity/hkpRigidBodyCinfo.h @@ -173,6 +180,7 @@ add_library(hkStubs OBJECT Havok/Physics2012/Dynamics/World/Simulation/hkpSimulation.h Havok/Physics2012/Internal/Collide/Mopp/Code/hkpMoppCode.h + Havok/Physics2012/Internal/Solver/Contact/hkpSimpleContactConstraintDataInfo.h Havok/Physics2012/Utilities/CharacterControl/CharacterRigidBody/hkpCharacterRigidBody.h Havok/Physics2012/Utilities/Collide/ShapeUtils/ShapeScaling/hkpShapeScalingUtility.h diff --git a/lib/hkStubs/Havok/Common/Base/Object/hkReferencedObject.cpp b/lib/hkStubs/Havok/Common/Base/Object/hkReferencedObject.cpp index b67324b2..2029b86a 100644 --- a/lib/hkStubs/Havok/Common/Base/Object/hkReferencedObject.cpp +++ b/lib/hkStubs/Havok/Common/Base/Object/hkReferencedObject.cpp @@ -1,6 +1,6 @@ #include -const void* hkReferencedObject::getClassType() const { +const hkClass* hkReferencedObject::getClassType() const { return nullptr; } diff --git a/lib/hkStubs/Havok/Common/Base/Object/hkReferencedObject.h b/lib/hkStubs/Havok/Common/Base/Object/hkReferencedObject.h index 0ee4e253..186fdeb6 100644 --- a/lib/hkStubs/Havok/Common/Base/Object/hkReferencedObject.h +++ b/lib/hkStubs/Havok/Common/Base/Object/hkReferencedObject.h @@ -5,6 +5,8 @@ #include #include "Havok/Common/Base/Thread/Atomic/hkAtomicPrimitives.h" +class hkClass; + class hkReferencedObject : public hkBaseObject { public: inline hkReferencedObject(); @@ -17,7 +19,7 @@ public: ~hkReferencedObject() override = default; - virtual const void* getClassType() const; + virtual const hkClass* getClassType() const; inline int getReferenceCount() const; inline void setReferenceCount(int newRefCount); diff --git a/lib/hkStubs/Havok/Common/Base/Types/hkBaseTypes.h b/lib/hkStubs/Havok/Common/Base/Types/hkBaseTypes.h index e81d7761..c6719c75 100644 --- a/lib/hkStubs/Havok/Common/Base/Types/hkBaseTypes.h +++ b/lib/hkStubs/Havok/Common/Base/Types/hkBaseTypes.h @@ -216,6 +216,11 @@ HK_FORCE_INLINE hkLong hkGetByteOffset(const void* base, const void* pntr) { return hkLong(pntr) - hkLong(base); } +template +HK_ALWAYS_INLINE const T* hkAddByteOffsetConst(const T* base, hkLong offset) { + return reinterpret_cast(reinterpret_cast(base) + offset); +} + template using hkAddConstPointer = std::conditional_t, diff --git a/lib/hkStubs/Havok/Physics2012/Collide/Dispatch/ContactMgr/hkpContactMgrFactory.h b/lib/hkStubs/Havok/Physics2012/Collide/Dispatch/ContactMgr/hkpContactMgrFactory.h new file mode 100644 index 00000000..e1f4edf5 --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Collide/Dispatch/ContactMgr/hkpContactMgrFactory.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +class hkpCollidable; +struct hkpCollisionInput; +class hkpContactMgr; + +class hkpContactMgrFactory : public hkReferencedObject { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkpContactMgrFactory) + + virtual hkpContactMgr* createContactMgr(const hkpCollidable& a, const hkpCollidable& b, + const hkpCollisionInput& input) = 0; +}; diff --git a/lib/hkStubs/Havok/Physics2012/Dynamics/Collide/hkpDynamicsContactMgr.h b/lib/hkStubs/Havok/Physics2012/Dynamics/Collide/hkpDynamicsContactMgr.h index 66bf6a56..b72f0f3f 100644 --- a/lib/hkStubs/Havok/Physics2012/Dynamics/Collide/hkpDynamicsContactMgr.h +++ b/lib/hkStubs/Havok/Physics2012/Dynamics/Collide/hkpDynamicsContactMgr.h @@ -6,7 +6,6 @@ class hkContactPoint; class hkpContactPointProperties; class hkpWorld; -/// An interface to access contact point information. class hkpDynamicsContactMgr : public hkpContactMgr { public: HK_DECLARE_CLASS_ALLOCATOR(hkpDynamicsContactMgr) diff --git a/lib/hkStubs/Havok/Physics2012/Dynamics/Collide/hkpSimpleConstraintContactMgr.h b/lib/hkStubs/Havok/Physics2012/Dynamics/Collide/hkpSimpleConstraintContactMgr.h new file mode 100644 index 00000000..69aba9da --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Dynamics/Collide/hkpSimpleConstraintContactMgr.h @@ -0,0 +1,112 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +class hkpRigidBody; + +extern const hkClass hkpSimpleConstraintContactMgrClass; + +class hkpSimpleConstraintContactMgr : public hkpDynamicsContactMgr { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkpSimpleConstraintContactMgr) + + hkpSimpleConstraintContactMgr(hkpWorld* world, hkpRigidBody* bodyA, hkpRigidBody* bodyB); + ~hkpSimpleConstraintContactMgr() override; + + explicit hkpSimpleConstraintContactMgr(hkFinishLoadedObjectFlag f) + : hkpDynamicsContactMgr(hkpContactMgr::TYPE_SIMPLE_CONSTRAINT_CONTACT_MGR), + m_contactConstraintData(f), m_constraint(f) { + m_constraint.m_uid = 0xffffffff; + } + + hkContactPoint* getContactPoint(hkContactPointId id) override; + hkpContactPointProperties* getContactPointProperties(hkContactPointId id) override; + + hkContactPointId addContactPointImpl(const hkpCdBody& a, const hkpCdBody& b, + const hkpProcessCollisionInput& input, + hkpProcessCollisionOutput& output, + const hkpGskCache* contactCache, + hkContactPoint& cp) override; + hkResult reserveContactPointsImpl(int numPoints) override; + void removeContactPointImpl(hkContactPointId cpId, + hkCollisionConstraintOwner& constraintOwner) override; + void processContactImpl(const hkpCollidable& a, const hkpCollidable& b, + const hkpProcessCollisionInput& input, + hkpProcessCollisionData& collisionData) override; + ToiAccept addToiImpl(const hkpCdBody& a, const hkpCdBody& b, + const hkpProcessCollisionInput& input, hkpProcessCollisionOutput& output, + hkTime toi, hkContactPoint& cp, const hkpGskCache* gskCache, + hkReal& projectedVelocity, hkpContactPointProperties& properties) override; + void removeToiImpl(class hkCollisionConstraintOwner& constraintOwner, + hkpContactPointProperties& properties) override; + hkBool fireCallbacksForEarliestToi(struct hkpToiEvent& event, hkReal& rotateNormal) override; + void confirmToi(struct hkpToiEvent& event, hkReal rotateNormal, + class hkArray& outToBeActivated) override; + void cleanup() override { delete this; } + Type getType() const override { return TYPE_SIMPLE_CONSTRAINT_CONTACT_MGR; } + void getAllContactPointIds(hkArray& contactPointIds) const override; + + HK_FORCE_INLINE hkpSimpleContactConstraintAtom* getAtom() { + return m_contactConstraintData.m_atom; + } + + HK_FORCE_INLINE const hkpSimpleContactConstraintAtom* getAtom() const { + return m_contactConstraintData.m_atom; + } + + hkpConstraintInstance* getConstraintInstance() override; + virtual const hkpConstraintInstance* getConstraintInstance() const; + + void toiCollisionResponseBeginCallback(const hkContactPoint& cp, + struct hkpSimpleConstraintInfoInitInput& inA, + struct hkpBodyVelocity& velA, + hkpSimpleConstraintInfoInitInput& inB, + hkpBodyVelocity& velB) override; + + void toiCollisionResponseEndCallback(const hkContactPoint& cp, hkReal impulseApplied, + struct hkpSimpleConstraintInfoInitInput& inA, + struct hkpBodyVelocity& velA, + hkpSimpleConstraintInfoInitInput& inB, + hkpBodyVelocity& velB) override; + + inline hkBool isConstraintDisabled() const { + return m_constraint.getConstraintModifiers() && + (m_constraint.getConstraintModifiers()->getType() == + hkpConstraintAtom::TYPE_MODIFIER_IGNORE_CONSTRAINT); + } + +protected: + inline hkpRigidBody* setContactPointProperties(const hkpCdBody& a, const hkpCdBody& b, + int maxNumExtraDataInEvent, + hkpContactPointProperties* cpi); + + const hkClass* getClassType() const override { return &hkpSimpleConstraintContactMgrClass; } + +public: + class Factory : public hkpContactMgrFactory { + public: + HK_DECLARE_CLASS_ALLOCATOR(Factory) + + explicit Factory(hkpWorld* mgr); + + hkpContactMgr* createContactMgr(const hkpCollidable& a, const hkpCollidable& b, + const hkpCollisionInput& input) override; + + protected: + hkpWorld* m_world; + }; + +public: + hkUint16 m_reservedContactPoints; + hkUint16 m_contactPointCallbackDelay; + + hkpSimpleContactConstraintData m_contactConstraintData; + hkpConstraintInstance m_constraint; + + hkUint32 m_pad[1]; +}; diff --git a/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpModifierConstraintAtom.h b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpModifierConstraintAtom.h new file mode 100644 index 00000000..508fb72b --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpModifierConstraintAtom.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +struct hkpConstraintInfo; + +struct hkpModifierConstraintAtom : public hkpConstraintAtom { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkpModifierConstraintAtom) + HK_DECLARE_REFLECTION() + + explicit hkpModifierConstraintAtom(hkFinishLoadedObjectFlag f) : hkpConstraintAtom(f) {} + + int addModifierDataToConstraintInfo(hkpConstraintInfo& cinfo, hkUint8& usedFlagsOut) const; + + static int addAllModifierDataToConstraintInfo(hkpModifierConstraintAtom* firstModifier, + hkpConstraintInfo& cinfo, hkUint8& usedFlagsOut); + +protected: + hkpModifierConstraintAtom(AtomType type, int size) + : hkpConstraintAtom(type), m_modifierAtomSize(static_cast(size)) {} + +public: + alignas(16) hkUint16 m_modifierAtomSize; + hkUint16 m_childSize; + hkpConstraintAtom* m_child; + hkUint32 m_pad[2]; +}; diff --git a/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpSimpleContactConstraintAtom.h b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpSimpleContactConstraintAtom.h new file mode 100644 index 00000000..82ce823d --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpSimpleContactConstraintAtom.h @@ -0,0 +1,47 @@ +#pragma once + +#include +#include +#include +#include +#include + +class hkpContactPointProperties; + +struct hkpSimpleContactConstraintAtom : public hkpConstraintAtom { +public: + HK_DECLARE_REFLECTION() + HK_DECLARE_CLASS_ALLOCATOR(hkpSimpleContactConstraintAtom) + + hkpSimpleContactConstraintAtom() : hkpConstraintAtom(TYPE_CONTACT) {} + explicit hkpSimpleContactConstraintAtom(hkFinishLoadedObjectFlag f); + + HK_FORCE_INLINE hkContactPoint* getContactPoints() const { + return const_cast(reinterpret_cast(this + 1)); + } + + HK_FORCE_INLINE int getContactPointPropertiesStriding() const; + + HK_FORCE_INLINE hkpContactPointProperties* getContactPointPropertiesStream() const { + return const_cast( + reinterpret_cast(hkAddByteOffsetConst( + getContactPoints(), sizeof(hkContactPoint) * m_numReservedContactPoints))); + } + + HK_FORCE_INLINE hkpContactPointProperties* getContactPointPropertiesStream(int i) const; + + HK_FORCE_INLINE hkpConstraintAtom* next() const { return nullptr; } + HK_FORCE_INLINE int numSolverResults() const { return m_numContactPoints + 3; } + HK_FORCE_INLINE void addToConstraintInfo(hkpConstraintInfo& infoOut) const; + + hkUint16 m_sizeOfAllAtoms; + hkUint16 m_numContactPoints; + hkUint16 m_numReservedContactPoints; + + hkUint8 m_numUserDatasForBodyA; + hkUint8 m_numUserDatasForBodyB; + hkUint8 m_contactPointPropertiesStriding; + hkUint16 m_maxNumContactPoints; + + alignas(16) hkpSimpleContactConstraintDataInfo m_info; +}; diff --git a/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpSimpleContactConstraintAtomUtil.h b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpSimpleContactConstraintAtomUtil.h new file mode 100644 index 00000000..ccd01fa6 --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Atom/hkpSimpleContactConstraintAtomUtil.h @@ -0,0 +1,33 @@ +#pragma once + +#include + +class hkpSimpleContactConstraintAtomUtil { +public: + static hkpSimpleContactConstraintAtom* + expandOne(hkpSimpleContactConstraintAtom* oldAtom_mightGetDeallocated, bool& atomReallocated); + + inline static void removeAtAndCopy(hkpSimpleContactConstraintAtom* atom, int index); + + static hkpSimpleContactConstraintAtom* + optimizeCapacity(hkpSimpleContactConstraintAtom* oldAtom_mightGetDeallocated, + int numFreeElemsLeft, bool& atomReallocated); + + static hkpSimpleContactConstraintAtom* allocateAtom(int numReservedContactPoints, + int numExtraUserDatasA, + int numExtraUserDatasB, + int maxNumContactPoints); + + static void copyContents(hkpSimpleContactConstraintAtom* dst, + const hkpSimpleContactConstraintAtom* src); + + static inline void deallocateAtom(hkpSimpleContactConstraintAtom* atom); + + static inline int calculateAtomSize(int numReservedContactPoints, int numExtraUserDatas); +}; + +void hkpSimpleContactConstraintAtomUtil::deallocateAtom(hkpSimpleContactConstraintAtom* atom) { + extern int atomSizeRoundUp(int); + int allocsize = atomSizeRoundUp(atom->m_sizeOfAllAtoms); + hkDeallocateChunk(reinterpret_cast(atom), allocsize); +} diff --git a/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpContactPointProperties.h b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpContactPointProperties.h index d6c9bdba..36aa99a9 100644 --- a/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpContactPointProperties.h +++ b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpContactPointProperties.h @@ -4,7 +4,7 @@ #include #include -class hkpSimpleContactConstraintAtom; +struct hkpSimpleContactConstraintAtom; class hkpContactPointProperties : public hkpSolverResults, public hkContactPointMaterial { public: diff --git a/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpDynamicsCpidMgr.h b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpDynamicsCpidMgr.h new file mode 100644 index 00000000..927cef3d --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpDynamicsCpidMgr.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include + +class hkpDynamicsCpIdMgr { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkpDynamicsCpIdMgr) + + using hkpValueType = hkUchar; + static constexpr int HK_MAX_IDS_PER_OBJECT = 8; + static constexpr hkpValueType FREE_VALUE = 0xff; + + inline hkpDynamicsCpIdMgr(); + inline ~hkpDynamicsCpIdMgr(); + + inline int newId(int value); + inline int indexOf(int value) const; + inline void freeId(int id); + inline void decrementValuesGreater(int relIndex); + inline void getAllUsedIds(hkArray& ids) const; + inline hkpValueType getValueAt(int id) const; + + hkInplaceArray m_values; +}; + +inline hkpDynamicsCpIdMgr::hkpDynamicsCpIdMgr() = default; + +inline hkpDynamicsCpIdMgr::~hkpDynamicsCpIdMgr() = default; diff --git a/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpSimpleContactConstraintData.h b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpSimpleContactConstraintData.h new file mode 100644 index 00000000..a501dc49 --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Dynamics/Constraint/Contact/hkpSimpleContactConstraintData.h @@ -0,0 +1,72 @@ +#pragma once + +#include +#include +#include +#include + +class hkpConstraintInstance; +class hkpConstraintOwner; +class hkpContactPointProperties; +class hkpRigidBody; +class hkpSimpleConstraintContactMgr; +struct hkpSimpleContactConstraintAtom; + +class hkpSimpleContactConstraintData : public hkpConstraintData { +public: + HK_DECLARE_CLASS_ALLOCATOR(hkpSimpleContactConstraintData) + + explicit hkpSimpleContactConstraintData(hkFinishLoadedObjectFlag f) {} + inline ~hkpSimpleContactConstraintData(); + + inline int getNumContactPoints() const; + inline hkContactPointId getContactPointIdAt(int index) const; + inline const hkContactPoint& getContactPoint(int id) const; + inline hkContactPoint& getContactPoint(int id); + inline hkpContactPointProperties* getContactPointProperties(int id); + + hkContactPointId allocateContactPoint(hkpConstraintOwner& constraintOwner, + hkContactPoint** cpOut, + hkpContactPointProperties** cpPropsOut); + + int freeContactPoint(hkpConstraintOwner& constraintOwner, hkContactPointId id); + + hkBool isValid() const override; + void getConstraintInfo(hkpConstraintData::ConstraintInfo& infoOut) const override; + void getRuntimeInfo(hkBool wantRuntime, hkpConstraintData::RuntimeInfo& infoOut) const override; + hkpSolverResults* getSolverResults(hkpConstraintRuntime* runtime) const override; + int getType() const override; + + virtual void collisionResponseBeginCallback(const hkContactPoint& cp, + struct hkpSimpleConstraintInfoInitInput& inA, + struct hkpBodyVelocity& velA, + hkpSimpleConstraintInfoInitInput& inB, + hkpBodyVelocity& velB); + + virtual void collisionResponseEndCallback(const hkContactPoint& cp, hkReal impulseApplied, + struct hkpSimpleConstraintInfoInitInput& inA, + struct hkpBodyVelocity& velA, + hkpSimpleConstraintInfoInitInput& inB, + hkpBodyVelocity& velB); + + hkpSimpleConstraintContactMgr* getSimpleConstraintContactMgr() const; + +private: + hkpSimpleContactConstraintData(hkpConstraintInstance* constraint, hkpRigidBody* bodyA, + hkpRigidBody* bodyB); + + friend class hkpSimpleConstraintContactMgr; + +public: + hkpDynamicsCpIdMgr m_idMgrA; + void* m_clientData; + hkpConstraintInstance* m_constraint; + hkpSimpleContactConstraintAtom* m_atom; + int m_atomSize; +}; + +hkpSimpleContactConstraintData::~hkpSimpleContactConstraintData() { + if (m_atom) { + hkpSimpleContactConstraintAtomUtil::deallocateAtom(m_atom); + } +} diff --git a/lib/hkStubs/Havok/Physics2012/Dynamics/World/hkpSimulationIsland.h b/lib/hkStubs/Havok/Physics2012/Dynamics/World/hkpSimulationIsland.h index 7142bfd5..0fceb995 100644 --- a/lib/hkStubs/Havok/Physics2012/Dynamics/World/hkpSimulationIsland.h +++ b/lib/hkStubs/Havok/Physics2012/Dynamics/World/hkpSimulationIsland.h @@ -25,7 +25,7 @@ public: inline int getMemUsageForIntegration(); - const void* getClassType() const override { return &hkpSimulationIslandClass; } + const hkClass* getClassType() const override { return &hkpSimulationIslandClass; } protected: friend class hkpAddModifierUtil; diff --git a/lib/hkStubs/Havok/Physics2012/Internal/Solver/Contact/hkpSimpleContactConstraintDataInfo.h b/lib/hkStubs/Havok/Physics2012/Internal/Solver/Contact/hkpSimpleContactConstraintDataInfo.h new file mode 100644 index 00000000..381408a1 --- /dev/null +++ b/lib/hkStubs/Havok/Physics2012/Internal/Solver/Contact/hkpSimpleContactConstraintDataInfo.h @@ -0,0 +1,39 @@ +#pragma once + +#include + +class hkpSimpleContactConstraintDataInfo { +public: + HK_DECLARE_REFLECTION() + HK_DECLARE_CLASS_ALLOCATOR(hkpSimpleContactConstraintDataInfo) + + enum { + HK_FLAG_OK = 0, + HK_FLAG_POINT_REMOVED = 1 << 0, + HK_FLAG_AREA_CHANGED = 1 << 2, + }; + + hkpSimpleContactConstraintDataInfo() { init(); } + explicit hkpSimpleContactConstraintDataInfo(hkFinishLoadedObjectFlag f) {} + + void init() { + m_flags = HK_FLAG_OK; + m_biNormalAxis = 3; + m_contactRadius = 0.0f; + m_internalData1.setZero(); + m_rhsRolling[0].setZero(); + m_rhsRolling[1].setZero(); + m_rollingFrictionMultiplier.setZero(); + for (int i = 0; i < 4; ++i) { + m_data[i] = 0; + } + } + + alignas(16) hkUint16 m_flags; + hkUint16 m_biNormalAxis; + hkHalf m_rollingFrictionMultiplier; + hkHalf m_internalData1; + hkHalf m_rhsRolling[2]; + hkReal m_contactRadius; + hkReal m_data[4]; +};