Skip to content
Merged
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
2 changes: 0 additions & 2 deletions modules/jolt_physics/objects/jolt_object_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ class JoltObject3D {
};

protected:
LocalVector<JoltShapeInstance3D> shapes;

RID rid;
ObjectID instance_id;
JoltSpace3D *space = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion modules/jolt_physics/objects/jolt_shaped_object_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions modules/jolt_physics/objects/jolt_shaped_object_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class JoltShapedObject3D : public JoltObject3D {
SelfList<JoltShapedObject3D> shapes_changed_element;
SelfList<JoltShapedObject3D> needs_optimization_element;

LocalVector<JoltShapeInstance3D> shapes;

Vector3 scale = Vector3(1, 1, 1);

JPH::ShapeRefC jolt_shape;
Expand Down
2 changes: 1 addition & 1 deletion modules/jolt_physics/spaces/jolt_contact_listener_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/jolt_physics/spaces/jolt_contact_listener_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions modules/jolt_physics/spaces/jolt_space_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,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()) {
Expand Down Expand Up @@ -195,8 +200,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) {
Expand All @@ -220,9 +223,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;
Expand Down
Loading