You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-11 13:10:58 +00:00
Merge pull request #12756 from Stratos695/master
Allowing double-axis lock in RigidBody & KinematicBody (Fixes #12500)
This commit is contained in:
@@ -559,6 +559,20 @@ void BodySW::integrate_velocities(real_t p_step) {
|
||||
if (fi_callback)
|
||||
get_space()->body_add_to_state_query_list(&direct_state_query_list);
|
||||
|
||||
//apply axis lock
|
||||
if (locked_axis[0] || locked_axis[1] || locked_axis[2]) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (locked_axis[i]) {
|
||||
linear_velocity[i] = 0;
|
||||
biased_linear_velocity[i] = 0;
|
||||
new_transform.origin[i] = get_transform().origin[i];
|
||||
} else {
|
||||
angular_velocity[i] = 0;
|
||||
biased_angular_velocity[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == PhysicsServer::BODY_MODE_KINEMATIC) {
|
||||
|
||||
_set_transform(new_transform, false);
|
||||
@@ -569,22 +583,6 @@ void BodySW::integrate_velocities(real_t p_step) {
|
||||
return;
|
||||
}
|
||||
|
||||
//apply axis lock
|
||||
if (axis_lock != PhysicsServer::BODY_AXIS_LOCK_DISABLED) {
|
||||
|
||||
int axis = axis_lock - 1;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (i == axis) {
|
||||
linear_velocity[i] = 0;
|
||||
biased_linear_velocity[i] = 0;
|
||||
} else {
|
||||
|
||||
angular_velocity[i] = 0;
|
||||
biased_angular_velocity[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 total_angular_velocity = angular_velocity + biased_angular_velocity;
|
||||
|
||||
real_t ang_vel = total_angular_velocity.length();
|
||||
@@ -775,7 +773,6 @@ BodySW::BodySW() :
|
||||
continuous_cd = false;
|
||||
can_sleep = false;
|
||||
fi_callback = NULL;
|
||||
axis_lock = PhysicsServer::BODY_AXIS_LOCK_DISABLED;
|
||||
}
|
||||
|
||||
BodySW::~BodySW() {
|
||||
|
||||
Reference in New Issue
Block a user