Fix Skeleton3D falsely assuming all physical bones will be children of their first bone
This commit is contained in:
parent
3229194dfc
commit
913f57f695
1 changed files with 9 additions and 7 deletions
|
@ -888,6 +888,9 @@ void _pb_start_simulation(const Skeleton3D *p_skeleton, Node *p_node, const Vect
|
||||||
|
|
||||||
PhysicalBone3D *pb = Object::cast_to<PhysicalBone3D>(p_node);
|
PhysicalBone3D *pb = Object::cast_to<PhysicalBone3D>(p_node);
|
||||||
if (pb) {
|
if (pb) {
|
||||||
|
if (p_sim_bones.is_empty()) { // If no bones is specified, activate ragdoll on full body.
|
||||||
|
pb->set_simulate_physics(true);
|
||||||
|
} else {
|
||||||
for (int i = p_sim_bones.size() - 1; 0 <= i; --i) {
|
for (int i = p_sim_bones.size() - 1; 0 <= i; --i) {
|
||||||
if (p_sim_bones[i] == pb->get_bone_id() || p_skeleton->is_bone_parent_of(pb->get_bone_id(), p_sim_bones[i])) {
|
if (p_sim_bones[i] == pb->get_bone_id() || p_skeleton->is_bone_parent_of(pb->get_bone_id(), p_sim_bones[i])) {
|
||||||
pb->set_simulate_physics(true);
|
pb->set_simulate_physics(true);
|
||||||
|
@ -896,14 +899,13 @@ void _pb_start_simulation(const Skeleton3D *p_skeleton, Node *p_node, const Vect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Skeleton3D::physical_bones_start_simulation_on(const TypedArray<StringName> &p_bones) {
|
void Skeleton3D::physical_bones_start_simulation_on(const TypedArray<StringName> &p_bones) {
|
||||||
set_physics_process_internal(false);
|
set_physics_process_internal(false);
|
||||||
|
|
||||||
Vector<int> sim_bones;
|
Vector<int> sim_bones;
|
||||||
if (p_bones.size() <= 0) {
|
if (p_bones.size() > 0) {
|
||||||
sim_bones.push_back(0); // If no bones is specified, activate ragdoll on full body.
|
|
||||||
} else {
|
|
||||||
sim_bones.resize(p_bones.size());
|
sim_bones.resize(p_bones.size());
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for (int i = sim_bones.size() - 1; 0 <= i; --i) {
|
for (int i = sim_bones.size() - 1; 0 <= i; --i) {
|
||||||
|
|
Loading…
Reference in a new issue