summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-08-05 16:06:15 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-08-05 16:06:15 -0300
commitde9fb90dbf9473b91e75edbd063fb96f9ea4d262 (patch)
treea2b9a1d38cf50ac1848a5c301819dbf10c111de3 /scene/3d
parentcfe4b30941a3388a5ee40690fd468f994180fa86 (diff)
Warn about resizing a rigidbody (2D or 3D), covers the most common cases, closes #7615
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/physics_body.cpp31
-rw-r--r--scene/3d/physics_body.h2
2 files changed, 33 insertions, 0 deletions
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 7e599ce2f5..9feed2fe7b 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -473,6 +473,21 @@ void RigidBody::_direct_state_changed(Object *p_state) {
}
void RigidBody::_notification(int p_what) {
+
+#ifdef TOOLS_ENABLED
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ if (get_tree()->is_editor_hint()) {
+ set_notify_local_transform(true); //used for warnings and only in editor
+ }
+ }
+
+ if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) {
+ if (get_tree()->is_editor_hint()) {
+ update_configuration_warning();
+ }
+ }
+
+#endif
}
void RigidBody::set_mode(Mode p_mode) {
@@ -747,6 +762,22 @@ Array RigidBody::get_colliding_bodies() const {
return ret;
}
+String RigidBody::get_configuration_warning() const {
+
+ Transform t = get_transform();
+
+ String warning = CollisionObject::get_configuration_warning();
+
+ if ((get_mode() == MODE_RIGID || get_mode() == MODE_CHARACTER) && (ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(0).length() - 1.0) > 0.05)) {
+ if (warning != String()) {
+ warning += "\n";
+ }
+ warning += TTR("Size changes to RigidBody (in character or rigid modes) will be overriden by the physics engine when running.\nChange the size in children collision shapes instead.");
+ }
+
+ return warning;
+}
+
void RigidBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mode", "mode"), &RigidBody::set_mode);
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index f86d7d957f..83811a1d93 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -252,6 +252,8 @@ public:
void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse);
+ virtual String get_configuration_warning() const;
+
RigidBody();
~RigidBody();
};