summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/audio_stream_player_2d.cpp2
-rw-r--r--scene/2d/canvas_item.cpp2
-rw-r--r--scene/2d/collision_object_2d.cpp14
-rw-r--r--scene/2d/collision_object_2d.h2
-rw-r--r--scene/2d/path_2d.cpp2
-rw-r--r--scene/2d/physics_body_2d.cpp13
6 files changed, 31 insertions, 4 deletions
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index ed602bbc70..b11deb08fd 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -195,7 +195,7 @@ void AudioStreamPlayer2D::_notification(int p_what) {
float dist = global_pos.distance_to(screen_in_global); //distance to screen center
if (dist > max_distance)
- continue; //cant hear this sound in this viewport
+ continue; //can't hear this sound in this viewport
float multiplier = Math::pow(1.0f - dist / max_distance, attenuation);
multiplier *= Math::db2linear(volume_db); //also apply player volume!
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 12d6f32567..87bcdae527 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -101,7 +101,7 @@ void CanvasItemMaterial::_update_shader() {
case LIGHT_MODE_UNSHADED: code += ",unshaded"; break;
case LIGHT_MODE_LIGHT_ONLY: code += ",light_only"; break;
}
- code += ";\n"; //thats it.
+ code += ";\n"; //that's it.
ShaderData shader_data;
shader_data.shader = VS::get_singleton()->shader_create();
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index e451e7a65b..8350e7c48a 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -328,6 +328,20 @@ void CollisionObject2D::_update_pickable() {
Physics2DServer::get_singleton()->body_set_pickable(rid, pickable);
}
+String CollisionObject2D::get_configuration_warning() const {
+
+ String warning = Node2D::get_configuration_warning();
+
+ if (shapes.empty()) {
+ if (warning == String()) {
+ warning += "\n";
+ }
+ warning += TTR("This node has no children shapes, so it can't interact with the space.\nConsider adding CollisionShape2D or CollisionPolygon2D children nodes to define its shape.");
+ }
+
+ return warning;
+}
+
void CollisionObject2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rid"), &CollisionObject2D::get_rid);
diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h
index ee3cea46a5..6da63d1a0b 100644
--- a/scene/2d/collision_object_2d.h
+++ b/scene/2d/collision_object_2d.h
@@ -107,6 +107,8 @@ public:
void set_pickable(bool p_enabled);
bool is_pickable() const;
+ String get_configuration_warning() const;
+
_FORCE_INLINE_ RID get_rid() const { return rid; }
CollisionObject2D();
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 2c8f509bd3..052a0ac026 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -39,7 +39,7 @@
Rect2 Path2D::_edit_get_rect() const {
- if (curve->get_point_count() == 0)
+ if (!curve.is_valid() || curve->get_point_count() == 0)
return Rect2(0, 0, 0, 0);
Rect2 aabb = Rect2(curve->get_point_position(0), Vector2(0, 0));
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 1b25b3588a..cc99ce5f49 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -244,6 +244,7 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) {
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
+ ERR_FAIL_COND(!contact_monitor);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(E->get().in_scene);
@@ -266,6 +267,7 @@ void RigidBody2D::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node);
+ ERR_FAIL_COND(!contact_monitor);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_scene);
@@ -291,6 +293,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
Object *obj = ObjectDB::get_instance(objid);
Node *node = Object::cast_to<Node>(obj);
+ ERR_FAIL_COND(!contact_monitor);
Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(objid);
/*if (obj) {
@@ -763,6 +766,14 @@ void RigidBody2D::set_contact_monitor(bool p_enabled) {
for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
//clean up mess
+ Object *obj = ObjectDB::get_instance(E->key());
+ Node *node = Object::cast_to<Node>(obj);
+
+ if (node) {
+
+ node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
+ }
}
memdelete(contact_monitor);
@@ -807,7 +818,7 @@ String RigidBody2D::get_configuration_warning() const {
if (warning != String()) {
warning += "\n";
}
- warning += TTR("Size changes to RigidBody2D (in character or rigid modes) will be overriden by the physics engine when running.\nChange the size in children collision shapes instead.");
+ warning += TTR("Size changes to RigidBody2D (in character or rigid modes) will be overridden by the physics engine when running.\nChange the size in children collision shapes instead.");
}
return warning;