diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-11-01 08:20:15 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-11-01 08:20:15 +0100 |
commit | 5dfde1e7bdb5e116996087e8661ffd634fdcfea9 (patch) | |
tree | 795def6687a7b24cef704dd071a9a676e91c3811 /servers | |
parent | ec3c3afeaf820c1126c802e5d542bcfc537ee5a0 (diff) | |
parent | 7d1a159ba1d799875a9b886f1689724c897057d5 (diff) |
Merge pull request #68082 from Klowner/softbody3d-reoptmizelinkorder-crash-fix
Avoid GodotSoftBody3D.reoptimize_link_order() crash if <2 nodes available.
Diffstat (limited to 'servers')
-rw-r--r-- | servers/physics_3d/godot_soft_body_3d.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/servers/physics_3d/godot_soft_body_3d.cpp b/servers/physics_3d/godot_soft_body_3d.cpp index 173843072a..77110c5fbc 100644 --- a/servers/physics_3d/godot_soft_body_3d.cpp +++ b/servers/physics_3d/godot_soft_body_3d.cpp @@ -722,7 +722,14 @@ void GodotSoftBody3D::reoptimize_link_order() { const int reop_not_dependent = -1; const int reop_node_complete = -2; - uint32_t i, link_count = links.size(), node_count = nodes.size(); + uint32_t link_count = links.size(); + uint32_t node_count = nodes.size(); + + if (link_count < 1 || node_count < 2) { + return; + } + + uint32_t i; Link *lr; int ar, br; Node *node0 = &(nodes[0]); |