summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/particles_2d.cpp1
-rw-r--r--scene/2d/tile_map.cpp147
-rw-r--r--scene/2d/tile_map.h8
-rw-r--r--scene/3d/baked_lightmap.cpp20
-rw-r--r--scene/3d/baked_lightmap.h4
-rw-r--r--scene/3d/gi_probe.cpp1
-rw-r--r--scene/3d/particles.cpp1
-rw-r--r--scene/3d/soft_body.cpp1
-rw-r--r--scene/3d/voxel_light_baker.cpp75
-rw-r--r--scene/3d/voxel_light_baker.h2
-rw-r--r--scene/animation/skeleton_ik.cpp3
-rw-r--r--scene/main/scene_tree.cpp5
12 files changed, 239 insertions, 29 deletions
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index 7759897420..93c12f0103 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -410,6 +410,7 @@ Particles2D::Particles2D() {
particles = VS::get_singleton()->particles_create();
+ one_shot = false; // Needed so that set_emitting doesn't access uninitialized values
set_emitting(true);
set_one_shot(false);
set_amount(8);
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index fc53c9e4ac..22bc0e44e6 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -234,6 +234,25 @@ void TileMap::_fix_cell_transform(Transform2D &xform, const Cell &p_cell, const
Size2 s = p_sc;
Vector2 offset = p_offset;
+ if (compatibility_mode && !centered_textures) {
+
+ if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT) {
+ offset.y += cell_size.y;
+ } else if (tile_origin == TILE_ORIGIN_CENTER) {
+ offset += cell_size / 2;
+ }
+
+ if (s.y > s.x) {
+ if ((p_cell.flip_h && (p_cell.flip_v || p_cell.transpose)) || (p_cell.flip_v && !p_cell.transpose)) {
+ offset.y += s.y - s.x;
+ }
+ } else if (s.y < s.x) {
+ if ((p_cell.flip_v && (p_cell.flip_h || p_cell.transpose)) || (p_cell.flip_h && !p_cell.transpose)) {
+ offset.x += s.x - s.y;
+ }
+ }
+ }
+
if (p_cell.transpose) {
SWAP(xform.elements[0].x, xform.elements[0].y);
SWAP(xform.elements[1].x, xform.elements[1].y);
@@ -244,16 +263,36 @@ void TileMap::_fix_cell_transform(Transform2D &xform, const Cell &p_cell, const
if (p_cell.flip_h) {
xform.elements[0].x = -xform.elements[0].x;
xform.elements[1].x = -xform.elements[1].x;
- offset.x = s.x - offset.x;
+ if (compatibility_mode && !centered_textures) {
+ if (tile_origin == TILE_ORIGIN_TOP_LEFT || tile_origin == TILE_ORIGIN_BOTTOM_LEFT) {
+ offset.x = s.x - offset.x;
+ } else if (tile_origin == TILE_ORIGIN_CENTER) {
+ offset.x = s.x - offset.x / 2;
+ }
+ } else {
+ offset.x = s.x - offset.x;
+ }
}
if (p_cell.flip_v) {
xform.elements[0].y = -xform.elements[0].y;
xform.elements[1].y = -xform.elements[1].y;
- offset.y = s.y - offset.y;
+ if (compatibility_mode && !centered_textures) {
+ if (tile_origin == TILE_ORIGIN_TOP_LEFT) {
+ offset.y = s.y - offset.y;
+ } else if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT) {
+ offset.y += s.y;
+ } else if (tile_origin == TILE_ORIGIN_CENTER) {
+ offset.y += s.y;
+ }
+ } else {
+ offset.y = s.y - offset.y;
+ }
+ }
+
+ if (centered_textures) {
+ offset += cell_size / 2 - s / 2;
}
- /* For a future CheckBox to Center Texture:
- offset += cell_size / 2 - s / 2; */
xform.elements[2] += offset;
}
@@ -434,13 +473,24 @@ void TileMap::update_dirty_quadrants() {
rect.size.x += fp_adjust;
rect.size.y += fp_adjust;
+ if (compatibility_mode && !centered_textures) {
+ if (rect.size.y > rect.size.x) {
+ if ((c.flip_h && (c.flip_v || c.transpose)) || (c.flip_v && !c.transpose))
+ tile_ofs.y += rect.size.y - rect.size.x;
+ } else if (rect.size.y < rect.size.x) {
+ if ((c.flip_v && (c.flip_h || c.transpose)) || (c.flip_h && !c.transpose))
+ tile_ofs.x += rect.size.x - rect.size.y;
+ }
+ }
+
if (c.transpose) {
SWAP(tile_ofs.x, tile_ofs.y);
- /* For a future CheckBox to Center Texture:
- rect.position.x += cell_size.x / 2 - rect.size.y / 2;
- rect.position.y += cell_size.y / 2 - rect.size.x / 2;
- } else {
- rect.position += cell_size / 2 - rect.size / 2; */
+ if (centered_textures) {
+ rect.position.x += cell_size.x / 2 - rect.size.y / 2;
+ rect.position.y += cell_size.y / 2 - rect.size.x / 2;
+ }
+ } else if (centered_textures) {
+ rect.position += cell_size / 2 - rect.size / 2;
}
if (c.flip_h) {
@@ -453,7 +503,43 @@ void TileMap::update_dirty_quadrants() {
tile_ofs.y = -tile_ofs.y;
}
- rect.position += tile_ofs;
+ if (compatibility_mode && !centered_textures) {
+ if (tile_origin == TILE_ORIGIN_TOP_LEFT) {
+ rect.position += tile_ofs;
+
+ } else if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT) {
+
+ rect.position += tile_ofs;
+
+ if (c.transpose) {
+ if (c.flip_h)
+ rect.position.x -= cell_size.x;
+ else
+ rect.position.x += cell_size.x;
+ } else {
+ if (c.flip_v)
+ rect.position.y -= cell_size.y;
+ else
+ rect.position.y += cell_size.y;
+ }
+
+ } else if (tile_origin == TILE_ORIGIN_CENTER) {
+
+ rect.position += tile_ofs;
+
+ if (c.flip_h)
+ rect.position.x -= cell_size.x / 2;
+ else
+ rect.position.x += cell_size.x / 2;
+
+ if (c.flip_v)
+ rect.position.y -= cell_size.y / 2;
+ else
+ rect.position.y += cell_size.y / 2;
+ }
+ } else {
+ rect.position += tile_ofs;
+ }
Ref<Texture> normal_map = tile_set->tile_get_normal_map(c.id);
Color modulate = tile_set->tile_get_modulate(c.id);
@@ -1156,10 +1242,7 @@ void TileMap::_set_tile_data(const PoolVector<int> &p_data) {
coord_x = decode_uint16(&local[8]);
coord_y = decode_uint16(&local[10]);
}
- /*
- if (x<-20 || y <-20 || x>4000 || y>4000)
- continue;
- */
+
set_cell(x, y, v, flip_h, flip_v, transpose, Vector2(coord_x, coord_y));
}
@@ -1570,6 +1653,32 @@ bool TileMap::is_y_sort_mode_enabled() const {
return y_sort_mode;
}
+void TileMap::set_compatibility_mode(bool p_enable) {
+
+ _clear_quadrants();
+ compatibility_mode = p_enable;
+ _recreate_quadrants();
+ emit_signal("settings_changed");
+}
+
+bool TileMap::is_compatibility_mode_enabled() const {
+
+ return compatibility_mode;
+}
+
+void TileMap::set_centered_textures(bool p_enable) {
+
+ _clear_quadrants();
+ centered_textures = p_enable;
+ _recreate_quadrants();
+ emit_signal("settings_changed");
+}
+
+bool TileMap::is_centered_textures_enabled() const {
+
+ return centered_textures;
+}
+
Array TileMap::get_used_cells() const {
Array a;
@@ -1707,6 +1816,12 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_y_sort_mode", "enable"), &TileMap::set_y_sort_mode);
ClassDB::bind_method(D_METHOD("is_y_sort_mode_enabled"), &TileMap::is_y_sort_mode_enabled);
+ ClassDB::bind_method(D_METHOD("set_compatibility_mode", "enable"), &TileMap::set_compatibility_mode);
+ ClassDB::bind_method(D_METHOD("is_compatibility_mode_enabled"), &TileMap::is_compatibility_mode_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_centered_textures", "enable"), &TileMap::set_centered_textures);
+ ClassDB::bind_method(D_METHOD("is_centered_textures_enabled"), &TileMap::is_centered_textures_enabled);
+
ClassDB::bind_method(D_METHOD("set_collision_use_kinematic", "use_kinematic"), &TileMap::set_collision_use_kinematic);
ClassDB::bind_method(D_METHOD("get_collision_use_kinematic"), &TileMap::get_collision_use_kinematic);
@@ -1775,6 +1890,8 @@ void TileMap::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_half_offset", PROPERTY_HINT_ENUM, "Offset X,Offset Y,Disabled,Offset Negative X,Offset Negative Y"), "set_half_offset", "get_half_offset");
ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_tile_origin", PROPERTY_HINT_ENUM, "Top Left,Center,Bottom Left"), "set_tile_origin", "get_tile_origin");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_y_sort"), "set_y_sort_mode", "is_y_sort_mode_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "compatibility_mode"), "set_compatibility_mode", "is_compatibility_mode_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "centered_textures"), "set_centered_textures", "is_centered_textures_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_clip_uv"), "set_clip_uv", "get_clip_uv");
ADD_GROUP("Collision", "collision_");
@@ -1832,6 +1949,8 @@ TileMap::TileMap() {
use_kinematic = false;
navigation = NULL;
y_sort_mode = false;
+ compatibility_mode = false;
+ centered_textures = false;
occluder_light_mask = 1;
clip_uv = false;
format = FORMAT_1; //Always initialize with the lowest format
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 1caaefa213..6c9648ff32 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -181,6 +181,8 @@ private:
bool used_size_cache_dirty;
bool quadrant_order_dirty;
bool y_sort_mode;
+ bool compatibility_mode;
+ bool centered_textures;
bool clip_uv;
float fp_adjust;
float friction;
@@ -311,6 +313,12 @@ public:
void set_y_sort_mode(bool p_enable);
bool is_y_sort_mode_enabled() const;
+ void set_compatibility_mode(bool p_enable);
+ bool is_compatibility_mode_enabled() const;
+
+ void set_centered_textures(bool p_enable);
+ bool is_centered_textures_enabled() const;
+
Array get_used_cells() const;
Array get_used_cells_by_id(int p_id) const;
Rect2 get_used_rect(); // Not const because of cache
diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp
index 2b12e78158..c5ff4dadbc 100644
--- a/scene/3d/baked_lightmap.cpp
+++ b/scene/3d/baked_lightmap.cpp
@@ -221,6 +221,15 @@ Vector3 BakedLightmap::get_extents() const {
return extents;
}
+void BakedLightmap::set_bake_default_texels_per_unit(const float &p_bake_texels_per_unit) {
+ bake_default_texels_per_unit = p_bake_texels_per_unit;
+ update_gizmo();
+}
+
+float BakedLightmap::get_bake_default_texels_per_unit() const {
+ return bake_default_texels_per_unit;
+}
+
void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, List<PlotMesh> &plot_meshes, List<PlotLight> &plot_lights) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_at_node);
@@ -236,7 +245,7 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, List<PlotMesh> &plo
}
}
- if (all_have_uv2 && mesh->get_lightmap_size_hint() != Size2()) {
+ if (all_have_uv2) {
//READY TO BAKE! size hint could be computed if not found, actually..
AABB aabb = mesh->get_aabb();
@@ -463,7 +472,7 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi
btd.text = RTR("Lighting Meshes: ") + mesh_name + " (" + itos(pmc) + "/" + itos(mesh_list.size()) + ")";
btd.pass = step;
btd.last_step = 0;
- err = baker.make_lightmap(E->get().local_xform, E->get().mesh, lm, _bake_time, &btd);
+ err = baker.make_lightmap(E->get().local_xform, E->get().mesh, bake_default_texels_per_unit, lm, _bake_time, &btd);
if (err != OK) {
bake_end_function();
if (err == ERR_SKIP)
@@ -473,7 +482,7 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi
step += 100;
} else {
- err = baker.make_lightmap(E->get().local_xform, E->get().mesh, lm);
+ err = baker.make_lightmap(E->get().local_xform, E->get().mesh, bake_default_texels_per_unit, lm);
}
if (err == OK) {
@@ -790,6 +799,9 @@ void BakedLightmap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extents", "extents"), &BakedLightmap::set_extents);
ClassDB::bind_method(D_METHOD("get_extents"), &BakedLightmap::get_extents);
+ ClassDB::bind_method(D_METHOD("set_bake_default_texels_per_unit", "texels"), &BakedLightmap::set_bake_default_texels_per_unit);
+ ClassDB::bind_method(D_METHOD("get_bake_default_texels_per_unit"), &BakedLightmap::get_bake_default_texels_per_unit);
+
ClassDB::bind_method(D_METHOD("set_propagation", "propagation"), &BakedLightmap::set_propagation);
ClassDB::bind_method(D_METHOD("get_propagation"), &BakedLightmap::get_propagation);
@@ -814,6 +826,7 @@ void BakedLightmap::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bake_energy", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_energy", "get_energy");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bake_hdr"), "set_hdr", "is_hdr");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "bake_extents"), "set_extents", "get_extents");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "bake_default_texels_per_unit"), "set_bake_default_texels_per_unit", "get_bake_default_texels_per_unit");
ADD_GROUP("Capture", "capture_");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "capture_cell_size", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_capture_cell_size", "get_capture_cell_size");
ADD_GROUP("Data", "");
@@ -836,6 +849,7 @@ void BakedLightmap::_bind_methods() {
BakedLightmap::BakedLightmap() {
extents = Vector3(10, 10, 10);
+ bake_default_texels_per_unit = 20;
bake_cell_size = 0.25;
capture_cell_size = 0.5;
diff --git a/scene/3d/baked_lightmap.h b/scene/3d/baked_lightmap.h
index bb3f84719a..fac4ad3908 100644
--- a/scene/3d/baked_lightmap.h
+++ b/scene/3d/baked_lightmap.h
@@ -119,6 +119,7 @@ private:
float bake_cell_size;
float capture_cell_size;
Vector3 extents;
+ float bake_default_texels_per_unit;
float propagation;
float energy;
BakeQuality bake_quality;
@@ -178,6 +179,9 @@ public:
void set_extents(const Vector3 &p_extents);
Vector3 get_extents() const;
+ void set_bake_default_texels_per_unit(const float &p_extents);
+ float get_bake_default_texels_per_unit() const;
+
void set_propagation(float p_propagation);
float get_propagation() const;
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index 414e932f61..a04f156d80 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -571,4 +571,5 @@ GIProbe::GIProbe() {
}
GIProbe::~GIProbe() {
+ VS::get_singleton()->free(gi_probe);
}
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 2bcd0eaa46..00a168fc39 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -411,6 +411,7 @@ Particles::Particles() {
particles = VS::get_singleton()->particles_create();
set_base(particles);
+ one_shot = false; // Needed so that set_emitting doesn't access uninitialized values
set_emitting(true);
set_one_shot(false);
set_amount(8);
diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp
index a9d96292a1..b9f6865298 100644
--- a/scene/3d/soft_body.cpp
+++ b/scene/3d/soft_body.cpp
@@ -712,6 +712,7 @@ SoftBody::SoftBody() :
}
SoftBody::~SoftBody() {
+ PhysicsServer::get_singleton()->free(physics_rid);
}
void SoftBody::reset_softbody_pin() {
diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp
index 5fa8c43f9f..8e09930aed 100644
--- a/scene/3d/voxel_light_baker.cpp
+++ b/scene/3d/voxel_light_baker.cpp
@@ -1792,19 +1792,82 @@ void VoxelLightBaker::_lightmap_bake_point(uint32_t p_x, LightMap *p_line) {
}
}
-Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh, LightMapData &r_lightmap, bool (*p_bake_time_func)(void *, float, float), void *p_bake_time_ud) {
+Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh, float default_texels_per_unit, LightMapData &r_lightmap, bool (*p_bake_time_func)(void *, float, float), void *p_bake_time_ud) {
//transfer light information to a lightmap
Ref<Mesh> mesh = p_mesh;
- int width = mesh->get_lightmap_size_hint().x;
- int height = mesh->get_lightmap_size_hint().y;
-
//step 1 - create lightmap
+ int width;
+ int height;
Vector<LightMap> lightmap;
- lightmap.resize(width * height);
-
Transform xform = to_cell_space * p_xform;
+ if (mesh->get_lightmap_size_hint() == Size2()) {
+ double area = 0;
+ double uv_area = 0;
+ for (int i = 0; i < mesh->get_surface_count(); i++) {
+ Array arrays = mesh->surface_get_arrays(i);
+ PoolVector<Vector3> vertices = arrays[Mesh::ARRAY_VERTEX];
+ PoolVector<Vector2> uv2 = arrays[Mesh::ARRAY_TEX_UV2];
+ PoolVector<int> indices = arrays[Mesh::ARRAY_INDEX];
+
+ ERR_FAIL_COND_V(vertices.size() == 0, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(uv2.size() == 0, ERR_INVALID_PARAMETER);
+
+ int vc = vertices.size();
+ PoolVector<Vector3>::Read vr = vertices.read();
+ PoolVector<Vector2>::Read u2r = uv2.read();
+ PoolVector<int>::Read ir;
+ int ic = 0;
+
+ if (indices.size()) {
+ ic = indices.size();
+ ir = indices.read();
+ }
+
+ int faces = ic ? ic / 3 : vc / 3;
+ for (int j = 0; j < faces; j++) {
+ Vector3 vertex[3];
+ Vector2 uv[3];
+
+ for (int k = 0; k < 3; k++) {
+ int idx = ic ? ir[j * 3 + k] : j * 3 + k;
+ vertex[k] = xform.xform(vr[idx]);
+ uv[k] = u2r[idx];
+ }
+
+ Vector3 p1 = vertex[0];
+ Vector3 p2 = vertex[1];
+ Vector3 p3 = vertex[2];
+ double a = p1.distance_to(p2);
+ double b = p2.distance_to(p3);
+ double c = p3.distance_to(p1);
+ double halfPerimeter = (a + b + c) / 2.0;
+ area += sqrt(halfPerimeter * (halfPerimeter - a) * (halfPerimeter - b) * (halfPerimeter - c));
+
+ Vector2 uv_p1 = uv[0];
+ Vector2 uv_p2 = uv[1];
+ Vector2 uv_p3 = uv[2];
+ double uv_a = uv_p1.distance_to(uv_p2);
+ double uv_b = uv_p2.distance_to(uv_p3);
+ double uv_c = uv_p3.distance_to(uv_p1);
+ double uv_halfPerimeter = (uv_a + uv_b + uv_c) / 2.0;
+ uv_area += sqrt(uv_halfPerimeter * (uv_halfPerimeter - uv_a) * (uv_halfPerimeter - uv_b) * (uv_halfPerimeter - uv_c));
+ }
+ }
+
+ if (uv_area < 0.0001f) {
+ uv_area = 1.0;
+ }
+
+ int pixels = (ceil((1.0 / sqrt(uv_area)) * sqrt(area * default_texels_per_unit)));
+ width = height = CLAMP(pixels, 2, 4096);
+ } else {
+ width = mesh->get_lightmap_size_hint().x;
+ height = mesh->get_lightmap_size_hint().y;
+ }
+
+ lightmap.resize(width * height);
//step 2 plot faces to lightmap
for (int i = 0; i < mesh->get_surface_count(); i++) {
diff --git a/scene/3d/voxel_light_baker.h b/scene/3d/voxel_light_baker.h
index 295e099d47..2e2efc62ff 100644
--- a/scene/3d/voxel_light_baker.h
+++ b/scene/3d/voxel_light_baker.h
@@ -177,7 +177,7 @@ public:
PoolVector<float> light;
};
- Error make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh, LightMapData &r_lightmap, bool (*p_bake_time_func)(void *, float, float) = NULL, void *p_bake_time_ud = NULL);
+ Error make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh, float default_texels_per_unit, LightMapData &r_lightmap, bool (*p_bake_time_func)(void *, float, float) = NULL, void *p_bake_time_ud = NULL);
PoolVector<int> create_gi_probe_data();
Ref<MultiMesh> create_debug_multimesh(DebugMode p_mode = DEBUG_ALBEDO);
diff --git a/scene/animation/skeleton_ik.cpp b/scene/animation/skeleton_ik.cpp
index 43c4b2aa51..7a1b10792b 100644
--- a/scene/animation/skeleton_ik.cpp
+++ b/scene/animation/skeleton_ik.cpp
@@ -406,6 +406,7 @@ void SkeletonIK::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
skeleton = Object::cast_to<Skeleton>(get_parent());
+ set_process_priority(1);
reload_chain();
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
@@ -431,8 +432,6 @@ SkeletonIK::SkeletonIK() :
skeleton(NULL),
target_node_override(NULL),
task(NULL) {
-
- set_process_priority(1);
}
SkeletonIK::~SkeletonIK() {
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 0e7cec57a4..0940a59a82 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -453,9 +453,6 @@ void SceneTree::init() {
//_quit=false;
initialized = true;
- input_handled = false;
-
- pause = false;
root->_set_tree(this);
MainLoop::init();
@@ -1986,6 +1983,8 @@ SceneTree::SceneTree() {
idle_process_time = 1;
root = NULL;
+ input_handled = false;
+ pause = false;
current_frame = 0;
current_event = 0;
tree_changed_name = "tree_changed";