Browse Source

Merge pull request #104167 from TokageItLab/spring-inside-tree

Add `is_inside_tree()` check to SpringBoneSimulator3D
Thaddeus Crews 4 months ago
parent
commit
6ef89f12bc
1 changed files with 10 additions and 0 deletions
  1. 10 0
      scene/3d/spring_bone_simulator_3d.cpp

+ 10 - 0
scene/3d/spring_bone_simulator_3d.cpp

@@ -1371,6 +1371,9 @@ void SpringBoneSimulator3D::_find_collisions() {
 }
 }
 
 
 void SpringBoneSimulator3D::_process_collisions() {
 void SpringBoneSimulator3D::_process_collisions() {
+	if (!is_inside_tree()) {
+		return;
+	}
 	for (const ObjectID &oid : collisions) {
 	for (const ObjectID &oid : collisions) {
 		Object *t_obj = ObjectDB::get_instance(oid);
 		Object *t_obj = ObjectDB::get_instance(oid);
 		if (!t_obj) {
 		if (!t_obj) {
@@ -1494,6 +1497,10 @@ void SpringBoneSimulator3D::_set_active(bool p_active) {
 }
 }
 
 
 void SpringBoneSimulator3D::_process_modification() {
 void SpringBoneSimulator3D::_process_modification() {
+	if (!is_inside_tree()) {
+		return;
+	}
+
 	Skeleton3D *skeleton = get_skeleton();
 	Skeleton3D *skeleton = get_skeleton();
 	if (!skeleton) {
 	if (!skeleton) {
 		return;
 		return;
@@ -1515,6 +1522,9 @@ void SpringBoneSimulator3D::_process_modification() {
 }
 }
 
 
 void SpringBoneSimulator3D::reset() {
 void SpringBoneSimulator3D::reset() {
+	if (!is_inside_tree()) {
+		return;
+	}
 	Skeleton3D *skeleton = get_skeleton();
 	Skeleton3D *skeleton = get_skeleton();
 	if (!skeleton) {
 	if (!skeleton) {
 		return;
 		return;