From 674ff09c548de5fad01b43c2ccd171eadf3fd202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Fri, 7 Jan 2022 19:44:59 +0100 Subject: [PATCH] Havok: Add hkpEntity getters/setters --- .../Base/Container/Array/hkSmallArray.h | 13 ++ .../Physics2012/Dynamics/Entity/hkpEntity.h | 146 ++++++++++++++++++ 2 files changed, 159 insertions(+) diff --git a/lib/hkStubs/Havok/Common/Base/Container/Array/hkSmallArray.h b/lib/hkStubs/Havok/Common/Base/Container/Array/hkSmallArray.h index 091c1e3e..79b27273 100644 --- a/lib/hkStubs/Havok/Common/Base/Container/Array/hkSmallArray.h +++ b/lib/hkStubs/Havok/Common/Base/Container/Array/hkSmallArray.h @@ -28,6 +28,9 @@ public: HK_FORCE_INLINE int getSize() const; HK_FORCE_INLINE int getCapacity() const; + HK_FORCE_INLINE T& operator[](int i); + HK_FORCE_INLINE const T& operator[](int i) const; + protected: void releaseMemory(); @@ -55,6 +58,16 @@ inline int hkSmallArray::getCapacity() const { return m_capacityAndFlags & CAPACITY_MASK; } +template +inline T& hkSmallArray::operator[](int i) { + return m_data[i]; +} + +template +inline const T& hkSmallArray::operator[](int i) const { + return m_data[i]; +} + template inline void hkSmallArray::releaseMemory() { if ((m_capacityAndFlags & DONT_DEALLOCATE_FLAG) == 0) diff --git a/lib/hkStubs/Havok/Physics2012/Dynamics/Entity/hkpEntity.h b/lib/hkStubs/Havok/Physics2012/Dynamics/Entity/hkpEntity.h index 9afc4cdd..15d2fd68 100644 --- a/lib/hkStubs/Havok/Physics2012/Dynamics/Entity/hkpEntity.h +++ b/lib/hkStubs/Havok/Physics2012/Dynamics/Entity/hkpEntity.h @@ -12,6 +12,7 @@ class hkpAction; class hkpBreakableBody; class hkpConstraintInstance; class hkpContactListener; +class hkpDynamicsContactMgr; class hkpEntityActivationListener; class hkpEntityListener; class hkpSimulationIsland; @@ -67,6 +68,70 @@ public: explicit hkpEntity(hkFinishLoadedObjectFlag flag); ~hkpEntity() override; + void addEntityListener(hkpEntityListener* el); + void removeEntityListener(hkpEntityListener* el); + + void addEntityActivationListener(hkpEntityActivationListener* el); + void removeEntityActivationListener(hkpEntityActivationListener* el); + + void addContactListener(hkpContactListener* cl); + void removeContactListener(hkpContactListener* cl); + + inline const hkSmallArray& getEntityListeners() const; + inline const hkSmallArray& getEntityActivationListeners() const; + inline const hkSmallArray& getContactListeners() const; + inline bool areContactListenersAdded() const; + + inline hkUint16 getContactPointCallbackDelay() const; + inline void setContactPointCallbackDelay(hkUint16 delay); + + inline hkpMaterial& getMaterial(); + inline const hkpMaterial& getMaterial() const; + + inline hkBool isFixed() const; + inline hkBool isFixedOrKeyframed() const; + inline hkUint32 getUid() const; + + hkpDynamicsContactMgr* findContactMgrTo(const hkpEntity* entity) const; + + hkpBreakableBody* getBreakableBody() const; + + void activate(); + void requestDeactivation(); + void deactivate(); + void activateAsCriticalOperation(); + void requestDeactivationAsCriticalOperation(); + void deactivateAsCriticalOperation(); + hkBool isActive() const; + + inline int getNumActions() const; + inline hkpAction* getAction(int i); + + int getNumConstraints() const; + hkpConstraintInstance* getConstraint(int i); + void getAllConstraints(hkArray& constraints); + const hkpConstraintInstance* getConstraint(int i) const; + inline const hkSmallArray& getConstraintMasters() const; + inline hkSmallArray& getConstraintMastersRw(); + inline const hkArray& getConstraintSlaves() const; + + void sortConstraintsSlavesDeterministically(); + + void setCachedShapeData(const hkpWorld* world, const hkpShape* shape); + + void updateCachedAabb(); + +protected: + const hkSmallArray& getConstraintMastersImpl() const; + hkSmallArray& getConstraintMastersRwImpl(); + const hkArray& getConstraintSlavesImpl() const; + + explicit hkpEntity(const hkpShape* shape); + +public: + inline hkpMotion* getMotion(); + inline hkpSimulationIsland* getSimulationIsland() const; + virtual void deallocateInternalArrays(); hkMotionState* getMotionState() override { return nullptr; } @@ -93,3 +158,84 @@ public: mutable ExtendedListeners* m_extendedListeners; hkUint32 m_npData; }; + +inline const hkSmallArray& hkpEntity::getEntityListeners() const { + if (!m_extendedListeners) + m_extendedListeners = new ExtendedListeners; + return m_extendedListeners->m_entityListeners; +} + +inline const hkSmallArray& +hkpEntity::getEntityActivationListeners() const { + if (!m_extendedListeners) + m_extendedListeners = new ExtendedListeners; + return m_extendedListeners->m_activationListeners; +} + +inline const hkSmallArray& hkpEntity::getContactListeners() const { + return m_contactListeners; +} + +inline bool hkpEntity::areContactListenersAdded() const { + return m_contactListeners.getSize() > 0; +} + +inline hkUint16 hkpEntity::getContactPointCallbackDelay() const { + return m_contactPointCallbackDelay; +} + +inline void hkpEntity::setContactPointCallbackDelay(hkUint16 delay) { + m_contactPointCallbackDelay = delay; +} + +inline hkpMaterial& hkpEntity::getMaterial() { + return m_material; +} + +inline const hkpMaterial& hkpEntity::getMaterial() const { + return m_material; +} + +inline hkBool hkpEntity::isFixed() const { + return m_motion.getType() == hkpMotion::MOTION_FIXED; +} + +inline hkBool hkpEntity::isFixedOrKeyframed() const { + return isFixed() || m_motion.getType() == hkpMotion::MOTION_KEYFRAMED; +} + +inline hkUint32 hkpEntity::getUid() const { + return m_uid; +} + +inline hkpBreakableBody* hkpEntity::getBreakableBody() const { + return m_breakableBody; +} + +inline const hkSmallArray& hkpEntity::getConstraintMasters() const { + return getConstraintMastersImpl(); +} + +inline hkSmallArray& hkpEntity::getConstraintMastersRw() { + return getConstraintMastersRwImpl(); +} + +inline const hkArray& hkpEntity::getConstraintSlaves() const { + return getConstraintSlavesImpl(); +} + +inline hkpMotion* hkpEntity::getMotion() { + return &m_motion; +} + +inline hkpSimulationIsland* hkpEntity::getSimulationIsland() const { + return m_simulationIsland; +} + +inline hkpAction* hkpEntity::getAction(int i) { + return m_actions[i]; +} + +inline int hkpEntity::getNumActions() const { + return m_actions.getSize(); +}