summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/physics_body_2d.cpp11
-rw-r--r--scene/3d/collision_object.cpp2
-rw-r--r--scene/3d/physics_body.cpp11
-rw-r--r--scene/resources/dynamic_font.cpp11
-rw-r--r--scene/resources/dynamic_font.h16
5 files changed, 35 insertions, 16 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index c4c9362387..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);
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index 73770a2dd2..07235b3da4 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -373,7 +373,7 @@ String CollisionObject::get_configuration_warning() const {
if (warning == String()) {
warning += "\n";
}
- warning += TTR("This node has no children shapes, so it can't interact with the space.\nConsider adding CollisionShape or CollisionPolygon children nodes to define it's shape.");
+ warning += TTR("This node has no children shapes, so it can't interact with the space.\nConsider adding CollisionShape or CollisionPolygon children nodes to define its shape.");
}
return warning;
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index bf7952b2dd..25acd6deb0 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -258,6 +258,7 @@ void RigidBody::_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_tree);
@@ -281,6 +282,7 @@ void RigidBody::_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_tree);
@@ -306,6 +308,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
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);
ERR_FAIL_COND(!body_in && !E);
@@ -719,6 +722,14 @@ void RigidBody::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);
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index b35a9ae963..e9d5ca969e 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -35,13 +35,7 @@
bool DynamicFontData::CacheID::operator<(CacheID right) const {
- if (size < right.size)
- return true;
- if (mipmaps != right.mipmaps)
- return right.mipmaps;
- if (filter != right.filter)
- return right.filter;
- return false;
+ return key < right.key;
}
Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_cache_id) {
@@ -654,6 +648,7 @@ DynamicFontAtSize::~DynamicFontAtSize() {
FT_Done_FreeType(library);
}
font->size_cache.erase(id);
+ font.unref();
}
/////////////////////////
@@ -983,7 +978,7 @@ void DynamicFont::update_oversampling() {
while (E) {
if (E->self()->data_at_size.is_valid() && E->self()->data_at_size->update_oversampling()) {
- changed.push_back(E->self());
+ changed.push_back(Ref<DynamicFont>(E->self()));
}
E = E->next();
}
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index a949892086..92bb77bed3 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -50,15 +50,17 @@ class DynamicFontData : public Resource {
public:
struct CacheID {
- int size;
- bool mipmaps;
- bool filter;
-
+ union {
+ struct {
+ uint32_t size : 16;
+ bool mipmaps : 1;
+ bool filter : 1;
+ };
+ uint32_t key;
+ };
bool operator<(CacheID right) const;
CacheID() {
- size = 16;
- mipmaps = false;
- filter = false;
+ key = 0;
}
};