Remove Jolt Physics project setting "Areas Detect Static Bodies"

This commit is contained in:
Mikael Hermansson 2025-04-25 12:49:47 +02:00
parent e45cc68092
commit e160040f0c
6 changed files with 23 additions and 24 deletions

View file

@ -48,6 +48,8 @@
#include "core/string/print_string.h"
#include "core/variant/variant_utility.h"
#include "Jolt/Physics/Collision/CollideShapeVsShapePerLeaf.h"
#include "Jolt/Physics/Collision/CollisionCollectorImpl.h"
#include "Jolt/Physics/PhysicsScene.h"
namespace {
@ -121,6 +123,18 @@ JoltSpace3D::JoltSpace3D(JPH::JobSystem *p_job_system) :
physics_system->SetContactListener(contact_listener);
physics_system->SetSoftBodyContactListener(contact_listener);
physics_system->SetSimCollideBodyVsBody([](const JPH::Body &p_body1, const JPH::Body &p_body2, JPH::Mat44Arg p_transform_com1, JPH::Mat44Arg p_transform_com2, JPH::CollideShapeSettings &p_collide_shape_settings, JPH::CollideShapeCollector &p_collector, const JPH::ShapeFilter &p_shape_filter) {
if (p_body1.IsSensor() || p_body2.IsSensor()) {
JPH::CollideShapeSettings new_collide_shape_settings = p_collide_shape_settings;
// Since we're breaking the sensor down into leaf shapes we'll end up stripping away our `JoltCustomDoubleSidedShape` decorator shape and thus any back-face collision, so we simply force-enable it like this rather than going through the trouble of reapplying the decorator.
new_collide_shape_settings.mBackFaceMode = JPH::EBackFaceMode::CollideWithBackFaces;
JPH::SubShapeIDCreator part1, part2;
JPH::CollideShapeVsShapePerLeaf<JPH::AnyHitCollisionCollector<JPH::CollideShapeCollector>>(p_body1.GetShape(), p_body2.GetShape(), JPH::Vec3::sOne(), JPH::Vec3::sOne(), p_transform_com1, p_transform_com2, part1, part2, new_collide_shape_settings, p_collector, p_shape_filter);
} else {
JPH::PhysicsSystem::sDefaultSimCollideBodyVsBody(p_body1, p_body2, p_transform_com1, p_transform_com2, p_collide_shape_settings, p_collector, p_shape_filter);
}
});
physics_system->SetCombineFriction([](const JPH::Body &p_body1, const JPH::SubShapeID &p_sub_shape_id1, const JPH::Body &p_body2, const JPH::SubShapeID &p_sub_shape_id2) {
return Math::abs(MIN(p_body1.GetFriction(), p_body2.GetFriction()));
});