Havok: Add hkpGroupFilter

This commit is contained in:
Léo Lam 2021-12-20 20:13:09 +01:00
parent 3e796ae9c7
commit 38bd3db171
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
4 changed files with 130 additions and 22 deletions

View File

@ -83804,7 +83804,7 @@ Address,Quality,Size,Name
0x0000007100fb6128,U,000004,nullsub_4242 0x0000007100fb6128,U,000004,nullsub_4242
0x0000007100fb612c,U,000004,j__ZdlPv_1005 0x0000007100fb612c,U,000004,j__ZdlPv_1005
0x0000007100fb6130,O,000004,_ZN18hkpCollisionFilter4initEP8hkpWorld 0x0000007100fb6130,O,000004,_ZN18hkpCollisionFilter4initEP8hkpWorld
0x0000007100fb6134,U,000008, 0x0000007100fb6134,O,000008,_ZN14hkpGroupFilter11dummyUnusedEv
0x0000007100fb613c,U,000204, 0x0000007100fb613c,U,000204,
0x0000007100fb6208,U,000092, 0x0000007100fb6208,U,000092,
0x0000007100fb6264,U,000044, 0x0000007100fb6264,U,000044,
@ -104117,27 +104117,27 @@ Address,Quality,Size,Name
0x00000071015c9ab4,U,000076, 0x00000071015c9ab4,U,000076,
0x00000071015c9b00,U,000256, 0x00000071015c9b00,U,000256,
0x00000071015c9c00,U,000004,nullsub_5103 0x00000071015c9c00,U,000004,nullsub_5103
0x00000071015c9c04,U,000100, 0x00000071015c9c04,L,000100,_ZN14hkpGroupFilterC1Ev
0x00000071015c9c68,U,000004,nullsub_5104 0x00000071015c9c68,L,000004,_ZN14hkpGroupFilterD1Ev
0x00000071015c9c6c,U,000004,nullsub_5105 0x00000071015c9c6c,L,000004,_ZThn16_N14hkpGroupFilterD1Ev
0x00000071015c9c70,U,000004,nullsub_5106 0x00000071015c9c70,L,000004,_ZThn24_N14hkpGroupFilterD1Ev
0x00000071015c9c74,U,000004,nullsub_5107 0x00000071015c9c74,L,000004,_ZThn32_N14hkpGroupFilterD1Ev
0x00000071015c9c78,U,000004,nullsub_5108 0x00000071015c9c78,L,000004,_ZThn40_N14hkpGroupFilterD1Ev
0x00000071015c9c7c,U,000084, 0x00000071015c9c7c,L,000084,_ZN14hkpGroupFilterD0Ev
0x00000071015c9cd0,U,000088, 0x00000071015c9cd0,L,000088,_ZThn16_N14hkpGroupFilterD0Ev
0x00000071015c9d28,U,000088, 0x00000071015c9d28,L,000088,_ZThn24_N14hkpGroupFilterD0Ev
0x00000071015c9d80,U,000088, 0x00000071015c9d80,L,000088,_ZThn32_N14hkpGroupFilterD0Ev
0x00000071015c9dd8,U,000088, 0x00000071015c9dd8,L,000088,_ZThn40_N14hkpGroupFilterD0Ev
0x00000071015c9e30,U,000108, 0x00000071015c9e30,L,000108,_ZNK14hkpGroupFilter18isCollisionEnabledERK13hkpCollidableS2_
0x00000071015c9e9c,U,000108, 0x00000071015c9e9c,L,000108,_ZThn16_NK14hkpGroupFilter18isCollisionEnabledERK13hkpCollidableS2_
0x00000071015c9f08,U,000244, 0x00000071015c9f08,L,000244,_ZNK14hkpGroupFilter18isCollisionEnabledERK17hkpCollisionInputRK9hkpCdBodyS5_RK17hkpShapeContainerS8_jj
0x00000071015c9ffc,U,000248, 0x00000071015c9ffc,L,000248,_ZThn24_NK14hkpGroupFilter18isCollisionEnabledERK17hkpCollisionInputRK9hkpCdBodyS5_RK17hkpShapeContainerS8_jj
0x00000071015ca0f4,U,000356, 0x00000071015ca0f4,L,000356,_ZNK14hkpGroupFilter18isCollisionEnabledERK17hkpCollisionInputRK9hkpCdBodyS5_RK17hkpShapeContainerj
0x00000071015ca258,U,000028, 0x00000071015ca258,L,000028,_ZThn24_NK14hkpGroupFilter18isCollisionEnabledERK17hkpCollisionInputRK9hkpCdBodyS5_RK17hkpShapeContainerj
0x00000071015ca274,U,000152, 0x00000071015ca274,L,000152,_ZNK14hkpGroupFilter18isCollisionEnabledERK20hkpShapeRayCastInputRK17hkpShapeContainerj
0x00000071015ca30c,U,000152, 0x00000071015ca30c,L,000152,_ZThn32_NK14hkpGroupFilter18isCollisionEnabledERK20hkpShapeRayCastInputRK17hkpShapeContainerj
0x00000071015ca3a4,U,000108, 0x00000071015ca3a4,L,000108,_ZNK14hkpGroupFilter18isCollisionEnabledERK20hkpWorldRayCastInputRK13hkpCollidable
0x00000071015ca410,U,000108, 0x00000071015ca410,L,000108,_ZThn40_NK14hkpGroupFilter18isCollisionEnabledERK20hkpWorldRayCastInputRK13hkpCollidable
0x00000071015ca47c,U,000216, 0x00000071015ca47c,U,000216,
0x00000071015ca554,U,000108, 0x00000071015ca554,U,000108,
0x00000071015ca5c0,U,000084, 0x00000071015ca5c0,U,000084,

Can't render this file because it is too large.

View File

@ -33,6 +33,8 @@ add_library(hkStubs OBJECT
Havok/Physics2012/Collide/Filter/hkpConvexListFilter.h Havok/Physics2012/Collide/Filter/hkpConvexListFilter.h
Havok/Physics2012/Collide/Filter/hkpRayCollidableFilter.h Havok/Physics2012/Collide/Filter/hkpRayCollidableFilter.h
Havok/Physics2012/Collide/Filter/hkpShapeCollectionFilter.h Havok/Physics2012/Collide/Filter/hkpShapeCollectionFilter.h
Havok/Physics2012/Collide/Filter/Group/hkpGroupFilter.cpp
Havok/Physics2012/Collide/Filter/Group/hkpGroupFilter.h
Havok/Physics2012/Collide/Shape/hkpShape.h Havok/Physics2012/Collide/Shape/hkpShape.h
Havok/Physics2012/Collide/Shape/hkpShapeBase.h Havok/Physics2012/Collide/Shape/hkpShapeBase.h
Havok/Physics2012/Collide/Shape/Convex/hkpConvexShape.h Havok/Physics2012/Collide/Shape/Convex/hkpConvexShape.h

View File

@ -0,0 +1,10 @@
#include <Havok/Physics2012/Collide/Filter/Group/hkpGroupFilter.h>
hkpGroupFilter::hkpGroupFilter() {
m_type = HK_FILTER_GROUP;
for (auto& x : m_collisionLookupTable)
x = 0xffffffff;
m_nextFreeSystemGroup = 0;
}
hkpGroupFilter::~hkpGroupFilter() = default;

View File

@ -0,0 +1,96 @@
#pragma once
#include <Havok/Physics2012/Collide/Filter/hkpCollisionFilter.h>
#include "Havok/Common/Base/Math/Vector/hkVector4.h"
class hkpGroupFilter : public hkpCollisionFilter {
public:
HK_DECLARE_CLASS_ALLOCATOR(hkpGroupFilter)
enum {
USE_COLLIDABLE_FILTER_INFO = 0xffffffff,
};
hkpGroupFilter();
~hkpGroupFilter() override;
explicit hkpGroupFilter(hkFinishLoadedObjectFlag flag) : hkpCollisionFilter(flag) {
if (flag.m_finishing) {
m_type = HK_FILTER_GROUP;
}
}
void enableCollisionsBetween(int layerA, int layerB);
void disableCollisionsBetween(int layerA, int layerB);
void enableCollisionsUsingBitfield(hkUint32 layerBitsA, hkUint32 layerBitsB);
void disableCollisionsUsingBitfield(hkUint32 layerBitsA, hkUint32 layerBitsB);
static inline hkUint32 calcFilterInfo(int layer, int systemGroup = 0, int subSystemId = 0,
int subSystemDontCollideWith = 0);
static inline int getLayerFromFilterInfo(hkUint32 filterInfo);
static inline int setLayer(hkUint32 filterInfo, int newLayer);
static inline int getSystemGroupFromFilterInfo(hkUint32 filterInfo);
static inline int getSubSystemIdFromFilterInfo(hkUint32 filterInfo);
static inline int getSubSystemDontCollideWithFromFilterInfo(hkUint32 filterInfo);
/// Creates a new unique identifier for system groups (maximum 65k).
inline int getNewSystemGroup();
hkBool isCollisionEnabled(const hkpCollidable& a, const hkpCollidable& b) const override;
hkBool isCollisionEnabled(const hkpCollisionInput& input, const hkpCdBody& a,
const hkpCdBody& b, const hkpShapeContainer& bContainer,
hkpShapeKey bKey) const override;
hkBool isCollisionEnabled(const hkpCollisionInput& input, const hkpCdBody& collectionBodyA,
const hkpCdBody& collectionBodyB,
const hkpShapeContainer& containerShapeA,
const hkpShapeContainer& containerShapeB, hkpShapeKey keyA,
hkpShapeKey keyB) const override;
hkBool isCollisionEnabled(const hkpShapeRayCastInput& aInput,
const hkpShapeContainer& bContainer, hkpShapeKey bKey) const override;
hkBool isCollisionEnabled(const hkpWorldRayCastInput& inputA,
const hkpCollidable& collidableB) const override;
hkBool isCollisionEnabled(hkUint32 infoA, hkUint32 infoB) const;
virtual int dummyUnused() { return 0; }
int m_nextFreeSystemGroup;
hkUint32 m_collisionLookupTable[32];
hkVector4 m_pad256[4];
};
inline hkUint32 hkpGroupFilter::calcFilterInfo(int layer, int systemGroup, int subSystemId,
int subSystemDontCollideWith) {
return (systemGroup << 16) | (subSystemDontCollideWith << 10) | (subSystemId << 5) | layer;
}
inline int hkpGroupFilter::getLayerFromFilterInfo(hkUint32 filterInfo) {
return int(filterInfo & 0x1f);
}
inline int hkpGroupFilter::setLayer(hkUint32 filterInfo, int newLayer) {
hkUint32 collisionLayerMask = 0xffffffff - 0x1f;
return int(newLayer + (collisionLayerMask & filterInfo));
}
inline int hkpGroupFilter::getSystemGroupFromFilterInfo(hkUint32 filterInfo) {
return int(filterInfo >> 16);
}
inline int hkpGroupFilter::getSubSystemIdFromFilterInfo(hkUint32 filterInfo) {
return int((filterInfo >> 5) & 0x1f);
}
inline int hkpGroupFilter::getSubSystemDontCollideWithFromFilterInfo(hkUint32 filterInfo) {
return int((filterInfo >> 10) & 0x1f);
}
inline int hkpGroupFilter::getNewSystemGroup() {
return ++m_nextFreeSystemGroup;
}