@@ -201,22 +201,24 @@ void SoftBodyBullet::get_node_offset(int p_node_index, btVector3 &r_offset) cons
201
201
G_TO_B (off, r_offset);
202
202
}
203
203
204
- void SoftBodyBullet::set_node_mass (int node_index , btScalar p_mass) {
204
+ void SoftBodyBullet::set_node_mass (int p_node_index , btScalar p_mass) {
205
205
if (0 >= p_mass) {
206
- pin_node (node_index );
206
+ pin_node (p_node_index );
207
207
} else {
208
- unpin_node (node_index );
208
+ unpin_node (p_node_index );
209
209
}
210
210
if (bt_soft_body) {
211
- bt_soft_body->setMass (node_index, p_mass);
211
+ ERR_FAIL_INDEX (p_node_index, bt_soft_body->m_nodes .size ());
212
+ bt_soft_body->setMass (p_node_index, p_mass);
212
213
}
213
214
}
214
215
215
- btScalar SoftBodyBullet::get_node_mass (int node_index ) const {
216
+ btScalar SoftBodyBullet::get_node_mass (int p_node_index ) const {
216
217
if (bt_soft_body) {
217
- return bt_soft_body->getMass (node_index);
218
+ ERR_FAIL_INDEX_V (p_node_index, bt_soft_body->m_nodes .size (), 1 );
219
+ return bt_soft_body->getMass (p_node_index);
218
220
} else {
219
- return -1 == search_node_pinned (node_index ) ? 1 : 0 ;
221
+ return -1 == search_node_pinned (p_node_index ) ? 1 : 0 ;
220
222
}
221
223
}
222
224
@@ -455,17 +457,25 @@ void SoftBodyBullet::setup_soft_body() {
455
457
456
458
// Set pinned nodes
457
459
for (int i = pinned_nodes.size () - 1 ; 0 <= i; --i) {
458
- bt_soft_body->setMass (pinned_nodes[i], 0 );
460
+ const int node_index = pinned_nodes[i];
461
+ ERR_CONTINUE (0 > node_index || bt_soft_body->m_nodes .size () <= node_index);
462
+ bt_soft_body->setMass (node_index, 0 );
459
463
}
460
464
}
461
465
462
466
void SoftBodyBullet::pin_node (int p_node_index) {
467
+ if (bt_soft_body) {
468
+ ERR_FAIL_INDEX (p_node_index, bt_soft_body->m_nodes .size ());
469
+ }
463
470
if (-1 == search_node_pinned (p_node_index)) {
464
471
pinned_nodes.push_back (p_node_index);
465
472
}
466
473
}
467
474
468
475
void SoftBodyBullet::unpin_node (int p_node_index) {
476
+ if (bt_soft_body) {
477
+ ERR_FAIL_INDEX (p_node_index, bt_soft_body->m_nodes .size ());
478
+ }
469
479
const int id = search_node_pinned (p_node_index);
470
480
if (-1 != id) {
471
481
pinned_nodes.remove (id);
0 commit comments