Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update damping values for jolt rigid bodies on mode switch at runtime #100473

Merged
merged 1 commit into from
Dec 20, 2024
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
20 changes: 20 additions & 0 deletions modules/jolt_physics/objects/jolt_body_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,26 @@ void JoltBody3D::set_angular_damp(float p_damp) {
_update_damp();
}

void JoltBody3D::set_linear_damp_mode(DampMode p_mode) {
if (p_mode == linear_damp_mode) {
return;
}

linear_damp_mode = p_mode;

_update_damp();
}

void JoltBody3D::set_angular_damp_mode(DampMode p_mode) {
if (p_mode == angular_damp_mode) {
return;
}

angular_damp_mode = p_mode;

_update_damp();
}

bool JoltBody3D::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const {
return (locked_axes & (uint32_t)p_axis) != 0;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/jolt_physics/objects/jolt_body_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ class JoltBody3D final : public JoltShapedObject3D {
void set_collision_priority(float p_priority) { collision_priority = p_priority; }

DampMode get_linear_damp_mode() const { return linear_damp_mode; }
void set_linear_damp_mode(DampMode p_mode) { linear_damp_mode = p_mode; }
void set_linear_damp_mode(DampMode p_mode);

DampMode get_angular_damp_mode() const { return angular_damp_mode; }
void set_angular_damp_mode(DampMode p_mode) { angular_damp_mode = p_mode; }
void set_angular_damp_mode(DampMode p_mode);

bool is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const;
void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_enabled);
Expand Down