Skip to content

Commit

Permalink
Remove scene context from errors/warnings in Jolt Physics module
Browse files Browse the repository at this point in the history
  • Loading branch information
mihe committed Feb 11, 2025
1 parent 296de7d commit 41d7aac
Show file tree
Hide file tree
Showing 29 changed files with 155 additions and 219 deletions.
9 changes: 4 additions & 5 deletions modules/jolt_physics/joints/jolt_cone_twist_joint_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,17 @@ void JoltConeTwistJoint3D::set_param(PhysicsServer3D::ConeTwistJointParam p_para
} break;
case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: {
if (!Math::is_equal_approx(p_value, DEFAULT_BIAS)) {
WARN_PRINT(vformat("Cone twist joint bias is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("Cone twist joint bias is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: {
if (!Math::is_equal_approx(p_value, DEFAULT_SOFTNESS)) {
WARN_PRINT(vformat("Cone twist joint softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("Cone twist joint softness is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: {
if (!Math::is_equal_approx(p_value, DEFAULT_RELAXATION)) {
WARN_PRINT(vformat("Cone twist joint relaxation is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("Cone twist joint relaxation is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
default: {
Expand Down Expand Up @@ -348,8 +348,7 @@ void JoltConeTwistJoint3D::rebuild() {
destroy();

JoltSpace3D *space = get_space();

if (space == nullptr) {
if (unlikely(space == nullptr)) {
return;
}

Expand Down
18 changes: 9 additions & 9 deletions modules/jolt_physics/joints/jolt_generic_6dof_joint_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,17 +351,17 @@ void JoltGeneric6DOFJoint3D::set_param(Axis p_axis, Param p_param, double p_valu
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: {
if (!Math::is_equal_approx(p_value, DEFAULT_LINEAR_LIMIT_SOFTNESS)) {
WARN_PRINT(vformat("6DOF joint linear limit softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("6DOF joint linear limit softness is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION: {
if (!Math::is_equal_approx(p_value, DEFAULT_LINEAR_RESTITUTION)) {
WARN_PRINT(vformat("6DOF joint linear restitution is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("6DOF joint linear restitution is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING: {
if (!Math::is_equal_approx(p_value, DEFAULT_LINEAR_DAMPING)) {
WARN_PRINT(vformat("6DOF joint linear damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("6DOF joint linear damping is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: {
Expand Down Expand Up @@ -394,27 +394,27 @@ void JoltGeneric6DOFJoint3D::set_param(Axis p_axis, Param p_param, double p_valu
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
if (!Math::is_equal_approx(p_value, DEFAULT_ANGULAR_LIMIT_SOFTNESS)) {
WARN_PRINT(vformat("6DOF joint angular limit softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("6DOF joint angular limit softness is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING: {
if (!Math::is_equal_approx(p_value, DEFAULT_ANGULAR_DAMPING)) {
WARN_PRINT(vformat("6DOF joint angular damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("6DOF joint angular damping is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: {
if (!Math::is_equal_approx(p_value, DEFAULT_ANGULAR_RESTITUTION)) {
WARN_PRINT(vformat("6DOF joint angular restitution is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("6DOF joint angular restitution is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: {
if (!Math::is_equal_approx(p_value, DEFAULT_ANGULAR_FORCE_LIMIT)) {
WARN_PRINT(vformat("6DOF joint angular force limit is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("6DOF joint angular force limit is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: {
if (!Math::is_equal_approx(p_value, DEFAULT_ANGULAR_ERP)) {
WARN_PRINT(vformat("6DOF joint angular ERP is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("6DOF joint angular ERP is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: {
Expand Down Expand Up @@ -652,7 +652,7 @@ void JoltGeneric6DOFJoint3D::rebuild() {
destroy();

JoltSpace3D *space = get_space();
if (space == nullptr) {
if (unlikely(space == nullptr)) {
return;
}

Expand Down
11 changes: 5 additions & 6 deletions modules/jolt_physics/joints/jolt_hinge_joint_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void JoltHingeJoint3D::set_param(Parameter p_param, double p_value) {
switch (p_param) {
case PhysicsServer3D::HINGE_JOINT_BIAS: {
if (!Math::is_equal_approx(p_value, DEFAULT_BIAS)) {
WARN_PRINT(vformat("Hinge joint bias is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("Hinge joint bias is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER: {
Expand All @@ -218,17 +218,17 @@ void JoltHingeJoint3D::set_param(Parameter p_param, double p_value) {
} break;
case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS: {
if (!Math::is_equal_approx(p_value, DEFAULT_LIMIT_BIAS)) {
WARN_PRINT(vformat("Hinge joint bias limit is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("Hinge joint bias limit is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS: {
if (!Math::is_equal_approx(p_value, DEFAULT_SOFTNESS)) {
WARN_PRINT(vformat("Hinge joint softness is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("Hinge joint softness is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION: {
if (!Math::is_equal_approx(p_value, DEFAULT_RELAXATION)) {
WARN_PRINT(vformat("Hinge joint relaxation is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("Hinge joint relaxation is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY: {
Expand Down Expand Up @@ -381,8 +381,7 @@ void JoltHingeJoint3D::rebuild() {
destroy();

JoltSpace3D *space = get_space();

if (space == nullptr) {
if (unlikely(space == nullptr)) {
return;
}

Expand Down
10 changes: 2 additions & 8 deletions modules/jolt_physics/joints/jolt_joint_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ void JoltJoint3D::_iterations_changed() {
_wake_up_bodies();
}

String JoltJoint3D::_bodies_to_string() const {
return vformat("'%s' and '%s'", body_a != nullptr ? body_a->to_string() : "<unknown>", body_b != nullptr ? body_b->to_string() : "<World>");
}

JoltJoint3D::JoltJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D *p_body_a, JoltBody3D *p_body_b, const Transform3D &p_local_ref_a, const Transform3D &p_local_ref_b) :
enabled(p_old_joint.enabled),
collision_disabled(p_old_joint.collision_disabled),
Expand Down Expand Up @@ -146,12 +142,10 @@ JoltSpace3D *JoltJoint3D::get_space() const {
JoltSpace3D *space_a = body_a->get_space();
JoltSpace3D *space_b = body_b->get_space();

if (space_a == nullptr || space_b == nullptr) {
if (space_a == nullptr || space_b == nullptr || space_a != space_b) {
return nullptr;
}

ERR_FAIL_COND_V_MSG(space_a != space_b, nullptr, vformat("Joint was found to connect bodies in different physics spaces. This joint will effectively be disabled. This joint connects %s.", _bodies_to_string()));

return space_a;
} else if (body_a != nullptr) {
return body_a->get_space();
Expand All @@ -178,7 +172,7 @@ int JoltJoint3D::get_solver_priority() const {

void JoltJoint3D::set_solver_priority(int p_priority) {
if (p_priority != DEFAULT_SOLVER_PRIORITY) {
WARN_PRINT(vformat("Joint solver priority is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("Joint solver priority is not supported when using Jolt Physics. Any such value will be ignored.");
}
}

Expand Down
2 changes: 0 additions & 2 deletions modules/jolt_physics/joints/jolt_joint_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ class JoltJoint3D {
void _enabled_changed();
void _iterations_changed();

String _bodies_to_string() const;

public:
JoltJoint3D() = default;
JoltJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D *p_body_a, JoltBody3D *p_body_b, const Transform3D &p_local_ref_a, const Transform3D &p_local_ref_b);
Expand Down
9 changes: 4 additions & 5 deletions modules/jolt_physics/joints/jolt_pin_joint_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ void JoltPinJoint3D::set_param(PhysicsServer3D::PinJointParam p_param, double p_
switch (p_param) {
case PhysicsServer3D::PIN_JOINT_BIAS: {
if (!Math::is_equal_approx(p_value, DEFAULT_BIAS)) {
WARN_PRINT(vformat("Pin joint bias is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("Pin joint bias is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::PIN_JOINT_DAMPING: {
if (!Math::is_equal_approx(p_value, DEFAULT_DAMPING)) {
WARN_PRINT(vformat("Pin joint damping is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("Pin joint damping is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP: {
if (!Math::is_equal_approx(p_value, DEFAULT_IMPULSE_CLAMP)) {
WARN_PRINT(vformat("Pin joint impulse clamp is not supported when using Jolt Physics. Any such value will be ignored. This joint connects %s.", _bodies_to_string()));
WARN_PRINT_ONCE("Pin joint impulse clamp is not supported when using Jolt Physics. Any such value will be ignored.");
}
} break;
default: {
Expand Down Expand Up @@ -138,8 +138,7 @@ void JoltPinJoint3D::rebuild() {
destroy();

JoltSpace3D *space = get_space();

if (space == nullptr) {
if (unlikely(space == nullptr)) {
return;
}

Expand Down
Loading

0 comments on commit 41d7aac

Please sign in to comment.