Merge pull request #116768 from mihe/jolt/tidying-up

Tidy some things up in `modules/jolt_physics`
This commit is contained in:
Thaddeus Crews 2026-02-26 08:15:17 -06:00
commit 5a5a806eaf
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
6 changed files with 10 additions and 10 deletions

View file

@ -61,8 +61,6 @@ public:
};
protected:
LocalVector<JoltShapeInstance3D> shapes;
RID rid;
ObjectID instance_id;
JoltSpace3D *space = nullptr;

View file

@ -286,7 +286,7 @@ JPH::ShapeRefC JoltShapedObject3D::build_shapes(bool p_optimize_compound) {
if (new_shape == nullptr) {
if (has_custom_center_of_mass()) {
new_shape = JPH::EmptyShapeSettings(to_jolt(get_center_of_mass_custom())).Create().Get();
new_shape = new JPH::EmptyShape(to_jolt(get_center_of_mass_custom()));
} else {
new_shape = new JPH::EmptyShape();
}

View file

@ -46,6 +46,8 @@ protected:
SelfList<JoltShapedObject3D> shapes_changed_element;
SelfList<JoltShapedObject3D> needs_optimization_element;
LocalVector<JoltShapeInstance3D> shapes;
Vector3 scale = Vector3(1, 1, 1);
JPH::ShapeRefC jolt_shape;

View file

@ -447,7 +447,7 @@ void JoltContactListener3D::_evaluate_area_overlap(const JoltArea3D &p_area, con
const MutexLock write_lock(write_mutex);
if (p_area.can_monitor(p_body)) {
area_soft_body_overlaps.insert(p_shape_pair);
area_soft_body_overlaps.push_back(p_shape_pair);
if (!area_exits.erase(p_shape_pair)) {
area_enters.insert(p_shape_pair);
}

View file

@ -88,9 +88,9 @@ class JoltContactListener3D final
HashMap<JPH::SubShapeIDPair, Manifold, ShapePairHasher> manifolds_by_shape_pair;
HashSet<JPH::SubShapeIDPair, ShapePairHasher> area_overlaps;
HashSet<JPH::SubShapeIDPair, ShapePairHasher> area_soft_body_overlaps;
HashSet<JPH::SubShapeIDPair, ShapePairHasher> area_enters;
HashSet<JPH::SubShapeIDPair, ShapePairHasher> area_exits;
LocalVector<JPH::SubShapeIDPair> area_soft_body_overlaps;
Mutex write_mutex;
JoltSpace3D *space = nullptr;

View file

@ -93,9 +93,14 @@ void JoltSpace3D::_pre_step(float p_step) {
JoltObject3D *object = reinterpret_cast<JoltObject3D *>(jolt_body->GetUserData());
object->pre_step(p_step, *jolt_body);
}
physics_system->SetBodyActivationListener(body_activation_listener);
}
void JoltSpace3D::_post_step(float p_step) {
// We only want a listener during the step, as it will otherwise be called when pending bodies are flushed, which causes issues (e.g. GH-115322).
physics_system->SetBodyActivationListener(nullptr);
contact_listener->post_step();
while (shapes_changed_list.first()) {
@ -189,8 +194,6 @@ void JoltSpace3D::step(float p_step) {
_pre_step(p_step);
physics_system->SetBodyActivationListener(body_activation_listener);
const JPH::EPhysicsUpdateError update_error = physics_system->Update(p_step, 1, temp_allocator, job_system);
if ((update_error & JPH::EPhysicsUpdateError::ManifoldCacheFull) != JPH::EPhysicsUpdateError::None) {
@ -214,9 +217,6 @@ void JoltSpace3D::step(float p_step) {
JoltProjectSettings::max_contact_constraints));
}
// We only want a listener during the step, as it will otherwise be called when pending bodies are flushed, which causes issues (e.g. GH-115322).
physics_system->SetBodyActivationListener(nullptr);
_post_step(p_step);
stepping = false;