소스 검색

Add a new configuration warning to CollisionShape

In the case where a ConcavePolygonShape is used as a shape for a RigidBody
in another mode than static, a configuration warning will appear in the
editor.
Pierre Caye 5 년 전
부모
커밋
ad227d9a85
2개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      scene/3d/collision_shape.cpp
  2. 1 0
      scene/3d/physics_body.cpp

+ 8 - 0
scene/3d/collision_shape.cpp

@@ -123,6 +123,14 @@ String CollisionShape::get_configuration_warning() const {
 		return TTR("A shape must be provided for CollisionShape to function. Please create a shape resource for it.");
 	}
 
+	if (Object::cast_to<RigidBody>(get_parent())) {
+		if (Object::cast_to<ConcavePolygonShape>(*shape)) {
+			if (Object::cast_to<RigidBody>(get_parent())->get_mode() != RigidBody::MODE_STATIC) {
+				return TTR("ConcavePolygonShape doesn't support RigidBody in another mode than static.");
+			}
+		}
+	}
+
 	return String();
 }
 

+ 1 - 0
scene/3d/physics_body.cpp

@@ -518,6 +518,7 @@ void RigidBody::set_mode(Mode p_mode) {
 			PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_KINEMATIC);
 		} break;
 	}
+	update_configuration_warning();
 }
 
 RigidBody::Mode RigidBody::get_mode() const {