浏览代码

Build System Changes
-=-=-=-=-=-=-=-=-=-=

Build System:
-Big clean up of SCons, changed how builds are done to a much cleaner method (check the Github Wiki for instructions).
-Deactivated BlackBerry10 (sorry), if no mantainer found (or BlackBerry does not send us a Passort ;), platform will be removed as we have no longer devices to test.

Engine:
-Removed deprecated object and scene format (was in there just for compatibility, not in use since a long time).
-Added ability to open scenes even if a node type was removed (will try to guess the closest type).
-Removed deprecated node types.

Juan Linietsky 11 年之前
父节点
当前提交
0fa94a9690
共有 72 个文件被更改,包括 888 次插入10490 次删除
  1. 67 73
      SConstruct
  2. 1 1
      core/SCsub
  3. 8 0
      core/bind/core_bind.cpp
  4. 1 0
      core/bind/core_bind.h
  5. 0 1491
      core/io/object_format_binary.cpp
  6. 0 158
      core/io/object_format_binary.h
  7. 0 3190
      core/io/object_format_xml.cpp
  8. 0 196
      core/io/object_format_xml.h
  9. 0 84
      core/io/object_loader.cpp
  10. 0 76
      core/io/object_loader.h
  11. 0 157
      core/io/object_saver.cpp
  12. 0 128
      core/io/object_saver.h
  13. 0 150
      core/io/object_saver_base.cpp
  14. 0 76
      core/io/object_saver_base.h
  15. 53 0
      core/math/geometry.h
  16. 0 35
      core/register_core_types.cpp
  17. 1 1
      drivers/SCsub
  18. 1 1
      main/SCsub
  19. 1 13
      main/main.cpp
  20. 7 7
      methods.py
  21. 1 1
      modules/SCsub
  22. 0 1
      modules/gdscript/gd_script.cpp
  23. 2 2
      platform/android/SCsub
  24. 5 23
      platform/android/detect.py
  25. 0 1
      platform/flash/SCsub
  26. 0 1
      platform/flash/detect.py
  27. 3 8
      platform/iphone/SCsub
  28. 4 2
      platform/iphone/app_delegate.mm
  29. 0 13
      platform/iphone/detect.py
  30. 1 3
      platform/javascript/SCsub
  31. 1 10
      platform/javascript/detect.py
  32. 1 1
      platform/osx/SCsub
  33. 3 15
      platform/osx/detect.py
  34. 12 26
      platform/server/detect.py
  35. 1 1
      platform/windows/SCsub
  36. 53 48
      platform/windows/detect.py
  37. 0 2
      platform/x11/SCsub
  38. 22 42
      platform/x11/detect.py
  39. 0 1
      scene/3d/SCsub
  40. 0 741
      scene/3d/car_body.cpp
  41. 0 170
      scene/3d/car_body.h
  42. 0 85
      scene/3d/editable_shape.cpp
  43. 0 73
      scene/3d/editable_shape.h
  44. 1 1
      scene/SCsub
  45. 0 851
      scene/io/scene_format_object.cpp
  46. 0 128
      scene/io/scene_format_object.h
  47. 0 65
      scene/io/scene_format_script.cpp
  48. 0 45
      scene/io/scene_format_script.h
  49. 0 161
      scene/io/scene_loader.cpp
  50. 0 90
      scene/io/scene_loader.h
  51. 0 94
      scene/io/scene_saver.cpp
  52. 0 80
      scene/io/scene_saver.h
  53. 0 1
      scene/main/node.cpp
  54. 9 47
      scene/register_scene_types.cpp
  55. 0 427
      scene/resources/image_path_finder.cpp
  56. 0 84
      scene/resources/image_path_finder.h
  57. 23 3
      scene/resources/packed_scene.cpp
  58. 426 427
      scene/resources/scene_preloader.cpp
  59. 0 55
      scene/scene_binds.cpp
  60. 0 62
      scene/scene_binds.h
  61. 1 1
      servers/SCsub
  62. 1 1
      tools/SCsub
  63. 0 105
      tools/editor/editor_node.cpp
  64. 1 1
      tools/editor/editor_settings.cpp
  65. 0 468
      tools/editor/editor_shape_gizmos.cpp
  66. 0 60
      tools/editor/editor_shape_gizmos.h
  67. 170 34
      tools/editor/plugins/baked_light_baker.cpp
  68. 2 1
      tools/editor/plugins/baked_light_baker.h
  69. 2 2
      tools/editor/project_export.cpp
  70. 1 1
      tools/editor/scenes_dock.cpp
  71. 1 74
      tools/editor/spatial_editor_gizmos.cpp
  72. 1 14
      tools/editor/spatial_editor_gizmos.h

+ 67 - 73
SConstruct

@@ -8,15 +8,6 @@ import sys
 import methods
 import multiprocessing
 
-# Enable aggresive compile mode if building on a multi core box
-# only is we have not set the number of jobs already or we do
-# not want it
-if ARGUMENTS.get('spawn_jobs', 'no') == 'yes' and \
-	int(GetOption('num_jobs')) <= 1:
-	NUM_JOBS = multiprocessing.cpu_count()
-	if NUM_JOBS > 1:
-		SetOption('num_jobs', NUM_JOBS+1)
-
 methods.update_version()
 
 # scan possible build platforms
@@ -58,8 +49,7 @@ for x in glob.glob("platform/*"):
 module_list=methods.detect_modules()
 
 
-print "Detected Platforms: "+str(platform_list)
-print("Detected Modules: "+str(module_list))
+#print "Detected Platforms: "+str(platform_list)
 
 methods.save_active_platforms(active_platforms,active_platform_ids)
 
@@ -99,19 +89,15 @@ if profile:
 		customs.append(profile+".py")
 
 opts=Variables(customs, ARGUMENTS)
-opts.Add('target', 'Compile Target (debug/profile/release).', "debug")
-opts.Add('platform','Platform: '+str(platform_list)+'(sfml).',"")
-opts.Add('python','Build Python Support: (yes/no)','no')
-opts.Add('squirrel','Build Squirrel Support: (yes/no)','no')
+opts.Add('target', 'Compile Target (debug/release_debug/release).', "debug")
+opts.Add('bits', 'Compile Target Bits (default/32/64).', "default")
+opts.Add('platform','Platform: '+str(platform_list)+'.',"")
+opts.Add('p','Platform (same as platform=).',"")
 opts.Add('tools','Build Tools (Including Editor): (yes/no)','yes')
-opts.Add('lua','Build Lua Support: (yes/no)','no')
-opts.Add('rfd','Remote Filesystem Driver: (yes/no)','no')
 opts.Add('gdscript','Build GDSCript support: (yes/no)','yes')
 opts.Add('vorbis','Build Ogg Vorbis Support: (yes/no)','yes')
 opts.Add('minizip','Build Minizip Archive Support: (yes/no)','yes')
-opts.Add('opengl', 'Build OpenGL Support: (yes/no)', 'yes')
-opts.Add('game', 'Game (custom) Code Directory', "")
-opts.Add('squish','Squish BC Texture Compression (yes/no)','yes')
+opts.Add('squish','Squish BC Texture Compression in editor (yes/no)','yes')
 opts.Add('theora','Theora Video (yes/no)','yes')
 opts.Add('freetype','Freetype support in editor','yes')
 opts.Add('speex','Speex Audio (yes/no)','yes')
@@ -124,15 +110,12 @@ opts.Add('pvr','PVR (PowerVR) Texture loader support (yes/no)','yes')
 opts.Add('builtin_zlib','Use built-in zlib (yes/no)','yes')
 opts.Add('openssl','Use OpenSSL (yes/no/builtin)','no')
 opts.Add('musepack','Musepack Audio (yes/no)','yes')
-opts.Add('default_gui_theme','Default GUI theme (yes/no)','yes')
 opts.Add("CXX", "Compiler");
-opts.Add("nedmalloc", "Add nedmalloc support", 'yes');
 opts.Add("CCFLAGS", "Custom flags for the C++ compiler");
 opts.Add("CFLAGS", "Custom flags for the C compiler");
 opts.Add("LINKFLAGS", "Custom flags for the linker");
 opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no")
 opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no")
-opts.Add('old_scenes', 'Compatibility with old-style scenes', "yes")
 
 # add platform specific options
 
@@ -152,7 +135,6 @@ Help(opts.GenerateHelpText(env_base)) # generate help
 env_base.Append(CPPPATH=['#core','#core/math','#tools','#drivers','#'])
 	
 # configure ENV for platform	
-env_base.detect_python=True
 env_base.platform_exporters=platform_exporters
 
 """
@@ -170,17 +152,26 @@ if (env_base['target']=='debug'):
 env_base.platforms = {}
 
 
-for p in platform_list:
+selected_platform =""
 
-	if env_base['platform'] != "" and env_base['platform'] != p:
-		continue
-	sys.path.append("./platform/"+p)
+if env_base['platform'] != "":
+	selected_platform=env_base['platform']
+elif env_base['p'] != "":
+	selected_platform=env_base['p']
+	env_base["platform"]=selected_platform
+
+
+if selected_platform in platform_list:
+
+	sys.path.append("./platform/"+selected_platform)
 	import detect
 	if "create" in dir(detect):
 		env = detect.create(env_base)
 	else:
 		env = env_base.Clone()
 
+	env.extra_suffix=""
+
 	CCFLAGS = env.get('CCFLAGS', '')
 	env['CCFLAGS'] = ''
 
@@ -197,17 +188,49 @@ for p in platform_list:
 	env.Append(LINKFLAGS=string.split(str(LINKFLAGS)))
 
 	detect.configure(env)
-	env['platform'] = p
-        if not env.has_key('platform_libsuffix'):
-                env['platform_libsuffix'] = env['LIBSUFFIX']
-	sys.path.remove("./platform/"+p)
-	sys.modules.pop('detect')
 
-	flag_list = platform_flags[p]
+
+	flag_list = platform_flags[selected_platform]
 	for f in flag_list:
 		if not (f[0] in ARGUMENTS): # allow command line to override platform flags
 			env[f[0]] = f[1]
-			print(f[0]+":"+f[1])
+
+        #env['platform_libsuffix'] = env['LIBSUFFIX']
+
+	suffix="."+selected_platform
+
+	if (env["target"]=="release"):
+		if (env["tools"]=="yes"):
+			print("Tools can only be built with targets 'debug' and 'release_debug'.")
+			sys.exit(255)
+		suffix+=".opt"
+
+	elif (env["target"]=="release_debug"):
+		if (env["tools"]=="yes"):
+			suffix+=".opt.tools"
+		else:
+			suffix+=".opt.debug"
+	else:
+		if (env["tools"]=="yes"):
+			suffix+=".tools"
+		else:
+			suffix+=".debug"
+
+	if (env["bits"]=="32"):
+		suffix+=".32"
+	elif (env["bits"]=="64"):
+		suffix+=".64"
+
+	suffix+=env.extra_suffix
+
+	env["PROGSUFFIX"]=suffix+env["PROGSUFFIX"]
+	env["OBJSUFFIX"]=suffix+env["OBJSUFFIX"]
+	env["LIBSUFFIX"]=suffix+env["LIBSUFFIX"]
+	env["SHLIBSUFFIX"]=suffix+env["SHLIBSUFFIX"]
+
+	sys.path.remove("./platform/"+selected_platform)
+	sys.modules.pop('detect')
+
 
 	env.module_list=[]
 
@@ -218,7 +241,7 @@ for p in platform_list:
 		sys.path.append(tmppath)
 		env.current_module=x
 		import config
-		if (config.can_build(p)):
+		if (config.can_build(selected_platform)):
 			config.configure(env)
 			env.module_list.append(x)
 		sys.path.remove(tmppath)
@@ -232,11 +255,6 @@ for p in platform_list:
             if (env['openssl']=="builtin"):
                 env.Append(CPPPATH=['#drivers/builtin_openssl2'])
 
-
-	if (env["old_scenes"]=='yes'):
-		env.Append(CPPFLAGS=['-DOLD_SCENE_FORMAT_ENABLED'])
-	if (env["rfd"]=='yes'):
-		env.Append(CPPFLAGS=['-DRFD_ENABLED'])
 	if (env["builtin_zlib"]=='yes'):
 		env.Append(CPPPATH=['#drivers/builtin_zlib/zlib'])
 
@@ -281,34 +299,6 @@ for p in platform_list:
 	if (env['xml']=='yes'):
 		env.Append(CPPFLAGS=['-DXML_ENABLED'])
 
-	if (env['default_gui_theme']=='no'):
-		env.Append(CPPFLAGS=['-DDEFAULT_THEME_DISABLED'])
-
-	if (env["python"]=='yes'):
-		detected=False;
-		if (env.detect_python):
-			print("Python 3.0 Prefix:");
-			pycfg_exec="python3-config"
-			errorval=os.system(pycfg_exec+" --prefix")
-			prefix=""
-			if (not errorval):
-				#gah, why can't it get both at the same time like pkg-config, sdl-config, etc?
-				env.ParseConfig(pycfg_exec+" --cflags")
-				env.ParseConfig(pycfg_exec+" --libs")
-				detected=True
-
-		if (detected):
-			env.Append(CPPFLAGS=['-DPYTHON_ENABLED'])
-			#remove annoying warnings
-			if ('-Wstrict-prototypes' in  env["CCFLAGS"]):
-				env["CCFLAGS"].remove('-Wstrict-prototypes');
-			if ('-fwrapv' in env["CCFLAGS"]):
-				env["CCFLAGS"].remove('-fwrapv');
-		else:
-			print("Python 3.0 not detected ("+pycfg_exec+") support disabled.");
-
-	#if env['nedmalloc'] == 'yes':
-	#	env.Append(CPPFLAGS = ['-DNEDMALLOC_ENABLED'])
 
 	Export('env')
 
@@ -321,11 +311,15 @@ for p in platform_list:
 	SConscript("drivers/SCsub")
 	SConscript("bin/SCsub")
 
-	if env['game']:
-		SConscript(env['game']+'/SCsub')
-
 	SConscript("modules/SCsub")
 	SConscript("main/SCsub")
 
-	SConscript("platform/"+p+"/SCsub"); # build selected platform
+	SConscript("platform/"+selected_platform+"/SCsub"); # build selected platform
+
+else:
 
+	print("No valid target platform selected.")
+	print("The following were detected:")
+	for x in platform_list:
+		print("\t"+x)
+	print("\nPlease run scons again with argument: platform=<string>")

+ 1 - 1
core/SCsub

@@ -60,7 +60,7 @@ SConscript('math/SCsub');
 SConscript('io/SCsub');
 SConscript('bind/SCsub');
 
-lib = env.Library("core",env.core_sources, LIBSUFFIX=env['platform_libsuffix'])
+lib = env.Library("core",env.core_sources)
 
 env.Prepend(LIBS=[lib])
 

+ 8 - 0
core/bind/core_bind.cpp

@@ -886,6 +886,12 @@ Dictionary _Geometry::make_atlas(const Vector<Size2>& p_rects) {
 };
 
 
+int _Geometry::get_uv84_normal_bit(const Vector3& p_vector) {
+
+	return Geometry::get_uv84_normal_bit(p_vector);
+}
+
+
 void _Geometry::_bind_methods() {
 
 
@@ -900,6 +906,8 @@ void _Geometry::_bind_methods() {
 
 	ObjectTypeDB::bind_method(_MD("get_closest_point_to_segment","point","s1","s2"),&_Geometry::get_closest_point_to_segment);
 
+	ObjectTypeDB::bind_method(_MD("get_uv84_normal_bit","normal"),&_Geometry::get_uv84_normal_bit);
+
 	ObjectTypeDB::bind_method(_MD("ray_intersects_triangle","from","dir","a","b","c"),&_Geometry::ray_intersects_triangle);
 	ObjectTypeDB::bind_method(_MD("segment_intersects_triangle","from","to","a","b","c"),&_Geometry::segment_intersects_triangle);
 	ObjectTypeDB::bind_method(_MD("segment_intersects_sphere","from","to","spos","sradius"),&_Geometry::segment_intersects_sphere);

+ 1 - 0
core/bind/core_bind.h

@@ -233,6 +233,7 @@ public:
 	DVector<Vector3> segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius);
 	DVector<Vector3> segment_intersects_convex(const Vector3& p_from, const Vector3& p_to,const Vector<Plane>& p_planes);
 	real_t segment_intersects_circle(const Vector2& p_from, const Vector2& p_to, const Vector2& p_circle_pos, real_t p_circle_radius);
+	int get_uv84_normal_bit(const Vector3& p_vector);
 
 	Vector<int> triangulate_polygon(const Vector<Vector2>& p_polygon);
 

+ 0 - 1491
core/io/object_format_binary.cpp

@@ -1,1491 +0,0 @@
-/*************************************************************************/
-/*  object_format_binary.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 "object_format_binary.h"
-#include "resource.h"
-#include "io/resource_loader.h"
-#include "print_string.h"
-#include "object_type_db.h"
-#include "globals.h"
-#include "os/os.h"
-#include "version.h"
-
-
-#define print_bl(m_what)
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
-
-enum {
-
-	SECTION_RESOURCE=0,
-	SECTION_OBJECT=1,
-	SECTION_META_OBJECT=2,
-	SECTION_PROPERTY=3,
-	SECTION_END=4,
-
-	//numbering must be different from variant, in case new variant types are added (variant must be always contiguous for jumptable optimization)
-	VARIANT_NIL=1,
-	VARIANT_BOOL=2,
-	VARIANT_INT=3,
-	VARIANT_REAL=4,
-	VARIANT_STRING=5,
-	VARIANT_VECTOR2=10,
-	VARIANT_RECT2=11,
-	VARIANT_VECTOR3=12,
-	VARIANT_PLANE=13,
-	VARIANT_QUAT=14,
-	VARIANT_AABB=15,
-	VARIANT_MATRIX3=16,
-	VARIANT_TRANSFORM=17,
-	VARIANT_MATRIX32=18,
-	VARIANT_COLOR=20,
-	VARIANT_IMAGE=21,
-	VARIANT_NODE_PATH=22,
-	VARIANT_RID=23,
-	VARIANT_OBJECT=24,
-	VARIANT_INPUT_EVENT=25,
-	VARIANT_DICTIONARY=26,
-	VARIANT_ARRAY=30,
-	VARIANT_RAW_ARRAY=31,
-	VARIANT_INT_ARRAY=32,
-	VARIANT_REAL_ARRAY=33,
-	VARIANT_STRING_ARRAY=34,
-	VARIANT_VECTOR3_ARRAY=35,
-	VARIANT_COLOR_ARRAY=36,
-	VARIANT_VECTOR2_ARRAY=37,
-
-	IMAGE_ENCODING_EMPTY=0,
-	IMAGE_ENCODING_RAW=1,
-	IMAGE_ENCODING_PNG=2, //not yet
-	IMAGE_ENCODING_JPG=3,
-
-	IMAGE_FORMAT_GRAYSCALE=0,
-	IMAGE_FORMAT_INTENSITY=1,
-	IMAGE_FORMAT_GRAYSCALE_ALPHA=2,
-	IMAGE_FORMAT_RGB=3,
-	IMAGE_FORMAT_RGBA=4,
-	IMAGE_FORMAT_INDEXED=5,
-	IMAGE_FORMAT_INDEXED_ALPHA=6,
-	IMAGE_FORMAT_BC1=7,
-	IMAGE_FORMAT_BC2=8,
-	IMAGE_FORMAT_BC3=9,
-	IMAGE_FORMAT_BC4=10,
-	IMAGE_FORMAT_BC5=11,
-	IMAGE_FORMAT_CUSTOM=12,
-
-	OBJECT_EMPTY=0,
-	OBJECT_EXTERNAL_RESOURCE=1,
-	OBJECT_INTERNAL_RESOURCE=2,
-
-
-};
-
-
-void ObjectFormatSaverBinary::_pad_buffer(int p_bytes) {
-
-	int extra = 4-(p_bytes%4);
-	if (extra<4) {
-		for(int i=0;i<extra;i++)
-			f->store_8(0); //pad to 32
-	}
-
-}
-
-
-void ObjectFormatSaverBinary::write_property(int p_idx,const Variant& p_property) {
-
-	f->store_32(SECTION_PROPERTY);
-	f->store_32(p_idx);
-
-	switch(p_property.get_type()) {
-
-		case Variant::NIL: {
-
-			f->store_32(VARIANT_NIL);
-			// don't store anything
-		} break;
-		case Variant::BOOL: {
-
-			f->store_32(VARIANT_BOOL);
-			bool val=p_property;
-			f->store_32(val);
-		} break;
-		case Variant::INT: {
-
-			f->store_32(VARIANT_INT);
-			int val=p_property;
-			f->store_32(val);
-		} break;
-		case Variant::REAL: {
-
-			f->store_32(VARIANT_REAL);
-			real_t val=p_property;
-			f->store_real(val);
-
-		} break;
-		case Variant::STRING: {
-
-			f->store_32(VARIANT_STRING);
-			String val=p_property;
-			save_unicode_string(val);
-
-		} break;
-		case Variant::VECTOR2: {
-
-			f->store_32(VARIANT_VECTOR2);
-			Vector2 val=p_property;
-			f->store_real(val.x);
-			f->store_real(val.y);
-
-		} break;
-		case Variant::RECT2: {
-
-			f->store_32(VARIANT_RECT2);
-			Rect2 val=p_property;
-			f->store_real(val.pos.x);
-			f->store_real(val.pos.y);
-			f->store_real(val.size.x);
-			f->store_real(val.size.y);
-
-		} break;
-		case Variant::VECTOR3: {
-
-			f->store_32(VARIANT_VECTOR3);
-			Vector3 val=p_property;
-			f->store_real(val.x);
-			f->store_real(val.y);
-			f->store_real(val.z);
-
-		} break;
-		case Variant::PLANE: {
-
-			f->store_32(VARIANT_PLANE);
-			Plane val=p_property;
-			f->store_real(val.normal.x);
-			f->store_real(val.normal.y);
-			f->store_real(val.normal.z);
-			f->store_real(val.d);
-
-		} break;
-		case Variant::QUAT: {
-
-			f->store_32(VARIANT_QUAT);
-			Quat val=p_property;
-			f->store_real(val.x);
-			f->store_real(val.y);
-			f->store_real(val.z);
-			f->store_real(val.w);
-
-		} break;
-		case Variant::_AABB: {
-
-			f->store_32(VARIANT_AABB);
-			AABB val=p_property;
-			f->store_real(val.pos.x);
-			f->store_real(val.pos.y);
-			f->store_real(val.pos.z);
-			f->store_real(val.size.x);
-			f->store_real(val.size.y);
-			f->store_real(val.size.z);
-
-		} break;
-		case Variant::MATRIX32: {
-
-			f->store_32(VARIANT_MATRIX32);
-			Matrix32 val=p_property;
-			f->store_real(val.elements[0].x);
-			f->store_real(val.elements[0].y);
-			f->store_real(val.elements[1].x);
-			f->store_real(val.elements[1].y);
-			f->store_real(val.elements[2].x);
-			f->store_real(val.elements[2].y);
-
-		} break;
-		case Variant::MATRIX3: {
-
-			f->store_32(VARIANT_MATRIX3);
-			Matrix3 val=p_property;
-			f->store_real(val.elements[0].x);
-			f->store_real(val.elements[0].y);
-			f->store_real(val.elements[0].z);
-			f->store_real(val.elements[1].x);
-			f->store_real(val.elements[1].y);
-			f->store_real(val.elements[1].z);
-			f->store_real(val.elements[2].x);
-			f->store_real(val.elements[2].y);
-			f->store_real(val.elements[2].z);
-
-		} break;
-		case Variant::TRANSFORM: {
-
-			f->store_32(VARIANT_TRANSFORM);
-			Transform val=p_property;
-			f->store_real(val.basis.elements[0].x);
-			f->store_real(val.basis.elements[0].y);
-			f->store_real(val.basis.elements[0].z);
-			f->store_real(val.basis.elements[1].x);
-			f->store_real(val.basis.elements[1].y);
-			f->store_real(val.basis.elements[1].z);
-			f->store_real(val.basis.elements[2].x);
-			f->store_real(val.basis.elements[2].y);
-			f->store_real(val.basis.elements[2].z);
-			f->store_real(val.origin.x);
-			f->store_real(val.origin.y);
-			f->store_real(val.origin.z);
-
-		} break;
-		case Variant::COLOR: {
-
-			f->store_32(VARIANT_COLOR);
-			Color val=p_property;
-			f->store_real(val.r);
-			f->store_real(val.g);
-			f->store_real(val.b);
-			f->store_real(val.a);
-
-		} break;
-		case Variant::IMAGE: {
-
-			f->store_32(VARIANT_IMAGE);
-			Image val =p_property;
-			if (val.empty()) {
-				f->store_32(IMAGE_ENCODING_EMPTY);
-				break;
-			}
-			f->store_32(IMAGE_ENCODING_RAW); //raw encoding
-			f->store_32(val.get_width());
-			f->store_32(val.get_height());
-			f->store_32(val.get_mipmaps());
-			switch(val.get_format()) {
-
-				case Image::FORMAT_GRAYSCALE: f->store_32(IMAGE_FORMAT_GRAYSCALE ); break; ///< one byte per pixel: f->store_32(IMAGE_FORMAT_ ); break; 0-255
-				case Image::FORMAT_INTENSITY: f->store_32(IMAGE_FORMAT_INTENSITY ); break; ///< one byte per pixel: f->store_32(IMAGE_FORMAT_ ); break; 0-255
-				case Image::FORMAT_GRAYSCALE_ALPHA: f->store_32(IMAGE_FORMAT_GRAYSCALE_ALPHA ); break; ///< two bytes per pixel: f->store_32(IMAGE_FORMAT_ ); break; 0-255. alpha 0-255
-				case Image::FORMAT_RGB: f->store_32(IMAGE_FORMAT_RGB ); break; ///< one byte R: f->store_32(IMAGE_FORMAT_ ); break; one byte G: f->store_32(IMAGE_FORMAT_ ); break; one byte B
-				case Image::FORMAT_RGBA: f->store_32(IMAGE_FORMAT_RGBA ); break; ///< one byte R: f->store_32(IMAGE_FORMAT_ ); break; one byte G: f->store_32(IMAGE_FORMAT_ ); break; one byte B: f->store_32(IMAGE_FORMAT_ ); break; one byte A
-				case Image::FORMAT_INDEXED: f->store_32(IMAGE_FORMAT_INDEXED ); break; ///< index byte 0-256: f->store_32(IMAGE_FORMAT_ ); break; and after image end: f->store_32(IMAGE_FORMAT_ ); break; 256*3 bytes of palette
-				case Image::FORMAT_INDEXED_ALPHA: f->store_32(IMAGE_FORMAT_INDEXED_ALPHA ); break; ///< index byte 0-256: f->store_32(IMAGE_FORMAT_ ); break; and after image end: f->store_32(IMAGE_FORMAT_ ); break; 256*4 bytes of palette (alpha)
-				case Image::FORMAT_BC1: f->store_32(IMAGE_FORMAT_BC1 ); break; // DXT1
-				case Image::FORMAT_BC2: f->store_32(IMAGE_FORMAT_BC2 ); break; // DXT3
-				case Image::FORMAT_BC3: f->store_32(IMAGE_FORMAT_BC3 ); break; // DXT5
-				case Image::FORMAT_BC4: f->store_32(IMAGE_FORMAT_BC4 ); break; // ATI1
-				case Image::FORMAT_BC5: f->store_32(IMAGE_FORMAT_BC5 ); break; // ATI2
-				case Image::FORMAT_CUSTOM: f->store_32(IMAGE_FORMAT_CUSTOM ); break;
-				default: {}
-
-			}
-
-			int dlen = val.get_data().size();
-			f->store_32(dlen);
-			DVector<uint8_t>::Read r = val.get_data().read();
-			f->store_buffer(r.ptr(),dlen);
-			_pad_buffer(dlen);
-
-		} break;
-		case Variant::NODE_PATH: {
-			f->store_32(VARIANT_NODE_PATH);
-			save_unicode_string(p_property);
-		} break;
-		case Variant::_RID: {
-
-			f->store_32(VARIANT_RID);
-			WARN_PRINT("Can't save RIDs");
-			RID val = p_property;
-			f->store_32(val.get_id());
-		} break;
-		case Variant::OBJECT: {
-
-			f->store_32(VARIANT_OBJECT);
-			RES res = p_property;
-			if (res.is_null()) {
-				f->store_32(OBJECT_EMPTY);
-				return; // don't save it
-			}
-
-			if (res->get_path().length() && res->get_path().find("::")==-1) {
-				f->store_32(OBJECT_EXTERNAL_RESOURCE);
-				save_unicode_string(res->get_type());
-				String path=relative_paths?local_path.path_to_file(res->get_path()):res->get_path();
-				save_unicode_string(path);
-			} else {
-
-				if (!resource_map.has(res)) {
-					f->store_32(OBJECT_EMPTY);
-					ERR_EXPLAIN("Resource was not pre cached for the resource section, bug?");
-					ERR_FAIL();
-				}
-
-				f->store_32(OBJECT_INTERNAL_RESOURCE);
-				f->store_32(resource_map[res]);
-				//internal resource
-			}
-
-
-		} break;
-		case Variant::INPUT_EVENT: {
-
-			f->store_32(VARIANT_INPUT_EVENT);
-			WARN_PRINT("Can't save InputEvent (maybe it could..)");
-		} break;
-		case Variant::DICTIONARY: {
-
-			f->store_32(VARIANT_DICTIONARY);
-			Dictionary d = p_property;
-			f->store_32(d.size());
-
-			List<Variant> keys;
-			d.get_key_list(&keys);
-
-			for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
-
-				//if (!_check_type(dict[E->get()]))
-				//	continue;
-
-				write_property(0,E->get());
-				write_property(0,d[E->get()]);
-			}
-
-
-		} break;
-		case Variant::ARRAY: {
-
-			f->store_32(VARIANT_ARRAY);
-			Array a=p_property;
-			f->store_32(a.size());
-			for(int i=0;i<a.size();i++) {
-
-				write_property(i,a[i]);
-			}
-
-		} break;
-		case Variant::RAW_ARRAY: {
-
-			f->store_32(VARIANT_RAW_ARRAY);
-			DVector<uint8_t> arr = p_property;
-			int len=arr.size();
-			f->store_32(len);
-			DVector<uint8_t>::Read r = arr.read();
-			f->store_buffer(r.ptr(),len);
-			_pad_buffer(len);
-
-		} break;
-		case Variant::INT_ARRAY: {
-
-			f->store_32(VARIANT_INT_ARRAY);
-			DVector<int> arr = p_property;
-			int len=arr.size();
-			f->store_32(len);
-			DVector<int>::Read r = arr.read();
-			for(int i=0;i<len;i++)
-				f->store_32(r[i]);
-
-		} break;
-		case Variant::REAL_ARRAY: {
-
-			f->store_32(VARIANT_REAL_ARRAY);
-			DVector<real_t> arr = p_property;
-			int len=arr.size();
-			f->store_32(len);
-			DVector<real_t>::Read r = arr.read();
-			for(int i=0;i<len;i++) {
-				f->store_real(r[i]);
-			}
-
-		} break;
-		case Variant::STRING_ARRAY: {
-
-			f->store_32(VARIANT_STRING_ARRAY);
-			DVector<String> arr = p_property;
-			int len=arr.size();
-			f->store_32(len);
-			DVector<String>::Read r = arr.read();
-			for(int i=0;i<len;i++) {
-				save_unicode_string(r[i]);
-			}
-
-		} break;
-		case Variant::VECTOR3_ARRAY: {
-
-			f->store_32(VARIANT_VECTOR3_ARRAY);
-			DVector<Vector3> arr = p_property;
-			int len=arr.size();
-			f->store_32(len);
-			DVector<Vector3>::Read r = arr.read();
-			for(int i=0;i<len;i++) {
-				f->store_real(r[i].x);
-				f->store_real(r[i].y);
-				f->store_real(r[i].z);
-			}
-
-		} break;
-		case Variant::VECTOR2_ARRAY: {
-
-			f->store_32(VARIANT_VECTOR2_ARRAY);
-			DVector<Vector2> arr = p_property;
-			int len=arr.size();
-			f->store_32(len);
-			DVector<Vector2>::Read r = arr.read();
-			for(int i=0;i<len;i++) {
-				f->store_real(r[i].x);
-				f->store_real(r[i].y);
-			}
-
-		} break;
-		case Variant::COLOR_ARRAY: {
-
-			f->store_32(VARIANT_COLOR_ARRAY);
-			DVector<Color> arr = p_property;
-			int len=arr.size();
-			f->store_32(len);
-			DVector<Color>::Read r = arr.read();
-			for(int i=0;i<len;i++) {
-				f->store_real(r[i].r);
-				f->store_real(r[i].g);
-				f->store_real(r[i].b);
-				f->store_real(r[i].a);
-			}
-
-		} break;
-		default: {
-
-			ERR_EXPLAIN("Invalid variant");
-			ERR_FAIL();
-		}
-	}
-}
-
-
-void ObjectFormatSaverBinary::_find_resources(const Variant& p_variant) {
-
-
-	switch(p_variant.get_type()) {
-		case Variant::OBJECT: {
-
-
-			RES res = p_variant.operator RefPtr();
-
-			if (res.is_null())
-				return;
-
-			if (!bundle_resources && res->get_path().length() && res->get_path().find("::") == -1 )
-				return;
-
-			if (resource_map.has(res))
-				return;
-
-			List<PropertyInfo> property_list;
-
-			res->get_property_list(&property_list);
-
-			for(List<PropertyInfo>::Element *E=property_list.front();E;E=E->next()) {
-
-				if (E->get().usage&PROPERTY_USAGE_STORAGE || (bundle_resources && E->get().usage&PROPERTY_USAGE_BUNDLE)) {
-
-					_find_resources(res->get(E->get().name));
-				}
-			}
-
-			SavedObject *so = memnew( SavedObject );
-			_save_obj(res.ptr(),so);
-			so->meta=res.get_ref_ptr();
-
-			resource_map[ res ] = saved_resources.size();
-			saved_resources.push_back(so);
-
-		} break;
-
-		case Variant::ARRAY: {
-
-			Array varray=p_variant;
-			int len=varray.size();
-			for(int i=0;i<len;i++) {
-
-				Variant v=varray.get(i);
-				_find_resources(v);
-			}
-
-		} break;
-
-		case Variant::DICTIONARY: {
-
-			Dictionary d=p_variant;
-			List<Variant> keys;
-			d.get_key_list(&keys);
-			for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
-
-				Variant v = d[E->get()];
-				_find_resources(v);
-			}
-		} break;
-		default: {}
-	}
-
-}
-Error ObjectFormatSaverBinary::_save_obj(const Object *p_object,SavedObject *so) {
-
-	if (optimizer.is_valid()) {
-		//use optimizer
-
-		List<OptimizedSaver::Property> props;
-		optimizer->get_property_list(p_object,&props);
-
-		for(List<OptimizedSaver::Property>::Element *E=props.front();E;E=E->next()) {
-
-			if (skip_editor && String(E->get().name).begins_with("__editor"))
-				continue;
-			_find_resources(E->get().value);
-			SavedObject::SavedProperty sp;
-
-			sp.name_idx=get_string_index(E->get().name);
-			sp.value=E->get().value;
-			so->properties.push_back(sp);
-		}
-
-	} else {
-		//use classic way
-		List<PropertyInfo> property_list;
-		p_object->get_property_list( &property_list );
-
-		for(List<PropertyInfo>::Element *E=property_list.front();E;E=E->next()) {
-
-			if (skip_editor && E->get().name.begins_with("__editor"))
-				continue;
-			if (E->get().usage&PROPERTY_USAGE_STORAGE || (bundle_resources && E->get().usage&PROPERTY_USAGE_BUNDLE)) {
-
-				SavedObject::SavedProperty sp;
-				sp.name_idx=get_string_index(E->get().name);
-				sp.value = p_object->get(E->get().name);
-				_find_resources(sp.value);
-				so->properties.push_back(sp);
-			}
-		}
-	}
-
-	return OK;
-
-}
-
-Error ObjectFormatSaverBinary::save(const Object *p_object,const Variant &p_meta) {
-
-	ERR_FAIL_COND_V(!f,ERR_UNCONFIGURED);
-	ERR_EXPLAIN("write_object should supply either an object, a meta, or both");
-	ERR_FAIL_COND_V(!p_object && p_meta.get_type()==Variant::NIL, ERR_INVALID_PARAMETER);
-
-	SavedObject *so = memnew( SavedObject );
-
-	if (p_object)
-		so->type=p_object->get_type();
-
-	_find_resources(p_meta);
-	so->meta=p_meta;
-	Error err = _save_obj(p_object,so);
-	ERR_FAIL_COND_V( err, ERR_INVALID_DATA );
-
-	saved_objects.push_back(so);
-
-	return OK;
-}
-
-void ObjectFormatSaverBinary::save_unicode_string(const String& p_string) {
-
-
-	CharString utf8 = p_string.utf8();
-	f->store_32(utf8.length()+1);
-	f->store_buffer((const uint8_t*)utf8.get_data(),utf8.length()+1);
-}
-
-ObjectFormatSaverBinary::ObjectFormatSaverBinary(FileAccess *p_file,const String& p_magic,const String& p_local_path,uint32_t p_flags,const Ref<OptimizedSaver>& p_optimizer) {
-
-	optimizer=p_optimizer;
-	relative_paths=p_flags&ObjectSaver::FLAG_RELATIVE_PATHS;
-	skip_editor=p_flags&ObjectSaver::FLAG_OMIT_EDITOR_PROPERTIES;
-	bundle_resources=p_flags&ObjectSaver::FLAG_BUNDLE_RESOURCES;
-	big_endian=p_flags&ObjectSaver::FLAG_SAVE_BIG_ENDIAN;
-	f=p_file; // should be already opened
-	local_path=p_local_path;
-	magic=p_magic;
-
-	bin_meta_idx = get_string_index("__bin_meta__"); //is often used, so create
-}
-
-int ObjectFormatSaverBinary::get_string_index(const String& p_string) {
-
-	StringName s=p_string;
-	if (string_map.has(s))
-		return string_map[s];
-
-	string_map[s]=strings.size();
-	strings.push_back(s);
-	return strings.size()-1;
-}
-
-ObjectFormatSaverBinary::~ObjectFormatSaverBinary() {
-
-
-	static const uint8_t header[4]={'O','B','D','B'};
-	f->store_buffer(header,4);
-	if (big_endian) {
-		f->store_32(1);
-		f->set_endian_swap(true);
-	} else
-		f->store_32(0);
-
-	f->store_32(0); //64 bits file, false for now
-	f->store_32(VERSION_MAJOR);
-	f->store_32(VERSION_MINOR);
-	save_unicode_string(magic);
-	for(int i=0;i<16;i++)
-		f->store_32(0); // reserved
-
-	f->store_32(strings.size()); //string table size
-	for(int i=0;i<strings.size();i++) {
-		print_bl("saving string: "+strings[i]);
-		save_unicode_string(strings[i]);
-	}
-
-	// save resources
-
-	for(int i=0;i<saved_resources.size();i++) {
-
-		SavedObject *so = saved_resources[i];
-		RES res = so->meta;
-		ERR_CONTINUE(!resource_map.has(res));
-
-		f->store_32(SECTION_RESOURCE);		
-		size_t skip_pos = f->get_pos();
-		f->store_64(0); // resource skip seek pos
-		save_unicode_string(res->get_type());
-
-		if (res->get_path().length() && res->get_path().find("::") == -1 )
-			save_unicode_string(res->get_path());
-		else
-			save_unicode_string("local://"+itos(i));
-
-
-
-		List<SavedObject::SavedProperty>::Element *SE = so->properties.front();
-
-		while(SE) {
-
-			write_property(SE->get().name_idx,SE->get().value);
-			SE=SE->next();
-		}
-
-		f->store_32(SECTION_END);
-
-		size_t end=f->get_pos();
-		f->seek(skip_pos);
-		f->store_64(end);
-		f->seek_end();
-
-		memdelete( so );
-	}
-
-	if (!saved_objects.empty()) {
-
-
-		for(List<SavedObject*>::Element *E=saved_objects.front();E;E=E->next()) {
-
-			SavedObject *so = E->get();
-
-
-			size_t section_end;
-
-			if (so->type!="") {
-				f->store_32(SECTION_OBJECT);
-				section_end=f->get_pos();
-				f->store_64(0); //section end
-				save_unicode_string(so->type);
-			} else {
-				f->store_32(SECTION_META_OBJECT);
-				section_end=f->get_pos();
-				f->store_64(0); //section end
-			}
-
-
-			if (so->meta.get_type()!=Variant::NIL)
-				write_property(bin_meta_idx,so->meta);
-
-			List<SavedObject::SavedProperty>::Element *SE = so->properties.front();
-
-			while(SE) {
-
-				write_property(SE->get().name_idx,SE->get().value);
-				SE=SE->next();
-			}
-
-			f->store_32(SECTION_END);
-
-			size_t end=f->get_pos();
-			f->seek(section_end);
-			f->store_64(end);
-			f->seek_end();
-
-			memdelete(so); //no longer needed
-		}
-
-
-	}
-
-	f->store_32(SECTION_END);
-
-	f->close();
-	memdelete(f);
-}
-
-
-ObjectFormatSaver* ObjectFormatSaverInstancerBinary::instance(const String& p_file,const String& p_magic,uint32_t p_flags,const Ref<OptimizedSaver>& p_optimizer) {
-
-	FileAccess *f = FileAccess::open(p_file, FileAccess::WRITE);
-
-	ERR_FAIL_COND_V( !f, NULL );
-	String local_path = Globals::get_singleton()->localize_path(p_file);
-
-	return memnew( ObjectFormatSaverBinary( f, p_magic,local_path,p_flags,p_optimizer ) );
-}
-
-void ObjectFormatSaverInstancerBinary::get_recognized_extensions(List<String> *p_extensions) const {
-
-	p_extensions->push_back("bin");
-}
-
-
-ObjectFormatSaverInstancerBinary::~ObjectFormatSaverInstancerBinary() {
-
-
-}
-
-
-
-/************************************************/
-/************************************************/
-/************************************************/
-/************************************************/
-/************************************************/
-
-
-void ObjectFormatLoaderBinary::_advance_padding(uint32_t p_len) {
-
-	uint32_t extra = 4-(p_len%4);
-	if (extra<4) {
-		for(uint32_t i=0;i<extra;i++)
-			f->get_8(); //pad to 32
-	}
-
-}
-
-Error ObjectFormatLoaderBinary::parse_property(Variant& r_v, int &r_index)  {
-
-
-	uint32_t prop = f->get_32();
-	if (prop==SECTION_END)
-		return ERR_FILE_EOF;
-	ERR_FAIL_COND_V(prop!=SECTION_PROPERTY,ERR_FILE_CORRUPT);
-
-	r_index = f->get_32();
-
-	uint32_t type = f->get_32();
-	print_bl("find property of type: "+itos(type));
-
-
-	switch(type) {
-
-		case VARIANT_NIL: {
-
-			r_v=Variant();
-		} break;
-		case VARIANT_BOOL: {
-
-			r_v=bool(f->get_32());
-		} break;
-		case VARIANT_INT: {
-
-			r_v=int(f->get_32());
-		} break;
-		case VARIANT_REAL: {
-
-			r_v=f->get_real();
-		} break;
-		case VARIANT_STRING: {
-
-			r_v=get_unicode_string();
-		} break;
-		case VARIANT_VECTOR2: {
-
-			Vector2 v;
-			v.x=f->get_real();
-			v.y=f->get_real();
-			r_v=v;
-
-		} break;
-		case VARIANT_RECT2: {
-
-			Rect2 v;
-			v.pos.x=f->get_real();
-			v.pos.y=f->get_real();
-			v.size.x=f->get_real();
-			v.size.y=f->get_real();
-			r_v=v;
-
-		} break;
-		case VARIANT_VECTOR3: {
-
-			Vector3 v;
-			v.x=f->get_real();
-			v.y=f->get_real();
-			v.z=f->get_real();
-			r_v=v;
-		} break;
-		case VARIANT_PLANE: {
-
-			Plane v;
-			v.normal.x=f->get_real();
-			v.normal.y=f->get_real();
-			v.normal.z=f->get_real();
-			v.d=f->get_real();
-			r_v=v;
-		} break;
-		case VARIANT_QUAT: {
-			Quat v;
-			v.x=f->get_real();
-			v.y=f->get_real();
-			v.z=f->get_real();
-			v.w=f->get_real();
-			r_v=v;
-
-		} break;
-		case VARIANT_AABB: {
-
-			AABB v;
-			v.pos.x=f->get_real();
-			v.pos.y=f->get_real();
-			v.pos.z=f->get_real();
-			v.size.x=f->get_real();
-			v.size.y=f->get_real();
-			v.size.z=f->get_real();
-			r_v=v;
-
-		} break;
-		case VARIANT_MATRIX32: {
-
-			Matrix32 v;
-			v.elements[0].x=f->get_real();
-			v.elements[0].y=f->get_real();
-			v.elements[1].x=f->get_real();
-			v.elements[1].y=f->get_real();
-			v.elements[2].x=f->get_real();
-			v.elements[2].y=f->get_real();
-			r_v=v;
-
-		} break;
-		case VARIANT_MATRIX3: {
-
-			Matrix3 v;
-			v.elements[0].x=f->get_real();
-			v.elements[0].y=f->get_real();
-			v.elements[0].z=f->get_real();
-			v.elements[1].x=f->get_real();
-			v.elements[1].y=f->get_real();
-			v.elements[1].z=f->get_real();
-			v.elements[2].x=f->get_real();
-			v.elements[2].y=f->get_real();
-			v.elements[2].z=f->get_real();
-			r_v=v;
-
-		} break;
-		case VARIANT_TRANSFORM: {
-
-			Transform v;
-			v.basis.elements[0].x=f->get_real();
-			v.basis.elements[0].y=f->get_real();
-			v.basis.elements[0].z=f->get_real();
-			v.basis.elements[1].x=f->get_real();
-			v.basis.elements[1].y=f->get_real();
-			v.basis.elements[1].z=f->get_real();
-			v.basis.elements[2].x=f->get_real();
-			v.basis.elements[2].y=f->get_real();
-			v.basis.elements[2].z=f->get_real();
-			v.origin.x=f->get_real();
-			v.origin.y=f->get_real();
-			v.origin.z=f->get_real();
-			r_v=v;
-		} break;
-		case VARIANT_COLOR: {
-
-			Color v;
-			v.r=f->get_real();
-			v.g=f->get_real();
-			v.b=f->get_real();
-			v.a=f->get_real();
-			r_v=v;
-
-		} break;
-		case VARIANT_IMAGE: {
-
-
-			uint32_t encoding = f->get_32();
-			if (encoding==IMAGE_ENCODING_EMPTY) {
-				r_v=Variant();
-				break;
-			}
-
-			if (encoding==IMAGE_ENCODING_RAW) {
-				uint32_t width = f->get_32();
-				uint32_t height = f->get_32();
-				uint32_t mipmaps = f->get_32();
-				uint32_t format = f->get_32();
-				Image::Format fmt;
-				switch(format) {
-
-					case IMAGE_FORMAT_GRAYSCALE: { fmt=Image::FORMAT_GRAYSCALE; } break;
-					case IMAGE_FORMAT_INTENSITY: { fmt=Image::FORMAT_INTENSITY; } break;
-					case IMAGE_FORMAT_GRAYSCALE_ALPHA: { fmt=Image::FORMAT_GRAYSCALE_ALPHA; } break;
-					case IMAGE_FORMAT_RGB: { fmt=Image::FORMAT_RGB; } break;
-					case IMAGE_FORMAT_RGBA: { fmt=Image::FORMAT_RGBA; } break;
-					case IMAGE_FORMAT_INDEXED: { fmt=Image::FORMAT_INDEXED; } break;
-					case IMAGE_FORMAT_INDEXED_ALPHA: { fmt=Image::FORMAT_INDEXED_ALPHA; } break;
-					case IMAGE_FORMAT_BC1: { fmt=Image::FORMAT_BC1; } break;
-					case IMAGE_FORMAT_BC2: { fmt=Image::FORMAT_BC2; } break;
-					case IMAGE_FORMAT_BC3: { fmt=Image::FORMAT_BC3; } break;
-					case IMAGE_FORMAT_BC4: { fmt=Image::FORMAT_BC4; } break;
-					case IMAGE_FORMAT_BC5: { fmt=Image::FORMAT_BC5; } break;
-					case IMAGE_FORMAT_CUSTOM: { fmt=Image::FORMAT_CUSTOM; } break;
-					default: {
-
-						ERR_FAIL_V(ERR_FILE_CORRUPT);
-					}
-
-				}
-
-
-				uint32_t datalen = f->get_32();
-
-				print_bl("width: "+itos(width));
-				print_bl("height: "+itos(height));
-				print_bl("mipmaps: "+itos(mipmaps));
-				print_bl("format: "+itos(format));
-				print_bl("datalen: "+itos(datalen));
-
-				DVector<uint8_t> imgdata;
-				imgdata.resize(datalen);
-				DVector<uint8_t>::Write w = imgdata.write();
-				f->get_buffer(w.ptr(),datalen);
-				_advance_padding(datalen);
-				w=DVector<uint8_t>::Write();
-
-				r_v=Image(width,height,mipmaps,fmt,imgdata);
-			}
-
-
-		} break;
-		case VARIANT_NODE_PATH: {
-
-			r_v=NodePath(get_unicode_string());
-		} break;
-		case VARIANT_RID: {
-
-			r_v=f->get_32();
-		} break;
-		case VARIANT_OBJECT: {
-
-			uint32_t type=f->get_32();
-
-			switch(type) {
-
-				case OBJECT_EMPTY: {
-					//do none
-
-				} break;
-				case OBJECT_INTERNAL_RESOURCE: {
-					uint32_t index=f->get_32();
-					String path = local_path+"::"+itos(index);
-					RES res = ResourceLoader::load(path);
-					if (res.is_null()) {
-						WARN_PRINT(String("Couldn't load resource: "+path).utf8().get_data());
-					}
-					r_v=res;
-
-				} break;
-				case OBJECT_EXTERNAL_RESOURCE: {
-
-					String type = get_unicode_string();
-					String path = get_unicode_string();
-
-					if (path.find("://")==-1 && path.is_rel_path()) {
-						// path is relative to file being loaded, so convert to a resource path
-						path=Globals::get_singleton()->localize_path(local_path.get_base_dir()+"/"+path);
-
-					}
-
-					RES res=ResourceLoader::load(path,type);
-
-					if (res.is_null()) {
-						WARN_PRINT(String("Couldn't load resource: "+path).utf8().get_data());
-					}
-					r_v=res;
-
-				} break;
-				default: {
-
-					ERR_FAIL_V(ERR_FILE_CORRUPT);
-				} break;
-			}
-
-		} break;
-		case VARIANT_INPUT_EVENT: {
-
-		} break;
-		case VARIANT_DICTIONARY: {
-
-			int len=f->get_32();
-			Dictionary d;
-			for(int i=0;i<len;i++) {
-				int idx;
-				Variant key;
-				Error err = parse_property(key,idx);
-				ERR_FAIL_COND_V(err,ERR_FILE_CORRUPT);
-				Variant value;
-				err = parse_property(value,idx);
-				ERR_FAIL_COND_V(err,ERR_FILE_CORRUPT);
-				d[key]=value;
-			}
-			r_v=d;
-		} break;
-		case VARIANT_ARRAY: {
-			int len=f->get_32();
-			Array a;
-			a.resize(len);
-			for(int i=0;i<len;i++) {
-				int idx;
-				Variant val;
-				Error err = parse_property(val,idx);
-				ERR_FAIL_COND_V(err,ERR_FILE_CORRUPT);
-				a[i]=val;
-			}
-			r_v=a;
-
-		} break;
-		case VARIANT_RAW_ARRAY: {
-
-			uint32_t len = f->get_32();
-
-			DVector<uint8_t> array;
-			array.resize(len);
-			DVector<uint8_t>::Write w = array.write();
-			f->get_buffer(w.ptr(),len);
-			_advance_padding(len);
-			w=DVector<uint8_t>::Write();
-			r_v=array;
-
-		} break;
-		case VARIANT_INT_ARRAY: {
-
-			uint32_t len = f->get_32();
-
-			DVector<int> array;
-			array.resize(len);
-			DVector<int>::Write w = array.write();
-			f->get_buffer((uint8_t*)w.ptr(),len*4);
-			w=DVector<int>::Write();
-			r_v=array;
-		} break;
-		case VARIANT_REAL_ARRAY: {
-
-			uint32_t len = f->get_32();
-
-			DVector<real_t> array;
-			array.resize(len);
-			DVector<real_t>::Write w = array.write();
-			f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t));
-			w=DVector<real_t>::Write();
-			r_v=array;
-		} break;
-		case VARIANT_STRING_ARRAY: {
-
-			uint32_t len = f->get_32();
-			DVector<String> array;
-			array.resize(len);
-			DVector<String>::Write w = array.write();
-			for(int i=0;i<len;i++)
-				w[i]=get_unicode_string();
-			w=DVector<String>::Write();
-			r_v=array;
-
-
-		} break;
-		case VARIANT_VECTOR2_ARRAY: {
-
-			uint32_t len = f->get_32();
-
-			DVector<Vector2> array;
-			array.resize(len);
-			DVector<Vector2>::Write w = array.write();
-			if (sizeof(Vector2)==8) {
-				f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*2);
-			} else {
-				ERR_EXPLAIN("Vector2 size is NOT 8!");
-				ERR_FAIL_V(ERR_UNAVAILABLE);
-			}
-			w=DVector<Vector2>::Write();
-			r_v=array;
-
-		} break;
-		case VARIANT_VECTOR3_ARRAY: {
-
-			uint32_t len = f->get_32();
-
-			DVector<Vector3> array;
-			array.resize(len);
-			DVector<Vector3>::Write w = array.write();
-			if (sizeof(Vector3)==12) {
-				f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*3);
-			} else {
-				ERR_EXPLAIN("Vector3 size is NOT 12!");
-				ERR_FAIL_V(ERR_UNAVAILABLE);
-			}
-			w=DVector<Vector3>::Write();
-			r_v=array;
-
-		} break;
-		case VARIANT_COLOR_ARRAY: {
-
-			uint32_t len = f->get_32();
-
-			DVector<Color> array;
-			array.resize(len);
-			DVector<Color>::Write w = array.write();
-			if (sizeof(Color)==16) {
-				f->get_buffer((uint8_t*)w.ptr(),len*sizeof(real_t)*4);
-			} else {
-				ERR_EXPLAIN("Color size is NOT 16!");
-				ERR_FAIL_V(ERR_UNAVAILABLE);
-			}
-			w=DVector<Color>::Write();
-			r_v=array;
-		} break;
-
-		default: {
-			ERR_FAIL_V(ERR_FILE_CORRUPT);
-		} break;
-	}
-
-
-
-	return OK; //never reach anyway
-
-}
-
-Error ObjectFormatLoaderBinary::load(Object **p_object,Variant &p_meta) {
-
-
-
-	while(true) {
-
-		if (f->eof_reached()) {
-			ERR_EXPLAIN("Premature end of file at: "+local_path);
-			ERR_FAIL_V(ERR_FILE_CORRUPT);
-		}
-
-		RES resource;
-		Object *obj=NULL;
-		bool meta=false;
-
-		uint32_t section = f->get_32();
-
-		switch(section) {
-
-
-			case SECTION_RESOURCE: {
-
-				print_bl("resource found");
-
-				size_t section_end = f->get_64();
-				print_bl("section end: "+itos(section_end));
-				String type = get_unicode_string();
-				String path = get_unicode_string();
-				print_bl("path: "+path);
-
-				if (path.begins_with("local://")) {
-					//built-in resource (but really external)
-					path=path.replace("local://",local_path+"::");
-				}
-
-				if (ResourceCache::has(path)) {
-					f->seek(section_end);
-					continue;
-				}
-
-				//load properties
-
-
-				obj = ObjectTypeDB::instance(type);
-				if (!obj) {
-					ERR_EXPLAIN("Object of unrecognized type '"+type+"' in file: "+type);
-				}
-
-				ERR_FAIL_COND_V(!obj,ERR_FILE_CORRUPT);
-
-				Resource *r = obj->cast_to<Resource>();
-				if (!r) {
-					memdelete(obj); //bye
-					ERR_EXPLAIN("Object type in resource field not a resource, type is: "+obj->get_type());
-					ERR_FAIL_COND_V(!obj->cast_to<Resource>(),ERR_FILE_CORRUPT);
-				}
-
-				resource = RES( r );
-				r->set_path(path);
-			} break;
-			case SECTION_META_OBJECT:
-				meta=true;
-				print_bl("meta found");
-
-			case SECTION_OBJECT: {
-
-				uint64_t section_end = f->get_64();
-
-				if (!meta) {
-					print_bl("object");
-
-					String type = get_unicode_string();
-					if (ObjectTypeDB::can_instance(type)) {
-						obj = ObjectTypeDB::instance(type);
-						if (!obj) {
-							ERR_EXPLAIN("Object of unrecognized type in file: "+type);
-						}
-						ERR_FAIL_COND_V(!obj,ERR_FILE_CORRUPT);
-					} else {
-
-						f->seek(section_end);
-						return ERR_SKIP;
-					};
-
-
-				}
-
-
-			} break;
-			case SECTION_END: {
-
-
-				return ERR_FILE_EOF;
-			} break;
-
-			default: {
-
-				ERR_EXPLAIN("Invalid Section ID '"+itos(section)+"' in file: "+local_path);
-				ERR_FAIL_V(ERR_FILE_CORRUPT);
-
-			}
-
-		}
-
-
-		//load properties
-
-		while(true) {
-
-			int name_idx;
-			Variant v;
-			Error err;
-			err = parse_property(v,name_idx);
-
-			print_bl("prop idx "+itos(name_idx)+" value: "+String(v));
-
-			if (err==ERR_FILE_EOF)
-				break;
-
-			if (err!=OK) {
-				ERR_EXPLAIN("File Corrupted");
-				ERR_FAIL_COND_V(err!=OK,ERR_FILE_CORRUPT);
-			}
-
-
-			if (resource.is_null() && name_idx==0) { //0 is __bin_meta__
-
-				p_meta=v;
-				continue;
-			} else if (!obj) {
-
-				ERR_EXPLAIN("Normal property found in meta object.");
-				ERR_FAIL_V(ERR_FILE_CORRUPT);
-			}
-
-			Map<int,StringName>::Element *E=string_map.find(name_idx);
-			if (!E) {
-				ERR_EXPLAIN("Property ID has no matching name: "+itos(name_idx));
-				ERR_FAIL_V(ERR_FILE_CORRUPT);
-			}
-
-			obj->set(E->get(),v);
-		}
-
-		if (!obj) {
-			*p_object=NULL;
-			return OK; // it was a meta object
-		}
-
-		if (resource.is_null()) {
-
-			//regular object
-			*p_object=obj;
-			return OK;
-		} else {
-
-			resource_cache.push_back(resource); //keep it in mem until finished loading
-		}
-
-	}
-}
-
-
-ObjectFormatLoaderBinary::~ObjectFormatLoaderBinary() {
-
-	if (f) {
-		if (f->is_open())
-			f->close();
-		memdelete(f);
-	}
-}
-
-
-String ObjectFormatLoaderBinary::get_unicode_string() {
-
-	uint32_t len = f->get_32();
-	if (len>str_buf.size()) {
-		str_buf.resize(len);
-	}
-	f->get_buffer((uint8_t*)&str_buf[0],len);
-	String s;
-	s.parse_utf8(&str_buf[0]);
-	return s;
-}
-
-ObjectFormatLoaderBinary::ObjectFormatLoaderBinary(FileAccess *p_f,bool p_endian_swap,bool p_use64) {
-
-	f=p_f;
-	endian_swap=p_endian_swap;
-	use_real64=p_use64;
-
-	//load string table
-	uint32_t string_table_size = f->get_32();
-	print_bl("string table size: "+itos(string_table_size));
-	for(int i=0;i<string_table_size;i++) {
-
-		String str = get_unicode_string();
-		print_bl("string "+itos(i)+" is: "+str);
-		string_map[i]=str;
-	}
-
-
-}
-
-ObjectFormatLoaderBinary* ObjectFormatLoaderInstancerBinary::instance(const String& p_file,const String& p_magic) {
-
-	FileAccess *f=FileAccess::open(p_file,FileAccess::READ);
-	ERR_FAIL_COND_V(!f,NULL);
-
-	uint8_t header[4];
-	f->get_buffer(header,4);
-	if (header[0]!='O' || header[1]!='B' || header[2]!='D' || header[3]!='B') {
-
-		ERR_EXPLAIN("File not in valid binary format: "+p_file);
-		ERR_FAIL_V(NULL);
-	}
-
-	uint32_t big_endian = f->get_32();
-#ifdef BIG_ENDIAN_ENABLED
-	bool endian_swap = !big_endian;
-#else
-	bool endian_swap = big_endian;
-#endif
-
-	bool use_real64 = f->get_32();
-
-	f->set_endian_swap(big_endian!=0); //read big endian if saved as big endian
-
-	uint32_t ver_major=f->get_32();
-	uint32_t ver_minor=f->get_32();
-
-	print_bl("big endian: "+itos(big_endian));
-	print_bl("endian swap: "+itos(endian_swap));
-	print_bl("real64: "+itos(use_real64));
-	print_bl("major: "+itos(ver_major));
-	print_bl("minor: "+itos(ver_minor));
-
-	if (ver_major>VERSION_MAJOR || (ver_major==VERSION_MAJOR && ver_minor>VERSION_MINOR)) {
-
-		f->close();
-		memdelete(f);
-		ERR_EXPLAIN("File Format '"+itos(ver_major)+"."+itos(ver_minor)+"' is too new! Please upgrade to a a new engine version: "+p_file);
-		ERR_FAIL_V(NULL);
-
-	}
-
-	uint32_t magic_len = f->get_32();
-	Vector<char> magic;
-	magic.resize(magic_len);
-	f->get_buffer((uint8_t*)&magic[0],magic_len);
-	String magic_str;
-	magic_str.parse_utf8(&magic[0]);
-
-	print_bl("magic: "+magic_str);
-	if (magic_str!=p_magic) {
-
-		f->close();
-		memdelete(f);
-		ERR_EXPLAIN("File magic mismatch, found '"+magic_str+"' in : "+p_file);
-		ERR_FAIL_V(NULL);
-	}
-
-	print_bl("skipping 32");
-	for(int i=0;i<16;i++)
-		f->get_32(); //skip a few reserved fields
-
-	if (f->eof_reached()) {
-
-		f->close();
-		memdelete(f);
-		ERR_EXPLAIN("Premature End Of File: "+p_file);
-		ERR_FAIL_V(NULL);
-
-	}
-
-	print_bl("creating loader");
-	ObjectFormatLoaderBinary *loader = memnew( ObjectFormatLoaderBinary(f,endian_swap,use_real64) );
-	loader->local_path=p_file;
-
-	return loader;
-}
-
-void ObjectFormatLoaderInstancerBinary::get_recognized_extensions(List<String> *p_extensions) const {
-
-	p_extensions->push_back("bin");
-}
-
-
-#endif

+ 0 - 158
core/io/object_format_binary.h

@@ -1,158 +0,0 @@
-/*************************************************************************/
-/*  object_format_binary.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 OBJECT_FORMAT_BINARY_H
-#define OBJECT_FORMAT_BINARY_H
-
-#include "object_loader.h"
-#include "object_saver_base.h"
-#include "dvector.h"
-#include "core/os/file_access.h"
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-/**
-	@author Juan Linietsky <[email protected]>
-*/
-
-
-class ObjectFormatSaverBinary : public ObjectFormatSaver {
-
-	String local_path;
-
-
-	Ref<OptimizedSaver> optimizer;
-
-	bool relative_paths;
-	bool bundle_resources;
-	bool skip_editor;
-	bool big_endian;
-	int bin_meta_idx;
-	FileAccess *f;
-	String magic;
-	Map<RES,int> resource_map;
-	Map<StringName,int> string_map;
-	Vector<StringName> strings;
-
-	struct SavedObject {
-
-		Variant meta;
-		String type;
-
-
-		struct SavedProperty {
-
-			int name_idx;
-			Variant value;
-		};
-
-		List<SavedProperty> properties;
-	};
-
-
-	int get_string_index(const String& p_string);
-	void save_unicode_string(const String& p_string);
-
-	List<SavedObject*> saved_objects;
-	List<SavedObject*> saved_resources;
-
-	void _pad_buffer(int p_bytes);
-	Error _save_obj(const Object *p_object,SavedObject *so);
-	void _find_resources(const Variant& p_variant);
-	void write_property(int p_idx,const Variant& p_property);
-
-
-public:
-
-	virtual Error save(const Object *p_object,const Variant &p_meta);
-
-	ObjectFormatSaverBinary(FileAccess *p_file,const String& p_magic,const String& p_local_path,uint32_t p_flags,const Ref<OptimizedSaver>& p_optimizer);
-	~ObjectFormatSaverBinary();
-};
-
-class ObjectFormatSaverInstancerBinary : public ObjectFormatSaverInstancer {
-public:
-
-	virtual ObjectFormatSaver* instance(const String& p_file,const String& p_magic,uint32_t p_flags=0,const Ref<OptimizedSaver>& p_optimizer=Ref<OptimizedSaver>());
-	virtual void get_recognized_extensions(List<String> *p_extensions) const;
-
-	virtual ~ObjectFormatSaverInstancerBinary();
-};
-
-
-
-
-/***********************************/
-/***********************************/
-/***********************************/
-/***********************************/
-
-class ObjectFormatLoaderBinary : public ObjectFormatLoader {
-
-	String local_path;
-
-	FileAccess *f;
-
-	bool endian_swap;
-	bool use_real64;
-
-	Vector<char> str_buf;
-	List<RES> resource_cache;
-
-	Map<int,StringName> string_map;
-
-	String get_unicode_string();
-	void _advance_padding(uint32_t p_len);
-
-friend class ObjectFormatLoaderInstancerBinary;
-
-
-	Error parse_property(Variant& r_v, int& r_index);
-
-public:
-
-
-	virtual Error load(Object **p_object,Variant &p_meta);
-
-	ObjectFormatLoaderBinary(FileAccess *f,bool p_endian_swap,bool p_use64);
-	virtual ~ObjectFormatLoaderBinary();
-};
-
-class ObjectFormatLoaderInstancerBinary : public ObjectFormatLoaderInstancer {
-public:
-
-	virtual ObjectFormatLoaderBinary* instance(const String& p_file,const String& p_magic);
-	virtual void get_recognized_extensions(List<String> *p_extensions) const;
-
-
-
-};
-
-
-
-#endif // OBJECT_FORMAT_BINARY_H
-#endif

+ 0 - 3190
core/io/object_format_xml.cpp

@@ -1,3190 +0,0 @@
-/*************************************************************************/
-/*  object_format_xml.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.                */
-/*************************************************************************/
-#ifdef XML_ENABLED
-#ifdef OLD_SCENE_FORMAT_ENABLED
-#include "object_format_xml.h"
-#include "resource.h"
-#include "io/resource_loader.h"
-#include "print_string.h"
-#include "object_type_db.h"
-#include "globals.h"
-#include "os/os.h"
-#include "version.h"
-
-void ObjectFormatSaverXML::escape(String& p_str) {
-	
-	p_str=p_str.replace("&","&amp;");
-	p_str=p_str.replace("<","&gt;");
-	p_str=p_str.replace(">","&lt;");
-	p_str=p_str.replace("'","&apos;");
-	p_str=p_str.replace("\"","&quot;");
-	for (int i=1;i<32;i++) {
-		
-		char chr[2]={i,0};
-		p_str=p_str.replace(chr,"&#"+String::num(i)+";");
-	}
-
-	
-}
-void ObjectFormatSaverXML::write_tabs(int p_diff) {
-
-	for (int i=0;i<depth+p_diff;i++) {
-
-		f->store_8('\t');
-	}
-}
-
-void ObjectFormatSaverXML::write_string(String p_str,bool p_escape) {
-	
-	/* write an UTF8 string */
-	if (p_escape)
-		escape(p_str);
-	
-	f->store_string(p_str);;
-	/*
-	CharString cs=p_str.utf8();
-	const char *data=cs.get_data();
-		
-	while (*data) {
-		f->store_8(*data);
-		data++;
-	}*/
-	
-	
-}	
-
-void ObjectFormatSaverXML::enter_tag(const String& p_section,const String& p_args) {
-	
-	if (p_args.length())
-		write_string("<"+p_section+" "+p_args+">",false);
-	else
-		write_string("<"+p_section+">",false);
-	depth++;
-}
-void ObjectFormatSaverXML::exit_tag(const String& p_section) {
-	
-	depth--;	
-	write_string("</"+p_section+">",false);
-
-}
-
-/*
-static bool _check_type(const Variant& p_property) {
-
-	if (p_property.get_type()==Variant::_RID)
-		return false;
-	if (p_property.get_type()==Variant::OBJECT) {
-		RES res = p_property;
-		if (res.is_null())
-			return false;
-	}
-
-	return true;
-}*/
-
-void ObjectFormatSaverXML::write_property(const String& p_name,const Variant& p_property,bool *r_ok) {
-
-	if (r_ok)
-		*r_ok=false;
-	
-	String type;
-	String params;
-	bool oneliner=true;
-	
-	switch( p_property.get_type() ) {
-			
-		case Variant::NIL: 		type="nil"; break;
-		case Variant::BOOL:		type="bool"; break;
-		case Variant::INT: 		type="int"; break;
-		case Variant::REAL:		type="real"; break;
-		case Variant::STRING:		type="string"; break;
-		case Variant::VECTOR2:		type="vector2"; break;
-		case Variant::RECT2:		type="rect2"; break;
-		case Variant::VECTOR3:		type="vector3"; break;
-		case Variant::PLANE:		type="plane"; break;
-		case Variant::_AABB:		type="aabb"; break;
-		case Variant::QUAT:		type="quaternion"; break;
-		case Variant::MATRIX32:		type="matrix32"; break;
-		case Variant::MATRIX3:		type="matrix3"; break;
-		case Variant::TRANSFORM:		type="transform"; break;
-		case Variant::COLOR:		type="color"; break;
-		case Variant::IMAGE: {			
-			type="image"; 
-			Image img=p_property;
-			if (img.empty()) {
-				enter_tag(type,"name=\""+p_name+"\"");
-				exit_tag(type);
-				if (r_ok)
-					*r_ok=true;
-				return;
-			}
-			params+="encoding=\"raw\"";
-			params+=" width=\""+itos(img.get_width())+"\"";
-			params+=" height=\""+itos(img.get_height())+"\"";
-			params+=" mipmaps=\""+itos(img.get_mipmaps())+"\"";
-
-			switch(img.get_format()) {
-				
-				case Image::FORMAT_GRAYSCALE: params+=" format=\"grayscale\""; break;
-				case Image::FORMAT_INTENSITY: params+=" format=\"intensity\""; break;
-				case Image::FORMAT_GRAYSCALE_ALPHA: params+=" format=\"grayscale_alpha\""; break;
-				case Image::FORMAT_RGB: params+=" format=\"rgb\""; break;
-				case Image::FORMAT_RGBA: params+=" format=\"rgba\""; break;
-				case Image::FORMAT_INDEXED : params+=" format=\"indexed\""; break;
-				case Image::FORMAT_INDEXED_ALPHA: params+=" format=\"indexed_alpha\""; break;
-				case Image::FORMAT_BC1: params+=" format=\"bc1\""; break;
-				case Image::FORMAT_BC2: params+=" format=\"bc2\""; break;
-				case Image::FORMAT_BC3: params+=" format=\"bc3\""; break;
-				case Image::FORMAT_BC4: params+=" format=\"bc4\""; break;
-				case Image::FORMAT_BC5: params+=" format=\"bc5\""; break;
-				case Image::FORMAT_CUSTOM: params+=" format=\"custom\" custom_size=\""+itos(img.get_data().size())+"\""; break;
-				default: {}
-			}
-		} break;
-		case Variant::NODE_PATH:		type="node_path"; break;			
-		case Variant::OBJECT:	{
-			type="resource"; 
-			RES res = p_property;
-			if (res.is_null()) {
-				enter_tag(type,"name=\""+p_name+"\"");
-				exit_tag(type);
-				if (r_ok)
-					*r_ok=true;
-
-				return; // don't save it
-			}
-				
-			params="resource_type=\""+res->get_type()+"\"";
-
-			if (res->get_path().length() && res->get_path().find("::")==-1) {
-				//external resource
-				String path=relative_paths?local_path.path_to_file(res->get_path()):res->get_path();
-				escape(path);
-				params+=" path=\""+path+"\"";
-			} else {
-
-				//internal resource
-				ERR_EXPLAIN("Resource was not pre cached for the resource section, bug?");
-				ERR_FAIL_COND(!resource_map.has(res));
-
-				params+=" path=\"local://"+itos(resource_map[res])+"\"";
-			}
-			
-		} break;
-		case Variant::INPUT_EVENT:	type="input_event"; break;
-		case Variant::DICTIONARY:	type="dictionary" ; oneliner=false; break;
-		case Variant::ARRAY:		type="array"; params="len=\""+itos(p_property.operator Array().size())+"\""; oneliner=false; break;
-		
-		case Variant::RAW_ARRAY:		type="raw_array"; params="len=\""+itos(p_property.operator DVector < uint8_t >().size())+"\""; break;
-		case Variant::INT_ARRAY:		type="int_array"; params="len=\""+itos(p_property.operator DVector < int >().size())+"\""; break;
-		case Variant::REAL_ARRAY:	type="real_array"; params="len=\""+itos(p_property.operator DVector < real_t >().size())+"\""; break;
-		case Variant::STRING_ARRAY:	type="string_array"; params="len=\""+itos(p_property.operator DVector < String >().size())+"\""; break;
-		case Variant::VECTOR2_ARRAY:	type="vector2_array"; params="len=\""+itos(p_property.operator DVector < Vector2 >().size())+"\""; break;
-		case Variant::VECTOR3_ARRAY:	type="vector3_array"; params="len=\""+itos(p_property.operator DVector < Vector3 >().size())+"\""; break;
-		case Variant::COLOR_ARRAY:	type="color_array"; params="len=\""+itos(p_property.operator DVector < Color >().size())+"\""; break;
-		default: {
-		
-			ERR_PRINT("Unknown Variant type.");
-			ERR_FAIL();
-		}
-			
-	}
-
-	write_tabs();
-
-	if (p_name!="") {
-		if (params.length())
-			enter_tag(type,"name=\""+p_name+"\" "+params);
-		else
-			enter_tag(type,"name=\""+p_name+"\"");
-	} else {
-		if (params.length())
-			enter_tag(type," "+params);
-		else
-			enter_tag(type,"");
-	}
-
-	if (!oneliner)
-		write_string("\n",false);
-	else
-		write_string(" ",false);
-	
-
-	switch( p_property.get_type() ) {
-
-		case Variant::NIL: {
-			
-		} break;
-		case Variant::BOOL: {
-			
-			write_string( p_property.operator bool() ? "True":"False" );
-		} break;
-		case Variant::INT: {
-			
-			write_string( itos(p_property.operator int()) );
-		} break;
-		case Variant::REAL: {
-			
-			write_string( rtos(p_property.operator real_t()) );
-		} break;
-		case Variant::STRING: {
-			
-			String str=p_property;
-			escape(str);
-			str="\""+str+"\"";
-			write_string( str,false );
-		} break;
-		case Variant::VECTOR2: {
-			
-			Vector2 v = p_property;
-			write_string( rtoss(v.x) +", "+rtoss(v.y) );
-		} break;
-		case Variant::RECT2: {
-		
-			Rect2 aabb = p_property;
-			write_string( rtoss(aabb.pos.x) +", "+rtoss(aabb.pos.y) +", "+rtoss(aabb.size.x) +", "+rtoss(aabb.size.y) );
-		
-		} break;
-		case Variant::VECTOR3: {
-			
-			Vector3 v = p_property;
-			write_string( rtoss(v.x) +", "+rtoss(v.y)+", "+rtoss(v.z) );
-		} break;
-		case Variant::PLANE: {
-			
-			Plane p = p_property;
-			write_string( rtoss(p.normal.x) +", "+rtoss(p.normal.y)+", "+rtoss(p.normal.z)+", "+rtoss(p.d) );
-			
-		} break;
-		case Variant::_AABB: {
-			
-			AABB aabb = p_property;
-			write_string( rtoss(aabb.pos.x) +", "+rtoss(aabb.pos.y) +", "+rtoss(aabb.pos.z) +", "+rtoss(aabb.size.x) +", "+rtoss(aabb.size.y) +", "+rtoss(aabb.size.z)  );
-			
-		} break; 
-		case Variant::QUAT: {
-			
-			Quat quat = p_property;
-			write_string( rtoss(quat.x)+", "+rtoss(quat.y)+", "+rtoss(quat.z)+", "+rtoss(quat.w)+", ");
-			
-		} break; 
-		case Variant::MATRIX32: {
-
-			String s;
-			Matrix32 m3 = p_property;
-			for (int i=0;i<3;i++) {
-				for (int j=0;j<2;j++) {
-
-					if (i!=0 || j!=0)
-						s+=", ";
-					s+=rtoss( m3.elements[i][j] );
-				}
-			}
-
-			write_string(s);
-
-		} break;
-		case Variant::MATRIX3: {
-			
-			String s;
-			Matrix3 m3 = p_property;
-			for (int i=0;i<3;i++) {
-				for (int j=0;j<3;j++) {
-					
-					if (i!=0 || j!=0)
-						s+=", ";
-					s+=rtoss( m3.elements[i][j] );
-				}
-			}
-					
-			write_string(s);
-			     
-		} break;
-		case Variant::TRANSFORM: {
-			
-			String s;
-			Transform t = p_property;
-			Matrix3 &m3 = t.basis;
-			for (int i=0;i<3;i++) {
-				for (int j=0;j<3;j++) {
-					
-					if (i!=0 || j!=0)
-						s+=", ";
-					s+=rtoss( m3.elements[i][j] );
-				}
-			}
-			
-			s=s+", "+rtoss(t.origin.x) +", "+rtoss(t.origin.y)+", "+rtoss(t.origin.z);
-			
-			write_string(s);
-		} break;
-			
-			// misc types		
-		case Variant::COLOR: {
-			
-			Color c = p_property;
-			write_string( rtoss(c.r) +", "+rtoss(c.g)+", "+rtoss(c.b)+", "+rtoss(c.a) );
-			
-		} break;
-		case Variant::IMAGE: {
-			
-			String s;
-			Image img = p_property;
-			DVector<uint8_t> data = img.get_data();
-			int len = data.size();
-			DVector<uint8_t>::Read r = data.read();
-			const uint8_t *ptr=r.ptr();;
-			for (int i=0;i<len;i++) {
-				
-				uint8_t byte = ptr[i];
-				const char  hex[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
-				char str[3]={ hex[byte>>4], hex[byte&0xF], 0};
-				s+=str;				
-			}
-			
-			write_string(s);
-		} break;
-		case Variant::NODE_PATH: {
-			
-			String str=p_property;
-			escape(str);
-			str="\""+str+"\"";
-			write_string( str,false);
-			
-		} break;
-
-		case Variant::OBJECT: {
-			/* this saver does not save resources in here
-			RES res = p_property;
-			
-			if (!res.is_null()) {
-				
-				String path=res->get_path();				
-				if (!res->is_shared() || !path.length()) {
-					// if no path, or path is from inside a scene
-					write_object( *res );
-				}
-				
-			}
-			*/
-								
-		} break;
-		case Variant::INPUT_EVENT: {
-			
-			write_string( p_property.operator String() );
-		} break;
-		case Variant::DICTIONARY: {
-			
-			Dictionary dict = p_property;
-			
-
-			List<Variant> keys;
-			dict.get_key_list(&keys);
-			
-			for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
-
-				//if (!_check_type(dict[E->get()]))
-				//	continue;
-
-				bool ok;
-				write_property("",E->get(),&ok);
-				ERR_CONTINUE(!ok);
-
-				write_property("",dict[E->get()],&ok);
-				if (!ok)
-					write_property("",Variant()); //at least make the file consistent..
-			}
-			
-			
-			
-			
-		} break;
-		case Variant::ARRAY: {
-			
-			Array array = p_property;
-			int len=array.size();
-			for (int i=0;i<len;i++) {
-				
-				write_property("",array[i]);
-				
-			}
-			
-		} break;
-			
-		case Variant::RAW_ARRAY: {
-			
-			String s;
-			DVector<uint8_t> data = p_property;
-			int len = data.size();
-			DVector<uint8_t>::Read r = data.read();
-			const uint8_t *ptr=r.ptr();;
-			for (int i=0;i<len;i++) {
-				
-				uint8_t byte = ptr[i];
-				const char  hex[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
-				char str[3]={ hex[byte>>4], hex[byte&0xF], 0};
-				s+=str;				
-			}
-			
-			write_string(s,false);
-			
-		} break;
-		case Variant::INT_ARRAY: {
-			
-			DVector<int> data = p_property;
-			int len = data.size();
-			DVector<int>::Read r = data.read();
-			const int *ptr=r.ptr();;
-			write_tabs();
-			
-			for (int i=0;i<len;i++) {
-				
-				if (i>0)
-					write_string(", ",false);
-
-				write_string(itos(ptr[i]),false);
-			}
-			
-
-
-		} break;
-		case Variant::REAL_ARRAY: {
-			
-			DVector<real_t> data = p_property;
-			int len = data.size();
-			DVector<real_t>::Read r = data.read();
-			const real_t *ptr=r.ptr();;
-			write_tabs();
-
-			for (int i=0;i<len;i++) {
-				
-				if (i>0)
-					write_string(", ",false);
-				write_string(rtoss(ptr[i]),false);
-			}
-
-
-		} break;
-		case Variant::STRING_ARRAY: {
-			
-			DVector<String> data = p_property;
-			int len = data.size();
-			DVector<String>::Read r = data.read();
-			const String *ptr=r.ptr();;
-			String s;
-			
-			for (int i=0;i<len;i++) {
-			
-				if (i>0)
-					s+=", ";
-				String str=ptr[i];
-				escape(str);
-				s=s+"\""+str+"\"";
-			}
-			
-			write_string(s,false);
-			
-		} break;
-		case Variant::VECTOR2_ARRAY: {
-
-			DVector<Vector2> data = p_property;
-			int len = data.size();
-			DVector<Vector2>::Read r = data.read();
-			const Vector2 *ptr=r.ptr();;
-			write_tabs();
-
-			for (int i=0;i<len;i++) {
-
-				if (i>0)
-					write_string(", ",false);
-				write_string(rtoss(ptr[i].x),false);
-				write_string(", "+rtoss(ptr[i].y),false);
-
-			}
-
-
-		} break;
-		case Variant::VECTOR3_ARRAY: {
-			
-			DVector<Vector3> data = p_property;
-			int len = data.size();
-			DVector<Vector3>::Read r = data.read();
-			const Vector3 *ptr=r.ptr();;
-			write_tabs();
-
-			for (int i=0;i<len;i++) {
-				
-				if (i>0)
-					write_string(", ",false);
-				write_string(rtoss(ptr[i].x),false);
-				write_string(", "+rtoss(ptr[i].y),false);
-				write_string(", "+rtoss(ptr[i].z),false);
-
-			}
-			
-
-		} break;
-		case Variant::COLOR_ARRAY: {
-			
-			DVector<Color> data = p_property;
-			int len = data.size();
-			DVector<Color>::Read r = data.read();
-			const Color *ptr=r.ptr();;
-			write_tabs();
-			
-			for (int i=0;i<len;i++) {
-				
-				if (i>0)
-					write_string(", ",false);
-
-				write_string(rtoss(ptr[i].r),false);
-				write_string(", "+rtoss(ptr[i].g),false);
-				write_string(", "+rtoss(ptr[i].b),false);
-				write_string(", "+rtoss(ptr[i].a),false);
-
-			}
-			
-		} break;
-		default: {}
-		
-	}
-	if (oneliner)
-		write_string(" ");
-	else
-		write_tabs(-1);
-	exit_tag(type);
-
-	write_string("\n",false);
-
-	if (r_ok)
-		*r_ok=true;
-
-}
-
-
-void ObjectFormatSaverXML::_find_resources(const Variant& p_variant) {
-
-
-	switch(p_variant.get_type()) {
-		case Variant::OBJECT: {
-
-
-
-			RES res = p_variant.operator RefPtr();
-
-			if (res.is_null())
-				return;
-
-			if (!bundle_resources && res->get_path().length() && res->get_path().find("::") == -1 )
-				return;
-
-			if (resource_map.has(res))
-				return;
-
-			List<PropertyInfo> property_list;
-
-			res->get_property_list( &property_list );
-
-			List<PropertyInfo>::Element *I=property_list.front();
-
-			while(I) {
-
-				PropertyInfo pi=I->get();
-
-				if (pi.usage&PROPERTY_USAGE_STORAGE || (bundle_resources && pi.usage&PROPERTY_USAGE_BUNDLE)) {
-
-					Variant v=res->get(I->get().name);
-					_find_resources(v);
-				}
-
-				I=I->next();
-			}
-
-			resource_map[ res ] = resource_map.size(); //saved after, so the childs it needs are available when loaded
-			saved_resources.push_back(res);
-
-		} break;
-
-		case Variant::ARRAY: {
-
-			Array varray=p_variant;
-			int len=varray.size();
-			for(int i=0;i<len;i++) {
-
-				Variant v=varray.get(i);
-				_find_resources(v);
-			}
-
-		} break;
-
-		case Variant::DICTIONARY: {
-
-			Dictionary d=p_variant;
-			List<Variant> keys;
-			d.get_key_list(&keys);
-			for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
-
-				Variant v = d[E->get()];
-				_find_resources(v);
-			}
-		} break;
-		default: {}
-	}
-
-}
-
-
-
-Error ObjectFormatSaverXML::save(const Object *p_object,const Variant &p_meta) {
-
-	ERR_FAIL_COND_V(!f,ERR_UNCONFIGURED);
-	ERR_EXPLAIN("write_object should supply either an object, a meta, or both");
-	ERR_FAIL_COND_V(!p_object && p_meta.get_type()==Variant::NIL, ERR_INVALID_PARAMETER);
-
-	SavedObject *so = memnew( SavedObject );
-
-	if (p_object)
-		so->type=p_object->get_type();
-
-	_find_resources(p_meta);
-	so->meta=p_meta;
-
-	if (p_object) {
-
-
-		if (optimizer.is_valid()) {
-			//use optimizer
-
-			List<OptimizedSaver::Property> props;
-			optimizer->get_property_list(p_object,&props);
-
-			for(List<OptimizedSaver::Property>::Element *E=props.front();E;E=E->next()) {
-
-				if (skip_editor && String(E->get().name).begins_with("__editor"))
-					continue;
-				_find_resources(E->get().value);
-				SavedObject::SavedProperty sp;
-				sp.name=E->get().name;
-				sp.value=E->get().value;
-				so->properties.push_back(sp);
-			}
-
-		} else {
-			//use classic way
-			List<PropertyInfo> property_list;
-			p_object->get_property_list( &property_list );
-
-			for(List<PropertyInfo>::Element *E=property_list.front();E;E=E->next()) {
-
-				if (skip_editor && E->get().name.begins_with("__editor"))
-					continue;
-				if (E->get().usage&PROPERTY_USAGE_STORAGE || (bundle_resources && E->get().usage&PROPERTY_USAGE_BUNDLE)) {
-
-					SavedObject::SavedProperty sp;
-					sp.name=E->get().name;
-					sp.value = p_object->get(E->get().name);
-					_find_resources(sp.value);
-					so->properties.push_back(sp);
-				}
-			}
-		}
-
-	}
-
-	saved_objects.push_back(so);
-
-	return OK;
-}
-
-ObjectFormatSaverXML::ObjectFormatSaverXML(FileAccess *p_file,const String& p_magic,const String& p_local_path,uint32_t p_flags,const Ref<OptimizedSaver>& p_optimizer) {
-
-	optimizer=p_optimizer;
-	relative_paths=p_flags&ObjectSaver::FLAG_RELATIVE_PATHS;
-	skip_editor=p_flags&ObjectSaver::FLAG_OMIT_EDITOR_PROPERTIES;
-	bundle_resources=p_flags&ObjectSaver::FLAG_BUNDLE_RESOURCES;
-	f=p_file; // should be already opened
-	depth=0;	
-	local_path=p_local_path;
-	magic=p_magic;
-}
-ObjectFormatSaverXML::~ObjectFormatSaverXML() {
-	
-	write_string("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>",false); //no escape
-	write_string("\n",false);
-	enter_tag("object_file","magic=\""+magic+"\" "+"version=\""+itos(VERSION_MAJOR)+"."+itos(VERSION_MINOR)+"\" version_name=\""+VERSION_FULL_NAME+"\"");
-	write_string("\n",false);
-
-	// save resources
-
-	for(List<RES>::Element *E=saved_resources.front();E;E=E->next()) {
-
-		RES res = E->get();
-		ERR_CONTINUE(!resource_map.has(res));
-
-		write_tabs();
-		if (res->get_path().length() && res->get_path().find("::") == -1 )
-			enter_tag("resource","type=\""+res->get_type()+"\" path=\""+res->get_path()+"\""); //bundled
-		else
-			enter_tag("resource","type=\""+res->get_type()+"\" path=\"local://"+itos(resource_map[res])+"\"");
-
-		if (optimizer.is_valid()) {
-
-			List<OptimizedSaver::Property> props;
-			optimizer->get_property_list(res.ptr(),&props);
-
-			for(List<OptimizedSaver::Property>::Element *E=props.front();E;E=E->next()) {
-
-				if (skip_editor && String(E->get().name).begins_with("__editor"))
-					continue;
-
-				write_property(E->get().name,E->get().value);
-			}
-
-
-		} else {
-
-			List<PropertyInfo> property_list;
-			res->get_property_list(&property_list);
-			for(List<PropertyInfo>::Element *PE = property_list.front();PE;PE=PE->next()) {
-
-
-				if (skip_editor && PE->get().name.begins_with("__editor"))
-					continue;
-
-				if (PE->get().usage&PROPERTY_USAGE_STORAGE || (bundle_resources && PE->get().usage&PROPERTY_USAGE_BUNDLE)) {
-
-					String name = PE->get().name;
-					Variant value = res->get(name);
-					write_property(name,value);
-				}
-
-
-			}
-
-		}
-		write_tabs(-1);
-		exit_tag("resource");
-		write_string("\n",false);
-	}
-
-	if (!saved_objects.empty()) {
-
-
-		for(List<SavedObject*>::Element *E=saved_objects.front();E;E=E->next()) {
-
-			SavedObject *so = E->get();
-
-
-
-			write_tabs();
-			if (so->type!="")
-				enter_tag("object","type=\""+so->type+"\"");
-			else
-				enter_tag("object");
-			write_string("\n",false);
-
-			if (so->meta.get_type()!=Variant::NIL) {
-
-				write_property("__xml_meta__",so->meta);
-
-			}
-
-			List<SavedObject::SavedProperty>::Element *SE = so->properties.front();
-
-			while(SE) {
-
-				write_property(SE->get().name,SE->get().value);
-				SE=SE->next();
-			}
-
-
-			write_tabs(-1);
-			exit_tag("object");
-			write_string("\n",false);
-			memdelete(so); //no longer needed
-		}
-
-
-	} else {
-
-		WARN_PRINT("File contains no saved objects.");
-	}
-
-	exit_tag("object_file");
-	f->close();
-	memdelete(f);
-}
-
-
-ObjectFormatSaver* ObjectFormatSaverInstancerXML::instance(const String& p_file,const String& p_magic,uint32_t p_flags,const Ref<OptimizedSaver>& p_optimizer) {
-	
-	Error err;
-	FileAccess *f = FileAccess::open(p_file, FileAccess::WRITE,&err);
-
-	ERR_FAIL_COND_V( err, NULL );
-	String local_path = Globals::get_singleton()->localize_path(p_file);		
-
-	return memnew( ObjectFormatSaverXML( f, p_magic,local_path,p_flags,p_optimizer ) );
-}	
-
-void ObjectFormatSaverInstancerXML::get_recognized_extensions(List<String> *p_extensions) const {
-	
-	p_extensions->push_back("xml");
-}
-
-
-ObjectFormatSaverInstancerXML::~ObjectFormatSaverInstancerXML() {
-	
-	
-}
-
-/************************************************/
-/************************************************/
-/************************************************/
-/************************************************/
-/************************************************/
-
-
-
-#ifdef OPTIMIZED_XML_LOADER
-
-#define IS_FLOAT_CHAR(m_c) \
-	((m_c>='0' && m_c<='9') || m_c=='e' || m_c=='-' || m_c=='+' || m_c=='.')
-
-#define XML_FAIL(m_cond,m_err) \
-	if (m_cond) {\
-		ERR_EXPLAIN(local_path+":"+itos(parser->get_current_line())+": "+String(m_err));\
-		ERR_FAIL_COND_V( m_cond, ERR_FILE_CORRUPT );\
-	}
-
-
-Error ObjectFormatLoaderXML::_parse_property(Variant& r_v,String& r_name) {
-
-	XML_FAIL( parser->is_empty(), "unexpected empty tag");
-
-	String type=parser->get_node_name();
-	String name=parser->get_attribute_value_safe("name");
-
-	r_v=Variant();
-	r_name=name;
-
-	if (type=="dictionary") {
-
-		Dictionary d;
-		int reading=0;
-		Variant key;
-		while(parser->read()==OK) {
-
-			if (parser->get_node_type()==XMLParser::NODE_ELEMENT) {
-				Error err;
-				String tagname;
-
-				if (reading==0) {
-
-					err=_parse_property(key,tagname);
-					XML_FAIL( err,"error parsing dictionary key: "+name);
-					reading++;
-				} else {
-
-					reading=0;
-					Variant value;
-					err=_parse_property(value,tagname);
-					XML_FAIL( err,"error parsing dictionary value: "+name);
-					d[key]=value;
-				}
-
-			} else if (parser->get_node_type()==XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="dictionary") {
-				r_v=d;
-				return OK;
-			}
-		}
-
-
-		XML_FAIL( true, "unexpected end of file while reading dictionary: "+name);
-
-	} else if (type=="array") {
-
-		XML_FAIL( !parser->has_attribute("len"), "array missing 'len' attribute");
-
-		int len=parser->get_attribute_value("len").to_int();
-
-		Array array;
-		array.resize(len);
-
-
-		Variant v;
-		String tagname;
-		int idx=0;
-
-
-		while(parser->read()==OK) {
-
-			if (parser->get_node_type()==XMLParser::NODE_ELEMENT) {
-
-				XML_FAIL( idx >= len, "array size mismatch (too many elements)");
-				Error err;
-				String tagname;
-				Variant key;
-
-				err=_parse_property(key,tagname);
-				XML_FAIL( err,"error parsing element of array: "+name);
-				array[idx]=key;
-				idx++;
-
-
-			} else if (parser->get_node_type()==XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="array") {
-
-				XML_FAIL( idx != len, "array size mismatch (not "+itos(len)+"):"+name);
-				r_v=array;
-				return OK;
-			}
-		}
-
-		XML_FAIL( true, "unexpected end of file while reading dictionary: "+name);
-
-	} else if (type=="resource") {
-
-
-		XML_FAIL(!parser->has_attribute("path"),"resource property has no 'path' set (embedding not supported).")
-
-		String path=parser->get_attribute_value("path");
-		String hint = parser->get_attribute_value_safe("resource_type");
-
-		if (path.begins_with("local://"))
-			path=path.replace("local://",local_path+"::");
-		else if (path.find("://")==-1 && path.is_rel_path()) {
-			// path is relative to file being loaded, so convert to a resource path
-			path=Globals::get_singleton()->localize_path(local_path.get_base_dir()+"/"+path);
-
-		}
-
-		//take advantage of the resource loader cache. The resource is cached on it, even if
-		RES res=ResourceLoader::load(path,hint);
-
-
-		if (res.is_null()) {
-
-			WARN_PRINT(String("Couldn't load resource: "+path).ascii().get_data());
-		}
-
-		r_v=res.get_ref_ptr();
-
-	} else if (type=="image") {
-
-		if (parser->has_attribute("encoding")) { //there is image data
-
-			String encoding=parser->get_attribute_value("encoding");
-
-			if (encoding=="raw") {
-
-				//raw image (bytes)
-
-				XML_FAIL( !parser->has_attribute("width"), "missing attribute in raw encoding: 'width'.");
-				XML_FAIL( !parser->has_attribute("height"), "missing attribute in raw encoding: 'height'.");
-				XML_FAIL( !parser->has_attribute("format"), "missing attribute in raw encoding: 'format'.");
-
-				String format = parser->get_attribute_value("format");
-				String width = parser->get_attribute_value("width");
-				String height = parser->get_attribute_value("height");
-
-				Image::Format imgformat;
-				int chans=0;
-				int pal=0;
-
-				if (format=="grayscale") {
-					imgformat=Image::FORMAT_GRAYSCALE;
-					chans=1;
-				} else if (format=="intensity") {
-					imgformat=Image::FORMAT_INTENSITY;
-					chans=1;
-				} else if (format=="grayscale_alpha") {
-					imgformat=Image::FORMAT_GRAYSCALE_ALPHA;
-					chans=2;
-				} else if (format=="rgb") {
-					imgformat=Image::FORMAT_RGB;
-					chans=3;
-				} else if (format=="rgba") {
-					imgformat=Image::FORMAT_RGBA;
-					chans=4;
-				} else if (format=="indexed") {
-					imgformat=Image::FORMAT_INDEXED;
-					chans=1;
-					pal=256*3;
-				} else if (format=="indexed_alpha") {
-					imgformat=Image::FORMAT_INDEXED_ALPHA;
-					chans=1;
-					pal=256*4;
-				} else {
-
-					XML_FAIL(true, "invalid format for image: "+format);
-
-				}
-
-				XML_FAIL( chans==0, "invalid number of color channels in image (0).");
-
-				int w=width.to_int();
-				int h=height.to_int();
-
-				if (w == 0 && w == 0) { //epmty, don't even bother
-					//r_v = Image(w, h, imgformat);
-					r_v=Image();
-					return OK;
-				} else {
-
-					//decode hexa
-
-					DVector<uint8_t> pixels;
-					pixels.resize(chans*w*h+pal);
-					int pixels_size=pixels.size();
-					XML_FAIL( pixels_size==0, "corrupt");
-
-					ERR_FAIL_COND_V(pixels_size==0,ERR_FILE_CORRUPT);
-					DVector<uint8_t>::Write wr=pixels.write();
-					uint8_t *bytes=wr.ptr();
-
-					XML_FAIL( parser->read()!=OK, "error reading" );
-					XML_FAIL( parser->get_node_type()!=XMLParser::NODE_TEXT, "expected text!");
-
-					String text = parser->get_node_data().strip_edges();
-					XML_FAIL( text.length()/2 != pixels_size, "unexpected image data size" );
-
-					for(int i=0;i<pixels_size*2;i++) {
-
-						uint8_t byte;
-						CharType c=text[i];
-
-						if ( (c>='0' && c<='9') || (c>='A' && c<='F') || (c>='a' && c<='f') ) {
-
-							if (i&1) {
-
-								byte|=HEX2CHR(c);
-								bytes[i>>1]=byte;
-							} else {
-
-								byte=HEX2CHR(c)<<4;
-							}
-
-
-						}
-					}
-
-					wr=DVector<uint8_t>::Write();
-					r_v=Image(w,h,imgformat,pixels);
-				}
-			}
-
-		} else {
-			r_v=Image(); // empty image, since no encoding defined
-		}
-
-	} else if (type=="raw_array") {
-
-		XML_FAIL( !parser->has_attribute("len"), "array missing 'len' attribute");
-
-		int len=parser->get_attribute_value("len").to_int();
-		if (len>0) {
-
-			XML_FAIL( parser->read()!=OK, "error reading" );
-			XML_FAIL( parser->get_node_type()!=XMLParser::NODE_TEXT, "expected text!");
-			String text = parser->get_node_data();
-
-			XML_FAIL( text.length() != len*2, "raw array length mismatch" );
-
-			DVector<uint8_t> bytes;
-			bytes.resize(len);
-			DVector<uint8_t>::Write w=bytes.write();
-			uint8_t *bytesptr=w.ptr();
-
-
-			for(int i=0;i<len*2;i++) {
-
-				uint8_t byte;
-				CharType c=text[i];
-
-				if ( (c>='0' && c<='9') || (c>='A' && c<='F') || (c>='a' && c<='f') ) {
-
-					if (i&1) {
-
-						byte|=HEX2CHR(c);
-						bytesptr[i>>1]=byte;
-					} else {
-
-						byte=HEX2CHR(c)<<4;
-					}
-				}
-			}
-
-			w=DVector<uint8_t>::Write();
-			r_v=bytes;
-		}
-
-	} else if (type=="int_array") {
-
-		int len=parser->get_attribute_value("len").to_int();
-
-		if (len>0) {
-
-			XML_FAIL( parser->read()!=OK, "error reading" );
-			XML_FAIL( parser->get_node_type()!=XMLParser::NODE_TEXT, "expected text!");
-			String text = parser->get_node_data();
-
-			const CharType *c=text.c_str();
-			DVector<int> varray;
-			varray.resize(len);
-			DVector<int>::Write w = varray.write();
-
-			int idx=0;
-			const CharType *from=c-1;
-
-			while(*c) {
-
-				bool ischar = (*c >='0' && *c<='9') || *c=='+' || *c=='-';
-				if (!ischar) {
-
-					if (int64_t(c-from)>1) {
-
-						int i = String::to_int(from+1,int64_t(c-from));
-						w[idx++]=i;
-					}
-
-					from=c;
-				} else {
-
-					XML_FAIL( idx >= len, "array too big");
-				}
-
-				c++;
-			}
-
-			XML_FAIL( idx != len, "array size mismatch");
-
-			w = varray.write();
-			r_v=varray;
-		}
-
-
-
-	} else if (type=="real_array") {
-
-		int len=parser->get_attribute_value("len").to_int();
-
-		if (len>0) {
-
-			XML_FAIL( parser->read()!=OK, "error reading" );
-			XML_FAIL( parser->get_node_type()!=XMLParser::NODE_TEXT, "expected text!");
-			String text = parser->get_node_data();
-
-			const CharType *c=text.c_str();
-			DVector<real_t> varray;
-			varray.resize(len);
-			DVector<real_t>::Write w = varray.write();
-
-			int idx=0;
-			const CharType *from=c-1;
-
-			while(*c) {
-
-				bool ischar = IS_FLOAT_CHAR((*c));
-				if (!ischar) {
-
-					if (int64_t(c-from)>1) {
-
-						real_t f = String::to_double(from+1,int64_t(c-from));
-						w[idx++]=f;
-					}
-
-					from=c;
-				} else {
-
-					XML_FAIL( idx >= len, "array too big");
-				}
-
-				c++;
-			}
-
-			XML_FAIL( idx != len, "array size mismatch");
-
-			w = varray.write();
-			r_v=varray;
-		}
-
-	} else if (type=="string_array") {
-
-
-		// this is invalid xml, and will have to be fixed at some point..
-
-		int len=parser->get_attribute_value("len").to_int();
-
-		if (len>0) {
-
-			XML_FAIL( parser->read()!=OK, "error reading" );
-			XML_FAIL( parser->get_node_type()!=XMLParser::NODE_TEXT, "expected text!");
-			String text = parser->get_node_data();
-
-			const CharType *c=text.c_str();
-			DVector<String> sarray;
-			sarray.resize(len);
-			DVector<String>::Write w = sarray.write();
-
-
-			bool inside=false;
-			const CharType *from=c;
-			int idx=0;
-
-			while(*c) {
-
-				if (inside) {
-
-					if (*c == '"') {
-						inside=false;
-						String s = String(from,int64_t(c-from));
-						w[idx]=s;
-						idx++;
-					}
-				} else {
-
-					if (*c == '"') {
-						inside=true;
-						from=c+1;
-						XML_FAIL( idx>=len, "string array is too big!!: "+name);
-					}
-				}
-
-				c++;
-			}
-
-			XML_FAIL( inside, "unterminated string array: "+name);
-			XML_FAIL( len != idx, "string array size mismatch: "+name);
-
-			w = DVector<String>::Write();
-
-			r_v=sarray;
-
-		}
-	} else if (type=="vector3_array") {
-
-		int len=parser->get_attribute_value("len").to_int();
-
-		if (len>0) {
-
-			XML_FAIL( parser->read()!=OK, "error reading" );
-			XML_FAIL( parser->get_node_type()!=XMLParser::NODE_TEXT, "expected text!");
-			String text = parser->get_node_data();
-
-			const CharType *c=text.c_str();
-			DVector<Vector3> varray;
-			varray.resize(len);
-			DVector<Vector3>::Write w = varray.write();
-
-			int idx=0;
-			int sidx=0;
-			Vector3 v;
-			const CharType *from=c-1;
-
-			while(*c) {
-
-				bool ischar = IS_FLOAT_CHAR((*c));
-				if (!ischar) {
-
-					if (int64_t(c-from)>1) {
-
-						real_t f = String::to_double(from+1,int64_t(c-from));
-						v[sidx++]=f;
-						if (sidx==3) {
-							w[idx++]=v;
-							sidx=0;
-
-						}
-					}
-
-					from=c;
-				} else {
-
-					XML_FAIL( idx >= len, "array too big");
-				}
-
-				c++;
-			}
-
-			XML_FAIL( idx != len, "array size mismatch");
-
-			w = varray.write();
-			r_v=varray;
-		}
-
-	} else if (type=="color_array") {
-
-		int len=parser->get_attribute_value("len").to_int();
-
-		if (len>0) {
-
-			XML_FAIL( parser->read()!=OK, "error reading" );
-			XML_FAIL( parser->get_node_type()!=XMLParser::NODE_TEXT, "expected text!");
-			String text = parser->get_node_data();
-
-			const CharType *c=text.c_str();
-			DVector<Color> carray;
-			carray.resize(len);
-			DVector<Color>::Write w = carray.write();
-
-			int idx=0;
-			int sidx=0;
-			Color v;
-			const CharType *from=c-1;
-
-			while(*c) {
-
-				bool ischar = IS_FLOAT_CHAR((*c));
-				if (!ischar) {
-
-					if (int64_t(c-from)>1) {
-
-						real_t f = String::to_double(from+1,int64_t(c-from));
-						v[sidx++]=f;
-						if (sidx==4) {
-							w[idx++]=v;
-							sidx=0;
-
-						}
-					}
-
-					from=c;
-				} else {
-
-					XML_FAIL( idx >= len, "array too big");
-				}
-
-				c++;
-			}
-
-			XML_FAIL( idx != len, "array size mismatch");
-
-			w = carray.write();
-			r_v=carray;
-		}
-	} else {
-		// simple string parsing code
-		XML_FAIL( parser->read()!=OK, "can't read data" );
-
-		String data=parser->get_node_data();
-		data=data.strip_edges();
-
-		if (type=="nil") {
-			// uh do nothing
-
-		} else if (type=="bool") {
-			// uh do nothing
-			if (data.nocasecmp_to("true")==0 || data.to_int()!=0)
-				r_v=true;
-			else
-				r_v=false;
-
-		} else if (type=="int") {
-
-			r_v=data.to_int();
-		} else if (type=="real") {
-
-			r_v=data.to_double();
-		} else if (type=="string") {
-
-			String str=data;
-			str=str.substr(1,str.length()-2);
-			r_v=str;
-		} else if (type=="vector3") {
-
-			r_v=Vector3(
-					data.get_slice(",",0).to_double(),
-					data.get_slice(",",1).to_double(),
-					data.get_slice(",",2).to_double()
-				   );
-
-		} else if (type=="vector2") {
-
-
-			r_v=Vector2(
-					data.get_slice(",",0).to_double(),
-					data.get_slice(",",1).to_double()
-				   );
-
-		} else if (type=="plane") {
-
-			r_v=Plane(
-					data.get_slice(",",0).to_double(),
-					data.get_slice(",",1).to_double(),
-					data.get_slice(",",2).to_double(),
-					data.get_slice(",",3).to_double()
-				 );
-
-		} else if (type=="quaternion") {
-
-			r_v=Quat(
-					data.get_slice(",",0).to_double(),
-					data.get_slice(",",1).to_double(),
-					data.get_slice(",",2).to_double(),
-					data.get_slice(",",3).to_double()
-				 );
-
-		} else if (type=="rect2") {
-
-			r_v=Rect2(
-				Vector2(
-					data.get_slice(",",0).to_double(),
-					data.get_slice(",",1).to_double()
-				),
-				Vector2(
-					data.get_slice(",",2).to_double(),
-					data.get_slice(",",3).to_double()
-				)
-			);
-
-
-		} else if (type=="aabb") {
-
-			r_v=AABB(
-				Vector3(
-					data.get_slice(",",0).to_double(),
-					data.get_slice(",",1).to_double(),
-					data.get_slice(",",2).to_double()
-				),
-				Vector3(
-					data.get_slice(",",3).to_double(),
-					data.get_slice(",",4).to_double(),
-					data.get_slice(",",5).to_double()
-				)
-			);
-
-
-		} else if (type=="matrix3") {
-
-			Matrix3 m3;
-			for (int i=0;i<3;i++) {
-				for (int j=0;j<3;j++) {
-					m3.elements[i][j]=data.get_slice(",",i*3+j).to_double();
-				}
-			}
-			r_v=m3;
-
-		} else if (type=="transform") {
-
-			Transform tr;
-			for (int i=0;i<3;i++) {
-				for (int j=0;j<3;j++) {
-					tr.basis.elements[i][j]=data.get_slice(",",i*3+j).to_double();
-				}
-
-			}
-			tr.origin=Vector3(
-				     data.get_slice(",",9).to_double(),
-				     data.get_slice(",",10).to_double(),
-				     data.get_slice(",",11).to_double()
-				   );
-			r_v=tr;
-
-		} else if (type=="color") {
-
-			r_v=Color(
-				   data.get_slice(",",0).to_double(),
-				   data.get_slice(",",1).to_double(),
-				   data.get_slice(",",2).to_double(),
-				   data.get_slice(",",3).to_double()
-				 );
-
-		} else if (type=="node_path") {
-
-			String str=data;
-			str=str.substr(1,str.length()-2);
-			r_v=NodePath( str );
-
-		} else if (type=="input_event") {
-
-			// ?
-		} else {
-
-			XML_FAIL(true,"unrecognized property tag: "+type);
-		}
-	}
-
-	_close_tag(type);
-
-	return OK;
-}
-
-
-
-
-Error ObjectFormatLoaderXML::_close_tag(const String& p_tag) {
-
-	int c=1;
-
-	while(parser->read()==OK) {
-
-
-		if (parser->get_node_type()==XMLParser::NODE_ELEMENT && parser->get_node_name()==p_tag) {
-			c++;
-		} else if (parser->get_node_type()==XMLParser::NODE_ELEMENT_END && parser->get_node_name()==p_tag) {
-			c--;
-
-			if (c==0)
-				return OK;
-		}
-
-	}
-
-	return ERR_FILE_CORRUPT;
-}
-
-Error ObjectFormatLoaderXML::load(Object **p_object,Variant &p_meta)  {
-
-	*p_object=NULL;
-	p_meta=Variant();
-
-	while(parser->read()==OK) {
-
-		if (parser->get_node_type()==XMLParser::NODE_ELEMENT) {
-
-			String name = parser->get_node_name();
-
-
-			XML_FAIL( !parser->has_attribute("type"), "'type' attribute missing." );
-			String type = parser->get_attribute_value("type");
-
-
-			Object *obj=NULL;
-			Ref<Resource> resource;
-			if (name=="resource") {
-
-				XML_FAIL( !parser->has_attribute("path"), "'path' attribute missing." );
-				String path = parser->get_attribute_value("path");
-
-				XML_FAIL(!path.begins_with("local://"),"path does not begin with 'local://'");
-
-
-				path=path.replace("local://",local_path+"::");
-
-				if (ResourceCache::has(path)) {
-					Error err = _close_tag(name);
-					XML_FAIL( err, "error skipping resource.");
-					continue; //it's a resource, and it's already loaded
-
-				}
-
-				obj = ObjectTypeDB::instance(type);
-				XML_FAIL(!obj,"couldn't instance object of type: '"+type+"'");
-
-				Resource *r = obj->cast_to<Resource>();
-				XML_FAIL(!obj,"object isn't of type Resource: '"+type+"'");
-
-				resource = RES( r );
-				r->set_path(path);
-
-
-			} else if (name=="object") {
-
-
-				if (ObjectTypeDB::can_instance(type)) {
-					obj = ObjectTypeDB::instance(type);
-					XML_FAIL(!obj,"couldn't instance object of type: '"+type+"'");
-				} else {
-
-					_close_tag(name);
-					return ERR_SKIP;
-				};
-			} else {
-				XML_FAIL(true,"Unknown main tag: "+parser->get_node_name());
-			}
-
-			//load properties
-
-			while (parser->read()==OK) {
-
-				if (parser->get_node_type()==XMLParser::NODE_ELEMENT_END && parser->get_node_name()==name)
-					break;
-				else if (parser->get_node_type()==XMLParser::NODE_ELEMENT) {
-
-					String name;
-					Variant v;
-					Error err;
-					err = _parse_property(v,name);
-					XML_FAIL(err,"Error parsing property: "+name);
-
-					if (resource.is_null() && name=="__xml_meta__") {
-
-						p_meta=v;
-						continue;
-					} else {
-
-						XML_FAIL( !obj, "Normal property found in meta object");
-
-					}
-
-					obj->set(name,v);
-
-
-				}
-			}
-
-
-			if (!obj) {
-				*p_object=NULL;
-				return OK; // it was a meta object
-			}
-
-			if (resource.is_null()) {
-				//regular object
-				*p_object=obj;
-				return OK;
-			} else {
-
-				resource_cache.push_back(resource); //keep it in mem until finished loading and load next
-			}
-
-
-		} else if (parser->get_node_type()==XMLParser::NODE_ELEMENT_END && parser->get_node_name()=="object_file")
-			return ERR_FILE_EOF;
-	}
-
-	return OK; //never reach anyway
-}
-
-ObjectFormatLoaderXML* ObjectFormatLoaderInstancerXML::instance(const String& p_file,const String& p_magic) {
-
-	Ref<XMLParser> parser = memnew( XMLParser );
-
-	Error err = parser->open(p_file);
-	ERR_FAIL_COND_V(err,NULL);
-
-	ObjectFormatLoaderXML *loader = memnew( ObjectFormatLoaderXML );
-
-	loader->parser=parser;
-	loader->local_path = Globals::get_singleton()->localize_path(p_file);
-
-	while(parser->read()==OK) {
-
-		if (parser->get_node_type()==XMLParser::NODE_ELEMENT && parser->get_node_name()=="object_file") {
-
-			ERR_FAIL_COND_V( parser->is_empty(), NULL );
-
-			String version = parser->get_attribute_value_safe("version");
-			String magic = parser->get_attribute_value_safe("MAGIC");
-
-			if (version.get_slice_count(".")!=2) {
-
-				ERR_EXPLAIN("Invalid Version String '"+version+"'' in file: "+p_file);
-				ERR_FAIL_V(NULL);
-			}
-
-			int major = version.get_slice(".",0).to_int();
-			int minor = version.get_slice(".",1).to_int();
-
-			if (major>VERSION_MAJOR || (major==VERSION_MAJOR && minor>VERSION_MINOR)) {
-
-				ERR_EXPLAIN("File Format '"+version+"' is too new! Please upgrade to a a new engine version: "+p_file);
-				ERR_FAIL_V(NULL);
-
-			}
-
-			return loader;
-		}
-
-	}
-
-	ERR_EXPLAIN("No data found in file!");
-	ERR_FAIL_V(NULL);
-}
-
-void ObjectFormatLoaderInstancerXML::get_recognized_extensions(List<String> *p_extensions) const {
-
-	p_extensions->push_back("xml");
-}
-
-
-
-#else
-
-ObjectFormatLoaderXML::Tag* ObjectFormatLoaderXML::parse_tag(bool *r_exit) {
-	
-	
-	while(get_char()!='<' && !f->eof_reached()) {}
-	if (f->eof_reached())
-		return NULL;
-	
-	Tag tag;
-	bool exit=false;
-	if (r_exit)
-		*r_exit=false;
-	
-	bool complete=false;
-	while(!f->eof_reached()) {
-		
-		CharType c=get_char();
-		if (c<33 && tag.name.length() && !exit) {
-			break;
-		} else if (c=='>') {
-			complete=true;
-			break;
-		} else if (c=='/') {
-			exit=true;
-		} else {
-			tag.name+=c;
-		}
-	}
-
-	if (f->eof_reached())
-		return NULL;
-	
-	if (exit) {
-		if (!tag_stack.size()) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Unmatched exit tag </"+tag.name+">");
-			ERR_FAIL_COND_V(!tag_stack.size(),NULL);
-		}
-
-		if (tag_stack.back()->get().name!=tag.name) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Mismatched exit tag. Got </"+tag.name+">, expected </"+tag_stack.back()->get().name+">");
-			ERR_FAIL_COND_V(tag_stack.back()->get().name!=tag.name,NULL);
-		}
-		                 
-		if (!complete) {
-			while(get_char()!='>' && !f->eof_reached()) {}
-			if (f->eof_reached())
-				return NULL;			
-		}
-
-		if (r_exit)
-			*r_exit=true;
-
-		tag_stack.pop_back();
-		return NULL;
-		                 
-	}
-	
-	if (!complete) {
-		String name;
-		String value;
-		bool reading_value=false;
-		
-		while(!f->eof_reached()) {
-			
-			CharType c=get_char();
-			if (c=='>') {
-				if (value.length()) {
-					
-					tag.args[name]=value;
-				}
-				break;
-				
-			} else if ( ((!reading_value && (c<33)) || c=='=' || c=='"') && tag.name.length()) {
-				
-				if (!reading_value && name.length()) {
-					
-					reading_value=true;
-				} else if (reading_value && value.length()) {
-					
-					tag.args[name]=value;
-					name="";
-					value="";
-					reading_value=false;
-				}
-				
-			} else if (reading_value) {
-				
-				value+=c;
-			} else {
-				
-				name+=c;
-			}
-		}
-		
-		if (f->eof_reached())
-			return NULL;
-	}	
-	
-	tag_stack.push_back(tag);
-		
-	return &tag_stack.back()->get();
-}
-
-
-Error ObjectFormatLoaderXML::close_tag(const String& p_name) {
-
-	int level=0;
-	bool inside_tag=false;
-
-	while(true) {
-	
-		if (f->eof_reached()) {
-
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": EOF found while attempting to find  </"+p_name+">");
-			ERR_FAIL_COND_V( f->eof_reached(), ERR_FILE_CORRUPT );
-		}
-		
-		uint8_t c = get_char();
-		
-		if (c == '<') {
-
-			if (inside_tag) {
-				ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Malformed XML. Already inside Tag.");
-				ERR_FAIL_COND_V(inside_tag,ERR_FILE_CORRUPT);
-			}
-			inside_tag=true;
-			c = get_char();
-			if (c == '/') {
-
-				--level;
-			} else {
-
-				++level;
-			};
-		} else if (c == '>') {
-
-			if (!inside_tag) {
-				ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Malformed XML. Already outside Tag");
-				ERR_FAIL_COND_V(!inside_tag,ERR_FILE_CORRUPT);
-			}
-			inside_tag=false;
-			if (level == -1) {
-				tag_stack.pop_back();
-				return OK;
-			};
-		};
-	}
-	
-	return OK;
-}
-
-void ObjectFormatLoaderXML::unquote(String& p_str) {
-	
-	p_str=p_str.strip_edges();
-	p_str=p_str.replace("\"","");
-	p_str=p_str.replace("&gt;","<");
-	p_str=p_str.replace("&lt;",">");
-	p_str=p_str.replace("&apos;","'");
-	p_str=p_str.replace("&quot;","\"");
-	for (int i=1;i<32;i++) {
-		
-		char chr[2]={i,0};
-		p_str=p_str.replace("&#"+String::num(i)+";",chr);
-	}
-	p_str=p_str.replace("&amp;","&");
-	
-	//p_str.parse_utf8( p_str.ascii(true).get_data() );
-		
-}
-
-Error ObjectFormatLoaderXML::goto_end_of_tag() {
-
-	uint8_t c;
-	while(true) {
-
-		c=get_char();
-		if (c=='>') //closetag
-			break;
-		if (f->eof_reached()) {
-
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": EOF found while attempting to find close tag.");
-			ERR_FAIL_COND_V( f->eof_reached(), ERR_FILE_CORRUPT );
-		}
-
-	}
-	tag_stack.pop_back();
-
-	return OK;
-}
-
-
-Error ObjectFormatLoaderXML::parse_property_data(String &r_data) {
-	
-	r_data="";
-	CharString cs;
-	while(true) {
-		
-		CharType c=get_char();
-		if (c=='<')
-			break;
-		ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-		cs.push_back(c);
-	}
-
-	cs.push_back(0);
-
-	r_data.parse_utf8(cs.get_data());
-
-	while(get_char()!='>' && !f->eof_reached()) {}
-	if (f->eof_reached()) {
-
-		ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Malformed XML.");
-		ERR_FAIL_COND_V( f->eof_reached(), ERR_FILE_CORRUPT );
-	}
-
-	r_data=r_data.strip_edges();
-	tag_stack.pop_back();
-	
-	return OK;	
-}
-
-
-Error ObjectFormatLoaderXML::_parse_array_element(Vector<char> &buff,bool p_number_only,FileAccess *f,bool *end) {
-
-	if (buff.empty())
-		buff.resize(32); // optimize
-
-	int buff_max=buff.size();
-	int buff_size=0;
-	*end=false;
-	char *buffptr=&buff[0];
-	bool found=false;
-	bool quoted=false;
-
-	while(true) {
-
-		char c=get_char();
-
-		if (c==0) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": File corrupt (zero found).");
-			ERR_FAIL_V(ERR_FILE_CORRUPT);
-		} else if (c=='"') {
-			quoted=!quoted;
-		} else if ((!quoted && ((p_number_only && c<33) || c==',')) || c=='<') {
-
-
-			if (c=='<') {
-				*end=true;
-				break;
-			}
-			if (c<32 && f->eof_reached()) {
-				*end=true;
-				ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": File corrupt (unexpected EOF).");
-				ERR_FAIL_V(ERR_FILE_CORRUPT);
-			}
-
-			if (found)
-				break;
-
-		} else {
-
-			found=true;
-			if (buff_size>=buff_max) {
-
-				buff_max++;
-				buff.resize(buff_max);
-
-			}
-
-			buffptr[buff_size]=c;
-			buff_size++;
-		}
-	}
-
-	if (buff_size>=buff_max) {
-
-		buff_max++;
-		buff.resize(buff_max);
-
-	}
-
-	buff[buff_size]=0;
-	buff_size++;
-
-	return OK;
-}
-
-Error ObjectFormatLoaderXML::parse_property(Variant& r_v, String &r_name)  {
-
-	bool exit;
-	Tag *tag = parse_tag(&exit);
-	
-	if (!tag) {
-		if (exit) // shouldn't have exited
-			return ERR_FILE_EOF;
-		ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": File corrupt (No Property Tag).");
-		ERR_FAIL_V(ERR_FILE_CORRUPT);
-	}
-	
-	r_v=Variant();
-	r_name="";
-
-
-	//ERR_FAIL_COND_V(tag->name!="property",ERR_FILE_CORRUPT);
-	//ERR_FAIL_COND_V(!tag->args.has("name"),ERR_FILE_CORRUPT);
-//	ERR_FAIL_COND_V(!tag->args.has("type"),ERR_FILE_CORRUPT);
-	
-	//String name=tag->args["name"];
-	//ERR_FAIL_COND_V(name=="",ERR_FILE_CORRUPT);
-	String type=tag->name;
-	String name=tag->args["name"];
-
-	if (type=="") {
-		ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": 'type' field is empty.");
-		ERR_FAIL_COND_V(type=="",ERR_FILE_CORRUPT);
-	}
-
-	if (type=="dictionary") {
-		
-		Dictionary d;
-		
-		while(true) {
-			
-			Error err;
-			String tagname;
-			Variant key;
-
-			int dictline = get_current_line();
-
-
-			err=parse_property(key,tagname);
-
-			if (err && err!=ERR_FILE_EOF) {
-				ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Error parsing dictionary: "+name+" (from line "+itos(dictline)+")");
-				ERR_FAIL_COND_V(err && err!=ERR_FILE_EOF,err);
-			}
-			//ERR_FAIL_COND_V(tagname!="key",ERR_FILE_CORRUPT);
-			if (err)
-				break;
-			Variant value;
-			err=parse_property(value,tagname);
-			if (err) {
-				ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Error parsing dictionary: "+name+" (from line "+itos(dictline)+")");
-			}
-
-			ERR_FAIL_COND_V(err,err);
-			//ERR_FAIL_COND_V(tagname!="value",ERR_FILE_CORRUPT);
-
-			d[key]=value;
-		}
-		
-
-		//err=parse_property_data(name); // skip the rest
-		//ERR_FAIL_COND_V(err,err);
-		
-		r_name=name;
-		r_v=d;
-		return OK;
-		
-	} else if (type=="array") {
-
-		if (!tag->args.has("len")) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Array missing 'len' field: "+name);
-			ERR_FAIL_COND_V(!tag->args.has("len"),ERR_FILE_CORRUPT);
-		}
-
-
-		int len=tag->args["len"].to_int();
-		
-		Array array;
-		array.resize(len);
-		
-		Error err;
-		Variant v;
-		String tagname;
-		int idx=0;
-		while( (err=parse_property(v,tagname))==OK ) {
-			
-			ERR_CONTINUE( idx <0 || idx >=len );
-			
-			array.set(idx,v);	
-			idx++;
-		}
-
-		if (idx!=len) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Error loading array (size mismatch): "+name);
-			ERR_FAIL_COND_V(idx!=len,err);
-		}
-
-		if (err!=ERR_FILE_EOF) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Error loading array: "+name);
-			ERR_FAIL_COND_V(err!=ERR_FILE_EOF,err);
-		}
-
-		//err=parse_property_data(name); // skip the rest
-		//ERR_FAIL_COND_V(err,err);
-		
-		r_name=name;
-		r_v=array;
-		return OK;
-		
-	} else if (type=="resource") {
-		
-		if (tag->args.has("path")) {
-			
-			String path=tag->args["path"];
-			String hint;
-			if (tag->args.has("resource_type"))
-				hint=tag->args["resource_type"];
-			
-			if (path.begins_with("local://"))
-				path=path.replace("local://",local_path+"::");
-			else if (path.find("://")==-1 && path.is_rel_path()) {
-				// path is relative to file being loaded, so convert to a resource path
-				path=Globals::get_singleton()->localize_path(local_path.get_base_dir()+"/"+path);
-
-			}
-
-			//take advantage of the resource loader cache. The resource is cached on it, even if
-			RES res=ResourceLoader::load(path,hint);
-					
-
-			if (res.is_null()) {
-			
-				WARN_PRINT(String("Couldn't load resource: "+path).ascii().get_data());
-			}
-			
-			r_v=res.get_ref_ptr();
-		}
-				
-
-
-		Error err=goto_end_of_tag();
-		if (err) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Error closing <resource> tag.");
-			ERR_FAIL_COND_V(err,err);
-		}
-
-
-		r_name=name;
-
-		return OK;
-		
-	} else if (type=="image") {
-		
-		if (!tag->args.has("encoding")) {
-			//empty image
-			r_v=Image();
-			String sdfsdfg;
-			Error err=parse_property_data(sdfsdfg);
-			return OK;
-		}
-
-		ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Image missing 'encoding' field.");
-		ERR_FAIL_COND_V( !tag->args.has("encoding"), ERR_FILE_CORRUPT );
-		ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Image missing 'width' field.");
-		ERR_FAIL_COND_V( !tag->args.has("width"), ERR_FILE_CORRUPT );
-		ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Image missing 'height' field.");
-		ERR_FAIL_COND_V( !tag->args.has("height"), ERR_FILE_CORRUPT );
-		ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Image missing 'format' field.");
-		ERR_FAIL_COND_V( !tag->args.has("format"), ERR_FILE_CORRUPT );
-		
-		String encoding=tag->args["encoding"];
-		
-		if (encoding=="raw") {
-			String width=tag->args["width"];
-			String height=tag->args["height"];
-			String format=tag->args["format"];
-			int mipmaps=tag->args.has("mipmaps")?int(tag->args["mipmaps"].to_int()):int(0);
-			int custom_size = tag->args.has("custom_size")?int(tag->args["custom_size"].to_int()):int(0);
-
-			r_name=name;
-
-			Image::Format imgformat;
-
-			
-			if (format=="grayscale") {
-				imgformat=Image::FORMAT_GRAYSCALE;
-			} else if (format=="intensity") {
-				imgformat=Image::FORMAT_INTENSITY;
-			} else if (format=="grayscale_alpha") {
-				imgformat=Image::FORMAT_GRAYSCALE_ALPHA;
-			} else if (format=="rgb") {
-				imgformat=Image::FORMAT_RGB;
-			} else if (format=="rgba") {
-				imgformat=Image::FORMAT_RGBA;
-			} else if (format=="indexed") {
-				imgformat=Image::FORMAT_INDEXED;
-			} else if (format=="indexed_alpha") {
-				imgformat=Image::FORMAT_INDEXED_ALPHA;
-			} else if (format=="bc1") {
-				imgformat=Image::FORMAT_BC1;
-			} else if (format=="bc2") {
-				imgformat=Image::FORMAT_BC2;
-			} else if (format=="bc3") {
-				imgformat=Image::FORMAT_BC3;
-			} else if (format=="bc4") {
-				imgformat=Image::FORMAT_BC4;
-			} else if (format=="bc5") {
-				imgformat=Image::FORMAT_BC5;
-			} else if (format=="custom") {
-				imgformat=Image::FORMAT_CUSTOM;
-			} else {
-				
-				ERR_FAIL_V( ERR_FILE_CORRUPT );
-			}
-
-
-			int datasize;
-			int w=width.to_int();
-			int h=height.to_int();
-
-			if (w == 0 && w == 0) {
-				//r_v = Image(w, h, imgformat);
-				r_v=Image();
-				String sdfsdfg;
-				Error err=parse_property_data(sdfsdfg);
-				return OK;
-			};
-
-			if (imgformat==Image::FORMAT_CUSTOM) {
-
-				datasize=custom_size;
-			} else {
-
-				datasize = Image::get_image_data_size(h,w,imgformat,mipmaps);
-			}
-
-			if (datasize==0) {
-				//r_v = Image(w, h, imgformat);
-				r_v=Image();
-				String sdfsdfg;
-				Error err=parse_property_data(sdfsdfg);
-				return OK;
-			};
-
-			DVector<uint8_t> pixels;
-			pixels.resize(datasize);
-			DVector<uint8_t>::Write wb = pixels.write();
-			
-			int idx=0;
-			uint8_t byte;
-			while( idx<datasize*2) {
-				
-				CharType c=get_char();
-				
-				ERR_FAIL_COND_V(c=='<',ERR_FILE_CORRUPT);
-
-				if ( (c>='0' && c<='9') || (c>='A' && c<='F') || (c>='a' && c<='f') ) {
-
-					if (idx&1) {
-
-						byte|=HEX2CHR(c);
-						wb[idx>>1]=byte;
-					} else {
-
-						byte=HEX2CHR(c)<<4;
-					}
-
-					idx++;
-				}
-
-			}
-			ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-
-			wb=DVector<uint8_t>::Write();
-
-			r_v=Image(w,h,mipmaps,imgformat,pixels);
-			String sdfsdfg;
-			Error err=parse_property_data(sdfsdfg);
-			ERR_FAIL_COND_V(err,err);
-			
-			return OK;
-		}
-		
-		ERR_FAIL_V(ERR_FILE_CORRUPT);
-		
-	} else if (type=="raw_array") {
-		
-		if (!tag->args.has("len")) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": RawArray missing 'len' field: "+name);
-			ERR_FAIL_COND_V(!tag->args.has("len"),ERR_FILE_CORRUPT);
-		}
-		int len=tag->args["len"].to_int();
-		
-		DVector<uint8_t> bytes;
-		bytes.resize(len);
-		DVector<uint8_t>::Write w=bytes.write();
-		uint8_t *bytesptr=w.ptr();		
-		int idx=0;			
-		uint8_t byte;
-		while( idx<len*2) {
-			
-			CharType c=get_char();
-			
-			if (idx&1) {
-				
-				byte|=HEX2CHR(c);
-				bytesptr[idx>>1]=byte;
-			} else {
-				
-				byte=HEX2CHR(c)<<4;
-			}
-
-			idx++;
-		}
-
-		ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-
-		w=DVector<uint8_t>::Write();
-		r_v=bytes;
-		String sdfsdfg;
-		Error err=parse_property_data(sdfsdfg);
-		ERR_FAIL_COND_V(err,err);
-		r_name=name;
-		
-		return OK;
-		
-	} else if (type=="int_array") {
-		
-		if (!tag->args.has("len")) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Array missing 'len' field: "+name);
-			ERR_FAIL_COND_V(!tag->args.has("len"),ERR_FILE_CORRUPT);
-		}
-		int len=tag->args["len"].to_int();
-		
-		DVector<int> ints;
-		ints.resize(len);
-		DVector<int>::Write w=ints.write();
-		int *intsptr=w.ptr();		
-		int idx=0;			
-		String str;
-#if 0
-		while( idx<len ) {
-			
-			
-			CharType c=get_char();
-			ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-						
-			if (c<33 || c==',' || c=='<') {
-								
-				if (str.length()) {
-					
-					intsptr[idx]=str.to_int();
-					str="";
-					idx++;
-				}
-				
-				if (c=='<') {
-					
-					while(get_char()!='>' && !f->eof_reached()) {}
-					ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-					break;
-				}
-				
-			} else {
-				
-				str+=c;
-			}
-		}
-
-#else
-
-		Vector<char> tmpdata;
-
-		while( idx<len ) {
-
-			bool end=false;
-			Error err = _parse_array_element(tmpdata,true,f,&end);
-			ERR_FAIL_COND_V(err,err);
-
-			intsptr[idx]=String::to_int(&tmpdata[0]);
-			idx++;
-			if (end)
-				break;
-
-		}
-
-#endif
-		w=DVector<int>::Write();
-
-		r_v=ints;		
-		Error err=goto_end_of_tag();
-		ERR_FAIL_COND_V(err,err);
-		r_name=name;
-		
-		return OK;
-	} else if (type=="real_array") {
-		
-		if (!tag->args.has("len")) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Array missing 'len' field: "+name);
-			ERR_FAIL_COND_V(!tag->args.has("len"),ERR_FILE_CORRUPT);
-		}
-		int len=tag->args["len"].to_int();;
-		
-		DVector<real_t> reals;
-		reals.resize(len);
-		DVector<real_t>::Write w=reals.write();
-		real_t *realsptr=w.ptr();		
-		int idx=0;			
-		String str;
-
-
-#if 0
-		while( idx<len ) {
-			
-			
-			CharType c=get_char();
-			ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-			
-			
-			if (c<33 || c==',' || c=='<') {
-				
-				if (str.length()) {
-					
-					realsptr[idx]=str.to_double();
-					str="";
-					idx++;
-				}
-				
-				if (c=='<') {
-					
-					while(get_char()!='>' && !f->eof_reached()) {}
-					ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-					break;
-				}
-				
-			} else {
-				
-				str+=c;
-			}
-		}
-
-#else
-
-
-
-		Vector<char> tmpdata;
-
-		while( idx<len ) {
-
-			bool end=false;
-			Error err = _parse_array_element(tmpdata,true,f,&end);
-			ERR_FAIL_COND_V(err,err);
-
-			realsptr[idx]=String::to_double(&tmpdata[0]);
-			idx++;
-
-			if (end)
-				break;
-		}
-
-#endif
-
-		w=DVector<real_t>::Write();
-		r_v=reals;
-
-		Error err=goto_end_of_tag();
-		ERR_FAIL_COND_V(err,err);
-		r_name=name;
-		
-		return OK;
-	} else if (type=="string_array") {
-		
-		if (!tag->args.has("len")) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Array missing 'len' field: "+name);
-			ERR_FAIL_COND_V(!tag->args.has("len"),ERR_FILE_CORRUPT);
-		}
-		int len=tag->args["len"].to_int();
-		
-		DVector<String> strings;
-		strings.resize(len);
-		DVector<String>::Write w=strings.write();
-		String *stringsptr=w.ptr();		
-		int idx=0;			
-		String str;
-		
-		bool inside_str=false;
-		CharString cs;
-		while( idx<len ) {
-			
-			
-			CharType c=get_char();
-			ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-			
-			
-			if (c=='"') {
-				if (inside_str) {
-					
-					cs.push_back(0);
-					String str;
-					str.parse_utf8(cs.get_data());
-					unquote(str);
-					stringsptr[idx]=str;
-					cs.clear();
-					idx++;
-					inside_str=false;
-				} else {
-					inside_str=true;
-				}
-			} else if (c=='<') {
-					
-				while(get_char()!='>' && !f->eof_reached()) {}
-				ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-				break;
-
-				
-			} else if (inside_str){
-
-				cs.push_back(c);
-			}
-		}
-		w=DVector<String>::Write();
-		r_v=strings;
-		String sdfsdfg;
-		Error err=parse_property_data(sdfsdfg);
-		ERR_FAIL_COND_V(err,err);
-		
-		r_name=name;
-		
-		return OK;
-	} else if (type=="vector3_array") {
-		
-		if (!tag->args.has("len")) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Array missing 'len' field: "+name);
-			ERR_FAIL_COND_V(!tag->args.has("len"),ERR_FILE_CORRUPT);
-		}
-		int len=tag->args["len"].to_int();;
-		
-		DVector<Vector3> vectors;
-		vectors.resize(len);
-		DVector<Vector3>::Write w=vectors.write();
-		Vector3 *vectorsptr=w.ptr();		
-		int idx=0;
-		int subidx=0;
-		Vector3 auxvec;
-		String str;
-
-//		uint64_t tbegin = OS::get_singleton()->get_ticks_usec();
-#if 0
-		while( idx<len ) {
-			
-			
-			CharType c=get_char();
-			ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-			
-			
-			if (c<33 || c==',' || c=='<') {
-				
-				if (str.length()) {
-					
-					auxvec[subidx]=str.to_double();
-					subidx++;
-					str="";
-					if (subidx==3) {
-						vectorsptr[idx]=auxvec;
-
-						idx++;
-						subidx=0;
-					}
-				}
-				
-				if (c=='<') {
-					
-					while(get_char()!='>' && !f->eof_reached()) {}
-					ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-					break;
-				}
-				
-			} else {
-				
-				str+=c;
-			}
-		}
-#else
-
-		Vector<char> tmpdata;
-
-		while( idx<len ) {
-
-			bool end=false;			
-			Error err = _parse_array_element(tmpdata,true,f,&end);
-			ERR_FAIL_COND_V(err,err);
-
-
-			auxvec[subidx]=String::to_double(&tmpdata[0]);
-			subidx++;
-			if (subidx==3) {
-				vectorsptr[idx]=auxvec;
-
-				idx++;
-				subidx=0;
-			}
-
-			if (end)
-				break;
-		}
-
-
-
-#endif
-		ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Premature end of vector3 array");
-		ERR_FAIL_COND_V(idx<len,ERR_FILE_CORRUPT);
-//		double time_taken = (OS::get_singleton()->get_ticks_usec() - tbegin)/1000000.0;
-
-
-		w=DVector<Vector3>::Write();
-		r_v=vectors;
-		String sdfsdfg;
-		Error err=goto_end_of_tag();
-		ERR_FAIL_COND_V(err,err);
-		r_name=name;
-		
-		return OK;
-
-	} else if (type=="vector2_array") {
-
-		if (!tag->args.has("len")) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Array missing 'len' field: "+name);
-			ERR_FAIL_COND_V(!tag->args.has("len"),ERR_FILE_CORRUPT);
-		}
-		int len=tag->args["len"].to_int();;
-
-		DVector<Vector2> vectors;
-		vectors.resize(len);
-		DVector<Vector2>::Write w=vectors.write();
-		Vector2 *vectorsptr=w.ptr();
-		int idx=0;
-		int subidx=0;
-		Vector2 auxvec;
-		String str;
-
-//		uint64_t tbegin = OS::get_singleton()->get_ticks_usec();
-#if 0
-		while( idx<len ) {
-
-
-			CharType c=get_char();
-			ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-
-
-			if (c<22 || c==',' || c=='<') {
-
-				if (str.length()) {
-
-					auxvec[subidx]=str.to_double();
-					subidx++;
-					str="";
-					if (subidx==2) {
-						vectorsptr[idx]=auxvec;
-
-						idx++;
-						subidx=0;
-					}
-				}
-
-				if (c=='<') {
-
-					while(get_char()!='>' && !f->eof_reached()) {}
-					ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-					break;
-				}
-
-			} else {
-
-				str+=c;
-			}
-		}
-#else
-
-		Vector<char> tmpdata;
-
-		while( idx<len ) {
-
-			bool end=false;
-			Error err = _parse_array_element(tmpdata,true,f,&end);
-			ERR_FAIL_COND_V(err,err);
-
-
-			auxvec[subidx]=String::to_double(&tmpdata[0]);
-			subidx++;
-			if (subidx==2) {
-				vectorsptr[idx]=auxvec;
-
-				idx++;
-				subidx=0;
-			}
-
-			if (end)
-				break;
-		}
-
-
-
-#endif
-		ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Premature end of vector2 array");
-		ERR_FAIL_COND_V(idx<len,ERR_FILE_CORRUPT);
-//		double time_taken = (OS::get_singleton()->get_ticks_usec() - tbegin)/1000000.0;
-
-
-		w=DVector<Vector2>::Write();
-		r_v=vectors;
-		String sdfsdfg;
-		Error err=goto_end_of_tag();
-		ERR_FAIL_COND_V(err,err);
-		r_name=name;
-
-		return OK;
-
-	} else if (type=="color_array") {
-		
-		if (!tag->args.has("len")) {
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Array missing 'len' field: "+name);
-			ERR_FAIL_COND_V(!tag->args.has("len"),ERR_FILE_CORRUPT);
-		}
-		int len=tag->args["len"].to_int();;
-		
-		DVector<Color> colors;
-		colors.resize(len);
-		DVector<Color>::Write w=colors.write();
-		Color *colorsptr=w.ptr();		
-		int idx=0;
-		int subidx=0;
-		Color auxcol;
-		String str;
-		
-		while( idx<len ) {
-			
-			
-			CharType c=get_char();
-			ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-			
-			
-			if (c<33 || c==',' || c=='<') {
-				
-				if (str.length()) {
-					
-					auxcol[subidx]=str.to_double();
-					subidx++;
-					str="";
-					if (subidx==4) {
-						colorsptr[idx]=auxcol;
-						idx++;
-						subidx=0;
-					}
-				}
-				
-				if (c=='<') {
-					
-					while(get_char()!='>' && !f->eof_reached()) {}
-					ERR_FAIL_COND_V(f->eof_reached(),ERR_FILE_CORRUPT);
-					break;
-				}
-				
-			} else {
-				
-				str+=c;
-			}
-		}
-		w=DVector<Color>::Write();
-		r_v=colors;
-		String sdfsdfg;
-		Error err=parse_property_data(sdfsdfg);
-		ERR_FAIL_COND_V(err,err);
-		r_name=name;
-		
-		return OK;
-	}
-	
-	
-	String data;
-	Error err = parse_property_data(data);
-	ERR_FAIL_COND_V(err!=OK,err);
-	
-	if (type=="nil") {
-		// uh do nothing
-		
-	} else if (type=="bool") {
-		// uh do nothing
-		if (data.nocasecmp_to("true")==0 || data.to_int()!=0)
-			r_v=true;
-		else
-			r_v=false;
-	} else if (type=="int") {
-		
-		r_v=data.to_int();
-	} else if (type=="real") {
-		
-		r_v=data.to_double();
-	} else if (type=="string") {
-		
-		String str=data;
-		unquote(str);
-		r_v=str;
-	} else if (type=="vector3") {
-		
-		
-		r_v=Vector3( 
-				data.get_slice(",",0).to_double(),
-				data.get_slice(",",1).to_double(),
-				data.get_slice(",",2).to_double()
-		           );
-		             
-	} else if (type=="vector2") {
-		
-		
-		r_v=Vector2( 
-				data.get_slice(",",0).to_double(),
-				data.get_slice(",",1).to_double()
-		           );
-		             
-	} else if (type=="plane") {
-		
-		r_v=Plane( 
-				data.get_slice(",",0).to_double(),
-				data.get_slice(",",1).to_double(),
-				data.get_slice(",",2).to_double(),
-				data.get_slice(",",3).to_double()
-		         );
-		
-	} else if (type=="quaternion") {
-		
-		r_v=Quat( 
-				data.get_slice(",",0).to_double(),
-				data.get_slice(",",1).to_double(),
-				data.get_slice(",",2).to_double(),
-				data.get_slice(",",3).to_double()
-		         );
-		
-	} else if (type=="rect2") {
-		
-		r_v=Rect2(
-			Vector2( 
-				data.get_slice(",",0).to_double(),
-				data.get_slice(",",1).to_double()
-			),
-			Vector2( 
-				data.get_slice(",",2).to_double(),
-				data.get_slice(",",3).to_double()
-			)
-		);
-		          
-		
-	} else if (type=="aabb") {
-		
-		r_v=AABB(
-			Vector3( 
-				data.get_slice(",",0).to_double(),
-				data.get_slice(",",1).to_double(),
-				data.get_slice(",",2).to_double()
-			),
-			Vector3( 
-				data.get_slice(",",3).to_double(),
-				data.get_slice(",",4).to_double(),
-				data.get_slice(",",5).to_double()
-			)
-		);
-		          
-	} else if (type=="matrix32") {
-
-		Matrix32 m3;
-		for (int i=0;i<3;i++) {
-			for (int j=0;j<2;j++) {
-				m3.elements[i][j]=data.get_slice(",",i*2+j).to_double();
-			}
-		}
-		r_v=m3;
-
-	} else if (type=="matrix3") {
-		
-		Matrix3 m3;
-		for (int i=0;i<3;i++) {
-			for (int j=0;j<3;j++) {
-				m3.elements[i][j]=data.get_slice(",",i*3+j).to_double();
-			}
-		}
-		r_v=m3;		
-		
-	} else if (type=="transform") {
-		
-		Transform tr;
-		for (int i=0;i<3;i++) {
-			for (int j=0;j<3;j++) {
-				tr.basis.elements[i][j]=data.get_slice(",",i*3+j).to_double();			
-			}
-		
-		}
-		tr.origin=Vector3( 
-		             data.get_slice(",",9).to_double(),
-		             data.get_slice(",",10).to_double(),
-		             data.get_slice(",",11).to_double()
-		           );
-		r_v=tr;
-		
-	} else if (type=="color") {
-		
-		r_v=Color( 
-		           data.get_slice(",",0).to_double(),
-		           data.get_slice(",",1).to_double(),
-		           data.get_slice(",",2).to_double(),
-		           data.get_slice(",",3).to_double()
-		         );
-		
-	} else if (type=="node_path") {
-		
-		String str=data;
-		unquote(str);
-		r_v=NodePath( str );
-	} else if (type=="input_event") {
-		
-		// ?	
-	} else {
-		ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Unrecognized tag in file: "+type);
-		ERR_FAIL_V(ERR_FILE_CORRUPT);
-	}
-	r_name=name;
-	return OK;
-}
-
-
-Error ObjectFormatLoaderXML::load(Object **p_object,Variant &p_meta)  {
-	
-	*p_object=NULL;
-	p_meta=Variant();
-	
-
-
-	while(true) {
-
-
-		bool exit;
-		Tag *tag = parse_tag(&exit);
-
-
-		if (!tag) {
-			if (!exit) // shouldn't have exited
-				ERR_FAIL_V(ERR_FILE_CORRUPT);
-			*p_object=NULL;
-			return ERR_FILE_EOF;
-		}
-
-		RES resource;
-		Object *obj=NULL;
-
-		if (tag->name=="resource") {
-			//loading resource
-
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": <resource> missing 'len' field.");
-			ERR_FAIL_COND_V(!tag->args.has("path"),ERR_FILE_CORRUPT);
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": <resource> missing 'type' field.");
-			ERR_FAIL_COND_V(!tag->args.has("type"),ERR_FILE_CORRUPT);
-			String path=tag->args["path"];
-
-			if (path.begins_with("local://")) {
-				//built-in resource (but really external)
-				path=path.replace("local://",local_path+"::");
-			}
-
-
-			if (ResourceCache::has(path)) {
-				Error err = close_tag(tag->name);
-				ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Unable to close <resource> tag.");
-				ERR_FAIL_COND_V( err, err );
-				continue; //it's a resource, and it's already loaded
-
-			}
-
-			String type = tag->args["type"];
-
-			obj = ObjectTypeDB::instance(type);
-			if (!obj) {
-				ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Object of unrecognized type in file: "+type);
-			}
-			ERR_FAIL_COND_V(!obj,ERR_FILE_CORRUPT);
-
-			Resource *r = obj->cast_to<Resource>();
-			if (!r) {
-				memdelete(obj); //bye
-				ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Object type in resource field not a resource, type is: "+obj->get_type());
-				ERR_FAIL_COND_V(!obj->cast_to<Resource>(),ERR_FILE_CORRUPT);
-			}
-
-			resource = RES( r );
-			r->set_path(path);
-
-
-
-		} else if (tag->name=="object") {
-
-			if ( tag->args.has("type") ) {
-
-				ERR_FAIL_COND_V(!ObjectTypeDB::type_exists(tag->args["type"]), ERR_FILE_CORRUPT);
-
-				if (ObjectTypeDB::can_instance(tag->args["type"])) {
-					obj = ObjectTypeDB::instance(tag->args["type"]);
-					if (!obj) {
-						ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Object of unrecognized type in file: "+tag->args["type"]);
-					}
-					ERR_FAIL_COND_V(!obj,ERR_FILE_CORRUPT);
-				} else {
-
-					close_tag(tag->name);
-					return ERR_SKIP;
-				};
-			} else {
-				//otherwise it's a meta object
-			}
-
-		} else {
-
-			ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Unknown main tag: "+tag->name);
-			ERR_FAIL_V( ERR_FILE_CORRUPT );
-		}
-
-		//load properties
-
-		while(true) {
-
-			String name;
-			Variant v;
-			Error err;
-			err = parse_property(v,name);
-			if (err==ERR_FILE_EOF) //tag closed
-				break;
-			if (err!=OK) {
-				ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": XML Parsing aborted.");
-				ERR_FAIL_COND_V(err!=OK,ERR_FILE_CORRUPT);
-			}
-			if (resource.is_null() && name=="__xml_meta__") {
-
-				p_meta=v;
-				continue;
-			} else if (!obj) {
-
-				ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": Normal property found in meta object.");
-				ERR_FAIL_V(ERR_FILE_CORRUPT);
-			}
-
-			obj->set(name,v);
-		}
-
-		if (!obj) {
-			*p_object=NULL;
-			return OK; // it was a meta object			
-		}
-
-		if (resource.is_null()) {
-
-			//regular object
-			*p_object=obj;
-			return OK;
-		} else {
-
-
-			resource_cache.push_back(resource); //keep it in mem until finished loading
-		}
-
-		// a resource.. continue!
-
-	}
-
-
-
-	return OK; //never reach anyway
-	
-}
-
-int ObjectFormatLoaderXML::get_current_line() const {
-
-	return lines;
-}
-
-
-uint8_t ObjectFormatLoaderXML::get_char() const {
-
-	uint8_t c = f->get_8();
-	if (c=='\n')
-		lines++;
-	return c;
-
-}
-
-ObjectFormatLoaderXML::~ObjectFormatLoaderXML() {
-
-	if (f) {
-		if (f->is_open())
-			f->close();
-		memdelete(f);
-	}
-}
-
-
-
-ObjectFormatLoaderXML* ObjectFormatLoaderInstancerXML::instance(const String& p_file,const String& p_magic) {
-
-	Error err;
-	FileAccess *f=FileAccess::open(p_file,FileAccess::READ,&err);
-	if (err!=OK) {
-
-		ERR_FAIL_COND_V(err!=OK,NULL);
-	}
-
-	ObjectFormatLoaderXML *loader = memnew( ObjectFormatLoaderXML );
-
-	loader->lines=1;
-	loader->f=f;
-	loader->local_path = Globals::get_singleton()->localize_path(p_file);
-
-	ObjectFormatLoaderXML::Tag *tag = loader->parse_tag();
-	if (!tag || tag->name!="?xml" || !tag->args.has("version") || !tag->args.has("encoding") || tag->args["encoding"]!="UTF-8") {
-
-		f->close();
-		memdelete(loader);
-		ERR_EXPLAIN("Not a XML:UTF-8 File: "+p_file);
-		ERR_FAIL_V(NULL);
-	}
-	
-	loader->tag_stack.clear(); 
-	
-	tag = loader->parse_tag();
-	
-	if (!tag || tag->name!="object_file" || !tag->args.has("magic") || !tag->args.has("version") || tag->args["magic"]!=p_magic) {
-		
-		f->close();
-		memdelete(loader);
-		ERR_EXPLAIN("Unrecognized XML File: "+p_file);
-		ERR_FAIL_V(NULL);
-	}
-
-	String version = tag->args["version"];
-	if (version.get_slice_count(".")!=2) {
-
-		f->close();
-		memdelete(loader);
-		ERR_EXPLAIN("Invalid Version String '"+version+"'' in file: "+p_file);
-		ERR_FAIL_V(NULL);
-	}
-
-	int major = version.get_slice(".",0).to_int();
-	int minor = version.get_slice(".",1).to_int();
-
-	if (major>VERSION_MAJOR || (major==VERSION_MAJOR && minor>VERSION_MINOR)) {
-
-		f->close();
-		memdelete(loader);
-		ERR_EXPLAIN("File Format '"+version+"' is too new! Please upgrade to a a new engine version: "+p_file);
-		ERR_FAIL_V(NULL);
-
-	}
-
-	return loader;
-}
-
-void ObjectFormatLoaderInstancerXML::get_recognized_extensions(List<String> *p_extensions) const {
-	
-	p_extensions->push_back("xml");	
-}
-
-
-#endif
-#endif
-#endif

+ 0 - 196
core/io/object_format_xml.h

@@ -1,196 +0,0 @@
-/*************************************************************************/
-/*  object_format_xml.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 OBJECT_FORMAT_XML_H
-#define OBJECT_FORMAT_XML_H
-
-#ifdef XML_ENABLED
-#ifdef OLD_SCENE_FORMAT_ENABLED
-#include "io/object_loader.h"
-#include "io/object_saver.h"
-#include "os/file_access.h"
-#include "map.h"
-#include "resource.h"
-#include "xml_parser.h"
-
-/**
-	@author Juan Linietsky <[email protected]>
-*/
-
-class ObjectFormatSaverXML : public ObjectFormatSaver {
-	
-	String local_path;
-
-
-	Ref<OptimizedSaver> optimizer;
-
-	bool relative_paths;
-	bool bundle_resources;
-	bool skip_editor;
-	FileAccess *f;
-	String magic;
-	int depth;
-	Map<RES,int> resource_map;
-
-	struct SavedObject {
-
-		Variant meta;
-		String type;
-
-
-		struct SavedProperty {
-
-			String name;
-			Variant value;
-		};
-
-		List<SavedProperty> properties;
-	};
-
-	List<RES> saved_resources;
-
-	List<SavedObject*> saved_objects;
-	
-	void enter_tag(const String& p_section,const String& p_args="");
-	void exit_tag(const String& p_section);
-	
-	void _find_resources(const Variant& p_variant);
-	void write_property(const String& p_name,const Variant& p_property,bool *r_ok=NULL);
-
-	
-	void escape(String& p_str);
-	void write_tabs(int p_diff=0);
-	void write_string(String p_str,bool p_escape=true);
-		
-public:	
-	
-	virtual Error save(const Object *p_object,const Variant &p_meta);
-	
-	ObjectFormatSaverXML(FileAccess *p_file,const String& p_magic,const String& p_local_path,uint32_t p_flags,const Ref<OptimizedSaver>& p_optimizer);
-	~ObjectFormatSaverXML();
-};
-
-class ObjectFormatSaverInstancerXML : public ObjectFormatSaverInstancer {
-public:	 
-
-	virtual ObjectFormatSaver* instance(const String& p_file,const String& p_magic,uint32_t p_flags=0,const Ref<OptimizedSaver>& p_optimizer=Ref<OptimizedSaver>());
-	virtual void get_recognized_extensions(List<String> *p_extensions) const;
-	
-	virtual ~ObjectFormatSaverInstancerXML();
-};
-
-/***********************************/
-/***********************************/
-/***********************************/
-/***********************************/
-
-//#define OPTIMIZED_XML_LOADER
-
-#ifdef OPTIMIZED_XML_LOADER
-
-class ObjectFormatLoaderXML : public ObjectFormatLoader {
-
-	Ref<XMLParser> parser;
-	String local_path;
-
-	Error _close_tag(const String& p_tag);
-	Error _parse_property(Variant& r_property,String& r_name);
-
-friend class ObjectFormatLoaderInstancerXML;
-
-	List<RES> resource_cache;
-public:
-
-
-	virtual Error load(Object **p_object,Variant &p_meta);
-
-
-};
-
-class ObjectFormatLoaderInstancerXML : public ObjectFormatLoaderInstancer {
-public:
-
-	virtual ObjectFormatLoaderXML* instance(const String& p_file,const String& p_magic);
-	virtual void get_recognized_extensions(List<String> *p_extensions) const;
-
-};
-
-#else
-
-
-class ObjectFormatLoaderXML : public ObjectFormatLoader {
-
-	String local_path;
-
-	FileAccess *f;
-
-	struct Tag {
-
-		String name;
-		HashMap<String,String> args;
-	};
-
-	_FORCE_INLINE_ Error _parse_array_element(Vector<char> &buff,bool p_number_only,FileAccess *f,bool *end);
-
-	mutable int lines;
-	uint8_t get_char() const;
-	int get_current_line() const;
-
-friend class ObjectFormatLoaderInstancerXML;
-	List<Tag> tag_stack;
-
-	List<RES> resource_cache;
-	Tag* parse_tag(bool* r_exit=NULL);
-	Error close_tag(const String& p_name);
-	void unquote(String& p_str);
-	Error goto_end_of_tag();
-	Error parse_property_data(String &r_data);
-	Error parse_property(Variant& r_v, String &r_name);
-
-public:
-
-
-	virtual Error load(Object **p_object,Variant &p_meta);
-
-	virtual ~ObjectFormatLoaderXML();
-};
-
-class ObjectFormatLoaderInstancerXML : public ObjectFormatLoaderInstancer {
-public:
-
-	virtual ObjectFormatLoaderXML* instance(const String& p_file,const String& p_magic);
-	virtual void get_recognized_extensions(List<String> *p_extensions) const;
-
-
-
-};
-
-#endif
-#endif
-#endif
-#endif

+ 0 - 84
core/io/object_loader.cpp

@@ -1,84 +0,0 @@
-/*************************************************************************/
-/*  object_loader.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 "object_loader.h"
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
-bool ObjectFormatLoaderInstancer::recognize(const String& p_extension) const {
-	
-	
-	List<String> extensions;
-	get_recognized_extensions(&extensions);
-	for (List<String>::Element *E=extensions.front();E;E=E->next()) {
-
-		if (E->get().nocasecmp_to(p_extension)==0)
-			return true;
-	}
-	
-	return false;
-}
-
-ObjectFormatLoaderInstancer *ObjectLoader::loader[MAX_LOADERS];
-int ObjectLoader::loader_count=0;
-
-
-ObjectFormatLoader *ObjectLoader::instance_format_loader(const String& p_path,const String& p_magic,String p_force_extension) {
-	
-	String extension=p_force_extension.length()?p_force_extension:p_path.extension();
-
-	for (int i=0;i<loader_count;i++) {
-		
-		if (!loader[i]->recognize(extension))
-			continue;
-		ObjectFormatLoader *format_loader = loader[i]->instance(p_path,p_magic);
-		if (format_loader)
-			return format_loader;
-	}
-	
-	return NULL;
-}
-
-void ObjectLoader::get_recognized_extensions(List<String> *p_extensions)  {
-	
-	for (int i=0;i<loader_count;i++) {
-		
-		loader[i]->get_recognized_extensions(p_extensions);
-	}	
-}
-
-
-
-void ObjectLoader::add_object_format_loader_instancer(ObjectFormatLoaderInstancer *p_format_loader_instancer) {
-	
-	ERR_FAIL_COND(loader_count>=MAX_LOADERS );
-	loader[loader_count++]=p_format_loader_instancer;	
-}
-
-
-#endif

+ 0 - 76
core/io/object_loader.h

@@ -1,76 +0,0 @@
-/*************************************************************************/
-/*  object_loader.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 OBJECT_LOADER_H
-#define OBJECT_LOADER_H
-
-#include "object.h"
-
-/**
-	@author Juan Linietsky <[email protected]>
-*/
-#ifdef OLD_SCENE_FORMAT_ENABLED
-class ObjectFormatLoader {
-public:	
-	
-	virtual Error load(Object **p_object,Variant &p_meta)=0;
-
-	virtual ~ObjectFormatLoader() {}
-};
-
-class ObjectFormatLoaderInstancer {
-public:	
-
-	virtual ObjectFormatLoader* instance(const String& p_file,const String& p_magic)=0;	
-	virtual void get_recognized_extensions(List<String> *p_extensions) const=0;		
-	bool recognize(const String& p_extension) const;
-		
-	virtual ~ObjectFormatLoaderInstancer() {}
-};
-
-class ObjectLoader {
-	
-	enum {
-		MAX_LOADERS=64
-	};
-	
-	static ObjectFormatLoaderInstancer *loader[MAX_LOADERS];
-	static int loader_count;
-	
-public:
-	
-	static ObjectFormatLoader *instance_format_loader(const String& p_path,const String& p_magic,String p_force_extension="");
-	static void add_object_format_loader_instancer(ObjectFormatLoaderInstancer *p_format_loader_instancer);
-	static void get_recognized_extensions(List<String> *p_extensions);
-
-		
-
-};
-
-#endif
-#endif

+ 0 - 157
core/io/object_saver.cpp

@@ -1,157 +0,0 @@
-/*************************************************************************/
-/*  object_saver.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 "object_saver.h"
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
-void OptimizedSaver::add_property(const StringName& p_name, const Variant& p_value) {
-
-	ERR_FAIL_COND(!_list);
-	Property p;
-	p.name=p_name;
-	p.value=p_value;
-	_list->push_back(p);
-}
-
-bool OptimizedSaver::optimize_object(const Object *p_object) {
-
-	return false; //not optimize
-}
-
-void OptimizedSaver::get_property_list(const Object* p_object,List<Property>  *p_properties) {
-
-
-	_list=p_properties;
-
-	bool res = call("optimize_object",p_object);
-
-	if (!res) {
-
-		List<PropertyInfo> plist;
-		p_object->get_property_list(&plist);
-		for(List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) {
-
-			PropertyInfo pinfo=E->get();
-			if ((pinfo.usage&PROPERTY_USAGE_STORAGE) || (is_bundle_resources_enabled() && pinfo.usage&PROPERTY_USAGE_BUNDLE)) {
-
-				add_property(pinfo.name,p_object->get(pinfo.name));
-			}
-		}
-
-	}
-
-	_list=NULL;
-}
-
-void OptimizedSaver::set_target_platform(const String& p_platform) {
-
-	ERR_FAIL_COND(p_platform!="" && !p_platform.is_valid_identifier());
-	platform=p_platform;
-}
-
-String OptimizedSaver::get_target_platform() const {
-
-	return platform;
-}
-
-void OptimizedSaver::set_target_name(const String& p_name) {
-
-	name=p_name;
-}
-
-String OptimizedSaver::get_target_name() const {
-
-	return name;
-}
-
-void OptimizedSaver::_bind_methods() {
-
-	ObjectTypeDB::bind_method(_MD("set_target_platform","name"),&OptimizedSaver::set_target_platform);
-	ObjectTypeDB::bind_method(_MD("get_target_platform"),&OptimizedSaver::get_target_platform);
-	ObjectTypeDB::bind_method(_MD("set_target_name","name"),&OptimizedSaver::set_target_name);
-	ObjectTypeDB::bind_method(_MD("add_property","name","value"),&OptimizedSaver::add_property);
-	ObjectTypeDB::bind_method(_MD("optimize_object","obj"),&OptimizedSaver::optimize_object);
-}
-
-OptimizedSaver::OptimizedSaver() {
-
-	_list=NULL;
-}
-
-ObjectFormatSaverInstancer *ObjectSaver::saver[MAX_LOADERS];
-int ObjectSaver::saver_count=0;
-
-bool ObjectFormatSaverInstancer::recognize(const String& p_extension) const {
-	
-	
-	List<String> extensions;
-	get_recognized_extensions(&extensions);
-	for (List<String>::Element *E=extensions.front();E;E=E->next()) {
-		
-		if (E->get().nocasecmp_to(p_extension.extension())==0)
-			return true;
-	}
-	
-	return false;
-}
-
-ObjectFormatSaver *ObjectSaver::instance_format_saver(const String& p_path,const String& p_magic,String p_force_extension,uint32_t p_flags,const Ref<OptimizedSaver>& p_optimizer) {
-	
-	String extension=p_force_extension.length()?p_force_extension:p_path.extension();
-	
-	for (int i=0;i<saver_count;i++) {
-		
-		if (!saver[i]->recognize(extension))
-			continue;
-		ObjectFormatSaver *format_saver = saver[i]->instance(p_path,p_magic,p_flags,p_optimizer);
-		if (format_saver)
-			return format_saver;
-	}
-	
-	return NULL;
-}
-
-void ObjectSaver::get_recognized_extensions(List<String> *p_extensions)  {
-	
-	for (int i=0;i<saver_count;i++) {
-		
-		saver[i]->get_recognized_extensions(p_extensions);
-	}	
-}
-
-
-
-void ObjectSaver::add_object_format_saver_instancer(ObjectFormatSaverInstancer *p_format_saver_instancer) {
-	
-	ERR_FAIL_COND(saver_count>=MAX_LOADERS );
-	saver[saver_count++]=p_format_saver_instancer;	
-}
-
-
-
-#endif

+ 0 - 128
core/io/object_saver.h

@@ -1,128 +0,0 @@
-/*************************************************************************/
-/*  object_saver.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 OBJECT_SAVER_H
-#define OBJECT_SAVER_H
-
-#include "object.h"
-#include "resource.h"
-/**
-	@author Juan Linietsky <[email protected]>
-*/
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
-class OptimizedSaver : public Reference {
-
-	OBJ_TYPE(OptimizedSaver,Reference);
-public:
-
-	struct Property {
-
-		StringName name;
-		Variant value;
-	};
-
-private:
-
-	String name;
-	String platform;
-	List<Property>  *_list;
-protected:
-
-
-	void set_target_platform(const String& p_platform);
-	void set_target_name(const String& p_name);
-	void add_property(const StringName& p_name, const Variant& p_value);
-	static void _bind_methods();
-
-	virtual bool optimize_object(const Object *p_object);
-
-public:
-
-
-	virtual bool is_bundle_resources_enabled() const { return false; }
-
-	String get_target_platform() const;
-	String get_target_name() const;
-	void get_property_list(const Object* p_object, List<Property>  *p_properties);
-
-
-	OptimizedSaver();
-
-};
-
-
-class ObjectFormatSaver {
-public:	
-	
-	virtual Error save(const Object *p_object,const Variant &p_meta=Variant())=0;
-	
-	virtual ~ObjectFormatSaver() {}
-};
-
-class ObjectFormatSaverInstancer {
-public:	
-
-	virtual void get_recognized_extensions(List<String> *p_extensions) const=0;
-	virtual ObjectFormatSaver* instance(const String& p_file,const String& p_magic="",uint32_t p_flags=0,const Ref<OptimizedSaver>& p_optimizer=Ref<OptimizedSaver>())=0;
-	bool recognize(const String& p_extension) const;
-		
-	virtual ~ObjectFormatSaverInstancer() {}
-};
-
-class ObjectSaver {
-	
-	enum {
-		MAX_LOADERS=64
-	};
-	
-	static ObjectFormatSaverInstancer *saver[MAX_LOADERS];
-	static int saver_count;
-	
-public:
-
-	enum SaverFlags {
-
-		FLAG_RELATIVE_PATHS=1,
-		FLAG_BUNDLE_RESOURCES=2,
-		FLAG_OMIT_EDITOR_PROPERTIES=4,
-		FLAG_SAVE_BIG_ENDIAN=8
-	};
-
-	
-	static ObjectFormatSaver *instance_format_saver(const String& p_path,const String& p_magic,String p_force_extension="",uint32_t p_flags=0,const Ref<OptimizedSaver>& p_optimizer=Ref<OptimizedSaver>());
-	static void get_recognized_extensions(List<String> *p_extensions);
-	
-	static void add_object_format_saver_instancer(ObjectFormatSaverInstancer *p_format_saver_instancer);
-	
-	
-};
-
-#endif
-#endif

+ 0 - 150
core/io/object_saver_base.cpp

@@ -1,150 +0,0 @@
-/*************************************************************************/
-/*  object_saver_base.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 "object_saver_base.h"
-#ifdef OLD_SCENE_FORMAT_ENABLED
-void ObjectSaverBase::_find_resources(const Variant& p_variant) {
-
-	switch(p_variant.get_type()) {
-		case Variant::OBJECT: {
-
-
-			RES res = p_variant.operator RefPtr();
-
-			if (res.is_null() || (res->get_path().length() && res->get_path().find("::") == -1 ))
-				return;
-
-			if (resource_map.has(res))
-				return;
-
-			List<PropertyInfo> property_list;
-
-			res->get_property_list( &property_list );
-
-			List<PropertyInfo>::Element *I=property_list.front();
-
-			while(I) {
-
-				PropertyInfo pi=I->get();
-
-				if (pi.usage&PROPERTY_USAGE_STORAGE) {
-
-					if (pi.type==Variant::OBJECT) {
-
-						Variant v=res->get(I->get().name);
-						_find_resources(v);
-					}
-				}
-
-				I=I->next();
-			}
-
-			resource_map[ res ] = resource_map.size(); //saved after, so the childs it needs are available when loaded
-			saved_resources.push_back(res);
-
-		} break;
-
-		case Variant::ARRAY: {
-
-			Array varray=p_variant;
-			int len=varray.size();
-			for(int i=0;i<len;i++) {
-
-				Variant v=varray.get(i);
-				_find_resources(v);
-			}
-
-		} break;
-
-		case Variant::DICTIONARY: {
-
-			Dictionary d=p_variant;
-			List<Variant> keys;
-			d.get_key_list(&keys);
-			for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
-
-				Variant v = d[E->get()];
-				_find_resources(v);
-			}
-		} break;
-		default: {}
-	}
-
-}
-
-
-Error ObjectSaverBase::save(const Object *p_object,const Variant &p_meta) {
-
-	ERR_EXPLAIN("write_object should supply either an object, a meta, or both");
-	ERR_FAIL_COND_V(!p_object && p_meta.get_type()==Variant::NIL, ERR_INVALID_PARAMETER);
-
-	SavedObject *so = memnew( SavedObject );
-
-	if (p_object) {
-		so->type=p_object->get_type();
-	};
-
-	_find_resources(p_meta);
-	so->meta=p_meta;
-
-	if (p_object) {
-
-		List<PropertyInfo> property_list;
-		p_object->get_property_list( &property_list );
-
-		List<PropertyInfo>::Element *I=property_list.front();
-
-		while(I) {
-
-			if (I->get().usage&PROPERTY_USAGE_STORAGE) {
-
-				SavedObject::SavedProperty sp;
-				sp.name=I->get().name;
-				sp.value = p_object->get(I->get().name);
-				_find_resources(sp.value);
-				so->properties.push_back(sp);
-			}
-
-			I=I->next();
-		}
-
-	}
-
-	saved_objects.push_back(so);
-
-	return OK;
-}
-
-ObjectSaverBase::ObjectSaverBase() {
-
-};
-
-ObjectSaverBase::~ObjectSaverBase() {
-	
-};
-#endif

+ 0 - 76
core/io/object_saver_base.h

@@ -1,76 +0,0 @@
-/*************************************************************************/
-/*  object_saver_base.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 OBJECT_SAVER_BASE_H
-#define OBJECT_SAVER_BASE_H
-
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-#include "object_saver.h"
-
-#include "map.h"
-#include "resource.h"
-
-class ObjectSaverBase : public ObjectFormatSaver {
-
-protected:
-
-	Map<RES,int> resource_map;
-
-	struct SavedObject {
-
-		Variant meta;
-		String type;
-
-
-		struct SavedProperty {
-
-			String name;
-			Variant value;
-		};
-
-		List<SavedProperty> properties;
-	};
-
-	List<RES> saved_resources;
-
-	List<SavedObject*> saved_objects;
-
-	void _find_resources(const Variant& p_variant);
-
-	virtual Error write()=0;
-public:
-
-	virtual Error save(const Object *p_object,const Variant &p_meta);
-
-	ObjectSaverBase();
-	~ObjectSaverBase();
-};
-
-#endif
-#endif // OBJECT_SAVER_BASE_H

+ 53 - 0
core/math/geometry.h

@@ -821,6 +821,59 @@ public:
 	};
 
 
+
+	_FORCE_INLINE_ static int get_uv84_normal_bit(const Vector3& p_vector) {
+
+		int lat = Math::fast_ftoi(Math::floor(Math::acos(p_vector.dot(Vector3(0,1,0)))*4.0/Math_PI+0.5));
+
+		if (lat==0) {
+			return 24;
+		} else if (lat==4) {
+			return 25;
+		}
+
+		int lon = Math::fast_ftoi(Math::floor( (Math_PI+Math::atan2(p_vector.x,p_vector.z))*8.0/(Math_PI*2.0) + 0.5))%8;
+
+		return lon+(lat-1)*8;
+	}
+
+	_FORCE_INLINE_ static int get_uv84_normal_bit_neighbors(int p_idx) {
+
+		if (p_idx==24) {
+			return 1|2|4|8;
+		} else if (p_idx==25) {
+			return (1<<23)|(1<<22)|(1<<21)|(1<<20);
+		} else {
+
+			int ret = 0;
+			if ((p_idx%8) == 0)
+				ret|=(1<<(p_idx+7));
+			else
+				ret|=(1<<(p_idx-1));
+			if ((p_idx%8) == 7)
+				ret|=(1<<(p_idx-7));
+			else
+				ret|=(1<<(p_idx+1));
+
+			int mask = ret|(1<<p_idx);
+			if (p_idx<8)
+				ret|=24;
+			else
+				ret|=mask>>8;
+
+			if (p_idx>=16)
+				ret|=25;
+			else
+				ret|=mask<<8;
+
+			return ret;
+		}
+
+	}
+
+
+
+
 	static MeshData build_convex_mesh(const DVector<Plane> &p_planes);
 	static DVector<Plane> build_sphere_planes(float p_radius, int p_lats, int p_lons, Vector3::Axis p_axis=Vector3::AXIS_Z);
 	static DVector<Plane> build_box_planes(const Vector3& p_extents);

+ 0 - 35
core/register_core_types.cpp

@@ -27,8 +27,6 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
 #include "register_core_types.h"
-#include "io/object_format_xml.h"
-#include "io/object_format_binary.h"
 
 #include "io/tcp_server.h"
 #include "io/config_file.h"
@@ -56,14 +54,6 @@
 #ifdef XML_ENABLED
 static ResourceFormatSaverXML *resource_saver_xml=NULL;
 static ResourceFormatLoaderXML *resource_loader_xml=NULL;
-#ifdef OLD_SCENE_FORMAT_ENABLED
-static ObjectFormatSaverInstancerXML *object_format_saver_xml=NULL;
-static ObjectFormatLoaderInstancerXML *object_format_loader_xml=NULL;
-#endif
-#endif
-#ifdef OLD_SCENE_FORMAT_ENABLED
-static ObjectFormatSaverInstancerBinary * object_format_saver_binary = NULL;
-static ObjectFormatLoaderInstancerBinary * object_format_loader_binary = NULL;
 #endif
 static ResourceFormatSaverBinary *resource_saver_binary=NULL;
 static ResourceFormatLoaderBinary *resource_loader_binary=NULL;
@@ -101,23 +91,6 @@ void register_core_types() {
 
 	CoreStringNames::create();
 	
-#ifdef XML_ENABLED
-#ifdef OLD_SCENE_FORMAT_ENABLED
-	object_format_saver_xml = memnew( ObjectFormatSaverInstancerXML );
-	ObjectSaver::add_object_format_saver_instancer( object_format_saver_xml );
-	
-	object_format_loader_xml = memnew( ObjectFormatLoaderInstancerXML );
-	ObjectLoader::add_object_format_loader_instancer( object_format_loader_xml );
-#endif
-#endif
-#ifdef OLD_SCENE_FORMAT_ENABLED
-	object_format_saver_binary = memnew( ObjectFormatSaverInstancerBinary );
-	ObjectSaver::add_object_format_saver_instancer( object_format_saver_binary );
-
-
-	object_format_loader_binary = memnew( ObjectFormatLoaderInstancerBinary );
-	ObjectLoader::add_object_format_loader_instancer( object_format_loader_binary );
-#endif
 	resource_format_po = memnew( TranslationLoaderPO );
 	ResourceLoader::add_resource_format_loader( resource_format_po );
 
@@ -212,10 +185,6 @@ void unregister_core_types() {
 
 	memdelete( _geometry );
 #ifdef XML_ENABLED
-#ifdef OLD_SCENE_FORMAT_ENABLED
-	memdelete( object_format_saver_xml );
-	memdelete( object_format_loader_xml );
-#endif
 	if (resource_saver_xml)
 		memdelete(resource_saver_xml);
 	if (resource_loader_xml)
@@ -228,10 +197,6 @@ void unregister_core_types() {
 		memdelete(resource_loader_binary);
 
 
-#ifdef OLD_SCENE_FORMAT_ENABLED
-	memdelete( object_format_saver_binary );
-	memdelete( object_format_loader_binary );
-#endif
 	memdelete( resource_format_po );
 
 	if (ip)

+ 1 - 1
drivers/SCsub

@@ -82,7 +82,7 @@ if len(list) > 0:
 
 drivers_base=[]
 env.add_source_files(drivers_base,"*.cpp")
-lib_list.insert(0, env.Library("drivers", drivers_base, LIBSUFFIX=env['platform_libsuffix']))
+lib_list.insert(0, env.Library("drivers", drivers_base))
 
 env.Prepend(LIBS=lib_list)
 

+ 1 - 1
main/SCsub

@@ -5,7 +5,7 @@ env.add_source_files(env.main_sources,"*.cpp")
 
 Export('env')
 
-lib = env.Library("main",env.main_sources, LIBSUFFIX=env['platform_libsuffix'])
+lib = env.Library("main",env.main_sources)
 
 env.Prepend(LIBS=[lib])
 

+ 1 - 13
main/main.cpp

@@ -43,7 +43,7 @@
 #include "io/resource_loader.h"
 #include "scene/main/scene_main_loop.h"
 
-#include "scene/io/scene_loader.h"
+
 #include "script_language.h"
 #include "io/resource_loader.h"
 
@@ -1131,10 +1131,6 @@ bool Main::start() {
 #ifdef TOOLS_ENABLED
 			if (editor) {
 
-#ifdef OLD_SCENE_FORMAT_ENABLED
-				if (convert_old)
-					editor_node->set_convert_old_scene(true);
-#endif
 
 				if (_import!="") {
 
@@ -1214,14 +1210,6 @@ bool Main::start() {
 				if (scenedata.is_valid())
 					scene=scenedata->instance();
 
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
-				if (!scene) {
-					scene = SceneLoader::load(local_game_path,true);
-				}
-
-#endif
-
 				ERR_EXPLAIN("Failed loading scene: "+local_game_path);
 				ERR_FAIL_COND_V(!scene,false)
 				sml->get_root()->add_child(scene);

+ 7 - 7
methods.py

@@ -205,7 +205,7 @@ def build_glsl_header( filename ):
 	out_file_base = out_file
 	out_file_base = out_file_base[ out_file_base.rfind("/")+1: ]
 	out_file_base = out_file_base[ out_file_base.rfind("\\")+1: ]
-	print("out file "+out_file+" base " +out_file_base)
+#	print("out file "+out_file+" base " +out_file_base)
 	out_file_ifdef = out_file_base.replace(".","_").upper()
 	fd.write("#ifndef "+out_file_ifdef+"\n")
 	fd.write("#define "+out_file_ifdef+"\n")
@@ -504,7 +504,7 @@ def build_hlsl_dx9_header( filename ):
 	out_file_base = out_file
 	out_file_base = out_file_base[ out_file_base.rfind("/")+1: ]
 	out_file_base = out_file_base[ out_file_base.rfind("\\")+1: ]
-	print("out file "+out_file+" base " +out_file_base)
+#	print("out file "+out_file+" base " +out_file_base)
 	out_file_ifdef = out_file_base.replace(".","_").upper()
 	fd.write("#ifndef "+out_file_ifdef+"\n")
 	fd.write("#define "+out_file_ifdef+"\n")
@@ -714,7 +714,7 @@ def build_legacygl_header( filename, include, class_suffix, output_attribs ):
 				enumbase = ifdefline[:ifdefline.find("_EN_")];
 				ifdefline = ifdefline.replace("_EN_","_")
 				line = line.replace("_EN_","_")
-				print(enumbase+":"+ifdefline);
+#				print(enumbase+":"+ifdefline);
 				if (enumbase not in enums):
 					enums[enumbase]=[]
 				if (ifdefline not in enums[enumbase]):
@@ -805,7 +805,7 @@ def build_legacygl_header( filename, include, class_suffix, output_attribs ):
 	out_file_base = out_file
 	out_file_base = out_file_base[ out_file_base.rfind("/")+1: ]
 	out_file_base = out_file_base[ out_file_base.rfind("\\")+1: ]
-	print("out file "+out_file+" base " +out_file_base)
+#	print("out file "+out_file+" base " +out_file_base)
 	out_file_ifdef = out_file_base.replace(".","_").upper()
 	fd.write("#ifndef "+out_file_ifdef+class_suffix+"_120\n")
 	fd.write("#define "+out_file_ifdef+class_suffix+"_120\n")
@@ -952,10 +952,10 @@ def build_legacygl_header( filename, include, class_suffix, output_attribs ):
 			x=enums[xv]
 			bits=1
 			amt = len(x);
-			print(x)
+#			print(x)
 			while(2**bits < amt):
 				bits+=1
-			print("amount: "+str(amt)+" bits "+str(bits));
+#			print("amount: "+str(amt)+" bits "+str(bits));
 			strs="{"
 			for i in range(amt):
 				strs+="\"#define "+x[i]+"\\n\","
@@ -1330,7 +1330,7 @@ def save_active_platforms(apnames,ap):
 
 	for x in ap:
 		pth = x+"/logo.png"
-		print("open path: "+pth)
+#		print("open path: "+pth)
 		pngf=open(pth,"rb");
 		b=pngf.read(1);
 		str=" /* AUTOGENERATED FILE, DO NOT EDIT */ \n"

+ 1 - 1
modules/SCsub

@@ -16,7 +16,7 @@ for x in env.module_list:
 	env_modules.Append(CPPFLAGS=["-DMODULE_"+x.upper()+"_ENABLED"])
 	SConscript(x+"/SCsub")
 
-lib = env_modules.Library("modules",env.modules_sources, LIBSUFFIX=env['platform_libsuffix'])
+lib = env_modules.Library("modules",env.modules_sources)
 
 env.Prepend(LIBS=[lib])
 

+ 0 - 1
modules/gdscript/gd_script.cpp

@@ -2410,7 +2410,6 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const  {
 		"func"	,
 		"if"	,
 		"in"	,
-		"varl",
 		"null"	,
 		"return"	,
 		"self"	,

+ 2 - 2
platform/android/SCsub

@@ -66,6 +66,6 @@ for x in env.android_module_libraries:
 	shutil.copy(x,abspath+"/java/libs")	
 
 
-env_android.SharedLibrary("#platform/android/libgodot_android.so",[android_objects])
+env_android.SharedLibrary("#bin/libgodot_android",[android_objects],SHLIBSUFFIX=env["SHLIBSUFFIX"])
 
-env.Command('#bin/libgodot_android.so', '#platform/android/libgodot_android.so', Copy('bin/libgodot_android.so', 'platform/android/libgodot_android.so'))
+#env.Command('#bin/libgodot_android.so', '#platform/android/libgodot_android.so', Copy('bin/libgodot_android.so', 'platform/android/libgodot_android.so'))

+ 5 - 23
platform/android/detect.py

@@ -27,14 +27,13 @@ def get_opts():
 		 ('NDK_TARGET', 'toolchain to use for the NDK',"arm-linux-androideabi-4.8"),
 		('android_stl','enable STL support in android port (for modules)','no'),
 		('armv6','compile for older phones running arm v6 (instead of v7+neon+smp)','no'),
-		 ('x86','compile for x86','no')
+		 ('x86','Xompile for Android-x86','no')
 
 	]
 
 def get_flags():
 
 	return [
-		('lua', 'no'),
 		('tools', 'no'),
 		('nedmalloc', 'no'),
 		('builtin_zlib', 'no'),
@@ -77,13 +76,7 @@ def configure(env):
 	env.Append(CPPPATH=['#platform/android'])
 	
 	if env['x86']=='yes':
-		env['OBJSUFFIX'] = ".android.ox"
-		env['LIBSUFFIX'] = ".android.ax"
-	else:
-		env['OBJSUFFIX'] = ".android.o"
-		env['LIBSUFFIX'] = ".android.a"
-	env['PROGSUFFIX'] = ".android"
-	env['SHLIBSUFFIX'] = ".so"
+		env.extra_suffix=".x86"
 	
 	gcc_path=env["ANDROID_NDK_ROOT"]+"/toolchains/"+env["NDK_TARGET"]+"/prebuilt/";
 	
@@ -128,7 +121,7 @@ def configure(env):
 	ld_path=env["ANDROID_NDK_ROOT"]+"/platforms/"+ndk_platform+"/"+env['ARCH']+"/usr/lib"
 	env.Append(CPPPATH=[gcc_include])
 #	env['CCFLAGS'] = string.split('-DNO_THREADS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv5te -mtune=xscale -msoft-float  -fno-exceptions -mthumb -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED ')
-	print("********* armv6", env['armv6'])
+
 	if env['x86']=='yes':
 		env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -D__GLIBC__  -Wno-psabi -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED -DGLES1_ENABLED')
 	elif env["armv6"]!="no":
@@ -149,23 +142,10 @@ def configure(env):
 	if (env["target"]=="release"):
 
 		env.Append(CCFLAGS=['-O2', '-ffast-math','-fomit-frame-pointer'])
-		env['OBJSUFFIX'] = "_opt"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = "_opt"+env['LIBSUFFIX']
 
 	elif (env["target"]=="release_debug"):
 
 		env.Append(CCFLAGS=['-O2', '-ffast-math','-DDEBUG_ENABLED'])
-		env['OBJSUFFIX'] = "_optd"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = "_optd"+env['LIBSUFFIX']
-
-	elif (env["target"]=="profile"):
-
-		env.Append(CCFLAGS=['-O2', '-ffast-math','-fomit-frame-pointer', '-g1'])
-		env.Append(LIBPATH=['#platform/android/armeabi'])
-		env.Append(LIBS=['andprof'])
-		env['OBJSUFFIX'] = "_prof"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = "_prof"+env['LIBSUFFIX']
-		env['SHLIBSUFFIX'] = "_prof"+env['SHLIBSUFFIX']
 
 	elif (env["target"]=="debug"):
 
@@ -174,8 +154,10 @@ def configure(env):
 
 	if env["armv6"] == "no" and env['x86'] != 'yes':
 		env['neon_enabled']=True
+
 	env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL','-DMPC_FIXED_POINT'])
 #	env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT'])
+
 	if (env['android_stl']=='yes'):
 		#env.Append(CCFLAGS=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/system/include"])
 		env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.4.3/include"])

+ 0 - 1
platform/flash/SCsub

@@ -8,7 +8,6 @@ common_flash=[\
 	#"dir_access_flash.cpp",
 ]
 
-print("** path is ", env['ENV']['PATH'])
 
 abc = env.Command('#platform/flash/Console.abc', '#platform/flash/Console.as',
 				"""

+ 0 - 1
platform/flash/detect.py

@@ -11,7 +11,6 @@ def get_name():
 def can_build():
 
 	#import os
-	print(os.environ)
 	if (not os.environ.has_key("FLASCC_ROOT")):
 		return False
 	return True

+ 3 - 8
platform/iphone/SCsub

@@ -35,11 +35,6 @@ if env['ios_appirater'] == "yes":
 obj = env_ios.Object('godot_iphone.cpp')
 
 prog = None
-if env["target"]=="release" or env["target"] == "release_debug":
-	prog = env_ios.Program('#bin/godot_opt', [obj] + iphone_lib)
-	#action = "dsymutil "+File(prog)[0].path+" -o ../build/script_exec/build/Debug-iphoneos/script_exec.app.dSYM"
-	#env.AddPostAction(prog, action)
-else:
-	prog = env_ios.Program('#bin/godot', [obj] + iphone_lib)
-	action = "dsymutil "+File(prog)[0].path+" -o bin/godot.iphone.dSYM"
-	env.AddPostAction(prog, action)
+prog = env_ios.Program('#bin/godot', [obj] + iphone_lib)
+action = "dsymutil "+File(prog)[0].path+" -o " + File(prog)[0].path + ".dSYM"
+env.AddPostAction(prog, action)

+ 4 - 2
platform/iphone/app_delegate.mm

@@ -257,7 +257,8 @@ static int frame_count = 0;
 - (void)applicationDidEnterBackground:(UIApplication *)application
 {
 	printf("********************* did enter background\n");
-	OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
+	if (OS::get_singleton()->get_main_loop())
+		OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
 	[view_controller.view stopAnimation];
 }
 
@@ -282,7 +283,8 @@ static int frame_count = 0;
     printf("********************* mobile app tracker found\n");
 	[MobileAppTracker measureSession];
 #endif
-	OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
+	if (OS::get_singleton()->get_main_loop())
+		OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
 	[view_controller.view startAnimation]; // FIXME: resume seems to be recommended elsewhere
 }
 

文件差异内容过多而无法显示
+ 0 - 13
platform/iphone/detect.py


+ 1 - 3
platform/javascript/SCsub

@@ -6,8 +6,6 @@ javascript_files = [
 	"javascript_main.cpp"
 ]
 
-#env.Depends('#core/math/vector3.h', 'vector3_psp.h')
-
 #obj = env.SharedObject('godot_javascript.cpp')
 
 env_javascript = env.Clone()
@@ -22,4 +20,4 @@ prog = None
 
 #env_javascript.SharedLibrary("#platform/javascript/libgodot_javascript.so",[javascript_objects])
 
-env.Program('#bin/godot.html', javascript_objects)
+env.Program('#bin/godot',javascript_objects,PROGSUFFIX=env["PROGSUFFIX"]+".html")

+ 1 - 10
platform/javascript/detect.py

@@ -46,11 +46,7 @@ def get_flags():
 def configure(env):
 
 
-	env.Append(CPPPATH=['#platform/android'])
-	
-	env['OBJSUFFIX'] = ".js.o"
-	env['LIBSUFFIX'] = ".js.a"
-	env['PROGSUFFIX'] = ".html"
+	env.Append(CPPPATH=['#platform/javascript'])
 	
 	em_path=os.environ["EMSCRIPTEN_ROOT"]
 	
@@ -68,17 +64,12 @@ def configure(env):
 	if (env["target"]=="release"):
 
 		env.Append(CCFLAGS=['-O2'])
-		env['OBJSUFFIX'] = "_opt"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = "_opt"+env['LIBSUFFIX']
 
 	elif (env["target"]=="release_debug"):
 
 		env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED'])
-		env['OBJSUFFIX'] = "_optd"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = "_optd"+env['LIBSUFFIX']
 
 	elif (env["target"]=="debug"):
-
 		env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED'])
 		env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
 

+ 1 - 1
platform/osx/SCsub

@@ -8,4 +8,4 @@ files = [
 #	'context_gl_osx.cpp',
 	]
 
-env.Program('#bin/godot_osx',files)
+env.Program('#bin/godot',files)

+ 3 - 15
platform/osx/detect.py

@@ -38,42 +38,30 @@ def configure(env):
 
 	env.Append(CPPPATH=['#platform/osx'])
 
-	if (env["tools"]=="no"):
-		#no tools suffix
-		env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
+	if (env["bits"]=="default"):
+	    env["bits"]="32"
 
 	if (env["target"]=="release"):
 
 		env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer','-ftree-vectorize','-msse2'])
-		env['OBJSUFFIX'] = "_opt"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = "_opt"+env['LIBSUFFIX']
 
 	elif (env["target"]=="release_debug"):
 
 		env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED'])
-		env['OBJSUFFIX'] = "_optd"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = "_optd"+env['LIBSUFFIX']
 
 	elif (env["target"]=="debug"):
 
 		env.Append(CCFLAGS=['-g3', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
 
 
-	elif (env["target"]=="profile"):
-		env.Append(CCFLAGS=['-g','-pg'])
-		env.Append(LINKFLAGS=['-pg'])
-
 	if (env["freetype"]!="no"):
 		env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
 		env.Append(CPPPATH=['#tools/freetype'])
 		env.Append(CPPPATH=['#tools/freetype/freetype/include'])
 
-	if (env["force_64_bits"]!="no"):
+	if (env["bits"]=="64"):
 		env.Append(CCFLAGS=['-arch', 'x86_64'])
 		env.Append(LINKFLAGS=['-arch', 'x86_64'])
-		env['OBJSUFFIX'] = ".64"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = ".64"+env['LIBSUFFIX']
 	else:
 		env.Append(CCFLAGS=['-arch', 'i386'])
 		env.Append(LINKFLAGS=['-arch', 'i386'])

+ 12 - 26
platform/server/detect.py

@@ -41,50 +41,36 @@ def configure(env):
 		env["CXX"]="clang++"
 		env["LD"]="clang++"
 
-	env['OBJSUFFIX'] = ".srv"+env['OBJSUFFIX']
-	env['LIBSUFFIX'] = ".srv"+env['LIBSUFFIX']
+	is64=sys.maxsize > 2**32
 
-	if (env["force_32_bits"]!="no"):
-		env['OBJSUFFIX'] = ".32"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = ".32"+env['LIBSUFFIX']
+	if (env["bits"]=="default"):
+		if (is64):
+			env["bits"]="64"
+		else:
+			env["bits"]="32"
 
 
-	if (env["tools"]=="no"):
-		#no tools suffix
-		env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
+	#if (env["tools"]=="no"):
+	#	#no tools suffix
+	#	env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
+	#	env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
 
 
 	if (env["target"]=="release"):
-		
+
 		env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer'])
-		env['OBJSUFFIX'] = "_opt"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = "_opt"+env['LIBSUFFIX']
 
 	elif (env["target"]=="release_debug"):
 
 		env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED'])
-		env['OBJSUFFIX'] = "_optd"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = "_optd"+env['LIBSUFFIX']
-
 
 	elif (env["target"]=="debug"):
-				
-		env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
 
-	elif (env["target"]=="profile"):
-		
-		env.Append(CCFLAGS=['-g','-pg'])
-		env.Append(LINKFLAGS=['-pg'])		
+		env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
 
-	
 	env.Append(CPPFLAGS=['-DSERVER_ENABLED','-DUNIX_ENABLED'])
 	env.Append(LIBS=['pthread','z']) #TODO detect linux/BSD!
 
-	if (env["force_32_bits"]=="yes"):
-		env.Append(CPPFLAGS=['-m32'])
-		env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu'])
-
 	if (env["CXX"]=="clang++"):
 		env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
 		env["CC"]="clang"

+ 1 - 1
platform/windows/SCsub

@@ -10,4 +10,4 @@ common_win=[
 	"stream_peer_winsock.cpp",
 ]
 
-env.Program('#bin/godot.exe',['godot_win.cpp']+common_win)
+env.Program('#bin/godot',['godot_win.cpp']+common_win,PROGSUFFIX=env["PROGSUFFIX"]+".exe")

+ 53 - 48
platform/windows/detect.py

@@ -25,26 +25,38 @@ def can_build():
 			
 			
 	if (os.name=="posix"):
-	
-		if os.system("i586-mingw32msvc-gcc --version") == 0:
+
+		mingw = "i586-mingw32msvc-"
+		mingw64 = "i686-w64-mingw32-"
+		if (os.getenv("MINGW32_PREFIX")):
+			mingw=os.getenv("MINGW32_PREFIX")
+		if (os.getenv("MINGW64_PREFIX")):
+			mingw64=os.getenv("MINGW64_PREFIX")
+
+		if os.system(mingw+"gcc --version >/dev/null") == 0 or os.system(mingw64+"gcc --version >/dev/null") ==0:
 			return True
 
+
 			
 	return False
 		
 def get_opts():
 
-	mwp=""
-	mwp64=""
+	mingw=""
+	mingw64=""
 	if (os.name!="nt"):
-		mwp="i586-mingw32msvc-"
-		mwp64="x86_64-w64-mingw32-"
+		mingw = "i586-mingw32msvc-"
+		mingw64 = "i686-w64-mingw32-"
+		if (os.getenv("MINGW32_PREFIX")):
+			mingw=os.getenv("MINGW32_PREFIX")
+		if (os.getenv("MINGW64_PREFIX")):
+			mingw64=os.getenv("MINGW64_PREFIX")
+
 
 	return [
-		('force_64_bits','Force 64 bits binary','no'),
-		('force_32_bits','Force 32 bits binary','no'),
-		('mingw_prefix','Mingw Prefix',mwp),
-		('mingw_prefix_64','Mingw Prefix 64 bits',mwp64),
+		('mingw_prefix','Mingw Prefix',mingw),
+		('mingw_prefix_64','Mingw Prefix 64 bits',mingw64),
+		('mingw64_for_32','Use Mingw 64 for 32 Bits Build',"no"),
 	]
   
 def get_flags():
@@ -58,19 +70,8 @@ def get_flags():
 
 def configure(env):
 
-	if os.name == "posix":
-		env['OBJSUFFIX'] = ".win"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = ".win"+env['LIBSUFFIX']
-
 	env.Append(CPPPATH=['#platform/windows'])
 
-	if (env["tools"]=="no"):
-		#no tools suffix
-		env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
-		#env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
-		env['platform_libsuffix'] = ".nt"+env['LIBSUFFIX']
-
-
 
 	if (os.name=="nt" and os.getenv("VSINSTALLDIR")!=None):
 		#build using visual studio
@@ -89,21 +90,17 @@ def configure(env):
 			env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS'])
 			env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup'])
 
-		elif (env["target"]=="test"):
+		elif (env["target"]=="release_debug"):
 
-			env.Append(CCFLAGS=['/O2','/DDEBUG_ENABLED','/DD3D_DEBUG_INFO'])
+			env.Append(CCFLAGS=['/O2','/DDEBUG_ENABLED'])
 			env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
 
 		elif (env["target"]=="debug"):
 
-			env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DD3D_DEBUG_INFO','/O1'])
+			env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED','/DD3D_DEBUG_INFO','/O1'])
 			env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
 			env.Append(LINKFLAGS=['/DEBUG'])
 
-		elif (env["target"]=="profile"):
-
-			env.Append(CCFLAGS=['-g','-pg'])
-			env.Append(LINKFLAGS=['-pg'])
 
 		env.Append(CCFLAGS=['/MT','/Gd','/GR','/nologo'])
 		env.Append(CXXFLAGS=['/TP'])
@@ -142,44 +139,52 @@ def configure(env):
 
 		mingw_prefix=""
 
-		if (env["force_32_bits"]!="no"):
-			env['OBJSUFFIX'] = ".32"+env['OBJSUFFIX']
-			env['LIBSUFFIX'] = ".32"+env['LIBSUFFIX']
-			env.Append(CCFLAGS=['-m32'])
-			env.Append(LINKFLAGS=['-m32'])
-			env.Append(LINKFLAGS=['-static-libgcc'])
-			env.Append(LINKFLAGS=['-static-libstdc++'])
+		if (env["bits"]=="default"):
+			env["bits"]="32"
 
+		use64=False
+		if (env["bits"]=="32"):
 
+			if (env["mingw64_for_32"]=="yes"):
+				env.Append(CCFLAGS=['-m32'])
+				env.Append(LINKFLAGS=['-m32'])
+				env.Append(LINKFLAGS=['-static-libgcc'])
+				env.Append(LINKFLAGS=['-static-libstdc++'])
+				mingw_prefix=env["mingw_prefix_64"];
+			else:
+				mingw_prefix=env["mingw_prefix"];
 
 
-		if (env["force_64_bits"]!="no"):
+		else:
 			mingw_prefix=env["mingw_prefix_64"];
-			env['OBJSUFFIX'] = ".64"+env['OBJSUFFIX']
-			env['LIBSUFFIX'] = ".64"+env['LIBSUFFIX']
 			env.Append(LINKFLAGS=['-static'])
+
+		nulstr=""
+
+		if (os.name=="posix"):
+		    nulstr=">/dev/null"
 		else:
-			mingw_prefix=env["mingw_prefix"];
+		    nulstr=">nul"
+
+
+
+		if os.system(mingw_prefix+"gcc --version"+nulstr)!=0:
+			#not really super consistent but..
+			print("Can't find Windows compiler: "+mingw_prefix)
+			sys.exit(255)
 
 		if (env["target"]=="release"):
 			
 			env.Append(CCFLAGS=['-O3','-ffast-math','-fomit-frame-pointer','-msse2'])
-			env['OBJSUFFIX'] = "_opt"+env['OBJSUFFIX']
-			env['LIBSUFFIX'] = "_opt"+env['LIBSUFFIX']
 			env.Append(LINKFLAGS=['-Wl,--subsystem,windows'])
+
 		elif (env["target"]=="release_debug"):
 
 			env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED'])
-			env['OBJSUFFIX'] = "_optd"+env['OBJSUFFIX']
-			env['LIBSUFFIX'] = "_optd"+env['LIBSUFFIX']
 
 		elif (env["target"]=="debug"):
 					
-			env.Append(CCFLAGS=['-g', '-Wall','-DDEBUG_ENABLED'])
-		elif (env["target"]=="release_tools"):
-
-			env.Append(CCFLAGS=['-O2','-Wall','-DDEBUG_ENABLED'])
-
+			env.Append(CCFLAGS=['-g', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
 
 		if (env["freetype"]!="no"):
 			env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])

+ 0 - 2
platform/x11/SCsub

@@ -8,5 +8,3 @@ common_x11=[\
 ]
 
 env.Program('#bin/godot',['godot_x11.cpp']+common_x11)
-if env['target'] == "release":
-	env.Command('#bin/godot_rel', '#bin/godot', Copy('bin/godot_rel', 'bin/godot'))

+ 22 - 42
platform/x11/detect.py

@@ -47,14 +47,11 @@ def get_opts():
 	return [
 	('use_llvm','Use llvm compiler','no'),
 	('use_sanitizer','Use llvm compiler sanitize address','no'),
-	('force_32_bits','Force 32 bits binary','no')
 	]
   
 def get_flags():
 
 	return [
-	('opengl', 'no'),
-	('legacygl', 'yes'),
 	('builtin_zlib', 'no'),
 	("openssl", "yes"),
         ]
@@ -63,6 +60,15 @@ def get_flags():
 
 def configure(env):
 
+	is64=sys.maxsize > 2**32
+
+	if (env["bits"]=="default"):
+		if (is64):
+			env["bits"]="64"
+		else:
+			env["bits"]="32"
+
+
 	env.Append(CPPPATH=['#platform/x11'])
 	if (env["use_llvm"]=="yes"):
 		env["CC"]="clang"
@@ -74,50 +80,23 @@ def configure(env):
 
 
 
-	if (env["tools"]=="no"):
-		#no tools suffix
-		env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
+	#if (env["tools"]=="no"):
+	#	#no tools suffix
+	#	env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
+	#	env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
 
 
 	if (env["target"]=="release"):
 		
 		env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer'])
-		env['OBJSUFFIX'] = "_opt"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = "_opt"+env['LIBSUFFIX']
 
 	elif (env["target"]=="release_debug"):
 
 		env.Append(CCFLAGS=['-O2','-ffast-math','-DDEBUG_ENABLED'])
-		env['OBJSUFFIX'] = "_optd"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = "_optd"+env['LIBSUFFIX']
-
-
-#		env.Append(CCFLAGS=['-Os','-ffast-math','-fomit-frame-pointer'])
-#does not seem to have much effect		
-#		env.Append(CCFLAGS=['-fno-default-inline'])
-#recommended by wxwidgets
-#		env.Append(CCFLAGS=['-ffunction-sections','-fdata-sections'])
-#		env.Append(LINKFLAGS=['-Wl','--gc-sections'])
 
 	elif (env["target"]=="debug"):
-				
-		env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
-#does not seem to have much effect		
-#		env.Append(CCFLAGS=['-fno-default-inline'])
-#recommended by wxwidgets
-#		env.Append(CCFLAGS=['-ffunction-sections','-fdata-sections'])
-#		env.Append(LINKFLAGS=['-Wl','--gc-sections'])
-
-	elif (env["target"]=="debug_light"):
 
-		env.Append(CCFLAGS=['-g1', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
-
-
-	elif (env["target"]=="profile"):
-		
-		env.Append(CCFLAGS=['-g','-pg'])
-		env.Append(LINKFLAGS=['-pg'])		
+		env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
 
 	env.ParseConfig('pkg-config x11 --cflags --libs')
 	env.ParseConfig('pkg-config xcursor --cflags --libs')
@@ -128,19 +107,20 @@ def configure(env):
 	env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
 
 	
-	if env['opengl'] == 'yes':
-                env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED'])
-	#env.Append(CPPFLAGS=["-DRTAUDIO_ENABLED"])
+	env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED'])
 	env.Append(CPPFLAGS=["-DALSA_ENABLED"])
 	env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES1_ENABLED','-DGLES_OVER_GL'])
-#        env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL'])
 	env.Append(LIBS=['GL', 'GLU', 'pthread','asound','z']) #TODO detect linux/BSD!
 	#env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
-	if (env["force_32_bits"]=="yes"):
+
+#host compiler is default..
+
+	if (is64 and env["bits"]=="32"):
 		env.Append(CPPFLAGS=['-m32'])
 		env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu'])
-		env['OBJSUFFIX'] = ".32"+env['OBJSUFFIX']
-		env['LIBSUFFIX'] = ".32"+env['LIBSUFFIX']
+	elif (not is64 and env["bits"]=="32"):
+		env.Append(CPPFLAGS=['-m64'])
+		env.Append(LINKFLAGS=['-m64','-L/usr/lib/i686-linux-gnu'])
 
 
 	if (env["CXX"]=="clang++"):

+ 0 - 1
scene/3d/SCsub

@@ -1,7 +1,6 @@
 Import('env')
 
 
-print("V: "+env["disable_3d"])
 if (env["disable_3d"]=="yes"):
 
 	env.scene_sources.append("3d/spatial.cpp")

+ 0 - 741
scene/3d/car_body.cpp

@@ -1,741 +0,0 @@
-/*************************************************************************/
-/*  car_body.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 "car_body.h"
-
-#define DEG2RADMUL (Math_PI/180.0)
-#define RAD2DEGMUL (180.0/Math_PI)
-
-void CarWheel::_notification(int p_what) {
-
-
-	if (p_what==NOTIFICATION_ENTER_SCENE) {
-
-		if (!get_parent())
-			return;
-		CarBody *cb = get_parent()->cast_to<CarBody>();
-		if (!cb)
-			return;
-		body=cb;
-		local_xform=get_transform();
-		cb->wheels.push_back(this);
-	}
-	if (p_what==NOTIFICATION_EXIT_SCENE) {
-
-		if (!get_parent())
-			return;
-		CarBody *cb = get_parent()->cast_to<CarBody>();
-		if (!cb)
-			return;
-		cb->wheels.erase(this);
-		body=NULL;
-	}
-}
-
-void CarWheel::set_side_friction(real_t p_friction) {
-
-	side_friction=p_friction;
-}
-void CarWheel::set_forward_friction(real_t p_friction)  {
-
-	forward_friction=p_friction;
-}
-void CarWheel::set_travel(real_t p_travel) {
-
-	travel=p_travel;
-	update_gizmo();
-
-}
-void CarWheel::set_radius(real_t p_radius) {
-
-	radius=p_radius;
-	update_gizmo();
-
-}
-void CarWheel::set_resting_frac(real_t p_frac) {
-
-	resting_frac=p_frac;
-}
-void CarWheel::set_damping_frac(real_t p_frac) {
-
-	damping_frac=p_frac;
-}
-void CarWheel::set_num_rays(real_t p_rays) {
-
-	num_rays=p_rays;
-}
-
-real_t CarWheel::get_side_friction() const{
-
-	return side_friction;
-}
-real_t CarWheel::get_forward_friction() const{
-
-	return forward_friction;
-}
-real_t CarWheel::get_travel() const{
-
-	return travel;
-}
-real_t CarWheel::get_radius() const{
-
-	return radius;
-}
-real_t CarWheel::get_resting_frac() const{
-
-	return resting_frac;
-}
-real_t CarWheel::get_damping_frac() const{
-
-	return damping_frac;
-}
-
-int CarWheel::get_num_rays() const{
-
-	return num_rays;
-}
-
-
-void CarWheel::update(real_t dt) {
-
-
-	if (dt <= 0.0f)
-		return;
-
-	float origAngVel = angVel;
-
-	if (locked)
-	{
-		angVel = 0;
-		torque = 0;
-	}
-	else
-	{
-
-		float wheelMass = 0.03f * body->mass;
-		float inertia = 0.5f * (radius * radius) * wheelMass;
-
-		angVel += torque * dt / inertia;
-		torque = 0;
-
-		// prevent friction from reversing dir - todo do this better
-		// by limiting the torque
-		if (((origAngVel > angVelForGrip) && (angVel < angVelForGrip)) ||
-				((origAngVel < angVelForGrip) && (angVel > angVelForGrip)))
-			angVel = angVelForGrip;
-
-		angVel += driveTorque * dt / inertia;
-		driveTorque = 0;
-
-		float maxAngVel = 200;
-		print_line("angvel: "+rtos(angVel));
-		angVel = CLAMP(angVel, -maxAngVel, maxAngVel);
-
-		axisAngle += Math::rad2deg(dt * angVel);
-	}
-}
-
-bool CarWheel::add_forces(PhysicsDirectBodyState *s) {
-
-
-	Vector3 force;
-
-	PhysicsDirectSpaceState *space = s->get_space_state();
-
-	Transform world = s->get_transform() * local_xform;
-
-	// OpenGl has differnet row/column order for matrixes than XNA has ..
-	//Vector3 wheelFwd = world.get_basis().get_axis(Vector3::AXIS_Z);
-	//Vector3 wheelFwd = RotationMatrix(mSteerAngle, worldAxis) * carBody.GetOrientation().GetCol(0);
-	Vector3 wheelUp = world.get_basis().get_axis(Vector3::AXIS_Y);
-	Vector3 wheelFwd = Matrix3(wheelUp,Math::deg2rad(steerAngle)).xform( world.get_basis().get_axis(Vector3::AXIS_Z) );
-	Vector3 wheelLeft = -wheelUp.cross(wheelFwd).normalized();
-	Vector3 worldPos = world.origin;
-	Vector3 worldAxis = wheelUp;
-
-	// start of ray
-	float rayLen = 2.0f * radius + travel;
-	Vector3 wheelRayEnd = worldPos - radius * worldAxis;
-	Vector3 wheelRayBegin = wheelRayEnd + rayLen * worldAxis;
-	//wheelRayEnd = -rayLen * worldAxis;
-
-	//Assert(PhysicsSystem.CurrentPhysicsSystem);
-
-
-	///Assert(collSystem);
- ///
-	const int maxNumRays = 32;
-
-	int numRaysUse = MIN(num_rays, maxNumRays);
-
-	// adjust the start position of the ray - divide the wheel into numRays+2
-	// rays, but don't use the first/last.
-	float deltaFwd = (2.0f * radius) / (numRaysUse + 1);
-	float deltaFwdStart = deltaFwd;
-
-	float fracs[maxNumRays];
-	Vector3 segmentEnds[maxNumRays];
-	Vector3 groundPositions[maxNumRays];
-	Vector3 groundNormals[maxNumRays];
-
-
-	lastOnFloor = false;
-	int bestIRay = 0;
-	int iRay;
-
-
-	for (iRay = 0; iRay < numRaysUse; ++iRay)
-	{
-		fracs[iRay] = 1e20;
-		// work out the offset relative to the middle ray
-		float distFwd = (deltaFwdStart + iRay * deltaFwd) - radius;
-		float zOffset = radius * (1.0f - (float)Math::cos( Math::deg2rad( 90.0f * (distFwd / radius))));
-
-		segmentEnds[iRay] = wheelRayEnd + distFwd * wheelFwd + zOffset * wheelUp;
-
-
-		PhysicsDirectSpaceState::RayResult rr;
-
-		bool collided = space->intersect_ray(wheelRayBegin,segmentEnds[iRay],rr,body->exclude);
-
-
-		if (collided){
-			lastOnFloor = true;
-			groundPositions[iRay]=rr.position;
-			groundNormals[iRay]=rr.normal;
-			fracs[iRay] = ((wheelRayBegin-rr.position).length() /  (wheelRayBegin-wheelRayEnd).length());
-			if (fracs[iRay] < fracs[bestIRay])
-				bestIRay = iRay;
-		}
-	}
-
-
-	if (!lastOnFloor)
-		return false;
-
-	//Assert(bestIRay < numRays);
-
-	// use the best one
-	Vector3 groundPos = groundPositions[bestIRay];
-	float frac = fracs[bestIRay];
-
-	//  const Vector3 groundNormal = (worldPos - segments[bestIRay].GetEnd()).NormaliseSafe();
-	//  const Vector3 groundNormal = groundNormals[bestIRay];
-
-
-	Vector3 groundNormal = worldAxis;
-
-	if (numRaysUse > 1)
-	{
-		for (iRay = 0; iRay < numRaysUse; ++iRay)
-		{
-			if (fracs[iRay] <= 1.0f)
-			{
-				groundNormal += (1.0f - fracs[iRay]) * (worldPos - segmentEnds[iRay]);
-			}
-		}
-
-		groundNormal.normalize();
-
-	}
-	else
-	{
-		groundNormal = groundNormals[bestIRay];
-	}
-
-
-
-	float spring = (body->mass/body->wheels.size()) * s->get_total_gravity().length() / (resting_frac * travel);
-
-	float displacement = rayLen * (1.0f - frac);
-	displacement = CLAMP(displacement, 0, travel);
-
-
-
-	float displacementForceMag = displacement * spring;
-
-	// reduce force when suspension is par to ground
-	displacementForceMag *= groundNormals[bestIRay].dot(worldAxis);
-
-	// apply damping
-	float damping = 2.0f * (float)Math::sqrt(spring * body->mass);
-	damping /= body->wheels.size(); // assume wheels act together
-	damping *= damping_frac;  // a bit bouncy
-
-	float upSpeed = (displacement - lastDisplacement) / s->get_step();
-
-	float dampingForceMag = upSpeed * damping;
-
-	float totalForceMag = displacementForceMag + dampingForceMag;
-
-	if (totalForceMag < 0.0f) totalForceMag = 0.0f;
-
-	Vector3 extraForce = totalForceMag * worldAxis;
-
-
-	force += extraForce;
-	// side-slip friction and drive force. Work out wheel- and floor-relative coordinate frame
-	Vector3 groundUp = groundNormal;
-	Vector3 groundLeft = groundNormal.cross(wheelFwd).normalized();
-
-	Vector3 groundFwd = groundLeft.cross(groundUp);
-
-	Vector3 wheelPointVel = s->get_linear_velocity() +
-			(s->get_angular_velocity()).cross(s->get_transform().basis.xform(local_xform.origin));// * mPos);
-
-	Vector3 rimVel = -angVel * wheelLeft.cross(groundPos - worldPos);
-	wheelPointVel += rimVel;
-
-	// if sitting on another body then adjust for its velocity.
-	/*if (worldBody != null)
-	{
-		Vector3 worldVel = worldBody.Velocity +
-				Vector3.Cross(worldBody.AngularVelocity, groundPos - worldBody.Position);
-
-		wheelPointVel -= worldVel;
-	}*/
-
-	// sideways forces
-	float noslipVel = 0.2f;
-	float slipVel = 0.4f;
-	float slipFactor = 0.7f;
-
-	float smallVel = 3;
-	float friction = side_friction;
-
-	float sideVel = wheelPointVel.dot(groundLeft);
-
-	if ((sideVel > slipVel) || (sideVel < -slipVel))
-		friction *= slipFactor;
-	else
-		if ((sideVel > noslipVel) || (sideVel < -noslipVel))
-			friction *= 1.0f - (1.0f - slipFactor) * (Math::absf(sideVel) - noslipVel) / (slipVel - noslipVel);
-
-	if (sideVel < 0.0f)
-		friction *= -1.0f;
-
-	if (Math::absf(sideVel) < smallVel)
-		friction *= Math::absf(sideVel) / smallVel;
-
-	float sideForce = -friction * totalForceMag;
-
-	extraForce = sideForce * groundLeft;
-	force += extraForce;
-	// fwd/back forces
-	friction = forward_friction;
-	float fwdVel = wheelPointVel.dot(groundFwd);
-
-	if ((fwdVel > slipVel) || (fwdVel < -slipVel))
-		friction *= slipFactor;
-	else
-		if ((fwdVel > noslipVel) || (fwdVel < -noslipVel))
-			friction *= 1.0f - (1.0f - slipFactor) * (Math::absf(fwdVel) - noslipVel) / (slipVel - noslipVel);
-
-	if (fwdVel < 0.0f)
-		friction *= -1.0f;
-
-	if (Math::absf(fwdVel) < smallVel)
-		friction *= Math::absf(fwdVel) / smallVel;
-
-	float fwdForce = -friction * totalForceMag;
-
-	extraForce = fwdForce * groundFwd;
-	force += extraForce;
-
-
-	//if (!force.IsSensible())
-	//{
-	//  TRACE_FILE_IF(ONCE_1)
-	//    TRACE("Bad force in car wheel\n");
-	//  return true;
-	//}
-
-	// fwd force also spins the wheel
-	Vector3 wheelCentreVel = s->get_linear_velocity() +
-			(s->get_angular_velocity()).cross(s->get_transform().basis.xform(local_xform.origin));
-
-	angVelForGrip = wheelCentreVel.dot(groundFwd) / radius;
-	torque += -fwdForce * radius;
-
-	// add force to car
-//	carBody.AddWorldForce(force, groundPos);
-
-	s->add_force(force,(groundPos-s->get_transform().origin));
-
-	// add force to the world
-	/*
-	if (worldBody != null && !worldBody.Immovable)
-	{
-		// todo get the position in the right place...
-		// also limit the velocity that this force can produce by looking at the
-		// mass/inertia of the other object
-		float maxOtherBodyAcc = 500.0f;
-		float maxOtherBodyForce = maxOtherBodyAcc * worldBody.Mass;
-
-		if (force.LengthSquared() > (maxOtherBodyForce * maxOtherBodyForce))
-			force *= maxOtherBodyForce / force.Length();
-
-		worldBody.AddWorldForce(-force, groundPos);
-	}*/
-
-	Transform wheel_xf = local_xform;
-	wheel_xf.origin += wheelUp * displacement;
-	wheel_xf.basis = wheel_xf.basis * Matrix3(Vector3(0,1,0),Math::deg2rad(steerAngle));
-	//wheel_xf.basis = wheel_xf.basis * Matrix3(wheel_xf.basis[0],-Math::deg2rad(axisAngle));
-
-	set_transform(wheel_xf);
-	lastDisplacement=displacement;
-	return true;
-
-}
-
-void CarWheel::set_type_drive(bool p_enable) {
-
-	type_drive=p_enable;
-}
-
-bool CarWheel::is_type_drive() const {
-
-	return type_drive;
-}
-
-void CarWheel::set_type_steer(bool p_enable) {
-
-	type_steer=p_enable;
-}
-
-bool CarWheel::is_type_steer() const {
-
-	return type_steer;
-}
-
-
-void CarWheel::_bind_methods() {
-
-	ObjectTypeDB::bind_method(_MD("set_side_friction","friction"),&CarWheel::set_side_friction);
-	ObjectTypeDB::bind_method(_MD("set_forward_friction","friction"),&CarWheel::set_forward_friction);
-	ObjectTypeDB::bind_method(_MD("set_travel","distance"),&CarWheel::set_travel);
-	ObjectTypeDB::bind_method(_MD("set_radius","radius"),&CarWheel::set_radius);
-	ObjectTypeDB::bind_method(_MD("set_resting_frac","frac"),&CarWheel::set_resting_frac);
-	ObjectTypeDB::bind_method(_MD("set_damping_frac","frac"),&CarWheel::set_damping_frac);
-	ObjectTypeDB::bind_method(_MD("set_num_rays","amount"),&CarWheel::set_num_rays);
-
-	ObjectTypeDB::bind_method(_MD("get_side_friction"),&CarWheel::get_side_friction);
-	ObjectTypeDB::bind_method(_MD("get_forward_friction"),&CarWheel::get_forward_friction);
-	ObjectTypeDB::bind_method(_MD("get_travel"),&CarWheel::get_travel);
-	ObjectTypeDB::bind_method(_MD("get_radius"),&CarWheel::get_radius);
-	ObjectTypeDB::bind_method(_MD("get_resting_frac"),&CarWheel::get_resting_frac);
-	ObjectTypeDB::bind_method(_MD("get_damping_frac"),&CarWheel::get_damping_frac);
-	ObjectTypeDB::bind_method(_MD("get_num_rays"),&CarWheel::get_num_rays);
-
-	ObjectTypeDB::bind_method(_MD("set_type_drive","enable"),&CarWheel::set_type_drive);
-	ObjectTypeDB::bind_method(_MD("is_type_drive"),&CarWheel::is_type_drive);
-
-	ObjectTypeDB::bind_method(_MD("set_type_steer","enable"),&CarWheel::set_type_steer);
-	ObjectTypeDB::bind_method(_MD("is_type_steer"),&CarWheel::is_type_steer);
-
-	ADD_PROPERTY( PropertyInfo(Variant::BOOL,"type/drive"),_SCS("set_type_drive"),_SCS("is_type_drive"));
-	ADD_PROPERTY( PropertyInfo(Variant::BOOL,"type/steer"),_SCS("set_type_steer"),_SCS("is_type_steer"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"config/side_friction",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_side_friction"),_SCS("get_side_friction"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"config/forward_friction",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_forward_friction"),_SCS("get_forward_friction"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"config/travel",PROPERTY_HINT_RANGE,"0.01,1024,0.01"),_SCS("set_travel"),_SCS("get_travel"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"config/radius",PROPERTY_HINT_RANGE,"0.01,1024,0.01"),_SCS("set_radius"),_SCS("get_radius"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"config/resting_frac",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_resting_frac"),_SCS("get_resting_frac"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"config/damping_frac",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_damping_frac"),_SCS("get_damping_frac"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"config/num_rays",PROPERTY_HINT_RANGE,"1,32,1"),_SCS("set_num_rays"),_SCS("get_num_rays"));
-
-}
-
-CarWheel::CarWheel() {
-
-	side_friction=4.7;
-	forward_friction=5.0;
-	travel=0.2;
-	radius=0.4;
-	resting_frac=0.45;
-	damping_frac=0.3;
-	num_rays=1;
-
-	angVel = 0.0f;
-	steerAngle = 0.0f;
-	torque = 0.0f;
-	driveTorque = 0.0f;
-	axisAngle = 0.0f;
-	upSpeed = 0.0f;
-	locked = false;
-	lastDisplacement = 0.0f;
-	lastOnFloor = false;
-	angVelForGrip = 0.0f;
-	angVelForGrip=0;
-
-	type_drive=false;
-	type_steer=false;
-
-}
-
-///
-
-
-void CarBody::set_max_steer_angle(real_t p_angle)  {
-
-	max_steer_angle=p_angle;
-}
-void CarBody::set_steer_rate(real_t p_rate) {
-
-	steer_rate=p_rate;
-}
-void CarBody::set_drive_torque(real_t p_torque) {
-
-	drive_torque=p_torque;
-}
-
-real_t CarBody::get_max_steer_angle() const{
-
-	return max_steer_angle;
-}
-real_t CarBody::get_steer_rate() const{
-
-	return steer_rate;
-}
-real_t CarBody::get_drive_torque() const{
-
-	return drive_torque;
-}
-
-
-void CarBody::set_target_steering(float p_steering) {
-
-	target_steering=p_steering;
-}
-
-void CarBody::set_target_accelerate(float p_accelerate) {
-	target_accelerate=p_accelerate;
-}
-
-void CarBody::set_hand_brake(float p_amont) {
-
-	hand_brake=p_amont;
-}
-
-real_t CarBody::get_target_steering() const {
-
-	return target_steering;
-}
-real_t CarBody::get_target_accelerate() const {
-
-	return target_accelerate;
-}
-real_t CarBody::get_hand_brake() const {
-
-	return hand_brake;
-}
-
-
-void CarBody::_direct_state_changed(Object *p_state) {
-
-	PhysicsDirectBodyState *state=p_state->cast_to<PhysicsDirectBodyState>();
-
-	float dt = state->get_step();
-	AABB aabb;
-	int drive_total=0;
-	for(int i=0;i<wheels.size();i++) {
-		CarWheel *w=wheels[i];
-		if (i==0) {
-			aabb.pos=w->local_xform.origin;
-		} else {
-			aabb.expand_to(w->local_xform.origin);
-		}
-		if (w->type_drive)
-			drive_total++;
-
-	}
-	// control inputs
-	float deltaAccelerate = dt * 4.0f;
-
-	float dAccelerate = target_accelerate - accelerate;
-	dAccelerate = CLAMP(dAccelerate, -deltaAccelerate, deltaAccelerate);
-	accelerate += dAccelerate;
-
-	float deltaSteering = dt * steer_rate;
-	float dSteering = target_steering - steering;
-	dSteering = CLAMP(dSteering, -deltaSteering, deltaSteering);
-	steering += dSteering;
-
-	// apply these inputs
-	float maxTorque = drive_torque;
-
-	float torque_div = drive_total/2;
-	if (torque_div>0)
-		maxTorque/=torque_div;
-
-
-	float alpha = ABS(max_steer_angle * steering);
-	float angleSgn = steering > 0.0f ? 1.0f : -1.0f;
-
-	int wheels_on_floor=0;
-
-	for(int i=0;i<wheels.size();i++) {
-
-		CarWheel *w=wheels[i];
-		if (w->type_drive)
-			w->driveTorque+=maxTorque * accelerate;
-		w->locked = !w->type_steer && (hand_brake > 0.5f);
-
-		if (w->type_steer) {
-			//steering
-
-			bool inner = (steering > 0 && w->local_xform.origin.x > 0) || (steering < 0 && w->local_xform.origin.x < 0);
-
-			if (inner || alpha==0.0) {
-
-				w->steerAngle = (angleSgn * alpha);
-			} else {
-				float dx = aabb.size.z;
-				float dy = aabb.size.x;
-
-				float beta = Math::atan2(dy, dx + (dy / (float)Math::tan(Math::deg2rad(alpha))));
-				beta = Math::rad2deg(beta);
-				w->steerAngle = (angleSgn * beta);
-
-			}
-		}
-
-		if (w->add_forces(state))
-			wheels_on_floor++;
-		w->update(dt);
-
-
-	}
-
-	print_line("onfloor: "+itos(wheels_on_floor));
-
-
-	set_ignore_transform_notification(true);
-	set_global_transform(state->get_transform());
-	linear_velocity=state->get_linear_velocity();
-	angular_velocity=state->get_angular_velocity();
-	//active=!state->is_sleeping();
-	//if (get_script_instance())
-	//	get_script_instance()->call("_integrate_forces",state);
-	set_ignore_transform_notification(false);
-
-
-}
-
-void CarBody::set_mass(real_t p_mass) {
-
-	mass=p_mass;
-	PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_MASS,mass);
-}
-
-real_t CarBody::get_mass() const{
-
-	return mass;
-}
-
-
-void CarBody::set_friction(real_t p_friction) {
-
-	friction=p_friction;
-	PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_FRICTION,friction);
-}
-
-real_t CarBody::get_friction() const{
-
-	return friction;
-}
-
-
-void CarBody::_bind_methods() {
-
-	ObjectTypeDB::bind_method(_MD("set_max_steer_angle","value"),&CarBody::set_max_steer_angle);
-	ObjectTypeDB::bind_method(_MD("set_steer_rate","rate"),&CarBody::set_steer_rate);
-	ObjectTypeDB::bind_method(_MD("set_drive_torque","value"),&CarBody::set_drive_torque);
-
-	ObjectTypeDB::bind_method(_MD("get_max_steer_angle"),&CarBody::get_max_steer_angle);
-	ObjectTypeDB::bind_method(_MD("get_steer_rate"),&CarBody::get_steer_rate);
-	ObjectTypeDB::bind_method(_MD("get_drive_torque"),&CarBody::get_drive_torque);
-
-	ObjectTypeDB::bind_method(_MD("set_target_steering","amount"),&CarBody::set_target_steering);
-	ObjectTypeDB::bind_method(_MD("set_target_accelerate","amount"),&CarBody::set_target_accelerate);
-	ObjectTypeDB::bind_method(_MD("set_hand_brake","amount"),&CarBody::set_hand_brake);
-
-	ObjectTypeDB::bind_method(_MD("get_target_steering"),&CarBody::get_target_steering);
-	ObjectTypeDB::bind_method(_MD("get_target_accelerate"),&CarBody::get_target_accelerate);
-	ObjectTypeDB::bind_method(_MD("get_hand_brake"),&CarBody::get_hand_brake);
-
-	ObjectTypeDB::bind_method(_MD("set_mass","mass"),&CarBody::set_mass);
-	ObjectTypeDB::bind_method(_MD("get_mass"),&CarBody::get_mass);
-
-	ObjectTypeDB::bind_method(_MD("set_friction","friction"),&CarBody::set_friction);
-	ObjectTypeDB::bind_method(_MD("get_friction"),&CarBody::get_friction);
-
-	ObjectTypeDB::bind_method(_MD("_direct_state_changed"),&CarBody::_direct_state_changed);
-
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"body/mass",PROPERTY_HINT_RANGE,"0.01,65536,0.01"),_SCS("set_mass"),_SCS("get_mass"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"body/friction",PROPERTY_HINT_RANGE,"0.01,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
-
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"config/max_steer_angle",PROPERTY_HINT_RANGE,"1,90,1"),_SCS("set_max_steer_angle"),_SCS("get_max_steer_angle"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"config/drive_torque",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_drive_torque"),_SCS("get_drive_torque"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"config/steer_rate",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_steer_rate"),_SCS("get_steer_rate"));
-
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"drive/target_steering",PROPERTY_HINT_RANGE,"-1,1,0.01"),_SCS("set_target_steering"),_SCS("get_target_steering"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"drive/target_accelerate",PROPERTY_HINT_RANGE,"-1,1,0.01"),_SCS("set_target_accelerate"),_SCS("get_target_accelerate"));
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"drive/hand_brake",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_hand_brake"),_SCS("get_hand_brake"));
-
-}
-
-CarBody::CarBody() : PhysicsBody(PhysicsServer::BODY_MODE_RIGID) {
-
-	forward_drive=true;
-	backward_drive=true;
-	max_steer_angle=30;
-	steer_rate=1;
-	drive_torque=520;
-
-	target_steering=0;
-	target_accelerate=0;
-	hand_brake=0;
-
-	steering=0;
-	accelerate=0;
-
-	mass=1;
-	friction=1;
-
-	ccd=false;
-//	can_sleep=true;
-
-
-
-
-	exclude.insert(get_rid());
-	PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(),this,"_direct_state_changed");
-
-
-}

+ 0 - 170
scene/3d/car_body.h

@@ -1,170 +0,0 @@
-/*************************************************************************/
-/*  car_body.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 CAR_BODY_H
-#define CAR_BODY_H
-
-#include "scene/3d/physics_body.h"
-
-
-class CarBody;
-
-class CarWheel : public Spatial {
-
-	OBJ_TYPE(CarWheel,Spatial);	
-
-friend class CarBody;
-	real_t side_friction;
-	real_t forward_friction;
-	real_t travel;
-	real_t radius;
-	real_t resting_frac;
-	real_t damping_frac;
-	int num_rays;
-	Transform local_xform;
-
-	CarBody *body;
-
-	float angVel;
-	float steerAngle;
-	float torque;
-	float driveTorque;
-	float axisAngle;
-	float upSpeed; // speed relative to the car
-	bool locked;
-	// last frame stuff
-	float lastDisplacement;
-	float angVelForGrip;
-	bool lastOnFloor;
-
-	bool type_drive;
-	bool type_steer;
-
-
-protected:
-	void update(real_t dt);
-	bool add_forces(PhysicsDirectBodyState *s);
-	void _notification(int p_what);
-	static void _bind_methods();
-
-public:
-
-	void set_side_friction(real_t p_friction);
-	void set_forward_friction(real_t p_friction);
-	void set_travel(real_t p_travel);
-	void set_radius(real_t p_radius);
-	void set_resting_frac(real_t p_frac);
-	void set_damping_frac(real_t p_frac);
-	void set_num_rays(real_t p_rays);
-
-	real_t get_side_friction() const;
-	real_t get_forward_friction() const;
-	real_t get_travel() const;
-	real_t get_radius() const;
-	real_t get_resting_frac() const;
-	real_t get_damping_frac() const;
-	int get_num_rays() const;
-
-	void set_type_drive(bool p_enable);
-	bool is_type_drive() const;
-
-	void set_type_steer(bool p_enable);
-	bool is_type_steer() const;
-
-	CarWheel();
-
-};
-
-
-
-class CarBody : public PhysicsBody {
-
-	OBJ_TYPE(CarBody,PhysicsBody);
-
-	real_t mass;
-	real_t friction;
-
-	Vector3 linear_velocity;
-	Vector3  angular_velocity;
-	bool ccd;
-
-	real_t max_steer_angle;
-	real_t steer_rate;
-	int wheel_num_rays;
-	real_t drive_torque;
-
-// control stuff
-	real_t target_steering;
-	real_t target_accelerate;
-
-	bool forward_drive;
-	bool backward_drive;
-
-	real_t steering;
-	real_t accelerate;
-	real_t hand_brake;
-	Set<RID> exclude;
-
-
-friend class CarWheel;
-	Vector<CarWheel*> wheels;
-
-	static void _bind_methods();
-
-	void _direct_state_changed(Object *p_state);
-public:
-
-
-	void set_mass(real_t p_mass);
-	real_t get_mass() const;
-
-	void set_friction(real_t p_friction);
-	real_t get_friction() const;
-
-	void set_max_steer_angle(real_t p_angle);
-	void set_steer_rate(real_t p_rate);
-	void set_drive_torque(real_t p_torque);
-
-	real_t get_max_steer_angle() const;
-	real_t get_steer_rate() const;
-	real_t get_drive_torque() const;
-
-
-	void set_target_steering(float p_steering);
-	void set_target_accelerate(float p_accelerate);
-	void set_hand_brake(float p_amont);
-
-	real_t get_target_steering() const;
-	real_t get_target_accelerate() const;
-	real_t get_hand_brake() const;
-
-
-	CarBody();
-};
-
-#endif // CAR_BODY_H

+ 0 - 85
scene/3d/editable_shape.cpp

@@ -1,85 +0,0 @@
-/*************************************************************************/
-/*  editable_shape.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 "editable_shape.h"
-
-
-void EditableShape::_notification(int p_what) {
-
-
-
-}
-
-
-void EditableShape::set_bsp_tree(const BSP_Tree& p_bsp) {
-
-	bsp=p_bsp;
-}
-
-void EditableShape::set_shape(const Ref<Shape>& p_shape) {
-
-	shape=p_shape;
-}
-
-
-
-EditableShape::EditableShape()
-{
-}
-
-
-
-/////////////////////////
-
-
-void EditableSphere::set_radius(float p_radius) {
-
-	radius=p_radius;
-	update_gizmo();
-	_change_notify("params/radius");
-}
-
-
-float EditableSphere::get_radius() const{
-
-	return radius;
-}
-
-
-void EditableSphere::_bind_methods() {
-
-	ObjectTypeDB::bind_method(_MD("set_radius","radius"),&EditableSphere::set_radius);
-	ObjectTypeDB::bind_method(_MD("get_radius"),&EditableSphere::get_radius);
-
-	ADD_PROPERTY( PropertyInfo(Variant::REAL,"params/radius",PROPERTY_HINT_EXP_RANGE,"0.001,16384,0.001"),_SCS("set_radius"),_SCS("get_radius"));
-}
-
-EditableSphere::EditableSphere() {
-
-	radius=1.0;
-}

+ 0 - 73
scene/3d/editable_shape.h

@@ -1,73 +0,0 @@
-/*************************************************************************/
-/*  editable_shape.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 EDITABLE_SHAPE_H
-#define EDITABLE_SHAPE_H
-
-#include "scene/3d/spatial.h"
-#include "scene/resources/shape.h"
-
-class EditableShape : public Spatial {
-
-	OBJ_TYPE(EditableShape,Spatial);
-
-	//can hold either of those
-	BSP_Tree bsp;
-	Ref<Shape> shape;
-
-	void _update_parent();
-protected:
-
-	void _notification(int p_what);
-
-	void set_bsp_tree(const BSP_Tree& p_bsp);
-	void set_shape(const Ref<Shape>& p_shape);
-public:
-	EditableShape();
-};
-
-
-class EditableSphere : public EditableShape {
-
-	OBJ_TYPE( EditableSphere, EditableShape );
-
-
-	float radius;
-protected:
-
-	static void _bind_methods();
-public:
-
-	void set_radius(float p_radius);
-	float get_radius() const;
-
-	EditableSphere();
-};
-
-
-#endif // EDITABLE_SHAPE_H

+ 1 - 1
scene/SCsub

@@ -15,7 +15,7 @@ SConscript('resources/SCsub');
 SConscript('io/SCsub');
 
 
-lib = env.Library("scene",env.scene_sources, LIBSUFFIX=env['platform_libsuffix'])
+lib = env.Library("scene",env.scene_sources)
 
 env.Prepend(LIBS=[lib])
 

+ 0 - 851
scene/io/scene_format_object.cpp

@@ -1,851 +0,0 @@
-/*************************************************************************/
-/*  scene_format_object.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 "scene_format_object.h"
-#include "print_string.h"
-#include "globals.h"
-#include "scene/resources/packed_scene.h"
-#include "io/resource_loader.h"
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
-void SceneFormatSaverObject::save_node(const Node* p_root,const Node* p_node,const Node* p_owner,ObjectFormatSaver *p_saver,String p_base_path,uint32_t p_flags,Map<const Node*,uint32_t>& owner_id) const {
-
-	if (p_node!=p_root && p_node->get_owner()==NULL)
-		return;
-
-
-	if (p_flags&SceneSaver::FLAG_BUNDLE_INSTANCED_SCENES || p_node->get_owner() == p_owner || p_node == p_owner ) {
-		
-		Dictionary d;
-		if (p_root!=p_node) {
-			d["path"]=p_root->get_path_to(p_node->get_parent());
-		}
-			
-		d["name"]=p_node->get_name();
-		
-		/* Connections */
-
-		List<MethodInfo> signal_list;
-
-		p_node->get_signal_list(&signal_list);
-		
-		int conn_count=0;
-
-		Set<Node::Connection> exclude_connections;
-
-		if (!(p_flags&SceneSaver::FLAG_BUNDLE_INSTANCED_SCENES)) {
-
-			Vector<Node::Connection> ex = p_node->get_instance_connections();
-			for(int i=0;i<ex.size();i++) {
-				exclude_connections.insert(ex[i]);
-			}
-		}
-
-		for (List<MethodInfo>::Element *S=signal_list.front();S;S=S->next()) {
-
-			List<Node::Connection> connections;
-			p_node->get_signal_connection_list(S->get().name,&connections);
-			for(List<Node::Connection>::Element *E=connections.front();E;E=E->next()) {
-
-				Node::Connection &c=E->get();
-				if (!(c.flags&Object::CONNECT_PERSIST))
-					continue;
-				if (exclude_connections.has(c))
-					continue;
-
-				Node *target = c.target->cast_to<Node>();
-				if (!target)
-					continue; //connected to something not a node, ignoring
-
-				Dictionary cd;
-				cd["signal"]=c.signal;
-				cd["target"]=p_node->get_path_to(target);
-				cd["method"]=c.method;
-				cd["realtime"]=!(c.flags&Object::CONNECT_DEFERRED);
-				if (c.binds.size())
-					cd["binds"]=c.binds;
-				d["connection/"+itos(conn_count+1)]=cd;
-
-				conn_count++;
-			}
-		}
-
-		d["connection_count"]=conn_count;
-		if (owner_id.has(p_node->get_owner())) {
-
-			d["owner"]=owner_id[p_node->get_owner()];
-		}
-		
-		/* Groups */
-		
-		DVector<String> group_array;
-		List<Node::GroupInfo> groups;
-		p_node->get_groups(&groups);
-		Set<StringName> exclude_groups;
-
-		if (!(p_flags&SceneSaver::FLAG_BUNDLE_INSTANCED_SCENES)) {
-			//generate groups to exclude (came from instance)
-			Vector<StringName> eg;
-			eg=p_node->get_instance_groups();
-			for(int i=0;i<eg.size();i++)
-				exclude_groups.insert(eg[i]);
-		}
-
-		for(List<Node::GroupInfo>::Element*E=groups.front();E;E=E->next()) {
-			
-			if (E->get().persistent && !exclude_groups.has(E->get().name))
-				group_array.push_back(E->get().name);
-		}
-		
-		if (group_array.size())
-			d["groups"]=group_array;
-
-		/* Save */
-		
-		if (p_owner!=p_node && p_node->get_filename()!="") {
-
-			String instance_path;
-			if (p_flags&SceneSaver::FLAG_RELATIVE_PATHS)
-				instance_path=p_base_path.path_to_file(Globals::get_singleton()->localize_path(p_node->get_filename()));
-			else
-				instance_path=p_node->get_filename();
-			d["instance"]=instance_path;
-
-			if (p_flags&SceneSaver::FLAG_BUNDLE_INSTANCED_SCENES) {
-
-				int id = owner_id.size();
-				d["owner_id"]=id;
-				owner_id[p_node]=id;
-
-				p_saver->save(p_node,d);
-
-				//owner change!
-				for (int i=0;i<p_node->get_child_count();i++) {
-
-					save_node(p_root,p_node->get_child(i),p_node,p_saver,p_base_path,p_flags,owner_id);
-				}
-				return;
-
-			} else {
-				DVector<String> prop_names;
-				Array prop_values;
-
-				List<PropertyInfo> properties;
-				p_node->get_property_list(&properties);
-
-				//instance state makes sure that only changes to instance are saved
-				Dictionary instance_state=p_node->get_instance_state();
-
-				for(List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) {
-
-					if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
-						continue;
-
-					String name=E->get().name;
-					Variant value=p_node->get(E->get().name);
-
-					if (!instance_state.has(name))
-						continue; // did not change since it was loaded, not save
-					if (value==instance_state[name])
-						continue;
-					prop_names.push_back( name );
-					prop_values.push_back( value );
-
-				}
-
-				d["override_names"]=prop_names;
-				d["override_values"]=prop_values;
-
-				p_saver->save(NULL,d);
-			}
-		} else {
-			
-			p_saver->save(p_node,d);	
-		}		
-	}
-	
-	for (int i=0;i<p_node->get_child_count();i++) {
-		
-		save_node(p_root,p_node->get_child(i),p_owner,p_saver,p_base_path,p_flags,owner_id);
-	}
-}
-
-
-Error SceneFormatSaverObject::save(const String &p_path,const Node* p_scene,uint32_t p_flags,const Ref<OptimizedSaver> &p_optimizer) {
-		
-	String extension=p_path.extension();
-	if (extension=="scn")
-		extension="bin";
-	if (extension=="xscn")
-		extension="xml";
-
-	String local_path=Globals::get_singleton()->localize_path(p_path);
-	uint32_t saver_flags=0;
-	if (p_flags&SceneSaver::FLAG_RELATIVE_PATHS)
-		saver_flags|=ObjectSaver::FLAG_RELATIVE_PATHS;
-	if (p_flags&SceneSaver::FLAG_BUNDLE_RESOURCES)
-		saver_flags|=ObjectSaver::FLAG_BUNDLE_RESOURCES;
-	if (p_flags&SceneSaver::FLAG_OMIT_EDITOR_PROPERTIES)
-		saver_flags|=ObjectSaver::FLAG_OMIT_EDITOR_PROPERTIES;
-	if (p_flags&SceneSaver::FLAG_SAVE_BIG_ENDIAN)
-		saver_flags|=ObjectSaver::FLAG_SAVE_BIG_ENDIAN;
-
-	ObjectFormatSaver *saver = ObjectSaver::instance_format_saver(local_path,"SCENE",extension,saver_flags,p_optimizer);
-	
-	ERR_FAIL_COND_V(!saver,ERR_FILE_UNRECOGNIZED);
-	
-	/* SAVE SCENE */
-	
-	Map<const Node*,uint32_t> node_id_map;
-	save_node(p_scene,p_scene,p_scene,saver,local_path,p_flags,node_id_map);
-		
-	memdelete(saver);
-	
-	return OK;
-}
-
-void SceneFormatSaverObject::get_recognized_extensions(List<String> *p_extensions) const {
-	
-	p_extensions->push_back("xml");
-	p_extensions->push_back("scn");
-	p_extensions->push_back("xscn");
-
-//	ObjectSaver::get_recognized_extensions(p_extensions);
-}
-
-
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-
-void SceneFormatLoaderObject::_apply_meta(Node *node,  const Variant&meta, ObjectFormatLoader *p_loader,List<ConnectionItem>& connections,Error& r_err,Map<uint32_t,Node*>& owner_map) {
-
-	r_err = OK;
-
-
-	Dictionary d=meta;
-
-	if (!d.has("name")) {
-
-		r_err=ERR_WTF;
-		memdelete(node);
-		ERR_FAIL_COND(!d.has("name"));
-	}
-
-
-	node->set_name(d["name"]);
-	int connection_count=d.has("connection_count")?d["connection_count"].operator int():0;
-
-
-	for (int i=0;i<connection_count;i++) {
-
-		Dictionary cd=d["connection/"+itos(i+1)];
-
-		ERR_CONTINUE(!cd.has("target"));
-		ERR_CONTINUE(!cd.has("method"));
-		ERR_CONTINUE(!cd.has("realtime"));
-		ERR_CONTINUE(!cd.has("signal"));
-
-		ConnectionItem ci;
-
-		ci.node=node;
-		ci.target=cd["target"];
-		ci.method=cd["method"];
-		ci.signal=cd["signal"];
-		ci.realtime=cd["realtime"];
-		if (cd.has("binds"))
-			ci.binds=cd["binds"];
-
-		connections.push_back(ci);
-
-	}
-
-	DVector<String> groups=d.has("groups")?d["groups"].operator DVector<String>():DVector<String>();
-	for (int i=0;i<groups.size();i++) {
-
-		node->add_to_group(groups[i],true);
-	}
-
-}
-
-
-
-Ref<SceneInteractiveLoader> SceneFormatLoaderObject::load_interactive(const String &p_path,bool p_save_root_state) {
-
-	SceneInteractiveLoaderObject *sil = memnew( SceneInteractiveLoaderObject(p_path,p_save_root_state) );
-
-	if (sil->error!=OK) {
-
-		memdelete( sil );
-		return Ref<SceneInteractiveLoader>();
-	}
-
-	return Ref<SceneInteractiveLoader>( sil );
-
-}
-
-
-Node* SceneFormatLoaderObject::load_node(Object *obj, const Variant& meta, Node *p_root, ObjectFormatLoader *p_loader,List<ConnectionItem>& connections,Error& r_err,bool p_save_instance_state,Map<uint32_t,Node*>& owner_map) {
-
-	r_err = OK;
-		
-	Node *node=obj->cast_to<Node>();
-
-	_apply_meta(node,meta,p_loader,connections,r_err,owner_map);
-	if (r_err!=OK)
-		return NULL;
-
-	Dictionary d=meta;
-
-	if (p_root) {
-		NodePath path=d.has("path")?d["path"].operator NodePath():NodePath("."); 
-
-		Node *parent=p_root->get_node(path);
-		if (!parent) {
-			memdelete(node);
-			r_err=ERR_FILE_CORRUPT;
-			ERR_FAIL_COND_V(!parent,NULL);
-		}
-
-		parent->add_child(node);
-
-		if (d.has("owner_id")) {
-			//is owner
-			owner_map[d["owner_id"]]=node;
-			if (d.has("instance"))
-				node->set_filename(d["instance"]);
-
-		}
-
-		if (d.has("owner")) {
-
-			uint32_t owner = d["owner"];
-			ERR_FAIL_COND_V(!owner_map.has(owner),NULL);
-			node->set_owner(owner_map[owner]);
-		} else {
-
-			node->set_owner(p_root);
-		}
-	}
-	
-	return node;
-}
-
-void SceneFormatLoaderObject::_apply_connections(List<ConnectionItem>& connections) {
-
-	int idx=0;
-	for (List<ConnectionItem>::Element *E=connections.front();E;E=E->next()) {
-
-		ConnectionItem &ci=E->get();
-		Node *target = ci.node->get_node(ci.target);
-		ERR_CONTINUE(!target);
-		ci.node->connect(ci.signal,target,ci.method,ci.binds,(ci.realtime?0:Object::CONNECT_DEFERRED)|Object::CONNECT_PERSIST);
-		idx++;
-	}
-
-}
-
-Node* SceneFormatLoaderObject::load(const String &p_path,bool p_save_instance_state) {
-
-	List<ConnectionItem> connections;
-
-	String extension=p_path.extension();
-	if (extension=="scn")
-		extension="bin";
-	if (extension=="xscn")
-		extension="xml";
-
-	String local_path = Globals::get_singleton()->localize_path(p_path);
-
-	ObjectFormatLoader *loader = ObjectLoader::instance_format_loader(local_path,"SCENE",extension);
-
-	ERR_EXPLAIN("Couldn't load scene: "+p_path);
-	ERR_FAIL_COND_V(!loader,NULL);
-	
-	Node *root=NULL;
-	Map<uint32_t,Node*> owner_map;
-	
-	while(true) {
-	
-		Object *obj=NULL;
-		Variant metav;
-		Error r_err=loader->load(&obj,metav);
-
-		if (r_err == ERR_SKIP) {
-			continue;
-		};
-		
-		if (r_err==ERR_FILE_EOF) {
-			memdelete(loader);
-			ERR_FAIL_COND_V(!root,NULL);
-			_apply_connections(connections);
-			return root;
-		}
-
-		if (r_err || (!obj && metav.get_type()==Variant::NIL)) {
-			memdelete(loader);
-			ERR_EXPLAIN("Object Loader Failed for Scene: "+p_path)	;
-			ERR_FAIL_COND_V( r_err, NULL);
-			ERR_EXPLAIN("Object Loader Failed for Scene: "+p_path)	;
-			ERR_FAIL_COND_V( !obj && metav.get_type()==Variant::NIL,NULL);
-		}
-		
-		if (obj) {
-			if (obj->cast_to<Node>()) {
-			
-				Error err;
-				Node* node = load_node(obj, metav, root, loader,connections,err,p_save_instance_state,owner_map);
-				if (err)
-					memdelete(loader);
-					
-				ERR_FAIL_COND_V( err, NULL );
-				if (!root)
-					root=node;
-			} else {
-			
-				memdelete(loader);
-				ERR_FAIL_V( NULL );
-				
-			}	
-		} else {
-		
-			// check for instance
-			Dictionary meta=metav;
-			if (meta.has("instance")) {
-				if (!root) {
-				
-					memdelete(loader);
-					ERR_FAIL_COND_V(!root,NULL);
-				}
-				
-				String path = meta["instance"];
-
-				if (path.find("://")==-1 && path.is_rel_path()) {
-					// path is relative to file being loaded, so convert to a resource path
-					path=Globals::get_singleton()->localize_path(
-							local_path.get_base_dir()+"/"+path);
-				}				
-
-
-				Node *scene = SceneLoader::load(path);
-
-				if (!scene) {
-
-					Ref<PackedScene> sd = ResourceLoader::load(path);
-					if (sd.is_valid()) {
-
-						scene=sd->instance();
-					}
-				}
-
-				
-				if (!scene) {
-				
-					memdelete(loader);
-					ERR_FAIL_COND_V(!scene,NULL);
-				}
-
-				if (p_save_instance_state)
-					scene->generate_instance_state();
-
-
-				Error err;
-				_apply_meta(scene,metav,loader,connections,err,owner_map);
-				if (err!=OK) {
-					memdelete(loader);
-					ERR_FAIL_COND_V(err!=OK,NULL);
-				}
-				
-				Node *parent=root;
-				
-				if (meta.has("path"))
-					parent=root->get_node(meta["path"]);
-					
-				
-				if (!parent) {
-				
-					memdelete(loader);
-					ERR_FAIL_COND_V(!parent,NULL);
-				}
-				
-
-				if (meta.has("override_names") && meta.has("override_values")) {
-				
-					DVector<String> override_names=meta["override_names"];
-					Array override_values=meta["override_values"];
-					
-					int len = override_names.size();
-					if ( len > 0 && len == override_values.size() ) {
-					
-						DVector<String>::Read names = override_names.read();
-						
-						for(int i=0;i<len;i++) {
-						
-							scene->set(names[i],override_values[i]);
-						}
-					
-					}
-				
-				}
-				
-				scene->set_filename(path);
-
-				parent->add_child(scene);
-				scene->set_owner(root);				
-			}
-		}
-	}
-		
-	return NULL;	
-}
-
-void SceneFormatLoaderObject::get_recognized_extensions(List<String> *p_extensions) const {
-
-	p_extensions->push_back("xml");
-	p_extensions->push_back("scn");
-	p_extensions->push_back("xscn");
-
-//	ObjectLoader::get_recognized_extensions(p_extensions);
-	
-}
-
-
-
-///////////////////////////////////////////////////
-
-
-void SceneInteractiveLoaderObject::_apply_meta(Node *node,  const Variant&meta, ObjectFormatLoader *p_loader,List<ConnectionItem>& connections,Error& r_err,Map<uint32_t,Node*>& owner_map) {
-
-	r_err = OK;
-
-
-	Dictionary d=meta;
-
-	if (!d.has("name")) {
-
-		r_err=ERR_WTF;
-		memdelete(node);
-		ERR_FAIL_COND(!d.has("name"));
-	}
-
-
-	node->set_name(d["name"]);
-	int connection_count=d.has("connection_count")?d["connection_count"].operator int():0;
-
-
-	for (int i=0;i<connection_count;i++) {
-
-		Dictionary cd=d["connection/"+itos(i+1)];
-
-		ERR_CONTINUE(!cd.has("target"));
-		ERR_CONTINUE(!cd.has("method"));
-		ERR_CONTINUE(!cd.has("realtime"));
-		ERR_CONTINUE(!cd.has("signal"));
-
-		ConnectionItem ci;
-
-		ci.node=node;
-		ci.target=cd["target"];
-		ci.method=cd["method"];
-		ci.signal=cd["signal"];
-		ci.realtime=cd["realtime"];
-		if (cd.has("binds"))
-			ci.binds=cd["binds"];
-
-		connections.push_back(ci);
-
-	}
-
-	DVector<String> groups=d.has("groups")?d["groups"].operator DVector<String>():DVector<String>();
-	for (int i=0;i<groups.size();i++) {
-
-		node->add_to_group(groups[i],true);
-	}
-
-}
-
-
-
-Node* SceneInteractiveLoaderObject::load_node(Object *obj, const Variant& meta, Node *p_root, ObjectFormatLoader *p_loader,List<ConnectionItem>& connections,Error& r_err,bool p_save_instance_state,Map<uint32_t,Node*>& owner_map) {
-
-	r_err = OK;
-
-	Node *node=obj->cast_to<Node>();
-
-	_apply_meta(node,meta,p_loader,connections,r_err,owner_map);
-	if (r_err!=OK)
-		return NULL;
-
-	Dictionary d=meta;
-
-	if (p_root) {
-		NodePath path=d.has("path")?d["path"].operator NodePath():NodePath(".");
-
-		Node *parent=p_root->get_node(path);
-		if (!parent) {
-			memdelete(node);
-			r_err=ERR_FILE_CORRUPT;
-			ERR_FAIL_COND_V(!parent,NULL);
-		}
-
-		parent->add_child(node);
-
-		if (d.has("owner_id")) {
-			//is owner
-			owner_map[d["owner_id"]]=node;
-			if (d.has("instance"))
-				node->set_filename(d["instance"]);
-
-		}
-
-		if (d.has("owner")) {
-
-			uint32_t owner = d["owner"];
-			ERR_FAIL_COND_V(!owner_map.has(owner),NULL);
-			node->set_owner(owner_map[owner]);
-		} else {
-
-			node->set_owner(p_root);
-		}
-	}
-
-	return node;
-}
-
-void SceneInteractiveLoaderObject::_apply_connections(List<ConnectionItem>& connections) {
-
-	int idx=0;
-	for (List<ConnectionItem>::Element *E=connections.front();E;E=E->next()) {
-
-		ConnectionItem &ci=E->get();
-		Node *target = ci.node->get_node(ci.target);
-		ERR_CONTINUE(!target);
-		ci.node->connect(ci.signal,target,ci.method,ci.binds,(ci.realtime?0:Object::CONNECT_DEFERRED)|Object::CONNECT_PERSIST);
-		idx++;
-	}
-
-}
-
-SceneInteractiveLoaderObject::SceneInteractiveLoaderObject(const String &p_path,bool p_save_root_state) {
-
-	error=OK;
-	path=p_path;
-	save_instance_state=p_save_root_state;
-	node_path=p_path;
-	root=NULL;
-	stage_max=1;
-	stage=0;
-
-
-	String extension=p_path.extension();
-	if (extension=="scn")
-		extension="bin";
-	if (extension=="xscn")
-		extension="xml";
-
-	local_path = Globals::get_singleton()->localize_path(p_path);
-
-	loader = ObjectLoader::instance_format_loader(local_path,"SCENE",extension);
-
-	if (!loader) {
-
-		error=ERR_CANT_OPEN;
-	}
-	ERR_EXPLAIN("Couldn't load scene: "+p_path);
-	ERR_FAIL_COND(!loader);
-
-}
-
-
-
-void SceneInteractiveLoaderObject::set_local_path(const String& p_local_path) {
-
-	node_path=p_local_path;
-}
-
-Node *SceneInteractiveLoaderObject::get_scene() {
-
-	if (error==ERR_FILE_EOF)
-		return root;
-	return NULL;
-}
-Error SceneInteractiveLoaderObject::poll() {
-
-	if (error!=OK)
-		return error;
-
-	Object *obj=NULL;
-	Variant metav;
-	Error r_err=loader->load(&obj,metav);
-
-
-	if (r_err == ERR_SKIP) {
-		stage++;
-		return OK;
-	};
-
-	if (r_err==ERR_FILE_EOF) {
-		memdelete(loader);
-		error=ERR_FILE_CORRUPT;
-		ERR_FAIL_COND_V(!root,ERR_FILE_CORRUPT);
-		_apply_connections(connections);
-		error=ERR_FILE_EOF;
-		if (root)
-			root->set_filename(node_path);
-		return error;
-	}
-
-	if (r_err || (!obj && metav.get_type()==Variant::NIL)) {
-		memdelete(loader);
-		error=ERR_FILE_CORRUPT;
-		ERR_EXPLAIN("Object Loader Failed for Scene: "+path);
-		ERR_FAIL_COND_V( r_err, ERR_FILE_CORRUPT);
-		ERR_EXPLAIN("Object Loader Failed for Scene: "+path);
-		ERR_FAIL_COND_V( !obj && metav.get_type()==Variant::NIL,ERR_FILE_CORRUPT);
-	}
-
-	if (obj) {
-		if (obj->cast_to<Node>()) {
-
-			Error err;
-			Node* node = load_node(obj, metav, root, loader,connections,err,save_instance_state,owner_map);
-			if (err) {
-				error=ERR_FILE_CORRUPT;
-				memdelete(loader);
-			}
-
-			ERR_FAIL_COND_V( err, ERR_FILE_CORRUPT );
-			if (!root)
-				root=node;
-		} else {
-
-			error=ERR_FILE_CORRUPT;
-			memdelete(loader);
-			ERR_EXPLAIN("Loaded something not a node.. (?)");
-			ERR_FAIL_V( ERR_FILE_CORRUPT );
-
-		}
-	} else {
-
-		// check for instance
-		Dictionary meta=metav;
-		if (meta.has("instance")) {
-
-			if (!root) {
-
-				error=ERR_FILE_CORRUPT;
-				memdelete(loader);
-				ERR_FAIL_COND_V(!root,ERR_FILE_CORRUPT);
-			}
-
-			String path = meta["instance"];
-
-			if (path.find("://")==-1 && path.is_rel_path()) {
-				// path is relative to file being loaded, so convert to a resource path
-				path=Globals::get_singleton()->localize_path(
-						local_path.get_base_dir()+"/"+path);
-			}
-
-			Node *scene = SceneLoader::load(path);
-
-			if (!scene) {
-
-				error=ERR_FILE_CORRUPT;
-				memdelete(loader);
-				ERR_FAIL_COND_V(!scene,ERR_FILE_CORRUPT);
-			}
-
-			if (save_instance_state)
-				scene->generate_instance_state();
-
-
-			Error err;
-			_apply_meta(scene,metav,loader,connections,err,owner_map);
-			if (err!=OK) {
-				error=ERR_FILE_CORRUPT;
-				memdelete(loader);
-				ERR_FAIL_COND_V(err!=OK,ERR_FILE_CORRUPT);
-			}
-
-			Node *parent=root;
-
-			if (meta.has("path"))
-				parent=root->get_node(meta["path"]);
-
-
-			if (!parent) {
-
-				error=ERR_FILE_CORRUPT;
-				memdelete(loader);
-				ERR_FAIL_COND_V(!parent,ERR_FILE_CORRUPT);
-			}
-
-
-			if (meta.has("override_names") && meta.has("override_values")) {
-
-				DVector<String> override_names=meta["override_names"];
-				Array override_values=meta["override_values"];
-
-				int len = override_names.size();
-				if ( len > 0 && len == override_values.size() ) {
-
-					DVector<String>::Read names = override_names.read();
-
-					for(int i=0;i<len;i++) {
-
-						scene->set(names[i],override_values[i]);
-					}
-
-				}
-
-			}
-
-			scene->set_filename(path);
-
-			parent->add_child(scene);
-			scene->set_owner(root);
-		}
-	}
-
-	stage++;
-	error=OK;
-	return error;
-
-}
-int SceneInteractiveLoaderObject::get_stage() const {
-
-	return stage;
-}
-int SceneInteractiveLoaderObject::get_stage_count() const {
-
-	return stage_max;
-}
-
-
-#endif

+ 0 - 128
scene/io/scene_format_object.h

@@ -1,128 +0,0 @@
-/*************************************************************************/
-/*  scene_format_object.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 SCENE_FORMAT_OBJECT_H
-#define SCENE_FORMAT_OBJECT_H
-
-
-#include "scene/main/node.h"
-#include "scene/io/scene_saver.h"
-#include "scene/io/scene_loader.h"
-#include "io/object_saver.h"
-#include "io/object_loader.h"
-/**
-	@author Juan Linietsky <[email protected]>
-*/
-
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
-class SceneFormatSaverObject : public SceneFormatSaver {
-	
-	void save_node(const Node* p_root,const Node* p_node,const Node* p_owner,ObjectFormatSaver *p_saver,String p_base_path,uint32_t p_flags,Map<const Node*,uint32_t>& owner_id) const;
-		
-public:
-	
-	virtual Error save(const String &p_path,const Node* p_scenezz,uint32_t p_flags=0,const Ref<OptimizedSaver> &p_optimizer=Ref<OptimizedSaver>());
-	virtual void get_recognized_extensions(List<String> *p_extensions) const;
-	virtual ~SceneFormatSaverObject() {}
-};
-
-
-
-class SceneFormatLoaderObject : public SceneFormatLoader {
-	
-
-	struct ConnectionItem {
-		Node *node;
-		NodePath target;
-		StringName method;
-		StringName signal;
-		Vector<Variant> binds;
-		bool realtime;
-	};
-
-	Node* load_node(Object *obj, const Variant& meta, Node *p_root, ObjectFormatLoader *p_loader,List<ConnectionItem>& connections,Error& r_err,bool p_root_scene_hint,Map<uint32_t,Node*>& owner_map);
-	void _apply_connections(List<ConnectionItem>& connections);
-	void _apply_meta(Node *node, const Variant& meta, ObjectFormatLoader *p_loader,List<ConnectionItem>& connections,Error& r_err,Map<uint32_t,Node*>& owner_map);
-
-public:
-	
-	virtual Ref<SceneInteractiveLoader> load_interactive(const String &p_path,bool p_root_scene_hint=false);
-	virtual Node* load(const String &p_path,bool p_save_root_state=false);
-	virtual void get_recognized_extensions(List<String> *p_extensions) const;
-
-};
-
-
-class SceneInteractiveLoaderObject : public SceneInteractiveLoader {
-
-	OBJ_TYPE(SceneInteractiveLoaderObject,SceneInteractiveLoader);
-
-	struct ConnectionItem {
-		Node *node;
-		NodePath target;
-		StringName method;
-		StringName signal;
-		Vector<Variant> binds;
-		bool realtime;
-	};
-	ObjectFormatLoader *loader;
-	String path;
-	String node_path;
-	String local_path;
-	Error error;
-	bool save_instance_state;
-	List<ConnectionItem> connections;
-	Map<uint32_t,Node*> owner_map;
-	Node *root;
-	int stage_max;
-	int stage;
-
-
-	Node* load_node(Object *obj, const Variant& meta, Node *p_root, ObjectFormatLoader *p_loader,List<ConnectionItem>& connections,Error& r_err,bool p_root_scene_hint,Map<uint32_t,Node*>& owner_map);
-	void _apply_connections(List<ConnectionItem>& connections);
-	void _apply_meta(Node *node, const Variant& meta, ObjectFormatLoader *p_loader,List<ConnectionItem>& connections,Error& r_err,Map<uint32_t,Node*>& owner_map);
-
-friend class SceneFormatLoaderObject;
-public:
-
-	virtual void set_local_path(const String& p_local_path);
-	virtual Node *get_scene();
-	virtual Error poll();
-	virtual int get_stage() const;
-	virtual int get_stage_count() const;
-
-
-	SceneInteractiveLoaderObject(const String &p_path,bool p_save_root_state=false);
-};
-
-
-
-#endif
-#endif

+ 0 - 65
scene/io/scene_format_script.cpp

@@ -1,65 +0,0 @@
-/*************************************************************************/
-/*  scene_format_script.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 "scene_format_script.h"
-#if 0
-Node* SceneFormatLoaderScript::load(const String &p_path,bool p_save_instance_state) {
-
-	Ref<Script> script = ResourceLoader::load(p_path);
-	ERR_EXPLAIN("Can't load script-based scene: "+p_path);
-	ERR_FAIL_COND_V(script.is_null(),NULL);
-	ERR_EXPLAIN("Script does not instance in a node: "+p_path);
-	ERR_FAIL_COND_V(script->get_node_type()=="",NULL);
-	String node_type=script->get_node_type();
-	Object *obj = ObjectTypeDB::instance(node_type);
-	ERR_EXPLAIN("Unknown node type for instancing '"+node_type+"' in script: "+p_path);
-	ERR_FAIL_COND_V(!obj,NULL);
-	Node *node = obj->cast_to<Node>();
-	if (!node)
-		memdelete(obj);
-	ERR_EXPLAIN("Node type '"+node_type+"' not of type 'Node'' in script: "+p_path);
-	ERR_FAIL_COND_V(!node,NULL);
-
-	node->set_script(script.get_ref_ptr());
-
-	return node;
-}
-
-void SceneFormatLoaderScript::get_recognized_extensions(List<String> *p_extensions) const {
-
-	for (int i=0;i<ScriptServer::get_language_count();i++) {
-
-		ScriptServer::get_language(i)->get_recognized_extensions(p_extensions);
-	}
-}
-
-
-SceneFormatLoaderScript::SceneFormatLoaderScript()
-{
-}
-#endif

+ 0 - 45
scene/io/scene_format_script.h

@@ -1,45 +0,0 @@
-/*************************************************************************/
-/*  scene_format_script.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 SCENE_FORMAT_SCRIPT_H
-#define SCENE_FORMAT_SCRIPT_H
-
-#include "scene/io/scene_loader.h"
-#include "io/resource_loader.h"
-#if 0
-
-class SceneFormatLoaderScript : public SceneFormatLoader {
-public:
-
-	virtual Node* load(const String &p_path,bool p_save_instance_state=false);
-	virtual void get_recognized_extensions(List<String> *p_extensions) const;
-
-	SceneFormatLoaderScript();
-};
-#endif
-#endif // SCENE_FORMAT_SCRIPT_H

+ 0 - 161
scene/io/scene_loader.cpp

@@ -1,161 +0,0 @@
-/*************************************************************************/
-/*  scene_loader.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 "scene_loader.h"
-#include "globals.h"
-#include "path_remap.h"
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
-SceneFormatLoader *SceneLoader::loader[MAX_LOADERS];
-
-int SceneLoader::loader_count=0;
-
-
-void SceneInteractiveLoader::_bind_methods() {
-
-	ObjectTypeDB::bind_method(_MD("get_scene"),&SceneInteractiveLoader::get_scene);
-	ObjectTypeDB::bind_method(_MD("poll"),&SceneInteractiveLoader::poll);
-	ObjectTypeDB::bind_method(_MD("get_stage"),&SceneInteractiveLoader::get_stage);
-	ObjectTypeDB::bind_method(_MD("get_stage_count"),&SceneInteractiveLoader::get_stage_count);
-}
-
-class SceneInteractiveLoaderDefault : public SceneInteractiveLoader {
-
-	OBJ_TYPE( SceneInteractiveLoaderDefault, SceneInteractiveLoader );
-public:
-	Node *scene;
-
-	virtual void set_local_path(const String& p_local_path) { scene->set_filename(p_local_path); }
-	virtual Node *get_scene() { return scene; }
-	virtual Error poll() { return ERR_FILE_EOF; }
-	virtual int get_stage() const { return 1; }
-	virtual int get_stage_count() const { return 1; }
-
-	SceneInteractiveLoaderDefault() {}
-};
-
-
-Ref<SceneInteractiveLoader> SceneFormatLoader::load_interactive(const String &p_path,bool p_root_scene_hint) {
-
-	Node *scene = load(p_path,p_root_scene_hint);
-	if (!scene)
-		return Ref<SceneInteractiveLoader>();
-	Ref<SceneInteractiveLoaderDefault> sil = Ref<SceneInteractiveLoaderDefault>( memnew( SceneInteractiveLoaderDefault ));
-	sil->scene=scene;
-	return sil;
-}
-
-
-
-bool SceneFormatLoader::recognize(const String& p_extension) const {
-	
-	
-	List<String> extensions;
-	get_recognized_extensions(&extensions);
-	for (List<String>::Element *E=extensions.front();E;E=E->next()) {
-		
-		if (E->get().nocasecmp_to(p_extension.extension())==0)
-			return true;
-	}
-	
-	return false;
-}
-
-Ref<SceneInteractiveLoader> SceneLoader::load_interactive(const String &p_path,bool p_save_root_state) {
-
-	String local_path=Globals::get_singleton()->localize_path(p_path);
-
-	String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
-	String extension=remapped_path.extension();
-
-	for (int i=0;i<loader_count;i++) {
-
-		if (!loader[i]->recognize(extension))
-			continue;
-		Ref<SceneInteractiveLoader> il = loader[i]->load_interactive(remapped_path,p_save_root_state);
-
-		if (il.is_null() && remapped_path!=local_path)
-			il = loader[i]->load_interactive(local_path,p_save_root_state);
-
-		ERR_EXPLAIN("Error loading scene: "+local_path);
-		ERR_FAIL_COND_V(il.is_null(),Ref<SceneInteractiveLoader>());
-		il->set_local_path(local_path);
-
-		return il;
-	}
-
-	ERR_EXPLAIN("No loader found for scene: "+p_path);
-	ERR_FAIL_V(Ref<SceneInteractiveLoader>());
-	return Ref<SceneInteractiveLoader>();
-}
-
-Node* SceneLoader::load(const String &p_path,bool p_root_scene_hint) {
-
-	String local_path=Globals::get_singleton()->localize_path(p_path);
-
-	String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
-	String extension=remapped_path.extension();
-
-	for (int i=0;i<loader_count;i++) {
-		
-		if (!loader[i]->recognize(extension))
-			continue;
-		Node*node = loader[i]->load(remapped_path,p_root_scene_hint);
-
-		if (!node && remapped_path!=local_path)
-			node = loader[i]->load(local_path,p_root_scene_hint);
-
-		ERR_EXPLAIN("Error loading scene: "+local_path);
-		ERR_FAIL_COND_V(!node,NULL);
-		node->set_filename(local_path);
-
-		return node;
-	}
-
-	ERR_EXPLAIN("No loader found for scene: "+p_path);
-	ERR_FAIL_V(NULL);
-}
-
-void SceneLoader::get_recognized_extensions(List<String> *p_extensions) {
-	
-	for (int i=0;i<loader_count;i++) {
-		
-		loader[i]->get_recognized_extensions(p_extensions);
-	}
-	
-}
-
-void SceneLoader::add_scene_format_loader(SceneFormatLoader *p_format_loader) {
-	
-	ERR_FAIL_COND( loader_count >= MAX_LOADERS );
-	loader[loader_count++]=p_format_loader;
-}
-
-
-#endif

+ 0 - 90
scene/io/scene_loader.h

@@ -1,90 +0,0 @@
-/*************************************************************************/
-/*  scene_loader.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 SCENE_LOADER_H
-#define SCENE_LOADER_H
-
-#include "scene/main/node.h"
-
-/**
-	@author Juan Linietsky <[email protected]>
-*/
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
-class SceneInteractiveLoader : public Reference {
-
-	OBJ_TYPE(SceneInteractiveLoader,Reference);
-protected:
-
-	static void _bind_methods();
-public:
-
-	virtual void set_local_path(const String& p_local_path)=0;
-	virtual Node *get_scene()=0;
-	virtual Error poll()=0;
-	virtual int get_stage() const=0;
-	virtual int get_stage_count() const=0;
-
-
-	SceneInteractiveLoader() {}
-};
-
-class SceneFormatLoader {
-public:
-	
-	virtual Ref<SceneInteractiveLoader> load_interactive(const String &p_path,bool p_root_scene_hint=false);
-	virtual Node* load(const String &p_path,bool p_root_scene_hint=false)=0;
-	virtual void get_recognized_extensions(List<String> *p_extensions) const=0;
-	bool recognize(const String& p_extension) const;
-		
-	virtual ~SceneFormatLoader() {}
-};
-
-class SceneLoader {	
-	
-	enum {
-		MAX_LOADERS=64
-	};
-	
-	static SceneFormatLoader *loader[MAX_LOADERS];
-	static int loader_count;
-	
-public:
-	
-	static Ref<SceneInteractiveLoader> load_interactive(const String &p_path,bool p_save_root_state=false);
-	static Node* load(const String &p_path,bool p_save_root_state=false);
-	static void add_scene_format_loader(SceneFormatLoader *p_format_loader);
-	static void get_recognized_extensions(List<String> *p_extensions);
-	
-	
-};
-
-#endif
-
-#endif

+ 0 - 94
scene/io/scene_saver.cpp

@@ -1,94 +0,0 @@
-/*************************************************************************/
-/*  scene_saver.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 "scene_saver.h"
-#include "print_string.h"
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-SceneFormatSaver *SceneSaver::saver[MAX_SAVERS];
-
-int SceneSaver::saver_count=0;
-
-bool SceneFormatSaver::recognize(const String& p_extension) const {
-	
-	
-	List<String> extensions;
-	get_recognized_extensions(&extensions);
-	for (List<String>::Element *E=extensions.front();E;E=E->next()) {
-		
-
-		if (E->get().nocasecmp_to(p_extension.extension())==0)
-			return true;
-	}
-	
-	return false;
-}
-
-Error SceneSaver::save(const String &p_path,const Node* p_scene,uint32_t p_flags,const Ref<OptimizedSaver> &p_optimizer) {
-	
-	String extension=p_path.extension();
-	Error err=ERR_FILE_UNRECOGNIZED;
-	bool recognized=false;
-	
-	for (int i=0;i<saver_count;i++) {
-		
-		if (!saver[i]->recognize(extension))
-			continue;
-		recognized=true;
-		err = saver[i]->save(p_path,p_scene,p_flags,p_optimizer);
-		if (err == OK )
-			return OK;
-	}
-
-	if (err) {
-		if (!recognized) {
-			ERR_EXPLAIN("No saver format found for scene: "+p_path);
-		} else {
-			ERR_EXPLAIN("Couldn't save scene: "+p_path);
-		}
-		ERR_FAIL_V(err);
-	}
-	
-	return err;
-}
-
-void SceneSaver::get_recognized_extensions(List<String> *p_extensions) {
-	
-	for (int i=0;i<saver_count;i++) {
-		
-		saver[i]->get_recognized_extensions(p_extensions);
-	}		
-}
-
-void SceneSaver::add_scene_format_saver(SceneFormatSaver *p_format_saver) {
-	
-	ERR_FAIL_COND( saver_count >= MAX_SAVERS );
-	saver[saver_count++]=p_format_saver;
-}
-
-#endif

+ 0 - 80
scene/io/scene_saver.h

@@ -1,80 +0,0 @@
-/*************************************************************************/
-/*  scene_saver.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 SCENE_SAVER_H
-#define SCENE_SAVER_H
-
-#include "scene/main/node.h"
-#include "io/object_saver.h"
-/**
-	@author Juan Linietsky <[email protected]>
-*/
-
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
-class SceneFormatSaver {
-public:
-	
-	virtual Error save(const String &p_path,const Node* p_scen,uint32_t p_flags=0,const Ref<OptimizedSaver> &p_optimizer=Ref<OptimizedSaver>())=0;
-	virtual void get_recognized_extensions(List<String> *p_extensions) const=0;
-	bool recognize(const String& p_extension) const;
-	virtual ~SceneFormatSaver() {}
-};
-
-
-
-
-class SceneSaver {	
-	
-	enum {
-		MAX_SAVERS=64
-	};
-	
-	static SceneFormatSaver *saver[MAX_SAVERS];
-	static int saver_count;
-	
-public:
-	enum SaverFlags {
-
-		FLAG_RELATIVE_PATHS=1,
-		FLAG_BUNDLE_RESOURCES=2,
-		FLAG_BUNDLE_INSTANCED_SCENES=4,
-		FLAG_OMIT_EDITOR_PROPERTIES=8,
-		FLAG_SAVE_BIG_ENDIAN=16
-	};
-
-	static Error save(const String &p_path,const Node* p_scenezz,uint32_t p_flags=0,const Ref<OptimizedSaver> &p_optimizer=Ref<OptimizedSaver>());
-	static void add_scene_format_saver(SceneFormatSaver *p_format_saver);
-	static void get_recognized_extensions(List<String> *p_extensions);
-};
-
-
-
-#endif
-#endif

+ 0 - 1
scene/main/node.cpp

@@ -28,7 +28,6 @@
 /*************************************************************************/
 #include "node.h"
 #include "print_string.h"
-#include "scene/io/scene_loader.h"
 #include "message_queue.h"
 #include "scene/scene_string_names.h"
 #include "scene/resources/packed_scene.h"

+ 9 - 47
scene/register_scene_types.cpp

@@ -32,7 +32,7 @@
 #include "scene/io/resource_format_image.h"
 #include "scene/io/resource_format_wav.h"
 
-#include "scene/io/scene_format_script.h"
+//#include "scene/io/scene_format_script.h"
 #include "resources/default_theme/default_theme.h"
 #include "object_type_db.h"
 #include "scene/main/canvas_layer.h"
@@ -120,7 +120,7 @@
 #include "scene/resources/scene_preloader.h"
 
 #include "scene/main/timer.h"
-#include "scene/io/scene_format_object.h"
+
 #include "scene/audio/stream_player.h"
 #include "scene/audio/event_player.h"
 #include "scene/audio/sound_room_params.h"
@@ -142,7 +142,7 @@
 
 #include "scene/resources/mesh_library.h"
 
-#include "scene/resources/image_path_finder.h"
+
 #include "scene/resources/polygon_path_finder.h"
 
 #include "scene/resources/sample.h"
@@ -174,7 +174,7 @@
 
 #ifndef _3D_DISABLED
 #include "scene/3d/camera.h"
-#include "scene/3d/editable_shape.h"
+
 #include "scene/3d/interpolated_camera.h"
 #include "scene/3d/follow_camera.h"
 #include "scene/3d/position_3d.h"
@@ -186,7 +186,7 @@
 #include "scene/3d/portal.h"
 #include "scene/resources/environment.h"
 #include "scene/3d/physics_body.h"
-#include "scene/3d/car_body.h"
+
 #include "scene/3d/vehicle_body.h"
 #include "scene/3d/body_shape.h"
 #include "scene/3d/area.h"
@@ -204,7 +204,7 @@
 #include "scene/3d/collision_polygon.h"
 #endif
 
-#include "scene/scene_binds.h"
+
 
 static ResourceFormatLoaderImage *resource_loader_image=NULL;
 static ResourceFormatLoaderWAV *resource_loader_wav=NULL;
@@ -216,15 +216,6 @@ static ResourceFormatLoaderBitMap *resource_loader_bitmap=NULL;
 #endif
 static ResourceFormatLoaderTheme *resource_loader_theme=NULL;
 static ResourceFormatLoaderShader *resource_loader_shader=NULL;
-#ifdef OLD_SCENE_FORMAT_ENABLED
-static SceneFormatSaverObject *scene_saver_object=NULL;
-static SceneFormatLoaderObject *scene_loader_object=NULL;
-//static SceneFormatLoaderScript *scene_loader_script=NULL;
-#endif
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-SceneIO *scene_io=NULL;
-#endif
 
 //static SceneStringNames *string_names;
 
@@ -236,13 +227,6 @@ void register_scene_types() {
 
 	Node::init_node_hrcr();
 
-#ifdef OLD_SCENE_FORMAT_ENABLED
-	ObjectTypeDB::register_type<SceneIO>();
-	ObjectTypeDB::register_virtual_type<SceneInteractiveLoader>();
-	scene_io = memnew( SceneIO );
-	Globals::get_singleton()->add_singleton(Globals::Singleton("SceneIO",scene_io));
-#endif
-
 	resource_loader_image = memnew( ResourceFormatLoaderImage );
 	ResourceLoader::add_resource_format_loader( resource_loader_image );
 
@@ -263,16 +247,6 @@ void register_scene_types() {
 
 	resource_loader_shader = memnew( ResourceFormatLoaderShader );
 	ResourceLoader::add_resource_format_loader( resource_loader_shader );
-#ifdef OLD_SCENE_FORMAT_ENABLED
-	scene_saver_object=memnew( SceneFormatSaverObject );
-	SceneSaver::add_scene_format_saver(scene_saver_object);
-	
-	scene_loader_object=memnew( SceneFormatLoaderObject );
-	SceneLoader::add_scene_format_loader(scene_loader_object);
-
-//	scene_loader_script=memnew( SceneFormatLoaderScript );
-//	SceneLoader::add_scene_format_loader(scene_loader_script);
-#endif
 
 	make_default_theme();
 
@@ -405,8 +379,8 @@ void register_scene_types() {
 	ObjectTypeDB::register_type<StaticBody>();
 	ObjectTypeDB::register_type<RigidBody>();
 	ObjectTypeDB::register_type<KinematicBody>();
-	ObjectTypeDB::register_type<CarBody>();
-	ObjectTypeDB::register_type<CarWheel>();
+
+
 	ObjectTypeDB::register_type<VehicleBody>();
 	ObjectTypeDB::register_type<VehicleWheel>();
 	ObjectTypeDB::register_type<Area>();
@@ -414,8 +388,6 @@ void register_scene_types() {
 	ObjectTypeDB::register_type<CollisionShape>();
 	ObjectTypeDB::register_type<CollisionPolygon>();
 	ObjectTypeDB::register_type<RayCast>();
-	ObjectTypeDB::register_virtual_type<EditableShape>();
-	ObjectTypeDB::register_type<EditableSphere>();
 	ObjectTypeDB::register_type<MultiMeshInstance>();
 	ObjectTypeDB::register_type<Room>();
 	ObjectTypeDB::register_type<Curve3D>();
@@ -561,7 +533,7 @@ void register_scene_types() {
 	ObjectTypeDB::register_type<StyleBoxFlat>();
 	ObjectTypeDB::register_type<StyleBoxImageMask>();
 	ObjectTypeDB::register_type<Theme>();
-	ObjectTypeDB::register_type<ImagePathFinder>();
+
 	ObjectTypeDB::register_type<PolygonPathFinder>();
 	ObjectTypeDB::register_type<BitMap>();
 
@@ -592,10 +564,6 @@ void register_scene_types() {
 	OS::get_singleton()->yield(); //may take time to init
 
 	ObjectTypeDB::register_type<PackedScene>();
-#ifdef OLD_SCENE_FORMAT_ENABLED
-	ObjectTypeDB::register_type<ScenePreloader>();
-#endif
-
 
 	ObjectTypeDB::register_type<SceneMainLoop>();
 
@@ -619,11 +587,5 @@ void unregister_scene_types() {
 
 	memdelete( resource_loader_theme );
 	memdelete( resource_loader_shader );
-#ifdef OLD_SCENE_FORMAT_ENABLED
-	memdelete( scene_saver_object );
-	memdelete( scene_loader_object );
-//	memdelete( scene_loader_script );
-	memdelete( scene_io );
-#endif
 	SceneStringNames::free();
 }

+ 0 - 427
scene/resources/image_path_finder.cpp

@@ -1,427 +0,0 @@
-/*************************************************************************/
-/*  image_path_finder.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 "image_path_finder.h"
-
-
-void ImagePathFinder::_unlock() {
-
-	lock=DVector<Cell>::Write();
-	cells=NULL;
-
-}
-
-void ImagePathFinder::_lock() {
-
-	lock = cell_data.write();
-	cells=lock.ptr();
-
-}
-
-
-bool ImagePathFinder::_can_go_straigth(const Point2& p_from, const Point2& p_to) const {
-
-	int x1=p_from.x;
-	int y1=p_from.y;
-	int x2=p_to.x;
-	int y2=p_to.y;
-
-#define _TEST_VALID \
-	{\
-		uint32_t ofs=drawy*width+drawx;\
-		if (cells[ofs].solid) {\
-			if (!((drawx>0 && cells[ofs-1].visited) ||\
-			    (drawx<width-1 && cells[ofs+1].visited) ||\
-			    (drawy>0 && cells[ofs-width].visited) ||\
-			    (drawy<height-1 && cells[ofs+width].visited))) {\
-				return false;\
-			}\
-		}\
-	}\
-
-
-	int n, deltax, deltay, sgndeltax, sgndeltay, deltaxabs, deltayabs, x, y, drawx, drawy;
-	deltax = x2 - x1;
-	deltay = y2 - y1;
-	deltaxabs = ABS(deltax);
-	deltayabs = ABS(deltay);
-	sgndeltax = SGN(deltax);
-	sgndeltay = SGN(deltay);
-	x = deltayabs >> 1;
-	y = deltaxabs >> 1;
-	drawx = x1;
-	drawy = y1;
-	int pc=0;
-
-	_TEST_VALID
-
-	if(deltaxabs >= deltayabs) {
-		for(n = 0; n < deltaxabs; n++) {
-			y += deltayabs;
-			if(y >= deltaxabs){
-				y -= deltaxabs;
-				drawy += sgndeltay;
-			}
-			drawx += sgndeltax;
-			_TEST_VALID
-		}
-	} else {
-		for(n = 0; n < deltayabs; n++) {
-			x += deltaxabs;
-			if(x >= deltayabs) {
-				x -= deltayabs;
-				drawx += sgndeltax;
-			}
-			drawy += sgndeltay;
-			_TEST_VALID
-		}
-	}
-	return true;
-
-
-}
-
-bool ImagePathFinder::_is_linear_path(const Point2& p_from, const Point2& p_to) {
-
-	int x1=p_from.x;
-	int y1=p_from.y;
-	int x2=p_to.x;
-	int y2=p_to.y;
-
-#define _TEST_CELL \
-	if (cells[drawy*width+drawx].solid)\
-		return false;
-
-
-	int n, deltax, deltay, sgndeltax, sgndeltay, deltaxabs, deltayabs, x, y, drawx, drawy;
-	deltax = x2 - x1;
-	deltay = y2 - y1;
-	deltaxabs = ABS(deltax);
-	deltayabs = ABS(deltay);
-	sgndeltax = SGN(deltax);
-	sgndeltay = SGN(deltay);
-	x = deltayabs >> 1;
-	y = deltaxabs >> 1;
-	drawx = x1;
-	drawy = y1;
-	int pc=0;
-
-	_TEST_CELL
-
-	if(deltaxabs >= deltayabs) {
-		for(n = 0; n < deltaxabs; n++) {
-			y += deltayabs;
-			if(y >= deltaxabs){
-				y -= deltaxabs;
-				drawy += sgndeltay;
-			}
-			drawx += sgndeltax;
-			_TEST_CELL
-		}
-	} else {
-		for(n = 0; n < deltayabs; n++) {
-			x += deltaxabs;
-			if(x >= deltayabs) {
-				x -= deltayabs;
-				drawx += sgndeltax;
-			}
-			drawy += sgndeltay;
-			_TEST_CELL
-		}
-	}
-	return true;
-}
-
-
-DVector<Point2> ImagePathFinder::find_path(const Point2& p_from, const Point2& p_to,bool p_optimize) {
-
-
-	Point2i from=p_from;
-	Point2i to=p_to;
-
-	ERR_FAIL_COND_V(from.x < 0,DVector<Point2>());
-	ERR_FAIL_COND_V(from.y < 0,DVector<Point2>());
-	ERR_FAIL_COND_V(from.x >=width,DVector<Point2>());
-	ERR_FAIL_COND_V(from.y >=height,DVector<Point2>());
-	ERR_FAIL_COND_V(to.x < 0,DVector<Point2>());
-	ERR_FAIL_COND_V(to.y < 0,DVector<Point2>());
-	ERR_FAIL_COND_V(to.x >=width,DVector<Point2>());
-	ERR_FAIL_COND_V(to.y >=height,DVector<Point2>());
-
-	if (from==to) {
-		DVector<Point2> p;
-		p.push_back(from);
-		return p;
-	}
-
-	_lock();
-
-
-	if (p_optimize) { //try a line first
-
-		if (_is_linear_path(p_from,p_to)) {
-			_unlock();
-			DVector<Point2> p;
-			p.push_back(from);
-			p.push_back(to);
-			return p;
-		}
-	}
-
-
-	//clear all
-	for(int i=0;i<width*height;i++) {
-
-		bool s = cells[i].solid;
-		cells[i].data=0;
-		cells[i].solid=s;
-	}
-
-#define CELL_INDEX(m_p) (m_p.y*width+m_p.x)
-#define CELL_COST(m_p) (cells[CELL_INDEX(m_p)].cost+( ABS(m_p.x-to.x)+ABS(m_p.y-to.y))*10)
-
-
-	Set<Point2i> pending;
-	pending.insert(from);
-
-	//helper constants
-	static const Point2i neighbour_rel[8]={
-		Point2i(-1,-1), //0
-		Point2i(-1, 0), //1
-		Point2i(-1,+1), //2
-		Point2i( 0,-1), //3
-		Point2i( 0,+1), //4
-		Point2i(+1,-1), //5
-		Point2i(+1, 0), //6
-		Point2i(+1,+1) }; //7
-
-	static const int neighbour_cost[8]={
-		14,
-		10,
-		14,
-		10,
-		10,
-		14,
-		10,
-		14
-	};
-
-	static const int neighbour_parent[8]={
-		7,
-		6,
-		5,
-		4,
-		3,
-		2,
-		1,
-		0,
-	};
-
-	while(true) {
-
-		if (pending.size() == 0) {
-			_unlock();
-			return DVector<Point2>(); // points don't connect
-		}
-		Point2i current;
-		int lc=0x7FFFFFFF;
-		{ //find the one with the least cost
-
-			Set<Point2i>::Element *Efound=NULL;
-			for (Set<Point2i>::Element *E=pending.front();E;E=E->next()) {
-
-				int cc =CELL_COST(E->get());
-				if (cc<lc) {
-					lc=cc;
-					current=E->get();
-					Efound=E;
-
-				}
-
-			}
-			pending.erase(Efound);
-		}
-
-		Cell &c = cells[CELL_INDEX(current)];
-
-		//search around other cells
-
-
-		int accum_cost = (from==current) ? 0 : cells[CELL_INDEX((current + neighbour_rel[c.parent]))].cost;
-
-		bool done=false;
-
-		for(int i=0;i<8;i++) {
-
-			Point2i neighbour=current+neighbour_rel[i];
-			if (neighbour.x<0 || neighbour.y<0 || neighbour.x>=width || neighbour.y>=height)
-				continue;
-
-			Cell &n = cells[CELL_INDEX(neighbour)];
-			if (n.solid)
-				continue; //no good
-
-			int cost = neighbour_cost[i]+accum_cost;
-
-			if (n.visited && n.cost < cost)
-				continue;
-
-			n.cost=cost;
-			n.parent=neighbour_parent[i];
-			n.visited=true;
-			pending.insert(neighbour);
-			if (neighbour==to)
-				done=true;
-
-		}
-
-		if (done)
-			break;
-	}
-
-
-	// go througuh poins twice, first compute amount, then add them
-
-	Point2i current=to;
-	int pcount=0;
-
-	while(true) {
-
-		Cell &c = cells[CELL_INDEX(current)];
-		c.visited=true;
-		pcount++;
-		if (current==from)
-			break;
-		current+=neighbour_rel[ c.parent ];
-	}
-
-	//now place them in an array
-	DVector<Vector2> result;
-	result.resize(pcount);
-
-	DVector<Vector2>::Write res=result.write();
-
-	current=to;
-	int pidx=pcount-1;
-
-	while(true) {
-
-		Cell &c = cells[CELL_INDEX(current)];
-		res[pidx]=current;
-		pidx--;
-		if (current==from)
-			break;
-		current+=neighbour_rel[ c.parent ];
-	}
-
-
-	//simplify..
-
-
-	if (p_optimize) {
-
-		int p=pcount-1;
-		while(p>0) {
-
-
-			int limit=p;
-			while(limit>0) {
-
-				limit--;
-				if (!_can_go_straigth(res[p],res[limit]))
-					break;
-			}
-
-
-			if (limit<p-1) {
-				int diff = p-limit-1;
-				pcount-=diff;
-				for(int i=limit+1;i<pcount;i++) {
-
-					res[i]=res[i+diff];
-				}
-			}
-			p=limit;
-		}
-	}
-
-	res=DVector<Vector2>::Write();
-	result.resize(pcount);
-	return result;
-}
-
-Size2 ImagePathFinder::get_size() const {
-
-	return Size2(width,height);
-}
-bool ImagePathFinder::is_solid(const Point2& p_pos) {
-
-
-	Point2i pos = p_pos;
-
-	ERR_FAIL_COND_V(pos.x<0,true);
-	ERR_FAIL_COND_V(pos.y<0,true);
-	ERR_FAIL_COND_V(pos.x>=width,true);
-	ERR_FAIL_COND_V(pos.y>=height,true);
-
-	return cell_data[pos.y*width+pos.x].solid;
-}
-
-void ImagePathFinder::create_from_image_alpha(const Image& p_image) {
-
-	ERR_FAIL_COND(p_image.get_format() != Image::FORMAT_RGBA);
-	width = p_image.get_width();
-	height = p_image.get_height();
-	DVector<uint8_t> data = p_image.get_data();
-	cell_data.resize(width * height);
-	DVector<uint8_t>::Read read = data.read();
-	DVector<Cell>::Write write = cell_data.write();
-	for (int i=0; i<width * height; i++) {
-		Cell cell;
-		cell.data = 0;
-		cell.solid = read[i*4+3] < 128;
-		write[i] = cell;
-	};
-};
-
-
-void ImagePathFinder::_bind_methods() {
-
-	ObjectTypeDB::bind_method(_MD("find_path","from","to","optimize"),&ImagePathFinder::find_path,DEFVAL(false));
-	ObjectTypeDB::bind_method(_MD("get_size"),&ImagePathFinder::get_size);
-	ObjectTypeDB::bind_method(_MD("is_solid","pos"),&ImagePathFinder::is_solid);
-	ObjectTypeDB::bind_method(_MD("create_from_image_alpha"),&ImagePathFinder::create_from_image_alpha);
-}
-
-ImagePathFinder::ImagePathFinder()
-{
-
-	cells=NULL;
-	width=0;
-	height=0;
-}

+ 0 - 84
scene/resources/image_path_finder.h

@@ -1,84 +0,0 @@
-/*************************************************************************/
-/*  image_path_finder.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 IMAGE_PATH_FINDER_H
-#define IMAGE_PATH_FINDER_H
-
-#include "resource.h"
-
-class ImagePathFinder : public Resource{
-
-
-	OBJ_TYPE(ImagePathFinder,Resource);
-	union Cell {
-
-		struct {
-			bool solid:1;
-			bool visited:1;
-			bool final:1;
-			uint8_t parent:3;
-			uint32_t cost:26;
-		};
-
-		uint32_t data;
-	};
-
-
-
-
-
-	DVector<Cell>::Write lock;
-	DVector<Cell> cell_data;
-
-	uint32_t width;
-	uint32_t height;
-	Cell* cells; //when unlocked
-
-	void _unlock();
-	void _lock();
-
-
-	_FORCE_INLINE_ bool _can_go_straigth(const Point2& p_from, const Point2& p_to) const;
-	_FORCE_INLINE_ bool _is_linear_path(const Point2& p_from, const Point2& p_to);
-
-protected:
-
-	static void _bind_methods();
-public:
-
-	DVector<Point2> find_path(const Point2& p_from, const Point2& p_to,bool p_optimize=false);
-	Size2 get_size() const;
-	bool is_solid(const Point2& p_pos);
-	void create_from_image_alpha(const Image& p_image);
-
-
-
-	ImagePathFinder();
-};
-
-#endif // IMAGE_PATH_FINDER_H

+ 23 - 3
scene/resources/packed_scene.cpp

@@ -29,6 +29,9 @@
 #include "packed_scene.h"
 #include "globals.h"
 #include "io/resource_loader.h"
+#include "scene/3d/spatial.h"
+#include "scene/gui/control.h"
+#include "scene/2d/node_2d.h"
 
 bool PackedScene::can_instance() const {
 
@@ -80,9 +83,26 @@ Node *PackedScene::instance(bool p_gen_edit_state) const {
 		} else {
 			//create anew
 			Object * obj = ObjectTypeDB::instance(snames[ n.type ]);
-			ERR_FAIL_COND_V(!obj,NULL);
-			node = obj->cast_to<Node>();
-			ERR_FAIL_COND_V(!node,NULL);
+			if (!obj || !obj->cast_to<Node>()) {
+				if (obj) {
+					memdelete(obj);
+					obj=NULL;
+				}
+				WARN_PRINT(String("Warning node of type "+snames[n.type].operator String()+" does not exist.").ascii().get_data());
+				if (n.parent>=0 && n.parent<nc && ret_nodes[n.parent]) {
+					if (ret_nodes[n.parent]->cast_to<Spatial>()) {
+						obj = memnew( Spatial );
+					} else if (ret_nodes[n.parent]->cast_to<Control>()) {
+						obj = memnew( Control );
+					} else if (ret_nodes[n.parent]->cast_to<Node2D>()) {
+						obj = memnew( Node2D );
+					}
+
+				}
+				if (!obj) {
+					obj = memnew( Node );
+				}
+			}
 
 		}
 

+ 426 - 427
scene/resources/scene_preloader.cpp

@@ -26,430 +26,429 @@
 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
 /*************************************************************************/
-#include "scene_preloader.h"
-#include "scene/io/scene_loader.h"
-#include "globals.h"
-
-bool ScenePreloader::can_instance() const {
-
-	return nodes.size()>0;
-}
-
-Node *ScenePreloader::instance() const {
-
-	int nc = nodes.size();
-	ERR_FAIL_COND_V(nc==0,NULL);
-
-	const StringName*snames=NULL;
-	int sname_count=names.size();
-	if (sname_count)
-		snames=&names[0];
-
-	const Variant*props=NULL;
-	int prop_count=variants.size();
-	if (prop_count)
-		props=&variants[0];
-
-	Vector<Variant> properties;
-
-	const NodeData *nd = &nodes[0];
-
-	Node **ret_nodes=(Node**)alloca( sizeof(Node*)*nc );
-
-	for(int i=0;i<nc;i++) {
-
-		const NodeData &n=nd[i];
-
-
-		if (!ObjectTypeDB::is_type_enabled(snames[n.type])) {
-			ret_nodes[i]=NULL;
-			continue;
-		}
-
-		Object * obj = ObjectTypeDB::instance(snames[ n.type ]);
-		ERR_FAIL_COND_V(!obj,NULL);
-		Node *node = obj->cast_to<Node>();
-		ERR_FAIL_COND_V(!node,NULL);
-
-		int nprop_count=n.properties.size();
-		if (nprop_count) {
-
-			const NodeData::Property* nprops=&n.properties[0];
-
-			for(int j=0;j<nprop_count;j++) {
-
-				bool valid;
-				node->set(snames[ nprops[j].name ],props[ nprops[j].value ],&valid);
-			}
-
-
-		}
-
-		node->set_name( snames[ n.name ] );
-		ret_nodes[i]=node;
-		if (i>0) {
-			ERR_FAIL_INDEX_V(n.parent,i,NULL);
-			ERR_FAIL_COND_V(!ret_nodes[n.parent],NULL);
-			ret_nodes[n.parent]->add_child(node);
-		}
-	}
-
-
-	//do connections
-
-	int cc = connections.size();
-	const ConnectionData *cdata = connections.ptr();
-
-	for(int i=0;i<cc;i++) {
-
-		const ConnectionData &c=cdata[i];
-		ERR_FAIL_INDEX_V( c.from, nc, NULL );
-		ERR_FAIL_INDEX_V( c.to, nc, NULL );
-
-		Vector<Variant> binds;
-		if (c.binds.size()) {
-			binds.resize(c.binds.size());
-			for(int j=0;j<c.binds.size();j++)
-				binds[j]=props[ c.binds[j] ];
-		}
-
-		if (!ret_nodes[c.from] || !ret_nodes[c.to])
-			continue;
-		ret_nodes[c.from]->connect( snames[ c.signal], ret_nodes[ c.to ], snames[ c.method], binds,CONNECT_PERSIST );
-	}
-
-	return ret_nodes[0];
-
-}
-
-
-static int _nm_get_string(const String& p_string, Map<StringName,int> &name_map) {
-
-	if (name_map.has(p_string))
-		return name_map[p_string];
-
-	int idx = name_map.size();
-	name_map[p_string]=idx;
-	return idx;
-}
-
-static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher> &variant_map) {
-
-	if (variant_map.has(p_variant))
-		return variant_map[p_variant];
-
-	int idx = variant_map.size();
-	variant_map[p_variant]=idx;
-	return idx;
-}
-
-void ScenePreloader::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map) {
-
-	if (p_node!=p_owner && !p_node->get_owner())
-		return;
-
-	NodeData nd;
-	nd.name=_nm_get_string(p_node->get_name(),name_map);
-	nd.type=_nm_get_string(p_node->get_type(),name_map);
-	nd.parent=p_parent_idx;
-
-	List<PropertyInfo> plist;
-	p_node->get_property_list(&plist);
-	for (List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) {
-
-		if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
-			continue;
-
-		NodeData::Property prop;
-		prop.name=_nm_get_string(E->get().name,name_map);
-		prop.value=_vm_get_variant( p_node->get( E->get().name ), variant_map);
-		nd.properties.push_back(prop);
-	}
-
-	int idx = nodes.size();
-	node_map[p_node]=idx;
-	nodes.push_back(nd);
-
-	for(int i=0;i<p_node->get_child_count();i++) {
-
-		Node *c=p_node->get_child(i);
-		_parse_node(p_owner,c,idx,name_map,variant_map,node_map);
-	}
-
-
-
-}
-
-void ScenePreloader::_parse_connections(Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,bool p_instance) {
-
-
-	List<MethodInfo> signals;
-	p_node->get_signal_list(&signals);
-
-	for(List<MethodInfo>::Element *E=signals.front();E;E=E->next()) {
-
-		List<Node::Connection> conns;
-		p_node->get_signal_connection_list(E->get().name,&conns);
-		for(List<Node::Connection>::Element *F=conns.front();F;F=F->next()) {
-
-			const Node::Connection &c = F->get();
-			if (!(c.flags&CONNECT_PERSIST))
-				continue;
-			Node *n=c.target->cast_to<Node>();
-			if (!n)
-				continue;
-
-			if (!node_map.has(n))
-				continue;
-
-			ConnectionData cd;
-			cd.from=node_map[p_node];
-			cd.to=node_map[n];
-			cd.method=_nm_get_string(c.method,name_map);
-			cd.signal=_nm_get_string(c.signal,name_map);
-			for(int i=0;i<c.binds.size();i++) {
-
-				cd.binds.push_back( _vm_get_variant(c.binds[i],variant_map));
-			}
-			connections.push_back(cd);
-		}
-	}
-
-}
-
-
-Error ScenePreloader::load_scene(const String& p_path) {
-
-	return ERR_CANT_OPEN;
-#if 0
-	if (path==p_path)
-		return OK;
-
-	String p=Globals::get_singleton()->localize_path(p_path);
-	clear();
-
-	Node *scene = SceneLoader::load(p);
-
-	ERR_FAIL_COND_V(!scene,ERR_CANT_OPEN);
-
-	path=p;
-
-	Map<StringName,int> name_map;
-	HashMap<Variant,int,VariantHasher> variant_map;
-	Map<Node*,int> node_map;
-
-	_parse_node(scene,scene,-1,name_map,variant_map,node_map);
-
-
-	names.resize(name_map.size());
-
-	for(Map<StringName,int>::Element *E=name_map.front();E;E=E->next()) {
-
-		names[E->get()]=E->key();
-	}
-
-	variants.resize(variant_map.size());
-	const Variant *K=NULL;
-	while((K=variant_map.next(K))) {
-
-		int idx = variant_map[*K];
-		variants[idx]=*K;
-	}
-
-
-	memdelete(scene); // <- me falto esto :(
-	return OK;
-#endif
-}
-
-String ScenePreloader::get_scene_path() const {
-
-	return path;
-}
-
-void ScenePreloader::clear() {
-
-	names.clear();
-	variants.clear();
-	nodes.clear();
-	connections.clear();
-
-}
-
-void ScenePreloader::_set_bundled_scene(const Dictionary& d) {
-
-
-	ERR_FAIL_COND( !d.has("names"));
-	ERR_FAIL_COND( !d.has("variants"));
-	ERR_FAIL_COND( !d.has("node_count"));
-	ERR_FAIL_COND( !d.has("nodes"));
-	ERR_FAIL_COND( !d.has("conn_count"));
-	ERR_FAIL_COND( !d.has("conns"));
-	ERR_FAIL_COND( !d.has("path"));
-
-	DVector<String> snames = d["names"];
-	if (snames.size()) {
-
-		int namecount = snames.size();
-		names.resize(namecount);
-		DVector<String>::Read r =snames.read();
-		for(int i=0;i<names.size();i++)
-			names[i]=r[i];
-	}
-
-	Array svariants = d["variants"];
-
-	if (svariants.size()) {
-		int varcount=svariants.size();
-		variants.resize(varcount);
-		for(int i=0;i<varcount;i++) {
-
-			variants[i]=svariants[i];
-		}
-
-	} else {
-		variants.clear();
-	}
-
-	nodes.resize(d["node_count"]);
-	int nc=nodes.size();
-	if (nc) {
-		DVector<int> snodes = d["nodes"];
-		DVector<int>::Read r = snodes.read();
-		int idx=0;
-		for(int i=0;i<nc;i++) {
-			NodeData &nd = nodes[i];
-			nd.parent=r[idx++];
-			nd.type=r[idx++];
-			nd.name=r[idx++];
-			nd.properties.resize(r[idx++]);
-			for(int j=0;j<nd.properties.size();j++) {
-
-				nd.properties[j].name=r[idx++];
-				nd.properties[j].value=r[idx++];
-			}
-		}
-
-	}
-
-	connections.resize(d["conn_count"]);
-	int cc=connections.size();
-
-	if (cc) {
-
-		DVector<int> sconns = d["conns"];
-		DVector<int>::Read r = sconns.read();
-		int idx=0;
-		for(int i=0;i<nc;i++) {
-			ConnectionData &cd = connections[nc];
-			cd.from=r[idx++];
-			cd.to=r[idx++];
-			cd.signal=r[idx++];
-			cd.method=r[idx++];
-			cd.binds.resize(r[idx++]);
-			for(int j=0;j<cd.binds.size();j++) {
-
-				cd.binds[j]=r[idx++];
-			}
-		}
-
-	}
-
-
-
-	path=d["path"];
-
-}
-
-Dictionary ScenePreloader::_get_bundled_scene() const {
-
-	DVector<String> rnames;
-	rnames.resize(names.size());
-
-	if (names.size()) {
-
-		DVector<String>::Write r=rnames.write();
-
-		for(int i=0;i<names.size();i++)
-			r[i]=names[i];
-	}
-
-	Dictionary d;
-	d["names"]=rnames;
-	d["variants"]=variants;
-
-	Vector<int> rnodes;
-	d["node_count"]=nodes.size();
-
-	for(int i=0;i<nodes.size();i++) {
-
-		const NodeData &nd=nodes[i];
-		rnodes.push_back(nd.parent);
-		rnodes.push_back(nd.type);
-		rnodes.push_back(nd.name);
-		rnodes.push_back(nd.properties.size());
-		for(int j=0;j<nd.properties.size();j++) {
-
-			rnodes.push_back(nd.properties[j].name);
-			rnodes.push_back(nd.properties[j].value);
-		}
-	}
-
-	d["nodes"]=rnodes;
-
-	Vector<int> rconns;
-	d["conn_count"]=connections.size();
-
-	for(int i=0;i<connections.size();i++) {
-
-		const ConnectionData &cd=connections[i];
-		rconns.push_back(cd.from);
-		rconns.push_back(cd.to);
-		rconns.push_back(cd.signal);
-		rconns.push_back(cd.method);
-		rconns.push_back(cd.binds.size());
-		for(int j=0;j<cd.binds.size();i++)
-			rconns.push_back(cd.binds[j]);
-
-	}
-
-	d["conns"]=rconns;
-
-	d["path"]=path;
-
-	return d;
-
-
-}
-
-void ScenePreloader::_bind_methods() {
-
-	ObjectTypeDB::bind_method(_MD("load_scene","path"),&ScenePreloader::load_scene);
-	ObjectTypeDB::bind_method(_MD("get_scene_path"),&ScenePreloader::get_scene_path);
-	ObjectTypeDB::bind_method(_MD("instance:Node"),&ScenePreloader::instance);
-	ObjectTypeDB::bind_method(_MD("can_instance"),&ScenePreloader::can_instance);
-	ObjectTypeDB::bind_method(_MD("_set_bundled_scene"),&ScenePreloader::_set_bundled_scene);
-	ObjectTypeDB::bind_method(_MD("_get_bundled_scene"),&ScenePreloader::_get_bundled_scene);
-
-	ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_bundled",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_BUNDLE),_SCS("_set_bundled_scene"),_SCS("_get_bundled_scene"));
-#if 0
-	List<String> extensions;
-	SceneLoader::get_recognized_extensions(&extensions);
-	String exthint;
-	for (List<String>::Element*E=extensions.front();E;E=E->next()) {
-
-		if (exthint!="")
-			exthint+=",";
-		exthint+="*."+E->get();
-	}
-
-	exthint+="; Scenes";
-
-	ADD_PROPERTY( PropertyInfo(Variant::STRING,"scene",PROPERTY_HINT_FILE,exthint),_SCS("load_scene"),_SCS("get_scene_path"));
-#endif
-}
-
-ScenePreloader::ScenePreloader() {
-
-
-}
+#include "scene_preloader.h"
+#include "globals.h"
+
+bool ScenePreloader::can_instance() const {
+
+	return nodes.size()>0;
+}
+
+Node *ScenePreloader::instance() const {
+
+	int nc = nodes.size();
+	ERR_FAIL_COND_V(nc==0,NULL);
+
+	const StringName*snames=NULL;
+	int sname_count=names.size();
+	if (sname_count)
+		snames=&names[0];
+
+	const Variant*props=NULL;
+	int prop_count=variants.size();
+	if (prop_count)
+		props=&variants[0];
+
+	Vector<Variant> properties;
+
+	const NodeData *nd = &nodes[0];
+
+	Node **ret_nodes=(Node**)alloca( sizeof(Node*)*nc );
+
+	for(int i=0;i<nc;i++) {
+
+		const NodeData &n=nd[i];
+
+
+		if (!ObjectTypeDB::is_type_enabled(snames[n.type])) {
+			ret_nodes[i]=NULL;
+			continue;
+		}
+
+		Object * obj = ObjectTypeDB::instance(snames[ n.type ]);
+		ERR_FAIL_COND_V(!obj,NULL);
+		Node *node = obj->cast_to<Node>();
+		ERR_FAIL_COND_V(!node,NULL);
+
+		int nprop_count=n.properties.size();
+		if (nprop_count) {
+
+			const NodeData::Property* nprops=&n.properties[0];
+
+			for(int j=0;j<nprop_count;j++) {
+
+				bool valid;
+				node->set(snames[ nprops[j].name ],props[ nprops[j].value ],&valid);
+			}
+
+
+		}
+
+		node->set_name( snames[ n.name ] );
+		ret_nodes[i]=node;
+		if (i>0) {
+			ERR_FAIL_INDEX_V(n.parent,i,NULL);
+			ERR_FAIL_COND_V(!ret_nodes[n.parent],NULL);
+			ret_nodes[n.parent]->add_child(node);
+		}
+	}
+
+
+	//do connections
+
+	int cc = connections.size();
+	const ConnectionData *cdata = connections.ptr();
+
+	for(int i=0;i<cc;i++) {
+
+		const ConnectionData &c=cdata[i];
+		ERR_FAIL_INDEX_V( c.from, nc, NULL );
+		ERR_FAIL_INDEX_V( c.to, nc, NULL );
+
+		Vector<Variant> binds;
+		if (c.binds.size()) {
+			binds.resize(c.binds.size());
+			for(int j=0;j<c.binds.size();j++)
+				binds[j]=props[ c.binds[j] ];
+		}
+
+		if (!ret_nodes[c.from] || !ret_nodes[c.to])
+			continue;
+		ret_nodes[c.from]->connect( snames[ c.signal], ret_nodes[ c.to ], snames[ c.method], binds,CONNECT_PERSIST );
+	}
+
+	return ret_nodes[0];
+
+}
+
+
+static int _nm_get_string(const String& p_string, Map<StringName,int> &name_map) {
+
+	if (name_map.has(p_string))
+		return name_map[p_string];
+
+	int idx = name_map.size();
+	name_map[p_string]=idx;
+	return idx;
+}
+
+static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher> &variant_map) {
+
+	if (variant_map.has(p_variant))
+		return variant_map[p_variant];
+
+	int idx = variant_map.size();
+	variant_map[p_variant]=idx;
+	return idx;
+}
+
+void ScenePreloader::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map) {
+
+	if (p_node!=p_owner && !p_node->get_owner())
+		return;
+
+	NodeData nd;
+	nd.name=_nm_get_string(p_node->get_name(),name_map);
+	nd.type=_nm_get_string(p_node->get_type(),name_map);
+	nd.parent=p_parent_idx;
+
+	List<PropertyInfo> plist;
+	p_node->get_property_list(&plist);
+	for (List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) {
+
+		if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+			continue;
+
+		NodeData::Property prop;
+		prop.name=_nm_get_string(E->get().name,name_map);
+		prop.value=_vm_get_variant( p_node->get( E->get().name ), variant_map);
+		nd.properties.push_back(prop);
+	}
+
+	int idx = nodes.size();
+	node_map[p_node]=idx;
+	nodes.push_back(nd);
+
+	for(int i=0;i<p_node->get_child_count();i++) {
+
+		Node *c=p_node->get_child(i);
+		_parse_node(p_owner,c,idx,name_map,variant_map,node_map);
+	}
+
+
+
+}
+
+void ScenePreloader::_parse_connections(Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,bool p_instance) {
+
+
+	List<MethodInfo> signals;
+	p_node->get_signal_list(&signals);
+
+	for(List<MethodInfo>::Element *E=signals.front();E;E=E->next()) {
+
+		List<Node::Connection> conns;
+		p_node->get_signal_connection_list(E->get().name,&conns);
+		for(List<Node::Connection>::Element *F=conns.front();F;F=F->next()) {
+
+			const Node::Connection &c = F->get();
+			if (!(c.flags&CONNECT_PERSIST))
+				continue;
+			Node *n=c.target->cast_to<Node>();
+			if (!n)
+				continue;
+
+			if (!node_map.has(n))
+				continue;
+
+			ConnectionData cd;
+			cd.from=node_map[p_node];
+			cd.to=node_map[n];
+			cd.method=_nm_get_string(c.method,name_map);
+			cd.signal=_nm_get_string(c.signal,name_map);
+			for(int i=0;i<c.binds.size();i++) {
+
+				cd.binds.push_back( _vm_get_variant(c.binds[i],variant_map));
+			}
+			connections.push_back(cd);
+		}
+	}
+
+}
+
+
+Error ScenePreloader::load_scene(const String& p_path) {
+
+	return ERR_CANT_OPEN;
+#if 0
+	if (path==p_path)
+		return OK;
+
+	String p=Globals::get_singleton()->localize_path(p_path);
+	clear();
+
+	Node *scene = SceneLoader::load(p);
+
+	ERR_FAIL_COND_V(!scene,ERR_CANT_OPEN);
+
+	path=p;
+
+	Map<StringName,int> name_map;
+	HashMap<Variant,int,VariantHasher> variant_map;
+	Map<Node*,int> node_map;
+
+	_parse_node(scene,scene,-1,name_map,variant_map,node_map);
+
+
+	names.resize(name_map.size());
+
+	for(Map<StringName,int>::Element *E=name_map.front();E;E=E->next()) {
+
+		names[E->get()]=E->key();
+	}
+
+	variants.resize(variant_map.size());
+	const Variant *K=NULL;
+	while((K=variant_map.next(K))) {
+
+		int idx = variant_map[*K];
+		variants[idx]=*K;
+	}
+
+
+	memdelete(scene); // <- me falto esto :(
+	return OK;
+#endif
+}
+
+String ScenePreloader::get_scene_path() const {
+
+	return path;
+}
+
+void ScenePreloader::clear() {
+
+	names.clear();
+	variants.clear();
+	nodes.clear();
+	connections.clear();
+
+}
+
+void ScenePreloader::_set_bundled_scene(const Dictionary& d) {
+
+
+	ERR_FAIL_COND( !d.has("names"));
+	ERR_FAIL_COND( !d.has("variants"));
+	ERR_FAIL_COND( !d.has("node_count"));
+	ERR_FAIL_COND( !d.has("nodes"));
+	ERR_FAIL_COND( !d.has("conn_count"));
+	ERR_FAIL_COND( !d.has("conns"));
+	ERR_FAIL_COND( !d.has("path"));
+
+	DVector<String> snames = d["names"];
+	if (snames.size()) {
+
+		int namecount = snames.size();
+		names.resize(namecount);
+		DVector<String>::Read r =snames.read();
+		for(int i=0;i<names.size();i++)
+			names[i]=r[i];
+	}
+
+	Array svariants = d["variants"];
+
+	if (svariants.size()) {
+		int varcount=svariants.size();
+		variants.resize(varcount);
+		for(int i=0;i<varcount;i++) {
+
+			variants[i]=svariants[i];
+		}
+
+	} else {
+		variants.clear();
+	}
+
+	nodes.resize(d["node_count"]);
+	int nc=nodes.size();
+	if (nc) {
+		DVector<int> snodes = d["nodes"];
+		DVector<int>::Read r = snodes.read();
+		int idx=0;
+		for(int i=0;i<nc;i++) {
+			NodeData &nd = nodes[i];
+			nd.parent=r[idx++];
+			nd.type=r[idx++];
+			nd.name=r[idx++];
+			nd.properties.resize(r[idx++]);
+			for(int j=0;j<nd.properties.size();j++) {
+
+				nd.properties[j].name=r[idx++];
+				nd.properties[j].value=r[idx++];
+			}
+		}
+
+	}
+
+	connections.resize(d["conn_count"]);
+	int cc=connections.size();
+
+	if (cc) {
+
+		DVector<int> sconns = d["conns"];
+		DVector<int>::Read r = sconns.read();
+		int idx=0;
+		for(int i=0;i<nc;i++) {
+			ConnectionData &cd = connections[nc];
+			cd.from=r[idx++];
+			cd.to=r[idx++];
+			cd.signal=r[idx++];
+			cd.method=r[idx++];
+			cd.binds.resize(r[idx++]);
+			for(int j=0;j<cd.binds.size();j++) {
+
+				cd.binds[j]=r[idx++];
+			}
+		}
+
+	}
+
+
+
+	path=d["path"];
+
+}
+
+Dictionary ScenePreloader::_get_bundled_scene() const {
+
+	DVector<String> rnames;
+	rnames.resize(names.size());
+
+	if (names.size()) {
+
+		DVector<String>::Write r=rnames.write();
+
+		for(int i=0;i<names.size();i++)
+			r[i]=names[i];
+	}
+
+	Dictionary d;
+	d["names"]=rnames;
+	d["variants"]=variants;
+
+	Vector<int> rnodes;
+	d["node_count"]=nodes.size();
+
+	for(int i=0;i<nodes.size();i++) {
+
+		const NodeData &nd=nodes[i];
+		rnodes.push_back(nd.parent);
+		rnodes.push_back(nd.type);
+		rnodes.push_back(nd.name);
+		rnodes.push_back(nd.properties.size());
+		for(int j=0;j<nd.properties.size();j++) {
+
+			rnodes.push_back(nd.properties[j].name);
+			rnodes.push_back(nd.properties[j].value);
+		}
+	}
+
+	d["nodes"]=rnodes;
+
+	Vector<int> rconns;
+	d["conn_count"]=connections.size();
+
+	for(int i=0;i<connections.size();i++) {
+
+		const ConnectionData &cd=connections[i];
+		rconns.push_back(cd.from);
+		rconns.push_back(cd.to);
+		rconns.push_back(cd.signal);
+		rconns.push_back(cd.method);
+		rconns.push_back(cd.binds.size());
+		for(int j=0;j<cd.binds.size();i++)
+			rconns.push_back(cd.binds[j]);
+
+	}
+
+	d["conns"]=rconns;
+
+	d["path"]=path;
+
+	return d;
+
+
+}
+
+void ScenePreloader::_bind_methods() {
+
+	ObjectTypeDB::bind_method(_MD("load_scene","path"),&ScenePreloader::load_scene);
+	ObjectTypeDB::bind_method(_MD("get_scene_path"),&ScenePreloader::get_scene_path);
+	ObjectTypeDB::bind_method(_MD("instance:Node"),&ScenePreloader::instance);
+	ObjectTypeDB::bind_method(_MD("can_instance"),&ScenePreloader::can_instance);
+	ObjectTypeDB::bind_method(_MD("_set_bundled_scene"),&ScenePreloader::_set_bundled_scene);
+	ObjectTypeDB::bind_method(_MD("_get_bundled_scene"),&ScenePreloader::_get_bundled_scene);
+
+	ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_bundled",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_BUNDLE),_SCS("_set_bundled_scene"),_SCS("_get_bundled_scene"));
+#if 0
+	List<String> extensions;
+	SceneLoader::get_recognized_extensions(&extensions);
+	String exthint;
+	for (List<String>::Element*E=extensions.front();E;E=E->next()) {
+
+		if (exthint!="")
+			exthint+=",";
+		exthint+="*."+E->get();
+	}
+
+	exthint+="; Scenes";
+
+	ADD_PROPERTY( PropertyInfo(Variant::STRING,"scene",PROPERTY_HINT_FILE,exthint),_SCS("load_scene"),_SCS("get_scene_path"));
+#endif
+}
+
+ScenePreloader::ScenePreloader() {
+
+
+}

+ 0 - 55
scene/scene_binds.cpp

@@ -1,55 +0,0 @@
-/*************************************************************************/
-/*  scene_binds.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 "scene_binds.h"
-
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-void SceneIO::_bind_methods() {
-
-	ObjectTypeDB::bind_method(_MD("load:Node","path"),&SceneIO::load);
-	ObjectTypeDB::bind_method(_MD("save","path","scene:Node","flags","optimizer:OptimizedSaver","scene"),&SceneIO::save,DEFVAL(0),DEFVAL(Ref<OptimizedSaver>()));
-	ObjectTypeDB::bind_method(_MD("load_interactive:SceneInteractiveLoader","path"),&SceneIO::load_interactive);
-}
-
-Node* SceneIO::load(const String& p_scene) {
-
-	return SceneLoader::load(p_scene);
-}
-
-Error SceneIO::save(const String& p_path, Node *p_scene,int p_flags,const Ref<OptimizedSaver> &p_optimizer) {
-
-	return SceneSaver::save(p_path,p_scene,p_flags,p_optimizer);
-}
-
-Ref<SceneInteractiveLoader> SceneIO::load_interactive(const String& p_scene) {
-
-	return SceneLoader::load_interactive(p_scene);
-}
-
-#endif

+ 0 - 62
scene/scene_binds.h

@@ -1,62 +0,0 @@
-/*************************************************************************/
-/*  scene_binds.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 SCENE_BINDS_H
-#define SCENE_BINDS_H
-
-#include "scene/io/scene_loader.h"
-#include "scene/io/scene_saver.h"
-
-#ifdef OLD_SCENE_FORMAT_ENABLED
-
-class SceneIO : public Object {
-
-	OBJ_TYPE( SceneIO, Object );
-protected:
-
-	static void _bind_methods();
-public:
-
-	enum SaveFlags {
-
-		SAVE_FLAG_RELATIVE_PATHS=SceneSaver::FLAG_RELATIVE_PATHS,
-		SAVE_FLAG_BUNDLE_RESOURCES=SceneSaver::FLAG_BUNDLE_RESOURCES,
-		SAVE_FLAG_BUNDLE_INSTANCED_SCENES=SceneSaver::FLAG_BUNDLE_INSTANCED_SCENES,
-		SAVE_FLAG_OMIT_EDITOR_PROPERTIES=SceneSaver::FLAG_OMIT_EDITOR_PROPERTIES,
-		SAVE_FLAG_SAVE_BIG_ENDIAN=SceneSaver::FLAG_SAVE_BIG_ENDIAN
-	};
-
-	Node* load(const String& p_scene);
-	Error save(const String& p_path, Node *p_scene,int p_flags=0,const Ref<OptimizedSaver> &p_optimizer=Ref<OptimizedSaver>());
-	Ref<SceneInteractiveLoader> load_interactive(const String& p_scene);
-
-	SceneIO() {}
-};
-
-#endif
-#endif // SCENE_BINDS_H

+ 1 - 1
servers/SCsub

@@ -12,7 +12,7 @@ SConscript('audio/SCsub');
 SConscript('spatial_sound/SCsub');
 SConscript('spatial_sound_2d/SCsub');
 
-lib = env.Library("servers",env.servers_sources, LIBSUFFIX=env['platform_libsuffix'])
+lib = env.Library("servers",env.servers_sources)
 
 env.Prepend(LIBS=[lib])
 

+ 1 - 1
tools/SCsub

@@ -13,7 +13,7 @@ SConscript('freetype/SCsub');
 SConscript('doc/SCsub');
 SConscript('pck/SCsub');
 
-lib = env.Library("tool",env.tool_sources, LIBSUFFIX=env['platform_libsuffix'])
+lib = env.Library("tool",env.tool_sources)
 
 env.Prepend(LIBS=[lib])
 

+ 0 - 105
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");
 

+ 1 - 1
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"

+ 0 - 468
tools/editor/editor_shape_gizmos.cpp

@@ -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()
-{
-}

+ 0 - 60
tools/editor/editor_shape_gizmos.h

@@ -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

+ 170 - 34
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
@@ -932,6 +1042,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;

+ 2 - 1
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;

+ 2 - 2
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"

+ 1 - 1
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"

+ 1 - 74
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>()) );

+ 1 - 14
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 {
 

部分文件因为文件数量过多而无法显示