summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/editor_node.cpp105
-rw-r--r--tools/editor/editor_settings.cpp2
-rw-r--r--tools/editor/editor_shape_gizmos.cpp468
-rw-r--r--tools/editor/editor_shape_gizmos.h60
-rw-r--r--tools/editor/plugins/baked_light_baker.cpp204
-rw-r--r--tools/editor/plugins/baked_light_baker.h3
-rw-r--r--tools/editor/project_export.cpp4
-rw-r--r--tools/editor/scenes_dock.cpp2
-rw-r--r--tools/editor/spatial_editor_gizmos.cpp75
-rw-r--r--tools/editor/spatial_editor_gizmos.h15
10 files changed, 178 insertions, 760 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index a137b6cd34..8c3eb844b7 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -33,8 +33,6 @@
#include "editor_fonts.h"
#include "editor_help.h"
-#include "scene/io/scene_saver.h"
-#include "scene/io/scene_loader.h"
#include "core/io/resource_saver.h"
#include "core/io/resource_loader.h"
#include "servers/physics_2d_server.h"
@@ -233,25 +231,6 @@ void EditorNode::_notification(int p_what) {
if (defer_load_scene!="") {
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
- if (convert_old) {
- get_scene()->quit();
- Node *scn = SceneLoader::load(defer_load_scene,true);
- ERR_EXPLAIN("Couldn't load scene: "+defer_load_scene);
- ERR_FAIL_COND(!scn);
- Ref<PackedScene> sdata = memnew( PackedScene );
- Error err = sdata->pack(scn);
- ERR_EXPLAIN("Couldn't repack scene: "+defer_load_scene);
- ERR_FAIL_COND(err!=OK);
- err = ResourceSaver::save(defer_load_scene,sdata);
- ERR_EXPLAIN("Couldn't resave scene: "+defer_load_scene);
- ERR_FAIL_COND(err!=OK);
-
- return;
- }
-
-#endif
load_scene(defer_load_scene);
defer_load_scene="";
}
@@ -886,65 +865,6 @@ void EditorNode::_dialog_action(String p_file) {
load_scene(p_file);
} break;
-#ifdef OLD_SCENE_FORMAT_ENABLED
- case FILE_OPEN_OLD_SCENE: {
-
- String lpath = Globals::get_singleton()->localize_path(p_file);
- if (!lpath.begins_with("res://")) {
-
- current_option=-1;
- //accept->get_cancel()->hide();
- accept->get_ok()->set_text("Ugh");
- accept->set_text("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path.");
- accept->popup_centered(Size2(300,120));
- return ;
- }
-
- Node*new_scene=SceneLoader::load(lpath,true);
-
- if (!new_scene) {
-
- current_option=-1;
- //accept->get_cancel()->hide();
- accept->get_ok()->set_text("Ugh");
- accept->set_text("Error loading scene.");
- accept->popup_centered(Size2(300,70));;
- return ;
- }
-
- Node *old_scene = edited_scene;
- _hide_top_editors();
- set_edited_scene(NULL);
- editor_data.clear_editor_states();
- if (old_scene) {
- memdelete(old_scene);
- }
-
- set_edited_scene(new_scene);
- scene_tree_dock->set_selected(new_scene);
- _get_scene_metadata();
-
- editor_data.get_undo_redo().clear_history();
- saved_version=editor_data.get_undo_redo().get_version();
- _update_title();
-
- _add_to_recent_scenes(lpath);
-
- if (new_scene->has_meta("__editor_plugin_screen__")) {
-
- String editor = new_scene->get_meta("__editor_plugin_screen__");
- for(int i=0;i<editor_table.size();i++) {
-
- if (editor_table[i]->get_name()==editor) {
- _editor_select(i);
- break;
- }
- }
- }
-
-
- } break;
-#endif
case FILE_SAVE_OPTIMIZED: {
@@ -1679,28 +1599,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
open_request(previous_scenes.back()->get());
} break;
-#ifdef OLD_SCENE_FORMAT_ENABLED
- case FILE_OPEN_OLD_SCENE: {
-
- //print_tree();
- file->set_mode(FileDialog::MODE_OPEN_FILE);
- //not for now?
- file->clear_filters();
- file->add_filter("*.xml");
-
-
- //file->set_current_path(current_path);
- Node *scene = edited_scene;
- if (scene) {
- file->set_current_path(scene->get_filename());
- };
- file->set_title("Open Scene");
- file->popup_centered_ratio();
-
-
- } break;
-
-#endif
case FILE_SAVE_SCENE: {
@@ -3549,9 +3447,6 @@ EditorNode::EditorNode() {
p=import_menu->get_popup();
p->add_item("Sub-Scene",FILE_IMPORT_SUBSCENE);
-#ifdef OLD_SCENE_FORMAT_ENABLED
- p->add_item("Import Old Scene",FILE_OPEN_OLD_SCENE);
-#endif
p->add_separator();
p->connect("item_pressed",this,"_menu_option");
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 6f1a24d7e8..2b54a334bf 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -30,7 +30,7 @@
#include "os/os.h"
#include "os/dir_access.h"
#include "os/file_access.h"
-#include "io/object_format_xml.h"
+
#include "version.h"
#include "scene/main/scene_main_loop.h"
#include "os/os.h"
diff --git a/tools/editor/editor_shape_gizmos.cpp b/tools/editor/editor_shape_gizmos.cpp
deleted file mode 100644
index df7332b64a..0000000000
--- a/tools/editor/editor_shape_gizmos.cpp
+++ /dev/null
@@ -1,468 +0,0 @@
-/*************************************************************************/
-/* editor_shape_gizmos.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "editor_shape_gizmos.h"
-
-
-
-
-
-
-String EditableShapeSpatialGizmo::get_handle_name(int p_idx) const {
-
- if (es->cast_to<EditableSphere>()) {
-
- return "Radius";
- }
-#if 0
- if (es->cast_to<EditableBox>()) {
-
- return "Extents";
- }
-
- if (es->cast_to<EditableCapsule>()) {
-
- return p_idx==0?"Radius":"Height";
- }
-
- if (es->cast_to<EditableRay>()) {
-
- return "Length";
- }
-#endif
- return "";
-}
-Variant EditableShapeSpatialGizmo::get_handle_value(int p_idx) const{
-
- if (es->cast_to<EditableSphere>()) {
-
- EditableSphere *ss = es->cast_to<EditableSphere>();
- return ss->get_radius();
- }
-#if 0
- if (es->cast_to<EditableBox>()) {
-
- EditableBox *bs = es->cast_to<EditableBox>();
- return bs->get_extents();
- }
-
- if (es->cast_to<EditableCapsule>()) {
-
- EditableCapsule *cs = es->cast_to<EditableCapsule>();
- return p_idx==0?es->get_radius():es->get_height();
- }
-
- if (es->cast_to<EditableRay>()) {
-
- EditableRay* cs = es->cast_to<EditableRay>();
- return es->get_length();
- }
-#endif
- return Variant();
-}
-void EditableShapeSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_point){
-
- Transform gt = es->get_global_transform();
- gt.orthonormalize();
- Transform gi = gt.affine_inverse();
-
- Vector3 ray_from = p_camera->project_ray_origin(p_point);
- Vector3 ray_dir = p_camera->project_ray_normal(p_point);
-
- Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*4096)};
-
- if (es->cast_to<EditableSphere>()) {
-
- EditableSphere *ss = es->cast_to<EditableSphere>();
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(),Vector3(4096,0,0),sg[0],sg[1],ra,rb);
- float d = ra.x;
- if (d<0.001)
- d=0.001;
-
- ss->set_radius(d);
- }
-
-#if 0
- if (es->cast_to<EditableRay>()) {
-
- EditableRay*cs = es->cast_to<EditableRay>();
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(),Vector3(0,0,4096),sg[0],sg[1],ra,rb);
- float d = ra.z;
- if (d<0.001)
- d=0.001;
-
- rs->set_length(d);
- }
-
-
- if (es->cast_to<EditableBox>()) {
-
- Vector3 axis;
- axis[p_idx]=1.0;
- EditableBox *bs = es->cast_to<EditableBox>();
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(),axis*4096,sg[0],sg[1],ra,rb);
- float d = ra[p_idx];
- if (d<0.001)
- d=0.001;
-
- Vector3 he = bs->get_extents();
- he[p_idx]=d;
- bs->set_extents(he);
-
- }
-
- if (es->cast_to<EditableCapsule>()) {
-
- Vector3 axis;
- axis[p_idx]=1.0;
- EditableCapsule *cs = es->cast_to<EditableCapsule>();
- Vector3 ra,rb;
- Geometry::get_closest_points_between_segments(Vector3(),axis*4096,sg[0],sg[1],ra,rb);
- float d = ra[p_idx];
- if (p_idx==1)
- d-=es->get_radius();
- if (d<0.001)
- d=0.001;
-
- if (p_idx==0)
- es->set_radius(d);
- else if (p_idx==1)
- es->set_height(d*2.0);
-
- }
-
-#endif
-
-}
-void EditableShapeSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_cancel){
-
-
- if (es->cast_to<EditableSphere>()) {
-
- EditableSphere *ss = es->cast_to<EditableSphere>();
- if (p_cancel) {
- ss->set_radius(p_restore);
- return;
- }
-
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
- ur->create_action("Change Sphere Shape Radius");
- ur->add_do_method(ss,"set_radius",ss->get_radius());
- ur->add_undo_method(ss,"set_radius",p_restore);
- ur->commit_action();
-
- }
-#if 0
- if (es->cast_to<EditableBox>()) {
-
- EditableBox *ss = es->cast_to<EditableBox>();
- if (p_cancel) {
- ss->set_extents(p_restore);
- return;
- }
-
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
- ur->create_action("Change Box Shape Extents");
- ur->add_do_method(ss,"set_extents",ss->get_extents());
- ur->add_undo_method(ss,"set_extents",p_restore);
- ur->commit_action();
- }
-
- if (es->cast_to<EditableCapsule>()) {
-
- EditableCapsule *cs = es->cast_to<EditableCapsule>();
- if (p_cancel) {
- if (p_idx==0)
- ss->set_radius(p_restore);
- else
- ss->set_height(p_restore);
- return;
- }
-
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
- if (p_idx==0) {
- ur->create_action("Change Capsule Shape Radius");
- ur->add_do_method(ss,"set_radius",ss->get_radius());
- ur->add_undo_method(ss,"set_radius",p_restore);
- } else {
- ur->create_action("Change Capsule Shape Height");
- ur->add_do_method(ss,"set_height",ss->get_height());
- ur->add_undo_method(ss,"set_height",p_restore);
-
- }
-
- ur->commit_action();
-
- }
-
- if (es->cast_to<EditableRay>()) {
-
- EditableRay*rs = es->cast_to<EditableRay>()
- if (p_cancel) {
- ss->set_length(p_restore);
- return;
- }
-
- UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
- ur->create_action("Change Ray Shape Length");
- ur->add_do_method(ss,"set_length",ss->get_length());
- ur->add_undo_method(ss,"set_length",p_restore);
- ur->commit_action();
-
- }
-#endif
-}
-void EditableShapeSpatialGizmo::redraw(){
-
- clear();
-
- if (es->cast_to<EditableSphere>()) {
-
- EditableSphere* sp= es->cast_to<EditableSphere>();
- float r=sp->get_radius();
-
- Vector<Vector3> points;
-
- for(int i=0;i<=360;i++) {
-
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+1);
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
-
- points.push_back(Vector3(a.x,0,a.y));
- points.push_back(Vector3(b.x,0,b.y));
- points.push_back(Vector3(0,a.x,a.y));
- points.push_back(Vector3(0,b.x,b.y));
- points.push_back(Vector3(a.x,a.y,0));
- points.push_back(Vector3(b.x,b.y,0));
-
- }
-
- Vector<Vector3> collision_segments;
-
- for(int i=0;i<64;i++) {
-
- float ra=i*Math_PI*2.0/64.0;
- float rb=(i+1)*Math_PI*2.0/64.0;
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
-
- collision_segments.push_back(Vector3(a.x,0,a.y));
- collision_segments.push_back(Vector3(b.x,0,b.y));
- collision_segments.push_back(Vector3(0,a.x,a.y));
- collision_segments.push_back(Vector3(0,b.x,b.y));
- collision_segments.push_back(Vector3(a.x,a.y,0));
- collision_segments.push_back(Vector3(b.x,b.y,0));
- }
-
- add_lines(points,SpatialEditorGizmos::singleton->shape_material);
- add_collision_segments(collision_segments);
- Vector<Vector3> handles;
- handles.push_back(Vector3(r,0,0));
- add_handles(handles);
-
- }
-
-#if 0
- if (es->cast_to<EditableBox>()) {
-
- EditableBox*bs = es->cast_to<EditableBox>();
- Vector<Vector3> lines;
- AABB aabb;
- aabb.pos=-bs->get_extents();
- aabb.size=aabb.pos*-2;
-
- for(int i=0;i<12;i++) {
- Vector3 a,b;
- aabb.get_edge(i,a,b);
- lines.push_back(a);
- lines.push_back(b);
- }
-
- Vector<Vector3> handles;
-
- for(int i=0;i<3;i++) {
-
- Vector3 ax;
- ax[i]=bs->get_extents()[i];
- handles.push_back(ax);
- }
-
- add_lines(lines,SpatialEditorGizmos::singleton->shape_material);
- add_collision_segments(lines);
- add_handles(handles);
-
- }
-
- if (es->cast_to<EditableCapsule>()) {
-
- EditableCapsule *cs = es->cast_to<EditableCapsule>();
- float radius = es->get_radius();
- float height = es->get_height();
-
-
- Vector<Vector3> points;
-
- Vector3 d(0,height*0.5,0);
- for(int i=0;i<360;i++) {
-
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+1);
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*radius;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*radius;
-
- points.push_back(Vector3(a.x,0,a.y)+d);
- points.push_back(Vector3(b.x,0,b.y)+d);
-
- points.push_back(Vector3(a.x,0,a.y)-d);
- points.push_back(Vector3(b.x,0,b.y)-d);
-
- if (i%90==0) {
-
- points.push_back(Vector3(a.x,0,a.y)+d);
- points.push_back(Vector3(a.x,0,a.y)-d);
- }
-
- Vector3 dud = i<180?d:-d;
-
- points.push_back(Vector3(0,a.x,a.y)+dud);
- points.push_back(Vector3(0,b.x,b.y)+dud);
- points.push_back(Vector3(a.y,a.x,0)+dud);
- points.push_back(Vector3(b.y,b.x,0)+dud);
-
- }
-
- add_lines(points,SpatialEditorGizmos::singleton->shape_material);
-
- Vector<Vector3> collision_segments;
-
- for(int i=0;i<64;i++) {
-
- float ra=i*Math_PI*2.0/64.0;
- float rb=(i+1)*Math_PI*2.0/64.0;
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*radius;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*radius;
-
- collision_segments.push_back(Vector3(a.x,0,a.y)+d);
- collision_segments.push_back(Vector3(b.x,0,b.y)+d);
-
- collision_segments.push_back(Vector3(a.x,0,a.y)-d);
- collision_segments.push_back(Vector3(b.x,0,b.y)-d);
-
- if (i%16==0) {
-
- collision_segments.push_back(Vector3(a.x,0,a.y)+d);
- collision_segments.push_back(Vector3(a.x,0,a.y)-d);
- }
-
- Vector3 dud = i<32?d:-d;
-
- collision_segments.push_back(Vector3(0,a.x,a.y)+dud);
- collision_segments.push_back(Vector3(0,b.x,b.y)+dud);
- collision_segments.push_back(Vector3(a.y,a.x,0)+dud);
- collision_segments.push_back(Vector3(b.y,b.x,0)+dud);
-
- }
-
- add_collision_segments(collision_segments);
-
- Vector<Vector3> handles;
- handles.push_back(Vector3(es->get_radius(),0,0));
- handles.push_back(Vector3(0,es->get_height()*0.5+es->get_radius(),0));
- add_handles(handles);
-
-
- }
-
- if (es->cast_to<EditablePlane>()) {
-
- EditablePlane* ps=es->cast_to<EditablePlane();
- Plane p = ps->get_plane();
- Vector<Vector3> points;
-
- Vector3 n1 = p.get_any_perpendicular_normal();
- Vector3 n2 = p.normal.cross(n1).normalized();
-
- Vector3 pface[4]={
- p.normal*p.d+n1*10.0+n2*10.0,
- p.normal*p.d+n1*10.0+n2*-10.0,
- p.normal*p.d+n1*-10.0+n2*-10.0,
- p.normal*p.d+n1*-10.0+n2*10.0,
- };
-
- points.push_back(pface[0]);
- points.push_back(pface[1]);
- points.push_back(pface[1]);
- points.push_back(pface[2]);
- points.push_back(pface[2]);
- points.push_back(pface[3]);
- points.push_back(pface[3]);
- points.push_back(pface[0]);
- points.push_back(p.normal*p.d);
- points.push_back(p.normal*p.d+p.normal*3);
-
- add_lines(points,SpatialEditorGizmos::singleton->shape_material);
- add_collision_segments(points);
-
- }
-
-
- if (es->cast_to<EditableRay>()) {
-
- EditableRay*cs = es->cast_to<EditableRay>();
-
- Vector<Vector3> points;
- points.push_back(Vector3());
- points.push_back(Vector3(0,0,rs->get_length()));
- add_lines(points,SpatialEditorGizmos::singleton->shape_material);
- add_collision_segments(points);
- Vector<Vector3> handles;
- handles.push_back(Vector3(0,0,rs->get_length()));
- add_handles(handles);
-
-
- }
-
-#endif
-
-}
-EditableShapeSpatialGizmo::EditableShapeSpatialGizmo(EditableShape* p_cs) {
-
- es=p_cs;
- set_spatial_node(p_cs);
-}
-
-
-
-EditorShapeGizmos::EditorShapeGizmos()
-{
-}
diff --git a/tools/editor/editor_shape_gizmos.h b/tools/editor/editor_shape_gizmos.h
deleted file mode 100644
index 4b5af49b4e..0000000000
--- a/tools/editor/editor_shape_gizmos.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*************************************************************************/
-/* editor_shape_gizmos.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 EDITOR_SHAPE_GIZMOS_H
-#define EDITOR_SHAPE_GIZMOS_H
-
-#include "spatial_editor_gizmos.h"
-#include "scene/3d/editable_shape.h"
-
-
-class EditableShapeSpatialGizmo : public SpatialGizmoTool {
-
- OBJ_TYPE(EditableShapeSpatialGizmo,SpatialGizmoTool);
-
- EditableShape *es;
-
-public:
- virtual String get_handle_name(int p_idx) const;
- virtual Variant get_handle_value(int p_idx) const;
- virtual void set_handle(int p_idx,Camera *p_camera, const Point2& p_point);
- virtual void commit_handle(int p_idx,const Variant& p_restore,bool p_cancel=false);
- void redraw();
- EditableShapeSpatialGizmo(EditableShape* p_cs=NULL);
-
-};
-
-
-
-class EditorShapeGizmos
-{
-public:
- EditorShapeGizmos();
-};
-
-#endif // EDITOR_SHAPE_GIZMOS_H
diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp
index dea83e0ff8..3774b7d25b 100644
--- a/tools/editor/plugins/baked_light_baker.cpp
+++ b/tools/editor/plugins/baked_light_baker.cpp
@@ -6,6 +6,44 @@
#include "tools/editor/editor_node.h"
+_FORCE_INLINE_ static uint64_t get_uv_normal_bit(const Vector3& p_vector) {
+
+ int lat = Math::fast_ftoi(Math::floor(Math::acos(p_vector.dot(Vector3(0,1,0)))*6.0/Math_PI+0.5));
+
+ if (lat==0) {
+ return 60;
+ } else if (lat==6) {
+ return 61;
+ }
+
+ int lon = Math::fast_ftoi(Math::floor( (Math_PI+Math::atan2(p_vector.x,p_vector.z))*12.0/(Math_PI*2.0) + 0.5))%12;
+
+ return lon+(lat-1)*12;
+}
+
+
+
+_FORCE_INLINE_ static Vector3 get_bit_normal(int p_bit) {
+
+ if (p_bit==61) {
+ return Vector3(0,1,0);
+ } else if (p_bit==62){
+ return Vector3(0,-1,0);
+ }
+
+ float latang = ((p_bit / 12)+1)*Math_PI/6.0;
+
+ Vector2 latv(Math::sin(latang),Math::cos(latang));
+
+ float lonang = ((p_bit%12)*Math_PI*2.0/12.0)-Math_PI;
+
+ Vector2 lonv(Math::sin(lonang),Math::cos(lonang));
+
+ return Vector3(lonv.x*latv.x,latv.y,lonv.y*latv.x).normalized();
+
+}
+
+
BakedLightBaker::MeshTexture* BakedLightBaker::_get_mat_tex(const Ref<Texture>& p_tex) {
if (!tex_map.has(p_tex)) {
@@ -533,10 +571,12 @@ void BakedLightBaker::_octree_insert(int p_octant,Triangle* p_triangle, int p_de
child->offset[2]=child->aabb.pos.z+child->aabb.size.z*0.5;
child->next_leaf=leaf_list;
+
for(int ci=0;ci<8;ci++) {
child->normal_accum[ci][0]=0;
child->normal_accum[ci][1]=0;
child->normal_accum[ci][2]=0;
+
}
child->bake_neighbour=0;
@@ -593,11 +633,26 @@ void BakedLightBaker::_octree_insert(int p_octant,Triangle* p_triangle, int p_de
pos.y=floor((pos.y+cell_size*0.5)/cell_size);
pos.z=floor((pos.z+cell_size*0.5)/cell_size);
- Map<Vector3,Vector3>::Element *E=endpoint_normal.find(pos);
- if (!E) {
- endpoint_normal[pos]=n;
- } else {
- E->get()+=n;
+ {
+ Map<Vector3,Vector3>::Element *E=endpoint_normal.find(pos);
+ if (!E) {
+ endpoint_normal[pos]=n;
+ } else {
+ E->get()+=n;
+ }
+ }
+
+ {
+
+ uint64_t bit = get_uv_normal_bit(n);
+
+ Map<Vector3,uint64_t>::Element *E=endpoint_normal_bits.find(pos);
+ if (!E) {
+ endpoint_normal_bits[pos]=(1<<bit);
+ } else {
+ E->get()|=(1<<bit);
+ }
+
}
}
@@ -677,18 +732,58 @@ void BakedLightBaker::_make_octree() {
pos.y=floor((pos.y+cell_size*0.5)/cell_size);
pos.z=floor((pos.z+cell_size*0.5)/cell_size);
- Map<Vector3,Vector3>::Element *E=endpoint_normal.find(pos);
- if (!E) {
- //?
- print_line("lolwut?");
- } else {
- Vector3 n = E->get().normalized();
- oct->normal_accum[ci][0]=n.x;
- oct->normal_accum[ci][1]=n.y;
- oct->normal_accum[ci][2]=n.z;
+ {
+ Map<Vector3,Vector3>::Element *E=endpoint_normal.find(pos);
+ if (!E) {
+ //?
+ print_line("lolwut?");
+ } else {
+ Vector3 n = E->get().normalized();
+ oct->normal_accum[ci][0]=n.x;
+ oct->normal_accum[ci][1]=n.y;
+ oct->normal_accum[ci][2]=n.z;
+
+ }
}
+ {
+
+ Map<Vector3,uint64_t>::Element *E=endpoint_normal_bits.find(pos);
+ if (!E) {
+ //?
+ print_line("lolwut?");
+ } else {
+
+ float max_aper=0;
+ for(uint64_t i=0;i<62;i++) {
+
+ if (!(E->get()&(1<<i)))
+ continue;
+ Vector3 ang_i = get_bit_normal(i);
+
+ for(uint64_t j=0;j<62;j++) {
+
+ if (i==j)
+ continue;
+ if (!(E->get()&(1<<j)))
+ continue;
+ Vector3 ang_j = get_bit_normal(j);
+ float ang = Math::acos(ang_i.dot(ang_j));
+ if (ang>max_aper)
+ max_aper=ang;
+ }
+ }
+ if (max_aper>0.75*Math_PI) {
+ //angle too wide prevent problems and forget
+ oct->normal_accum[ci][0]=0;
+ oct->normal_accum[ci][1]=0;
+ oct->normal_accum[ci][2]=0;
+ }
+ }
+ }
+
+
}
oct_idx=oct->next_leaf;
@@ -742,13 +837,23 @@ void BakedLightBaker::_plot_light(int p_light_index, const Vector3& p_plot_pos,
float d = p_plot_pos.distance_to(pos);
- if (d<=r) {
+ if ((p_plane.distance_to(pos)>-cell_size*1.75) && d<=r) {
float intensity = 1.0 - (d/r)*(d/r); //not gauss but..
- float damp = Math::abs(p_plane.normal.dot(Vector3(octant.normal_accum[i][0],octant.normal_accum[i][1],octant.normal_accum[i][2])));
- intensity*=pow(damp,edge_damp);
+ if (edge_damp>0) {
+ Vector3 normal = Vector3(octant.normal_accum[i][0],octant.normal_accum[i][1],octant.normal_accum[i][2]);
+ if (normal.x>0 || normal.y>0 || normal.z>0) {
+
+ float damp = Math::abs(p_plane.normal.dot(normal));
+ intensity*=pow(damp,edge_damp);
+
+ }
+ }
+
//intensity*=1.0-Math::abs(p_plane.distance_to(pos))/(plot_size*cell_size);
+ //intensity = Math::cos(d*Math_PI*0.5/r);
+
octant.light[p_light_index].accum[i][0]+=p_light.r*intensity;
octant.light[p_light_index].accum[i][1]+=p_light.g*intensity;
octant.light[p_light_index].accum[i][2]+=p_light.b*intensity;
@@ -788,7 +893,7 @@ void BakedLightBaker::_plot_light(int p_light_index, const Vector3& p_plot_pos,
}
-float BakedLightBaker::_throw_ray(int p_light_index,const Vector3& p_begin, const Vector3& p_end,float p_rest,const Color& p_light,float *p_att_curve,float p_att_pos,int p_att_curve_len,int p_bounces,bool p_first_bounce) {
+float BakedLightBaker::_throw_ray(int p_light_index,const Vector3& p_begin, const Vector3& p_end,float p_rest,const Color& p_light,float *p_att_curve,float p_att_pos,int p_att_curve_len,int p_bounces,bool p_first_bounce,bool p_only_dist) {
uint32_t* stack = ray_stack;
@@ -918,8 +1023,13 @@ float BakedLightBaker::_throw_ray(int p_light_index,const Vector3& p_begin, cons
}
+
if (inters) {
+ if (p_only_dist) {
+
+ return p_begin.distance_to(r_point);
+ }
//should check if there is normals first
@@ -933,6 +1043,9 @@ float BakedLightBaker::_throw_ray(int p_light_index,const Vector3& p_begin, cons
}
if (n.dot(r_normal)>0)
+ return -1;
+
+ if (n.dot(r_normal)>0)
r_normal=-r_normal;
@@ -969,6 +1082,20 @@ float BakedLightBaker::_throw_ray(int p_light_index,const Vector3& p_begin, cons
//the multiplication can happen with more detail in the shader
+
+ if (triangle->material) {
+
+ //triangle->get_uv(r_point);
+
+ diffuse_at_point=triangle->material->diffuse.get_color(uv);
+ specular_at_point=triangle->material->specular.get_color(uv);
+ }
+
+
+ diffuse_at_point.r=res_light.r*diffuse_at_point.r;
+ diffuse_at_point.g=res_light.g*diffuse_at_point.g;
+ diffuse_at_point.b=res_light.b*diffuse_at_point.b;
+
float ret=1e6;
if (p_bounces>0) {
@@ -985,18 +1112,6 @@ float BakedLightBaker::_throw_ray(int p_light_index,const Vector3& p_begin, cons
- if (triangle->material) {
-
- //triangle->get_uv(r_point);
-
- diffuse_at_point=triangle->material->diffuse.get_color(uv);
- specular_at_point=triangle->material->specular.get_color(uv);
- }
-
-
- diffuse_at_point.r=res_light.r*diffuse_at_point.r;
- diffuse_at_point.g=res_light.g*diffuse_at_point.g;
- diffuse_at_point.b=res_light.b*diffuse_at_point.b;
specular_at_point.r=res_light.r*specular_at_point.r;
specular_at_point.g=res_light.g*specular_at_point.g;
@@ -1043,7 +1158,7 @@ float BakedLightBaker::_throw_ray(int p_light_index,const Vector3& p_begin, cons
// _plot_light_point(r_point,octree,octree_aabb,p_light);
- Color plot_light=res_light;
+ Color plot_light=diffuse_at_point;
plot_light.r*=att;
plot_light.g*=att;
plot_light.b*=att;
@@ -1051,11 +1166,31 @@ float BakedLightBaker::_throw_ray(int p_light_index,const Vector3& p_begin, cons
if (!p_first_bounce) {
- float r = plot_size * cell_size*4;
- if (ret<r) {
+ float r = plot_size * cell_size*2;
+ if (dist<r) {
//avoid accumulaiton of light on corners
//plot_light=plot_light.linear_interpolate(Color(0,0,0,0),1.0-sd/plot_size*plot_size);
plot_light=Color(0,0,0,0);
+
+ } else {
+
+
+ Vector3 c1=r_normal.cross(n).normalized();
+ Vector3 c2=r_normal.cross(c1).normalized();
+ double r1 = double(rand())/RAND_MAX;
+ double r2 = double(rand())/RAND_MAX;
+ double r3 = double(rand())/RAND_MAX;
+ Vector3 rn = ((c1*(r1-0.5)) + (c2*(r2-0.5)) + (r_normal*r3*0.25)).normalized();
+ float d =_throw_ray(p_light_index,r_point,r_point+rn*p_rest,p_rest,diffuse_at_point,p_att_curve,p_att_pos,p_att_curve_len,p_bounces-1,false,true);
+ r = plot_size*cell_size*0.7;
+ if (d>0 && d<r) {
+ //avoid accumulaiton of light on corners
+ //plot_light=plot_light.linear_interpolate(Color(0,0,0,0),1.0-sd/plot_size*plot_size);
+ plot_light=Color(0,0,0,0);
+
+ } else {
+ //plot_light=Color(0,0,0,0);
+ }
}
}
@@ -1070,7 +1205,7 @@ float BakedLightBaker::_throw_ray(int p_light_index,const Vector3& p_begin, cons
return dist;
}
- return 0;
+ return -1;
}
@@ -2248,6 +2383,7 @@ void BakedLightBaker::clear() {
lights.clear();
triangles.clear();;
endpoint_normal.clear();
+ endpoint_normal_bits.clear();
baked_octree_texture_w=0;
baked_octree_texture_h=0;
paused=false;
diff --git a/tools/editor/plugins/baked_light_baker.h b/tools/editor/plugins/baked_light_baker.h
index 722255a565..e0a9d91cd4 100644
--- a/tools/editor/plugins/baked_light_baker.h
+++ b/tools/editor/plugins/baked_light_baker.h
@@ -239,6 +239,7 @@ public:
uint32_t *octant_stack;
uint32_t *octantptr_stack;
Map<Vector3,Vector3> endpoint_normal;
+ Map<Vector3,uint64_t> endpoint_normal_bits;
BVH **bvh_stack;
float cell_size;
float plot_size; //multiplied by cell size
@@ -287,7 +288,7 @@ public:
void _plot_light(int p_light_index,const Vector3& p_plot_pos,const AABB& p_plot_aabb,const Color& p_light,const Plane& p_plane);
//void _plot_light_point(const Vector3& p_plot_pos, Octant *p_octant, const AABB& p_aabb,const Color& p_light);
- float _throw_ray(int p_light_index,const Vector3& p_begin, const Vector3& p_end,float p_rest,const Color& p_light,float *p_att_curve,float p_att_pos,int p_att_curve_len,int p_bounces,bool p_first_bounce=false);
+ float _throw_ray(int p_light_index,const Vector3& p_begin, const Vector3& p_end,float p_rest,const Color& p_light,float *p_att_curve,float p_att_pos,int p_att_curve_len,int p_bounces,bool p_first_bounce=false,bool p_only_dist=false);
float total_light_area;
diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp
index 22331c86bf..1da29c5e7b 100644
--- a/tools/editor/project_export.cpp
+++ b/tools/editor/project_export.cpp
@@ -31,13 +31,13 @@
#include "os/dir_access.h"
#include "os/file_access.h"
#include "globals.h"
-#include "scene/io/scene_loader.h"
+
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/os.h"
#include "scene/gui/box_container.h"
#include "default_saver.h"
-#include "scene/io/scene_saver.h"
+
#include "scene/gui/tab_container.h"
#include "scene/gui/scroll_container.h"
#include "editor_data.h"
diff --git a/tools/editor/scenes_dock.cpp b/tools/editor/scenes_dock.cpp
index a23c9cead7..34422b4d50 100644
--- a/tools/editor/scenes_dock.cpp
+++ b/tools/editor/scenes_dock.cpp
@@ -30,7 +30,7 @@
#include "os/dir_access.h"
#include "os/file_access.h"
#include "globals.h"
-#include "scene/io/scene_loader.h"
+
#include "io/resource_loader.h"
#include "os/os.h"
#include "editor_node.h"
diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp
index 082878655c..c613a34895 100644
--- a/tools/editor/spatial_editor_gizmos.cpp
+++ b/tools/editor/spatial_editor_gizmos.cpp
@@ -36,7 +36,7 @@
#include "scene/resources/ray_shape.h"
#include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/plane_shape.h"
-#include "editor_shape_gizmos.h"
+
// Keep small children away from this file.
// It's so ugly it will eat them alive
@@ -1474,69 +1474,6 @@ RayCastSpatialGizmo::RayCastSpatialGizmo(RayCast* p_raycast){
}
-/////
-
-
-void CarWheelSpatialGizmo::redraw() {
-
- clear();
-
-
- Vector<Vector3> points;
-
- float r = car_wheel->get_radius();
- const int skip=10;
- for(int i=0;i<=360;i+=skip) {
-
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+skip);
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
-
- points.push_back(Vector3(0,a.x,a.y));
- points.push_back(Vector3(0,b.x,b.y));
-
- const int springsec=4;
-
- for(int j=0;j<springsec;j++) {
- float t = car_wheel->get_travel()*5;
- points.push_back(Vector3(a.x,i/360.0*t/springsec+j*(t/springsec),a.y)*0.2);
- points.push_back(Vector3(b.x,(i+skip)/360.0*t/springsec+j*(t/springsec),b.y)*0.2);
- }
-
-
- }
-
- //travel
- points.push_back(Vector3(0,0,0));
- points.push_back(Vector3(0,car_wheel->get_travel(),0));
-
- //axis
- points.push_back(Vector3(r*0.2,car_wheel->get_travel(),0));
- points.push_back(Vector3(-r*0.2,car_wheel->get_travel(),0));
- //axis
- points.push_back(Vector3(r*0.2,0,0));
- points.push_back(Vector3(-r*0.2,0,0));
-
- //forward line
- points.push_back(Vector3(0,-r,0));
- points.push_back(Vector3(0,-r,r*2));
- points.push_back(Vector3(0,-r,r*2));
- points.push_back(Vector3(r*2*0.2,-r,r*2*0.8));
- points.push_back(Vector3(0,-r,r*2));
- points.push_back(Vector3(-r*2*0.2,-r,r*2*0.8));
-
- add_lines(points,SpatialEditorGizmos::singleton->car_wheel_material);
- add_collision_segments(points);
-
-}
-
-CarWheelSpatialGizmo::CarWheelSpatialGizmo(CarWheel* p_car_wheel){
-
- set_spatial_node(p_car_wheel);
- car_wheel=p_car_wheel;
-}
-
/////
@@ -2888,16 +2825,6 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
return misg;
}
- if (p_spatial->cast_to<EditableShape>()) {
-
- Ref<EditableShapeSpatialGizmo> misg = memnew( EditableShapeSpatialGizmo(p_spatial->cast_to<EditableShape>()) );
- return misg;
- }
- if (p_spatial->cast_to<CarWheel>()) {
-
- Ref<CarWheelSpatialGizmo> misg = memnew( CarWheelSpatialGizmo(p_spatial->cast_to<CarWheel>()) );
- return misg;
- }
if (p_spatial->cast_to<VehicleWheel>()) {
Ref<VehicleWheelSpatialGizmo> misg = memnew( VehicleWheelSpatialGizmo(p_spatial->cast_to<VehicleWheel>()) );
diff --git a/tools/editor/spatial_editor_gizmos.h b/tools/editor/spatial_editor_gizmos.h
index 55e40c7b7c..7f39b648d7 100644
--- a/tools/editor/spatial_editor_gizmos.h
+++ b/tools/editor/spatial_editor_gizmos.h
@@ -44,7 +44,7 @@
#include "scene/3d/portal.h"
#include "scene/3d/ray_cast.h"
#include "scene/3d/navigation_mesh.h"
-#include "scene/3d/car_body.h"
+
#include "scene/3d/vehicle_body.h"
#include "scene/3d/collision_polygon.h"
#include "scene/3d/physics_joint.h"
@@ -332,19 +332,6 @@ public:
};
-class CarWheelSpatialGizmo : public SpatialGizmoTool {
-
- OBJ_TYPE(CarWheelSpatialGizmo,SpatialGizmoTool);
-
- CarWheel* car_wheel;
-
-public:
-
- void redraw();
- CarWheelSpatialGizmo(CarWheel* p_car_wheel=NULL);
-
-};
-
class VehicleWheelSpatialGizmo : public SpatialGizmoTool {