Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions data/uking_functions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -84881,9 +84881,9 @@ Address,Quality,Size,Name
0x0000007100fd0698,U,000004,j__ZdlPv_1016
0x0000007100fd069c,O,000372,_ZN4ksys4phys18motionTypeFromTextERKN4sead14SafeStringBaseIcEE
0x0000007100fd0810,U,000092,
0x0000007100fd086c,U,000356,
0x0000007100fd09d0,U,000076,
0x0000007100fd0a1c,U,000016,_ZN4ksys4phys36getCollisionFilterInfoFromCollidableEPNS0_23RigidBodyCollisionMasksEPjRK13hkpCollidablePKj
0x0000007100fd086c,O,000356,_ZN4ksys4phys29getMaterialMaskFromCollidableEPNS0_23RigidBodyCollisionMasksEPjRK8hkpShapePKj
0x0000007100fd09d0,O,000076,_ZN4ksys4phys32getBodyGroupAndObjectFromSCShapeEPPNS0_28StaticCompoundRigidBodyGroupEPPNS_3map6ObjectERK8hkpShapePKj
0x0000007100fd0a1c,O,000016,_ZN4ksys4phys36getCollisionFilterInfoFromCollidableEPNS0_23RigidBodyCollisionMasksEPjRK13hkpCollidablePKj
0x0000007100fd0a2c,U,000680,
0x0000007100fd0cd4,U,000036,_ZN4ksys19PlayerTrackReporterC1Ev
0x0000007100fd0cf8,U,000064,PlayerTrackReporter::dtor
Expand Down Expand Up @@ -106571,7 +106571,7 @@ Address,Quality,Size,Name
0x000000710164ed44,U,002824,
0x000000710164f84c,U,000272,
0x000000710164f95c,U,000004,nullsub_5216
0x000000710164f960,U,000312,
0x000000710164f960,L,000312,_ZNK24hkpBvCompressedMeshShape20getPrimitiveUserDataEj
0x000000710164fa98,U,000060,
0x000000710164fad4,U,000468,
0x000000710164fca8,U,000240,
Expand Down
95 changes: 95 additions & 0 deletions src/KingSystem/Physics/StaticCompound/physStaticCompoundUtil.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,96 @@
#include "KingSystem/Physics/StaticCompound/physStaticCompoundUtil.h"
#include <Havok/Physics2012/Collide/Agent/Collidable/hkpCollidable.h>
#include <Havok/Physics2012/Collide/Shape/Compound/Collection/List/hkpListShape.h>
#include <Havok/Physics2012/Internal/Collide/BvCompressedMesh/hkpBvCompressedMeshShape.h>
#include <Havok/Physics2012/Internal/Collide/StaticCompound/hkpStaticCompoundShape.h>
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
#include "KingSystem/Physics/StaticCompound/physStaticCompoundMgr.h"
#include "KingSystem/Physics/System/physSystem.h"

namespace ksys::phys {

u32 getMaterialMaskFromCollidable(RigidBodyCollisionMasks* p_masks, u32* p_collision_filter_info,
const hkpShape& shape, const u32* shape_key) {
auto no_material = [&] {
p_masks->material_mask = 0;
*p_collision_filter_info = 0;
return 1;
};

switch (shape.getType()) {
case hkcdShapeType::BV_COMPRESSED_MESH: {
if (*shape_key == HK_INVALID_SHAPE_KEY)
return no_material();

const auto& mesh = static_cast<const hkpBvCompressedMeshShape&>(shape);
if (mesh.getCollisionFilterInfoMode() ==
hkpBvCompressedMeshShape::PER_PRIMITIVE_DATA_PALETTE) {
*p_collision_filter_info = mesh.getCollisionFilterInfo(*shape_key);
}

if (mesh.getUserDataMode() != hkpBvCompressedMeshShape::PER_PRIMITIVE_DATA_NONE) {
p_masks->material_mask = mesh.getPrimitiveUserData(*shape_key);
return 0;
}

p_masks->material_mask = mesh.getUserData();
return 0;
}

case hkcdShapeType::STATIC_COMPOUND: {
if (*shape_key == HK_INVALID_SHAPE_KEY)
return no_material();

const auto& compound = static_cast<const hkpStaticCompoundShape&>(shape);
int instance_id;
hkpShapeKey child_key;
compound.decomposeShapeKey(*shape_key, instance_id, child_key);
const auto& instance = compound.getInstances()[instance_id];
*p_collision_filter_info = compound.getCollisionFilterInfo(*shape_key);
return getMaterialMaskFromCollidable(p_masks, p_collision_filter_info, *instance.getShape(),
&child_key);
}

case hkcdShapeType::LIST: {
if (*shape_key == HK_INVALID_SHAPE_KEY)
return no_material();

hkpShapeBuffer buffer;
const auto& list = static_cast<const hkpListShape&>(shape);
return getMaterialMaskFromCollidable(p_masks, p_collision_filter_info,
*list.getChildShape(*shape_key, buffer), shape_key);
}

default:
p_masks->material_mask = shape.getUserData();
return 0;
}
}

void getBodyGroupAndObjectFromSCShape(StaticCompoundRigidBodyGroup** p_body_group,
map::Object** p_object, const hkpShape& shape,
const u32* shape_key) {
if (shape.getType() != hkcdShapeType::STATIC_COMPOUND) {
*p_body_group = nullptr;
return;
}

auto* mgr = System::instance()->getStaticCompoundMgr();
if (!mgr) {
*p_body_group = nullptr;
return;
}

mgr->getBodyGroupAndMapObject(p_body_group, p_object,
static_cast<const hkpStaticCompoundShape&>(shape), shape_key);
}

u32 getCollisionFilterInfoFromCollidable(RigidBodyCollisionMasks* p_masks,
u32* p_collision_filter_info,
const hkpCollidable& collidable, const u32* shape_key) {
*p_collision_filter_info = collidable.getCollisionFilterInfo();
return getMaterialMaskFromCollidable(p_masks, p_collision_filter_info, *collidable.getShape(),
shape_key);
}

} // namespace ksys::phys
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@ namespace ksys::phys {
class StaticCompoundRigidBodyGroup;
struct RigidBodyCollisionMasks;

// 0x0000007100fd0810
u32 getMaterialMaskFromShape(const hkpShape& shape, const u32* shape_key,
const sead::Vector3f& position);

// 0x0000007100fd086c
bool getMaterialMaskFromCollidable(RigidBodyCollisionMasks* p_masks, u32* p_collision_filter_info,
const hkpShape& shape, const u32* shape_key);
u32 getMaterialMaskFromCollidable(RigidBodyCollisionMasks* p_masks, u32* p_collision_filter_info,
const hkpShape& shape, const u32* shape_key);

// 0x0000007100fd09d0
void getBodyGroupAndObjectFromSCShape(StaticCompoundRigidBodyGroup** p_body_group,
map::Object** p_object, const hkpShape& shape,
const u32* shape_key);

// 0x0000007100fd0a1c
u32 getCollisionFilterInfoFromCollidable(RigidBodyCollisionMasks* p_masks,
u32* p_collision_filter_info,
const hkpCollidable& collidable, const u32* shape_key);
Expand Down