summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/arvr_nodes.cpp13
-rw-r--r--scene/3d/camera.cpp10
-rw-r--r--scene/3d/cpu_particles.cpp6
-rw-r--r--scene/3d/cpu_particles.h1
-rw-r--r--scene/3d/path.cpp6
-rw-r--r--scene/3d/physics_body.cpp4
-rw-r--r--scene/3d/portal.cpp232
-rw-r--r--scene/3d/portal.h88
-rw-r--r--scene/3d/room_instance.cpp164
-rw-r--r--scene/3d/room_instance.h81
-rw-r--r--scene/3d/spatial.cpp1
-rw-r--r--scene/3d/voxel_light_baker.cpp4
12 files changed, 24 insertions, 586 deletions
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index 82293268b9..8d1556ef1c 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -85,9 +85,8 @@ Vector3 ARVRCamera::project_local_ray_normal(const Point2 &p_pos) const {
Vector3 ray;
CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
- float screen_w, screen_h;
- cm.get_viewport_size(screen_w, screen_h);
- ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_w, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_h, -get_znear()).normalized();
+ Vector2 screen_he = cm.get_viewport_half_extents();
+ ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_he.y, -get_znear()).normalized();
return ray;
};
@@ -138,13 +137,12 @@ Vector3 ARVRCamera::project_position(const Point2 &p_point, float p_z_depth) con
CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
- Size2 vp_size;
- cm.get_viewport_size(vp_size.x, vp_size.y);
+ Vector2 vp_he = cm.get_viewport_half_extents();
Vector2 point;
point.x = (p_point.x / viewport_size.x) * 2.0 - 1.0;
point.y = (1.0 - (p_point.y / viewport_size.y)) * 2.0 - 1.0;
- point *= vp_size;
+ point *= vp_he;
Vector3 p(point.x, point.y, -p_z_depth);
@@ -295,7 +293,8 @@ int ARVRController::get_joystick_id() const {
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
if (tracker == NULL) {
- return 0;
+ // No tracker? no joystick id... (0 is our first joystick)
+ return -1;
};
return tracker->get_joy_id();
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 3a30755f7f..640189a26e 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -291,9 +291,8 @@ Vector3 Camera::project_local_ray_normal(const Point2 &p_pos) const {
} else {
CameraMatrix cm;
cm.set_perspective(fov, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
- float screen_w, screen_h;
- cm.get_viewport_size(screen_w, screen_h);
- ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_w, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_h, -near).normalized();
+ Vector2 screen_he = cm.get_viewport_half_extents();
+ ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_he.y, -near).normalized();
}
return ray;
@@ -402,13 +401,12 @@ Vector3 Camera::project_position(const Point2 &p_point, float p_z_depth) const {
else
cm.set_perspective(fov, viewport_size.aspect(), p_z_depth, far, keep_aspect == KEEP_WIDTH);
- Size2 vp_size;
- cm.get_viewport_size(vp_size.x, vp_size.y);
+ Vector2 vp_he = cm.get_viewport_half_extents();
Vector2 point;
point.x = (p_point.x / viewport_size.x) * 2.0 - 1.0;
point.y = (1.0 - (p_point.y / viewport_size.y)) * 2.0 - 1.0;
- point *= vp_size;
+ point *= vp_he;
Vector3 p(point.x, point.y, -p_z_depth);
diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp
index 0ac424b09e..aa7a413548 100644
--- a/scene/3d/cpu_particles.cpp
+++ b/scene/3d/cpu_particles.cpp
@@ -405,7 +405,7 @@ bool CPUParticles::get_particle_flag(Flags p_flag) const {
}
void CPUParticles::set_emission_shape(EmissionShape p_shape) {
-
+ ERR_FAIL_INDEX(p_shape, EMISSION_SHAPE_MAX);
emission_shape = p_shape;
}
@@ -784,6 +784,9 @@ void CPUParticles::_particles_process(float p_delta) {
p.base_color = emission_colors.get(random_idx);
}
} break;
+ case EMISSION_SHAPE_MAX: { // Max value for validity check.
+ break;
+ }
}
if (!local_coords) {
@@ -1488,6 +1491,7 @@ void CPUParticles::_bind_methods() {
BIND_ENUM_CONSTANT(EMISSION_SHAPE_BOX);
BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS);
BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS);
+ BIND_ENUM_CONSTANT(EMISSION_SHAPE_MAX);
}
CPUParticles::CPUParticles() {
diff --git a/scene/3d/cpu_particles.h b/scene/3d/cpu_particles.h
index 18f9718e70..d5a549b976 100644
--- a/scene/3d/cpu_particles.h
+++ b/scene/3d/cpu_particles.h
@@ -75,6 +75,7 @@ public:
EMISSION_SHAPE_BOX,
EMISSION_SHAPE_POINTS,
EMISSION_SHAPE_DIRECTED_POINTS,
+ EMISSION_SHAPE_MAX
};
private:
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index 3ed0677480..ac012de1ab 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path.cpp
@@ -253,7 +253,7 @@ void PathFollow::_validate_property(PropertyInfo &property) const {
if (path && path->get_curve().is_valid())
max = path->get_curve()->get_baked_length();
- property.hint_string = "0," + rtos(max) + ",0.01,or_lesser";
+ property.hint_string = "0," + rtos(max) + ",0.01,or_lesser,or_greater";
}
}
@@ -297,8 +297,8 @@ void PathFollow::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_loop", "loop"), &PathFollow::set_loop);
ClassDB::bind_method(D_METHOD("has_loop"), &PathFollow::has_loop);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_RANGE, "0,10000,0.01,or_lesser"), "set_offset", "get_offset");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE, "0,1,0.0001,or_lesser", PROPERTY_USAGE_EDITOR), "set_unit_offset", "get_unit_offset");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_RANGE, "0,10000,0.01,or_lesser,or_greater"), "set_offset", "get_offset");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE, "0,1,0.0001,or_lesser,or_greater", PROPERTY_USAGE_EDITOR), "set_unit_offset", "get_unit_offset");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "h_offset"), "set_h_offset", "get_h_offset");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_offset"), "set_v_offset", "get_v_offset");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rotation_mode", PROPERTY_HINT_ENUM, "None,Y,XY,XYZ,Oriented"), "set_rotation_mode", "get_rotation_mode");
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 999f39c841..caeae90238 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -1159,7 +1159,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
on_ceiling = false;
on_wall = false;
colliders.clear();
- floor_normal = p_up_direction;
+ floor_normal = Vector3();
floor_velocity = Vector3();
while (p_max_slides) {
@@ -1401,7 +1401,7 @@ void KinematicBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &KinematicBody::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false));
ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "floor_normal", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide_with_snap, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("move_and_slide_with_snap", "linear_velocity", "snap", "up_direction", "stop_on_slope", "max_slides", "floor_max_angle", "infinite_inertia"), &KinematicBody::move_and_slide_with_snap, DEFVAL(Vector3(0, 0, 0)), DEFVAL(false), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)), DEFVAL(true));
ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "infinite_inertia"), &KinematicBody::test_move, DEFVAL(true));
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
deleted file mode 100644
index e60ca619dd..0000000000
--- a/scene/3d/portal.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*************************************************************************/
-/* portal.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "portal.h"
-#include "core/project_settings.h"
-#include "scene/resources/surface_tool.h"
-#include "servers/visual_server.h"
-
-// FIXME: This will be removed, kept as reference for new implementation
-#if 0
-bool Portal::_set(const StringName &p_name, const Variant &p_value) {
-
- if (p_name == "shape") {
- PoolVector<float> src_coords = p_value;
- Vector<Point2> points;
- int src_coords_size = src_coords.size();
- ERR_FAIL_COND_V(src_coords_size % 2, false);
- points.resize(src_coords_size / 2);
- for (int i = 0; i < points.size(); i++) {
-
- points[i].x = src_coords[i * 2 + 0];
- points[i].y = src_coords[i * 2 + 1];
- set_shape(points);
- }
- } else if (p_name == "enabled") {
- set_enabled(p_value);
- } else if (p_name == "disable_distance") {
- set_disable_distance(p_value);
- } else if (p_name == "disabled_color") {
- set_disabled_color(p_value);
- } else if (p_name == "connect_range") {
- set_connect_range(p_value);
- } else
- return false;
-
- return true;
-}
-
-bool Portal::_get(const StringName &p_name, Variant &r_ret) const {
-
- if (p_name == "shape") {
- Vector<Point2> points = get_shape();
- PoolVector<float> dst_coords;
- dst_coords.resize(points.size() * 2);
-
- for (int i = 0; i < points.size(); i++) {
-
- dst_coords.set(i * 2 + 0, points[i].x);
- dst_coords.set(i * 2 + 1, points[i].y);
- }
-
- r_ret = dst_coords;
- } else if (p_name == "enabled") {
- r_ret = is_enabled();
- } else if (p_name == "disable_distance") {
- r_ret = get_disable_distance();
- } else if (p_name == "disabled_color") {
- r_ret = get_disabled_color();
- } else if (p_name == "connect_range") {
- r_ret = get_connect_range();
- } else
- return false;
- return true;
-}
-
-void Portal::_get_property_list(List<PropertyInfo> *p_list) const {
-
- p_list->push_back(PropertyInfo(Variant::POOL_REAL_ARRAY, "shape"));
- p_list->push_back(PropertyInfo(Variant::BOOL, "enabled"));
- p_list->push_back(PropertyInfo(Variant::REAL, "disable_distance", PROPERTY_HINT_RANGE, "0,4096,0.01"));
- p_list->push_back(PropertyInfo(Variant::COLOR, "disabled_color"));
- p_list->push_back(PropertyInfo(Variant::REAL, "connect_range", PROPERTY_HINT_RANGE, "0.1,4096,0.01"));
-}
-
-AABB Portal::get_aabb() const {
-
- return aabb;
-}
-PoolVector<Face3> Portal::get_faces(uint32_t p_usage_flags) const {
-
- if (!(p_usage_flags & FACES_ENCLOSING))
- return PoolVector<Face3>();
-
- Vector<Point2> shape = get_shape();
- if (shape.size() == 0)
- return PoolVector<Face3>();
-
- Vector2 center;
- for (int i = 0; i < shape.size(); i++) {
-
- center += shape[i];
- }
-
- PoolVector<Face3> ret;
- center /= shape.size();
-
- for (int i = 0; i < shape.size(); i++) {
-
- int n = (i + 1) % shape.size();
-
- Face3 f;
- f.vertex[0] = Vector3(center.x, center.y, 0);
- f.vertex[1] = Vector3(shape[i].x, shape[i].y, 0);
- f.vertex[2] = Vector3(shape[n].x, shape[n].y, 0);
- ret.push_back(f);
- }
-
- return ret;
-}
-
-void Portal::set_shape(const Vector<Point2> &p_shape) {
-
- VisualServer::get_singleton()->portal_set_shape(portal, p_shape);
- shape = p_shape;
- update_gizmo();
-}
-
-Vector<Point2> Portal::get_shape() const {
-
- return shape;
-}
-
-void Portal::set_connect_range(float p_range) {
-
- connect_range = p_range;
- //VisualServer::get_singleton()->portal_set_connect_range(portal,p_range);
-}
-
-float Portal::get_connect_range() const {
-
- return connect_range;
-}
-
-void Portal::set_enabled(bool p_enabled) {
-
- enabled = p_enabled;
- VisualServer::get_singleton()->portal_set_enabled(portal, enabled);
-}
-
-bool Portal::is_enabled() const {
-
- return enabled;
-}
-
-void Portal::set_disable_distance(float p_distance) {
-
- disable_distance = p_distance;
- VisualServer::get_singleton()->portal_set_disable_distance(portal, disable_distance);
-}
-float Portal::get_disable_distance() const {
-
- return disable_distance;
-}
-
-void Portal::set_disabled_color(const Color &p_disabled_color) {
-
- disabled_color = p_disabled_color;
- VisualServer::get_singleton()->portal_set_disabled_color(portal, disabled_color);
-}
-
-Color Portal::get_disabled_color() const {
-
- return disabled_color;
-}
-
-void Portal::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_shape", "points"), &Portal::set_shape);
- ClassDB::bind_method(D_METHOD("get_shape"), &Portal::get_shape);
-
- ClassDB::bind_method(D_METHOD("set_enabled", "enable"), &Portal::set_enabled);
- ClassDB::bind_method(D_METHOD("is_enabled"), &Portal::is_enabled);
-
- ClassDB::bind_method(D_METHOD("set_disable_distance", "distance"), &Portal::set_disable_distance);
- ClassDB::bind_method(D_METHOD("get_disable_distance"), &Portal::get_disable_distance);
-
- ClassDB::bind_method(D_METHOD("set_disabled_color", "color"), &Portal::set_disabled_color);
- ClassDB::bind_method(D_METHOD("get_disabled_color"), &Portal::get_disabled_color);
-
- ClassDB::bind_method(D_METHOD("set_connect_range", "range"), &Portal::set_connect_range);
- ClassDB::bind_method(D_METHOD("get_connect_range"), &Portal::get_connect_range);
-}
-
-Portal::Portal() {
-
- portal = VisualServer::get_singleton()->portal_create();
- Vector<Point2> points;
- points.push_back(Point2(-1, 1));
- points.push_back(Point2(1, 1));
- points.push_back(Point2(1, -1));
- points.push_back(Point2(-1, -1));
- set_shape(points); // default shape
-
- set_connect_range(0.8);
- set_disable_distance(50);
- set_enabled(true);
-
- set_base(portal);
-}
-
-Portal::~Portal() {
-
- VisualServer::get_singleton()->free(portal);
-}
-#endif
diff --git a/scene/3d/portal.h b/scene/3d/portal.h
deleted file mode 100644
index 7e8b016e79..0000000000
--- a/scene/3d/portal.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*************************************************************************/
-/* portal.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef PORTAL_H
-#define PORTAL_H
-
-#include "scene/3d/visual_instance.h"
-
-/* Portal Logic:
- If a portal is placed next (very close to) a similar, opposing portal, they automatically connect,
- otherwise, a portal connects to the parent room
-*/
-// FIXME: This will be redone and replaced by area portals, left for reference
-// since a new class with this name will have to exist and want to reuse the gizmos
-#if 0
-class Portal : public VisualInstance {
-
- GDCLASS(Portal, VisualInstance);
-
- RID portal;
- Vector<Point2> shape;
-
- bool enabled;
- float disable_distance;
- Color disabled_color;
- float connect_range;
-
- AABB aabb;
-
-protected:
- bool _set(const StringName &p_name, const Variant &p_value);
- bool _get(const StringName &p_name, Variant &r_ret) const;
- void _get_property_list(List<PropertyInfo> *p_list) const;
-
- static void _bind_methods();
-
-public:
- virtual AABB get_aabb() const;
- virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
-
- void set_enabled(bool p_enabled);
- bool is_enabled() const;
-
- void set_disable_distance(float p_distance);
- float get_disable_distance() const;
-
- void set_disabled_color(const Color &p_disabled_color);
- Color get_disabled_color() const;
-
- void set_shape(const Vector<Point2> &p_shape);
- Vector<Point2> get_shape() const;
-
- void set_connect_range(float p_range);
- float get_connect_range() const;
-
- Portal();
- ~Portal();
-};
-
-#endif
-#endif
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
deleted file mode 100644
index 61687360a6..0000000000
--- a/scene/3d/room_instance.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*************************************************************************/
-/* room_instance.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "room_instance.h"
-
-#include "servers/visual_server.h"
-
-// FIXME: Will be removed, kept as reference for new implementation
-#if 0
-#include "core/math/geometry.h"
-#include "core/project_settings.h"
-#include "scene/resources/surface_tool.h"
-
-void Room::_notification(int p_what) {
-
- switch (p_what) {
- case NOTIFICATION_ENTER_WORLD: {
- // go find parent level
- Node *parent_room = get_parent();
- level = 0;
-
- while (parent_room) {
-
- Room *r = Object::cast_to<Room>(parent_room);
- if (r) {
-
- level = r->level + 1;
- break;
- }
-
- parent_room = parent_room->get_parent();
- }
-
- } break;
- case NOTIFICATION_TRANSFORM_CHANGED: {
- } break;
- case NOTIFICATION_EXIT_WORLD: {
-
- } break;
- }
-}
-
-AABB Room::get_aabb() const {
-
- if (room.is_null())
- return AABB();
-
- return AABB();
-}
-
-PoolVector<Face3> Room::get_faces(uint32_t p_usage_flags) const {
-
- return PoolVector<Face3>();
-}
-
-void Room::set_room(const Ref<RoomBounds> &p_room) {
-
- room = p_room;
- update_gizmo();
-
- if (room.is_valid()) {
-
- set_base(room->get_rid());
- } else {
- set_base(RID());
- }
-
- if (!is_inside_tree())
- return;
-
- propagate_notification(NOTIFICATION_AREA_CHANGED);
- update_gizmo();
-}
-
-Ref<RoomBounds> Room::get_room() const {
-
- return room;
-}
-
-void Room::_parse_node_faces(PoolVector<Face3> &all_faces, const Node *p_node) const {
-
- const VisualInstance *vi = Object::cast_to<VisualInstance>(p_node);
-
- if (vi) {
- PoolVector<Face3> faces = vi->get_faces(FACES_ENCLOSING);
-
- if (faces.size()) {
- int old_len = all_faces.size();
- all_faces.resize(all_faces.size() + faces.size());
- int new_len = all_faces.size();
- PoolVector<Face3>::Write all_facesw = all_faces.write();
- Face3 *all_facesptr = all_facesw.ptr();
-
- PoolVector<Face3>::Read facesr = faces.read();
- const Face3 *facesptr = facesr.ptr();
-
- Transform tr = vi->get_relative_transform(this);
-
- for (int i = old_len; i < new_len; i++) {
-
- Face3 f = facesptr[i - old_len];
- for (int j = 0; j < 3; j++)
- f.vertex[j] = tr.xform(f.vertex[j]);
- all_facesptr[i] = f;
- }
- }
- }
-
- for (int i = 0; i < p_node->get_child_count(); i++) {
-
- _parse_node_faces(all_faces, p_node->get_child(i));
- }
-}
-
-void Room::_bounds_changed() {
-
- update_gizmo();
-}
-
-void Room::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_room", "room"), &Room::set_room);
- ClassDB::bind_method(D_METHOD("get_room"), &Room::get_room);
-
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "room/room", PROPERTY_HINT_RESOURCE_TYPE, "Area"), "set_room", "get_room");
-}
-
-Room::Room() {
-
- // sound_enabled=false;
-
- level = 0;
-}
-
-Room::~Room() {
-}
-#endif
diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h
deleted file mode 100644
index 071d42cff2..0000000000
--- a/scene/3d/room_instance.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*************************************************************************/
-/* room_instance.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef ROOM_INSTANCE_H
-#define ROOM_INSTANCE_H
-
-#include "scene/3d/visual_instance.h"
-#include "scene/resources/room.h"
-
-/* RoomInstance Logic:
- a) Instances that belong to the room are drawn only if the room is visible (seen through portal, or player inside)
- b) Instances that don't belong to any room are considered to belong to the root room (RID empty)
- c) "dynamic" Instances are assigned to the rooms their AABB touch
-
-*/
-
-// FIXME: this will be removed, left for reference
-#if 0
-
-class Room : public VisualInstance {
-
- GDCLASS(Room, VisualInstance);
-
-public:
-private:
- Ref<RoomBounds> room;
-
- int level;
- void _parse_node_faces(PoolVector<Face3> &all_faces, const Node *p_node) const;
-
- void _bounds_changed();
-
-protected:
- void _notification(int p_what);
-
- static void _bind_methods();
-
-public:
- enum {
- // used to notify portals that the room in which they are has changed.
- NOTIFICATION_AREA_CHANGED = 60
- };
-
- virtual AABB get_aabb() const;
- virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
-
- void set_room(const Ref<RoomBounds> &p_room);
- Ref<RoomBounds> get_room() const;
-
- Room();
- ~Room();
-};
-#endif
-#endif // ROOM_INSTANCE_H
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index b7cd2114db..f1911348ce 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -125,6 +125,7 @@ void Spatial::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
+ ERR_FAIL_COND(!get_tree());
Node *p = get_parent();
if (p)
diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp
index 9970b9350f..c1ec59d49f 100644
--- a/scene/3d/voxel_light_baker.cpp
+++ b/scene/3d/voxel_light_baker.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "voxel_light_baker.h"
+
#include "core/os/os.h"
#include "core/os/threaded_array_processor.h"
@@ -2118,8 +2119,7 @@ Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh
}
}
-// Enable for debugging
-#if 0
+#if 0 // Enable for debugging.
{
PoolVector<uint8_t> img;
int ls = lightmap.size();