diff options
56 files changed, 1292 insertions, 177 deletions
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index 52d77b6ebc..a60dea7379 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -67,9 +67,10 @@ Plane CameraMatrix::xform4(const Plane& p_vec4) { void CameraMatrix::set_perspective(float p_fovy_degrees, float p_aspect, float p_z_near, float p_z_far,bool p_flip_fov) { - if (p_flip_fov) - p_fovy_degrees=get_fovy(p_fovy_degrees,p_aspect); + if (p_flip_fov) { + p_fovy_degrees=get_fovy(p_fovy_degrees,1.0/p_aspect); + } float sine, cotangent, deltaZ; float radians = p_fovy_degrees / 2.0 * Math_PI / 180.0; @@ -110,7 +111,7 @@ void CameraMatrix::set_orthogonal(float p_left, float p_right, float p_bottom, f void CameraMatrix::set_orthogonal(float p_size, float p_aspect, float p_znear, float p_zfar,bool p_flip_fov) { - if (p_flip_fov) { + if (!p_flip_fov) { p_size*=p_aspect; } diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index 6ffcb0ed0b..767236ea04 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -60,7 +60,7 @@ struct CameraMatrix { static float get_fovy(float p_fovx,float p_aspect) { - return Math::atan(p_aspect * Math::tan(p_fovx * 0.5))*2.0; + return Math::rad2deg(Math::atan(p_aspect * Math::tan(Math::deg2rad(p_fovx) * 0.5))*2.0); } float get_z_far() const; diff --git a/demos/2d/kinematic_char/colworld.gd b/demos/2d/kinematic_char/colworld.gd index efd1dab805..d13ff9236b 100644 --- a/demos/2d/kinematic_char/colworld.gd +++ b/demos/2d/kinematic_char/colworld.gd @@ -1,12 +1,12 @@ extends Node2D -# member variables here, example: -# var a=2 -# var b="textvar" +#member variables here, example: +#var a=2 +#var b="textvar" func _ready(): - # Initalization here + #Initalization here pass diff --git a/demos/2d/kinematic_char/player.gd b/demos/2d/kinematic_char/player.gd index b35bbfa693..5c56477758 100644 --- a/demos/2d/kinematic_char/player.gd +++ b/demos/2d/kinematic_char/player.gd @@ -1,18 +1,18 @@ extends KinematicBody2D -# This is a simple collision demo showing how -# the kinematic cotroller works. -# move() will allow to move the node, and will -# always move it to a non-colliding spot, -# as long as it starts from a non-colliding spot too. +#This is a simple collision demo showing how +#the kinematic cotroller works. +#move() will allow to move the node, and will +#always move it to a non-colliding spot, +#as long as it starts from a non-colliding spot too. #pixels / second const GRAVITY = 500.0 -# Angle in degrees towards either side that the player can -# consider "floor". +#Angle in degrees towards either side that the player can +#consider "floor". const FLOOR_ANGLE_TOLERANCE = 40 const WALK_FORCE = 600 const WALK_MAX_SPEED = 200 @@ -68,7 +68,6 @@ func _fixed_process(delta): var motion = velocity * delta #move and consume motion -# motion = move(motion) @@ -85,9 +84,9 @@ func _fixed_process(delta): floor_velocity=get_collider_velocity() #velocity.y=0 - # But we were moving and our motion was interrupted, - # so try to complete the motion by "sliding" - # by the normal + #But we were moving and our motion was interrupted, + #so try to complete the motion by "sliding" + #by the normal motion = n.slide(motion) velocity = n.slide(velocity) @@ -109,7 +108,7 @@ func _fixed_process(delta): prev_jump_pressed=jump func _ready(): - # Initalization here + #Initalization here set_fixed_process(true) pass diff --git a/demos/2d/pong/pong.gd b/demos/2d/pong/pong.gd index bfffdcf0d8..cf6003c659 100644 --- a/demos/2d/pong/pong.gd +++ b/demos/2d/pong/pong.gd @@ -1,9 +1,9 @@ extends Node2D -# member variables here, example: -# var a=2 -# var b="textvar" +#member variables here, example: +#var a=2 +#var b="textvar" const INITIAL_BALL_SPEED = 80 var ball_speed = INITIAL_BALL_SPEED var screen_size = Vector2(640,400) @@ -16,7 +16,7 @@ const PAD_SPEED = 150 func _process(delta): - # get ball positio and pad rectangles + #get ball position and pad rectangles var ball_pos = get_node("ball").get_pos() var left_rect = Rect2( get_node("left").get_pos() - pad_size*0.5, pad_size ) var right_rect = Rect2( get_node("right").get_pos() - pad_size*0.5, pad_size ) @@ -44,7 +44,7 @@ func _process(delta): get_node("ball").set_pos(ball_pos) - #move left pad + #move left pad var left_pos = get_node("left").get_pos() if (left_pos.y > 0 and Input.is_action_pressed("left_move_up")): @@ -67,7 +67,7 @@ func _process(delta): func _ready(): - screen_size = get_viewport_rect().size # get actual size + screen_size = get_viewport_rect().size #get actual size pad_size = get_node("left").get_texture().get_size() set_process(true) diff --git a/demos/3d/platformer/follow_camera.gd b/demos/3d/platformer/follow_camera.gd index 0b9ff9bbb2..60eef5787a 100644 --- a/demos/3d/platformer/follow_camera.gd +++ b/demos/3d/platformer/follow_camera.gd @@ -45,13 +45,13 @@ func _fixed_process(dt): var col = ds.intersect_ray(target,target,collision_exception) var col_right = ds.intersect_ray(target,target+Matrix3(up,deg2rad(-autoturn_ray_aperture)).xform(delta),collision_exception) - if (col!=null): + if (!col.empty()): #if main ray was occluded, get camera closer, this is the worst case scenario delta = col.position - target - elif (col_left!=null and col_right==null): + elif (!col_left.empty() and col_right.empty()): #if only left ray is occluded, turn the camera around to the right delta = Matrix3(up,deg2rad(-dt*autoturn_speed)).xform(delta) - elif (col_left==null and col_right!=null): + elif (col_left.empty() and !col_right.empty()): #if only right ray is occluded, turn the camera around to the left delta = Matrix3(up,deg2rad(dt*autoturn_speed)).xform(delta) else: diff --git a/drivers/builtin_openssl2/crypto/o_str.c b/drivers/builtin_openssl2/crypto/o_str.c index 56104a6c34..d233afd46b 100644 --- a/drivers/builtin_openssl2/crypto/o_str.c +++ b/drivers/builtin_openssl2/crypto/o_str.c @@ -63,7 +63,11 @@ #if !defined(OPENSSL_IMPLEMENTS_strncasecmp) && \ !defined(OPENSSL_SYSNAME_WIN32) && \ !defined(NETWARE_CLIB) -# include <strings.h> +#ifdef _WIN32 +#include <string.h> +#else +#include <strings.h> +#endif #endif int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n) diff --git a/drivers/builtin_openssl2/openssl/rand.h b/drivers/builtin_openssl2/openssl/rand.h index 290f069f4d..b5adb825fd 100644 --- a/drivers/builtin_openssl2/openssl/rand.h +++ b/drivers/builtin_openssl2/openssl/rand.h @@ -64,6 +64,7 @@ #include <openssl/e_os2.h> #if defined(OPENSSL_SYS_WINDOWS) +#define WIN32_LEAN_AND_MEAN #include <windows.h> #ifdef OCSP_RESPONSE #undef OCSP_RESPONSE diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index b928d3709b..ada9efa4b3 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -611,7 +611,11 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { replace_table["sign"]= "sign"; replace_table["floor"]= "floor"; replace_table["trunc"]= "trunc"; +#ifdef GLEW_ENABLED + replace_table["round"]= "roundfix"; +#else replace_table["round"]= "round"; +#endif replace_table["ceil" ]= "ceil"; replace_table["fract"]= "fract"; replace_table["mod" ]= "mod"; diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp index dc68ee489a..6a4596cb1e 100644 --- a/drivers/gles2/shader_gles2.cpp +++ b/drivers/gles2/shader_gles2.cpp @@ -267,7 +267,9 @@ ShaderGLES2::Version* ShaderGLES2::get_current_version() { /* SETUP CONDITIONALS */ Vector<const char*> strings; - //strings.push_back("#version 120\n"); //ATI requieres this before anything +#ifdef GLEW_ENABLED + strings.push_back("#version 120\n"); //ATI requieres this before anything +#endif int define_line_ofs=1; for(int j=0;j<conditional_count;j++) { diff --git a/drivers/gles2/shaders/material.glsl b/drivers/gles2/shaders/material.glsl index 3aa27c98ff..ad8a364ac1 100644 --- a/drivers/gles2/shaders/material.glsl +++ b/drivers/gles2/shaders/material.glsl @@ -4,6 +4,7 @@ #ifdef USE_GLES_OVER_GL #define mediump #define highp +#define roundfix( m_val ) floor( (m_val) + 0.5 ) #else precision mediump float; precision mediump int; @@ -470,6 +471,7 @@ VERTEX_SHADER_CODE #ifdef USE_GLES_OVER_GL #define mediump #define highp +#define roundfix( m_val ) floor( (m_val) + 0.5 ) #else precision mediump float; diff --git a/drivers/webp/dec/alpha.c b/drivers/webp/dec/alpha.c index 6e65de9030..d1095fa555 100644 --- a/drivers/webp/dec/alpha.c +++ b/drivers/webp/dec/alpha.c @@ -14,7 +14,7 @@ #include "./vp8li.h" #include "../utils/filters.h" #include "../utils/quant_levels.h" -#include "../webp/format_constants.h" +#include "../format_constants.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/dec/vp8li.h b/drivers/webp/dec/vp8li.h index ee29eb5faf..5f6cd6a01c 100644 --- a/drivers/webp/dec/vp8li.h +++ b/drivers/webp/dec/vp8li.h @@ -18,7 +18,7 @@ #include "../utils/bit_reader.h" #include "../utils/color_cache.h" #include "../utils/huffman.h" -#include "../webp/format_constants.h" +#include "../format_constants.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/dsp/dsp.h b/drivers/webp/dsp/dsp.h index 042c98aad2..9ff53174d4 100644 --- a/drivers/webp/dsp/dsp.h +++ b/drivers/webp/dsp/dsp.h @@ -12,7 +12,7 @@ #ifndef WEBP_DSP_DSP_H_ #define WEBP_DSP_DSP_H_ -#include "../webp/types.h" +#include "../types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/dsp/lossless.h b/drivers/webp/dsp/lossless.h index 992516fcdf..7c7d5555ed 100644 --- a/drivers/webp/dsp/lossless.h +++ b/drivers/webp/dsp/lossless.h @@ -13,8 +13,8 @@ #ifndef WEBP_DSP_LOSSLESS_H_ #define WEBP_DSP_LOSSLESS_H_ -#include "../webp/types.h" -#include "../webp/decode.h" +#include "../types.h" +#include "../decode.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/enc/alpha.c b/drivers/webp/enc/alpha.c index 0e519b6c66..e554eb7f30 100644 --- a/drivers/webp/enc/alpha.c +++ b/drivers/webp/enc/alpha.c @@ -15,7 +15,7 @@ #include "./vp8enci.h" #include "../utils/filters.h" #include "../utils/quant_levels.h" -#include "../webp/format_constants.h" +#include "../format_constants.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/enc/backward_references.h b/drivers/webp/enc/backward_references.h index 91c03361ed..8006a56ba1 100644 --- a/drivers/webp/enc/backward_references.h +++ b/drivers/webp/enc/backward_references.h @@ -13,8 +13,8 @@ #include <assert.h> #include <stdlib.h> -#include "../webp/types.h" -#include "../webp/format_constants.h" +#include "../types.h" +#include "../format_constants.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/enc/config.c b/drivers/webp/enc/config.c index 1a26113554..4136f6c227 100644 --- a/drivers/webp/enc/config.c +++ b/drivers/webp/enc/config.c @@ -9,7 +9,7 @@ // // Author: Skal (pascal.massimino@gmail.com) -#include "../webp/encode.h" +#include "../encode.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/enc/histogram.h b/drivers/webp/enc/histogram.h index ec573c5c85..5b5de25539 100644 --- a/drivers/webp/enc/histogram.h +++ b/drivers/webp/enc/histogram.h @@ -19,8 +19,8 @@ #include <string.h> #include "./backward_references.h" -#include "../webp/format_constants.h" -#include "../webp/types.h" +#include "../format_constants.h" +#include "../types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/enc/syntax.c b/drivers/webp/enc/syntax.c index 7c8c7b1a84..4221436ff9 100644 --- a/drivers/webp/enc/syntax.c +++ b/drivers/webp/enc/syntax.c @@ -11,7 +11,7 @@ #include <assert.h> -#include "../webp/format_constants.h" +#include "../format_constants.h" #include "./vp8enci.h" #if defined(__cplusplus) || defined(c_plusplus) diff --git a/drivers/webp/enc/vp8enci.h b/drivers/webp/enc/vp8enci.h index a77778c0d8..936e1c18ce 100644 --- a/drivers/webp/enc/vp8enci.h +++ b/drivers/webp/enc/vp8enci.h @@ -13,7 +13,7 @@ #define WEBP_ENC_VP8ENCI_H_ #include <string.h> // for memcpy() -#include "../webp/encode.h" +#include "../encode.h" #include "../dsp/dsp.h" #include "../utils/bit_writer.h" diff --git a/drivers/webp/enc/vp8l.c b/drivers/webp/enc/vp8l.c index 9c202f8d36..f4eb6e783f 100644 --- a/drivers/webp/enc/vp8l.c +++ b/drivers/webp/enc/vp8l.c @@ -21,7 +21,7 @@ #include "../utils/bit_writer.h" #include "../utils/huffman_encode.h" #include "../utils/utils.h" -#include "../webp/format_constants.h" +#include "../format_constants.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/enc/vp8li.h b/drivers/webp/enc/vp8li.h index eae90dd61f..bb111aec33 100644 --- a/drivers/webp/enc/vp8li.h +++ b/drivers/webp/enc/vp8li.h @@ -14,8 +14,8 @@ #include "./histogram.h" #include "../utils/bit_writer.h" -#include "../webp/encode.h" -#include "../webp/format_constants.h" +#include "../encode.h" +#include "../format_constants.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/utils/bit_reader.h b/drivers/webp/utils/bit_reader.h index 36fc13e2da..d80b497149 100644 --- a/drivers/webp/utils/bit_reader.h +++ b/drivers/webp/utils/bit_reader.h @@ -18,7 +18,7 @@ #include <stdlib.h> // _byteswap_ulong #endif #include <string.h> // For memcpy -#include "../webp/types.h" +#include "../types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/utils/bit_writer.h b/drivers/webp/utils/bit_writer.h index f7ca08497f..57f39b11b1 100644 --- a/drivers/webp/utils/bit_writer.h +++ b/drivers/webp/utils/bit_writer.h @@ -12,7 +12,7 @@ #ifndef WEBP_UTILS_BIT_WRITER_H_ #define WEBP_UTILS_BIT_WRITER_H_ -#include "../webp/types.h" +#include "../types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/utils/color_cache.h b/drivers/webp/utils/color_cache.h index 13be629f36..da5e260195 100644 --- a/drivers/webp/utils/color_cache.h +++ b/drivers/webp/utils/color_cache.h @@ -13,7 +13,7 @@ #ifndef WEBP_UTILS_COLOR_CACHE_H_ #define WEBP_UTILS_COLOR_CACHE_H_ -#include "../webp/types.h" +#include "../types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/utils/filters.h b/drivers/webp/utils/filters.h index c5cdbd6deb..db886be29a 100644 --- a/drivers/webp/utils/filters.h +++ b/drivers/webp/utils/filters.h @@ -12,7 +12,7 @@ #ifndef WEBP_UTILS_FILTERS_H_ #define WEBP_UTILS_FILTERS_H_ -#include "../webp/types.h" +#include "../types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/utils/huffman.c b/drivers/webp/utils/huffman.c index 41529cc9da..1cc1cfd355 100644 --- a/drivers/webp/utils/huffman.c +++ b/drivers/webp/utils/huffman.c @@ -13,7 +13,7 @@ #include <stdlib.h> #include "./huffman.h" #include "../utils/utils.h" -#include "../webp/format_constants.h" +#include "../format_constants.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/utils/huffman.h b/drivers/webp/utils/huffman.h index 70220a67fb..f16447e649 100644 --- a/drivers/webp/utils/huffman.h +++ b/drivers/webp/utils/huffman.h @@ -13,7 +13,7 @@ #define WEBP_UTILS_HUFFMAN_H_ #include <assert.h> -#include "../webp/types.h" +#include "../types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/utils/huffman_encode.c b/drivers/webp/utils/huffman_encode.c index 8ccd291d22..e172b10a85 100644 --- a/drivers/webp/utils/huffman_encode.c +++ b/drivers/webp/utils/huffman_encode.c @@ -14,7 +14,7 @@ #include <string.h> #include "./huffman_encode.h" #include "../utils/utils.h" -#include "../webp/format_constants.h" +#include "../format_constants.h" // ----------------------------------------------------------------------------- // Util function to optimize the symbol map for RLE coding diff --git a/drivers/webp/utils/huffman_encode.h b/drivers/webp/utils/huffman_encode.h index cc3b38d330..7f4aedc102 100644 --- a/drivers/webp/utils/huffman_encode.h +++ b/drivers/webp/utils/huffman_encode.h @@ -12,7 +12,7 @@ #ifndef WEBP_UTILS_HUFFMAN_ENCODE_H_ #define WEBP_UTILS_HUFFMAN_ENCODE_H_ -#include "../webp/types.h" +#include "../types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/utils/quant_levels.h b/drivers/webp/utils/quant_levels.h index 89ccafe40d..4f165fd230 100644 --- a/drivers/webp/utils/quant_levels.h +++ b/drivers/webp/utils/quant_levels.h @@ -14,7 +14,7 @@ #include <stdlib.h> -#include "../webp/types.h" +#include "../types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/drivers/webp/utils/rescaler.h b/drivers/webp/utils/rescaler.h index ef93d465f0..9c9133d19b 100644 --- a/drivers/webp/utils/rescaler.h +++ b/drivers/webp/utils/rescaler.h @@ -16,7 +16,7 @@ extern "C" { #endif -#include "../webp/types.h" +#include "../types.h" // Structure used for on-the-fly rescaling typedef struct { diff --git a/drivers/webp/utils/utils.h b/drivers/webp/utils/utils.h index a034762556..316ac90612 100644 --- a/drivers/webp/utils/utils.h +++ b/drivers/webp/utils/utils.h @@ -12,7 +12,7 @@ #ifndef WEBP_UTILS_UTILS_H_ #define WEBP_UTILS_UTILS_H_ -#include "../webp/types.h" +#include "../types.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 22e6a5d864..aef223470a 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -378,8 +378,8 @@ bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret) void EditorExportPlatformAndroid::_get_property_list( List<PropertyInfo> *p_list) const{ - p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/debug", PROPERTY_HINT_FILE,"apk")); - p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/release", PROPERTY_HINT_FILE,"apk")); + p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE,"apk")); + p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE,"apk")); p_list->push_back( PropertyInfo( Variant::STRING, "command_line/extra_args")); p_list->push_back( PropertyInfo( Variant::INT, "version/code", PROPERTY_HINT_RANGE,"1,65535,1")); p_list->push_back( PropertyInfo( Variant::STRING, "version/name") ); diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp index 5edcf39396..d40cb82cdf 100644 --- a/platform/bb10/export/export.cpp +++ b/platform/bb10/export/export.cpp @@ -147,7 +147,7 @@ void EditorExportPlatformBB10::_get_property_list( List<PropertyInfo> *p_list) c p_list->push_back( PropertyInfo( Variant::STRING, "package/name") ); p_list->push_back( PropertyInfo( Variant::STRING, "package/description",PROPERTY_HINT_MULTILINE_TEXT) ); p_list->push_back( PropertyInfo( Variant::STRING, "package/icon",PROPERTY_HINT_FILE,"png") ); - p_list->push_back( PropertyInfo( Variant::STRING, "package/custom_template", PROPERTY_HINT_FILE,"zip")); + p_list->push_back( PropertyInfo( Variant::STRING, "package/custom_template", PROPERTY_HINT_GLOBAL_FILE,"zip")); p_list->push_back( PropertyInfo( Variant::STRING, "release/author") ); p_list->push_back( PropertyInfo( Variant::STRING, "release/author_id") ); diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 928d128799..8924f38de0 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -126,8 +126,8 @@ bool EditorExportPlatformJavaScript::_get(const StringName& p_name,Variant &r_re } void EditorExportPlatformJavaScript::_get_property_list( List<PropertyInfo> *p_list) const{ - p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/debug", PROPERTY_HINT_FILE,"zip")); - p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/release", PROPERTY_HINT_FILE,"zip")); + p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE,"zip")); + p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE,"zip")); p_list->push_back( PropertyInfo( Variant::INT, "options/memory_size",PROPERTY_HINT_ENUM,"32mb,64mb,128mb,256mb,512mb,1024mb")); p_list->push_back( PropertyInfo( Variant::BOOL, "browser/enable_run")); diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 087a648700..885f234a0a 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -138,8 +138,8 @@ bool EditorExportPlatformOSX::_get(const StringName& p_name,Variant &r_ret) cons } void EditorExportPlatformOSX::_get_property_list( List<PropertyInfo> *p_list) const{ - p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/debug", PROPERTY_HINT_FILE,"zip")); - p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/release", PROPERTY_HINT_FILE,"zip")); + p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE,"zip")); + p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE,"zip")); p_list->push_back( PropertyInfo( Variant::STRING, "application/name") ); p_list->push_back( PropertyInfo( Variant::STRING, "application/info") ); diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 5ab223a1b8..ef63286697 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -153,6 +153,7 @@ void CollisionPolygon2D::set_build_mode(BuildMode p_mode) { ERR_FAIL_INDEX(p_mode,2); build_mode=p_mode; + _update_parent(); } CollisionPolygon2D::BuildMode CollisionPolygon2D::get_build_mode() const{ @@ -174,7 +175,7 @@ void CollisionPolygon2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_build_mode"),&CollisionPolygon2D::set_build_mode); ObjectTypeDB::bind_method(_MD("get_build_mode"),&CollisionPolygon2D::get_build_mode); - ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Automatic,Segments,Solids"),_SCS("set_build_mode"),_SCS("get_build_mode")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Solids,Segments"),_SCS("set_build_mode"),_SCS("get_build_mode")); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); } diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index 56fbf358bc..4245bfa2c9 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -74,16 +74,18 @@ bool Camera::_set(const StringName& p_name, const Variant& p_value) { mode=PROJECTION_ORTHOGONAL; changed_all=true; - } else if (p_name=="fov") + } else if (p_name=="fov" || p_name=="fovy" || p_name=="fovx") fov=p_value; - else if (p_name=="size") + else if (p_name=="size" || p_name=="sizex" || p_name=="sizey") size=p_value; else if (p_name=="near") near=p_value; else if (p_name=="far") far=p_value; + else if (p_name=="keep_aspect") + set_keep_aspect_mode(KeepAspect(int(p_value))); else if (p_name=="vaspect") - set_use_vertical_aspect(p_value); + set_keep_aspect_mode(p_value?KEEP_WIDTH:KEEP_HEIGHT); else if (p_name=="current") { if (p_value.operator bool()) { make_current(); @@ -107,16 +109,16 @@ bool Camera::_get(const StringName& p_name,Variant &r_ret) const { if (p_name=="projection") { r_ret= mode; - } else if (p_name=="fov") + } else if (p_name=="fov" || p_name=="fovy" || p_name=="fovx") r_ret= fov; - else if (p_name=="size") + else if (p_name=="size" || p_name=="sizex" || p_name=="sizey") r_ret= size; else if (p_name=="near") r_ret= near; else if (p_name=="far") r_ret= far; - else if (p_name=="vaspect") - r_ret= vaspect; + else if (p_name=="keep_aspect") + r_ret= int(keep_aspect); else if (p_name=="current") { if (is_inside_scene() && get_scene()->is_editor_hint()) { @@ -142,19 +144,29 @@ void Camera::_get_property_list( List<PropertyInfo> *p_list) const { case PROJECTION_PERSPECTIVE: { - p_list->push_back( PropertyInfo( Variant::REAL, "fov" , PROPERTY_HINT_RANGE, "1,89,0.1") ); + p_list->push_back( PropertyInfo( Variant::REAL, "fov" , PROPERTY_HINT_RANGE, "1,89,0.1",PROPERTY_USAGE_NOEDITOR) ); + if (keep_aspect==KEEP_WIDTH) + p_list->push_back( PropertyInfo( Variant::REAL, "fovx" , PROPERTY_HINT_RANGE, "1,89,0.1",PROPERTY_USAGE_EDITOR) ); + else + p_list->push_back( PropertyInfo( Variant::REAL, "fovy" , PROPERTY_HINT_RANGE, "1,89,0.1",PROPERTY_USAGE_EDITOR) ); + } break; case PROJECTION_ORTHOGONAL: { - p_list->push_back( PropertyInfo( Variant::REAL, "size" , PROPERTY_HINT_RANGE, "1,16384,0.01" ) ); + p_list->push_back( PropertyInfo( Variant::REAL, "size" , PROPERTY_HINT_RANGE, "1,16384,0.01",PROPERTY_USAGE_NOEDITOR ) ); + if (keep_aspect==KEEP_WIDTH) + p_list->push_back( PropertyInfo( Variant::REAL, "sizex" , PROPERTY_HINT_RANGE, "0.1,16384,0.01",PROPERTY_USAGE_EDITOR) ); + else + p_list->push_back( PropertyInfo( Variant::REAL, "sizey" , PROPERTY_HINT_RANGE, "0.1,16384,0.01",PROPERTY_USAGE_EDITOR) ); + } break; } p_list->push_back( PropertyInfo( Variant::REAL, "near" , PROPERTY_HINT_EXP_RANGE, "0.01,4096.0,0.01") ); p_list->push_back( PropertyInfo( Variant::REAL, "far" , PROPERTY_HINT_EXP_RANGE, "0.01,4096.0,0.01") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "vaspect") ); + p_list->push_back( PropertyInfo( Variant::INT, "keep_aspect",PROPERTY_HINT_ENUM,"Keep Width,Keep Height") ); p_list->push_back( PropertyInfo( Variant::BOOL, "current" ) ); p_list->push_back( PropertyInfo( Variant::INT, "visible_layers",PROPERTY_HINT_ALL_FLAGS ) ); p_list->push_back( PropertyInfo( Variant::OBJECT, "environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment" ) ); @@ -441,7 +453,7 @@ Vector3 Camera::project_local_ray_normal(const Point2& p_pos) const { ray=Vector3(0,0,-1); } else { CameraMatrix cm; - cm.set_perspective(fov,viewport_size.get_aspect(),near,far,vaspect); + cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH); float screen_w,screen_h; cm.get_viewport_size(screen_w,screen_h); ray=Vector3( ((p_pos.x/viewport_size.width)*2.0-1.0)*screen_w, ((1.0-(p_pos.y/viewport_size.height))*2.0-1.0)*screen_h,-near).normalized(); @@ -472,7 +484,7 @@ Vector3 Camera::project_ray_origin(const Point2& p_pos) const { Vector2 pos = p_pos / viewport_size; float vsize,hsize; - if (vaspect) { + if (keep_aspect==KEEP_WIDTH) { vsize = size/viewport_size.get_aspect(); hsize = size; } else { @@ -503,9 +515,9 @@ Point2 Camera::unproject_position(const Vector3& p_pos) const { if (mode==PROJECTION_ORTHOGONAL) - cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,vaspect); + cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH); else - cm.set_perspective(fov,viewport_size.get_aspect(),near,far,vaspect); + cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH); Plane p(get_camera_transform().xform_inv(p_pos),1.0); @@ -533,9 +545,9 @@ Vector3 Camera::project_position(const Point2& p_point) const { CameraMatrix cm; if (mode==PROJECTION_ORTHOGONAL) - cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,vaspect); + cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH); else - cm.set_perspective(fov,viewport_size.get_aspect(),near,far,vaspect); + cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH); Size2 vp_size; cm.get_viewport_size(vp_size.x,vp_size.y); @@ -583,6 +595,20 @@ Ref<Environment> Camera::get_environment() const { } +void Camera::set_keep_aspect_mode(KeepAspect p_aspect) { + + keep_aspect=p_aspect; + VisualServer::get_singleton()->camera_set_use_vertical_aspect(camera,p_aspect==KEEP_WIDTH); + + _change_notify(); +} + +Camera::KeepAspect Camera::get_keep_aspect_mode() const{ + + return keep_aspect; +} + + void Camera::_bind_methods() { @@ -608,12 +634,16 @@ void Camera::_bind_methods() { ObjectTypeDB::bind_method( _MD("look_at_from_pos","pos","target","up"),&Camera::look_at_from_pos ); ObjectTypeDB::bind_method(_MD("set_environment","env:Environment"),&Camera::set_environment); ObjectTypeDB::bind_method(_MD("get_environment:Environment"),&Camera::get_environment); - ObjectTypeDB::bind_method(_MD("set_use_vertical_aspect","enable"),&Camera::set_use_vertical_aspect); - ObjectTypeDB::bind_method(_MD("is_using_vertical_aspect"),&Camera::is_using_vertical_aspect); + ObjectTypeDB::bind_method(_MD("set_keep_aspect_mode","mode"),&Camera::set_keep_aspect_mode); + ObjectTypeDB::bind_method(_MD("get_keep_aspect_mode"),&Camera::get_keep_aspect_mode); //ObjectTypeDB::bind_method( _MD("_camera_make_current"),&Camera::_camera_make_current ); BIND_CONSTANT( PROJECTION_PERSPECTIVE ); BIND_CONSTANT( PROJECTION_ORTHOGONAL ); + + BIND_CONSTANT( KEEP_WIDTH ); + BIND_CONSTANT( KEEP_HEIGHT ); + } float Camera::get_fov() const { @@ -661,26 +691,15 @@ Vector<Plane> Camera::get_frustum() const { Size2 viewport_size = viewport_ptr->get_visible_rect().size; CameraMatrix cm; if (mode==PROJECTION_PERSPECTIVE) - cm.set_perspective(fov,viewport_size.get_aspect(),near,far,vaspect); + cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH); else - cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,vaspect); + cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH); return cm.get_projection_planes(get_global_transform()); } -void Camera::set_use_vertical_aspect(bool p_enable) { - - vaspect=p_enable; - VisualServer::get_singleton()->camera_set_use_vertical_aspect(camera,p_enable); -} - - -bool Camera::is_using_vertical_aspect() const{ - - return vaspect; -} void Camera::look_at(const Vector3& p_target, const Vector3& p_up_normal) { @@ -712,7 +731,7 @@ Camera::Camera() { force_change=false; mode=PROJECTION_PERSPECTIVE; set_perspective(60.0,0.1,100.0); - vaspect=false; + keep_aspect=KEEP_HEIGHT; layers=0xFFFFFFFF; //active=false; } diff --git a/scene/3d/camera.h b/scene/3d/camera.h index a8599497ac..014c7cb520 100644 --- a/scene/3d/camera.h +++ b/scene/3d/camera.h @@ -46,6 +46,11 @@ public: PROJECTION_ORTHOGONAL }; + enum KeepAspect { + KEEP_WIDTH, + KEEP_HEIGHT + }; + private: bool force_change; @@ -56,7 +61,7 @@ private: float fov; float size; float near,far; - bool vaspect; + KeepAspect keep_aspect; RID camera; RID scenario_id; @@ -126,8 +131,8 @@ public: void set_environment(const Ref<Environment>& p_environment); Ref<Environment> get_environment() const; - void set_use_vertical_aspect(bool p_enable); - bool is_using_vertical_aspect() const; + void set_keep_aspect_mode(KeepAspect p_aspect); + KeepAspect get_keep_aspect_mode() const; void look_at(const Vector3& p_target, const Vector3& p_up_normal); void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal); @@ -140,5 +145,6 @@ public: VARIANT_ENUM_CAST( Camera::Projection ); +VARIANT_ENUM_CAST( Camera::KeepAspect ); #endif diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp new file mode 100644 index 0000000000..5a613f360a --- /dev/null +++ b/scene/3d/collision_polygon.cpp @@ -0,0 +1,206 @@ +#include "collision_polygon.h" + +#include "collision_object.h" +#include "scene/resources/concave_polygon_shape.h" +#include "scene/resources/convex_polygon_shape.h" + +void CollisionPolygon::_add_to_collision_object(Object *p_obj) { + + + CollisionObject *co = p_obj->cast_to<CollisionObject>(); + ERR_FAIL_COND(!co); + + if (polygon.size()==0) + return; + + bool solids=build_mode==BUILD_SOLIDS; + + Vector< Vector<Vector2> > decomp = Geometry::decompose_polygon(polygon); + if (decomp.size()==0) + return; + + if (true || solids) { + + //here comes the sun, lalalala + //decompose concave into multiple convex polygons and add them + for(int i=0;i<decomp.size();i++) { + Ref<ConvexPolygonShape> convex = memnew( ConvexPolygonShape ); + DVector<Vector3> cp; + int cs = decomp[i].size(); + cp.resize(cs*2); + { + DVector<Vector3>::Write w = cp.write(); + int idx=0; + for(int j=0;j<cs;j++) { + + Vector2 d = decomp[i][j]; + w[idx++]=Vector3(d.x,d.y,depth*0.5); + w[idx++]=Vector3(d.x,d.y,-depth*0.5); + } + } + + convex->set_points(cp); + co->add_shape(convex,get_transform()); + + } + + } else { +#if 0 + Ref<ConcavePolygonShape> concave = memnew( ConcavePolygonShape ); + + DVector<Vector2> segments; + segments.resize(polygon.size()*2); + DVector<Vector2>::Write w=segments.write(); + + for(int i=0;i<polygon.size();i++) { + w[(i<<1)+0]=polygon[i]; + w[(i<<1)+1]=polygon[(i+1)%polygon.size()]; + } + + w=DVector<Vector2>::Write(); + concave->set_segments(segments); + + co->add_shape(concave,get_transform()); +#endif + } + + + //co->add_shape(shape,get_transform()); + +} + +void CollisionPolygon::_update_parent() { + + Node *parent = get_parent(); + if (!parent) + return; + CollisionObject *co = parent->cast_to<CollisionObject>(); + if (!co) + return; + co->_update_shapes_from_children(); +} + +void CollisionPolygon::_notification(int p_what) { + + + switch(p_what) { + case NOTIFICATION_TRANSFORM_CHANGED: { + + if (!is_inside_scene()) + break; + _update_parent(); + + } break; +#if 0 + case NOTIFICATION_DRAW: { + for(int i=0;i<polygon.size();i++) { + + Vector2 p = polygon[i]; + Vector2 n = polygon[(i+1)%polygon.size()]; + draw_line(p,n,Color(0,0.6,0.7,0.5),3); + } + + Vector< Vector<Vector2> > decomp = Geometry::decompose_polygon(polygon); +#define DEBUG_DECOMPOSE +#ifdef DEBUG_DECOMPOSE + Color c(0.4,0.9,0.1); + for(int i=0;i<decomp.size();i++) { + + c.set_hsv( Math::fmod(c.get_h() + 0.738,1),c.get_s(),c.get_v(),0.5); + draw_colored_polygon(decomp[i],c); + } +#endif + + } break; +#endif + } +} + +void CollisionPolygon::set_polygon(const Vector<Point2>& p_polygon) { + + polygon=p_polygon; + + for(int i=0;i<polygon.size();i++) { + + Vector3 p1(polygon[i].x,polygon[i].y,depth*0.5); + + if (i==0) + aabb=AABB(p1,Vector3()); + else + aabb.expand_to(p1); + + Vector3 p2(polygon[i].x,polygon[i].y,-depth*0.5); + aabb.expand_to(p2); + + + } + if (aabb==AABB()) { + + aabb=AABB(Vector3(-1,-1,-1),Vector3(2,2,2)); + } else { + aabb.pos-=aabb.size*0.3; + aabb.size+=aabb.size*0.6; + } + _update_parent(); + update_gizmo(); +} + +Vector<Point2> CollisionPolygon::get_polygon() const { + + return polygon; +} + +void CollisionPolygon::set_build_mode(BuildMode p_mode) { + + ERR_FAIL_INDEX(p_mode,2); + build_mode=p_mode; + _update_parent(); +} + +CollisionPolygon::BuildMode CollisionPolygon::get_build_mode() const{ + + return build_mode; +} + +AABB CollisionPolygon::get_item_rect() const { + + return aabb; +} + +void CollisionPolygon::set_depth(float p_depth) { + + depth=p_depth; + _update_parent(); + update_gizmo(); +} + +float CollisionPolygon::get_depth() const { + + return depth; +} + + +void CollisionPolygon::_bind_methods() { + + ObjectTypeDB::bind_method(_MD("_add_to_collision_object"),&CollisionPolygon::_add_to_collision_object); + ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon::set_polygon); + ObjectTypeDB::bind_method(_MD("get_polygon"),&CollisionPolygon::get_polygon); + + ObjectTypeDB::bind_method(_MD("set_depth","depth"),&CollisionPolygon::set_depth); + ObjectTypeDB::bind_method(_MD("get_depth"),&CollisionPolygon::get_depth); + + ObjectTypeDB::bind_method(_MD("set_build_mode"),&CollisionPolygon::set_build_mode); + ObjectTypeDB::bind_method(_MD("get_build_mode"),&CollisionPolygon::get_build_mode); + + ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Solids,Triangles"),_SCS("set_build_mode"),_SCS("get_build_mode")); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"depth"),_SCS("set_depth"),_SCS("get_depth")); +} + +CollisionPolygon::CollisionPolygon() { + + aabb=AABB(Vector3(-1,-1,-1),Vector3(2,2,2)); + build_mode=BUILD_SOLIDS; + depth=1.0; + +} diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h new file mode 100644 index 0000000000..efb3666778 --- /dev/null +++ b/scene/3d/collision_polygon.h @@ -0,0 +1,50 @@ +#ifndef COLLISION_POLYGON_H +#define COLLISION_POLYGON_H + +#include "scene/3d/spatial.h" +#include "scene/resources/shape.h" + + + +class CollisionPolygon : public Spatial { + + OBJ_TYPE(CollisionPolygon,Spatial); +public: + + enum BuildMode { + BUILD_SOLIDS, + BUILD_TRIANGLES, + }; + +protected: + + + float depth; + AABB aabb; + BuildMode build_mode; + Vector<Point2> polygon; + + void _add_to_collision_object(Object *p_obj); + void _update_parent(); + +protected: + + void _notification(int p_what); + static void _bind_methods(); +public: + + void set_build_mode(BuildMode p_mode); + BuildMode get_build_mode() const; + + void set_depth(float p_depth); + float get_depth() const; + + void set_polygon(const Vector<Point2>& p_polygon); + Vector<Point2> get_polygon() const; + + virtual AABB get_item_rect() const; + CollisionPolygon(); +}; + +VARIANT_ENUM_CAST( CollisionPolygon::BuildMode ); +#endif // COLLISION_POLYGON_H diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 3c95b102d7..2d6f3cd27a 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -113,7 +113,7 @@ void TabContainer::_input_event(const InputEvent& p_event) { break; } - String s = c->has_meta("_tab_title")?String(XL_MESSAGE(String(c->get_meta("_tab_title")))):String(c->get_name()); + String s = c->has_meta("_tab_name")?String(XL_MESSAGE(String(c->get_meta("_tab_name")))):String(c->get_name()); int tab_width=font->get_string_size(s).width; if (c->has_meta("_tab_icon")) { @@ -220,7 +220,7 @@ void TabContainer::_notification(int p_what) { continue; - String s = c->has_meta("_tab_title")?String(XL_MESSAGE(String(c->get_meta("_tab_title")))):String(c->get_name()); + String s = c->has_meta("_tab_name")?String(XL_MESSAGE(String(c->get_meta("_tab_name")))):String(c->get_name()); w+=font->get_string_size(s).width; if (c->has_meta("_tab_icon")) { Ref<Texture> icon = c->get_meta("_tab_icon"); @@ -284,7 +284,7 @@ void TabContainer::_notification(int p_what) { continue; } - String s = c->has_meta("_tab_title")?String(c->get_meta("_tab_title")):String(c->get_name()); + String s = c->has_meta("_tab_name")?String(c->get_meta("_tab_name")):String(c->get_name()); int w=font->get_string_size(s).width; Ref<Texture> icon; if (c->has_meta("_tab_icon")) { diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index b7c857b9c7..ae7a4d59a7 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -278,7 +278,8 @@ void Tabs::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_tab_title","tab_idx"),&Tabs::get_tab_title); ObjectTypeDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&Tabs::set_tab_icon); ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&Tabs::get_tab_icon); - ObjectTypeDB::bind_method(_MD("remove_tab","tab_idx","icon:Texture"),&Tabs::remove_tab); + ObjectTypeDB::bind_method(_MD("remove_tab","tab_idx"),&Tabs::remove_tab); + ObjectTypeDB::bind_method(_MD("add_tab","title","icon:Texture"),&Tabs::add_tab); ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab"))); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 83dd64c31d..92dcef803c 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1252,6 +1252,7 @@ void Viewport::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_use_own_world","enable"), &Viewport::set_use_own_world); ObjectTypeDB::bind_method(_MD("is_using_own_world"), &Viewport::is_using_own_world); + ObjectTypeDB::bind_method(_MD("get_camera:Camera"), &Viewport::get_camera); ObjectTypeDB::bind_method(_MD("set_as_audio_listener","enable"), &Viewport::set_as_audio_listener); ObjectTypeDB::bind_method(_MD("is_audio_listener","enable"), &Viewport::is_audio_listener); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 804c6c6f34..08e6ff2e54 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -199,7 +199,7 @@ #include "scene/3d/proximity_group.h" #include "scene/3d/navigation_mesh.h" #include "scene/3d/navigation.h" - +#include "scene/3d/collision_polygon.h" #endif #include "scene/scene_binds.h" @@ -409,6 +409,7 @@ void register_scene_types() { ObjectTypeDB::register_type<Area>(); ObjectTypeDB::register_type<ProximityGroup>(); ObjectTypeDB::register_type<CollisionShape>(); + ObjectTypeDB::register_type<CollisionPolygon>(); ObjectTypeDB::register_type<RayCast>(); ObjectTypeDB::register_virtual_type<EditableShape>(); ObjectTypeDB::register_type<EditableSphere>(); diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index 8f9195110b..6e8cb987e9 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -439,8 +439,8 @@ bool EditorExportPlatformPC::_get(const StringName& p_name,Variant &r_ret) const void EditorExportPlatformPC::_get_property_list( List<PropertyInfo> *p_list) const { - p_list->push_back( PropertyInfo( Variant::STRING, "custom_binary/debug", PROPERTY_HINT_FILE,binary_extension)); - p_list->push_back( PropertyInfo( Variant::STRING, "custom_binary/release", PROPERTY_HINT_FILE,binary_extension)); + p_list->push_back( PropertyInfo( Variant::STRING, "custom_binary/debug", PROPERTY_HINT_GLOBAL_FILE,binary_extension)); + p_list->push_back( PropertyInfo( Variant::STRING, "custom_binary/release", PROPERTY_HINT_GLOBAL_FILE,binary_extension)); p_list->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Single Exec.,Exec+Pack (.pck),Copy,Bundles (Optical)")); p_list->push_back( PropertyInfo( Variant::BOOL, "binary/64_bits")); } @@ -1009,15 +1009,15 @@ Error EditorExportPlatformPC::export_project(const String& p_path, bool p_debug, String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; if (use64) { if (p_debug) - exe_path+=custom_debug_binary!=""?custom_debug_binary:debug_binary64; + exe_path=custom_debug_binary!=""?custom_debug_binary:exe_path+debug_binary64; else - exe_path+=custom_release_binary!=""?custom_release_binary:release_binary64; + exe_path=custom_release_binary!=""?custom_release_binary:exe_path+release_binary64; } else { if (p_debug) - exe_path+=custom_debug_binary!=""?custom_debug_binary:debug_binary32; + exe_path=custom_debug_binary!=""?custom_debug_binary:exe_path+debug_binary32; else - exe_path+=custom_release_binary!=""?custom_release_binary:release_binary32; + exe_path=custom_release_binary!=""?custom_release_binary:exe_path+release_binary32; } diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 6ac72fc401..4e2e5118dd 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -79,6 +79,7 @@ #include "plugins/path_editor_plugin.h" #include "plugins/rich_text_editor_plugin.h" #include "plugins/collision_polygon_editor_plugin.h" +#include "plugins/collision_polygon_2d_editor_plugin.h" #include "plugins/script_editor_plugin.h" #include "plugins/path_2d_editor_plugin.h" #include "plugins/particles_editor_plugin.h" @@ -4086,6 +4087,7 @@ EditorNode::EditorNode() { add_editor_plugin( memnew( ItemListEditorPlugin(this) ) ); add_editor_plugin( memnew( RichTextEditorPlugin(this) ) ); add_editor_plugin( memnew( CollisionPolygonEditorPlugin(this) ) ); + add_editor_plugin( memnew( CollisionPolygon2DEditorPlugin(this) ) ); add_editor_plugin( memnew( TileSetEditorPlugin(this) ) ); add_editor_plugin( memnew( TileMapEditorPlugin(this) ) ); add_editor_plugin( memnew( SpriteFramesEditorPlugin(this) ) ); diff --git a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp new file mode 100644 index 0000000000..080ed7d11c --- /dev/null +++ b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -0,0 +1,457 @@ +#include "collision_polygon_2d_editor_plugin.h" + +#include "canvas_item_editor_plugin.h" +#include "os/file_access.h" +#include "tools/editor/editor_settings.h" + +void CollisionPolygon2DEditor::_notification(int p_what) { + + switch(p_what) { + + case NOTIFICATION_READY: { + + button_create->set_icon( get_icon("Edit","EditorIcons")); + button_edit->set_icon( get_icon("MovePoint","EditorIcons")); + button_edit->set_pressed(true); + + + } break; + case NOTIFICATION_FIXED_PROCESS: { + + + } break; + } + +} +void CollisionPolygon2DEditor::_node_removed(Node *p_node) { + + if(p_node==node) { + node=NULL; + hide(); + } + +} + + +Vector2 CollisionPolygon2DEditor::snap_point(const Vector2& p_point) const { + + if (canvas_item_editor->is_snap_active()) { + + return p_point.snapped(Vector2(1,1)*canvas_item_editor->get_snap()); + + } else { + return p_point; + } +} + +void CollisionPolygon2DEditor::_menu_option(int p_option) { + + switch(p_option) { + + case MODE_CREATE: { + + mode=MODE_CREATE; + button_create->set_pressed(true); + button_edit->set_pressed(false); + } break; + case MODE_EDIT: { + + mode=MODE_EDIT; + button_create->set_pressed(false); + button_edit->set_pressed(true); + } break; + + } +} + +void CollisionPolygon2DEditor::_wip_close() { + + undo_redo->create_action("Create Poly"); + undo_redo->add_undo_method(node,"set_polygon",node->get_polygon()); + undo_redo->add_do_method(node,"set_polygon",wip); + undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); + undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update"); + undo_redo->commit_action(); + wip.clear(); + wip_active=false; + mode=MODE_EDIT; + button_edit->set_pressed(true); + button_create->set_pressed(false); + edited_point=-1; +} + +bool CollisionPolygon2DEditor::forward_input_event(const InputEvent& p_event) { + + + switch(p_event.type) { + + case InputEvent::MOUSE_BUTTON: { + + const InputEventMouseButton &mb=p_event.mouse_button; + + Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); + + + Vector2 gpoint = Point2(mb.x,mb.y); + Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint); + cpoint=snap_point(cpoint); + cpoint = node->get_global_transform().affine_inverse().xform(cpoint); + + Vector<Vector2> poly = node->get_polygon(); + + //first check if a point is to be added (segment split) + real_t grab_treshold=EDITOR_DEF("poly_editor/point_grab_radius",8); + + switch(mode) { + + + case MODE_CREATE: { + + if (mb.button_index==BUTTON_LEFT && mb.pressed) { + + + if (!wip_active) { + + wip.clear(); + wip.push_back( cpoint ); + wip_active=true; + edited_point_pos=cpoint; + canvas_item_editor->get_viewport_control()->update(); + edited_point=1; + return true; + } else { + + + if (wip.size()>1 && xform.xform(wip[0]).distance_to(gpoint)<grab_treshold) { + //wip closed + _wip_close(); + + return true; + } else { + + wip.push_back( cpoint ); + edited_point=wip.size(); + canvas_item_editor->get_viewport_control()->update(); + return true; + + //add wip point + } + } + } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && wip_active) { + _wip_close(); + } + + + + } break; + + case MODE_EDIT: { + + if (mb.button_index==BUTTON_LEFT) { + if (mb.pressed) { + + if (mb.mod.control) { + + + if (poly.size() < 3) { + + undo_redo->create_action("Edit Poly"); + undo_redo->add_undo_method(node,"set_polygon",poly); + poly.push_back(cpoint); + undo_redo->add_do_method(node,"set_polygon",poly); + undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); + undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update"); + undo_redo->commit_action(); + return true; + } + + //search edges + int closest_idx=-1; + Vector2 closest_pos; + real_t closest_dist=1e10; + for(int i=0;i<poly.size();i++) { + + Vector2 points[2] ={ xform.xform(poly[i]), + xform.xform(poly[(i+1)%poly.size()]) }; + + Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint,points); + if (cp.distance_squared_to(points[0])<CMP_EPSILON2 || cp.distance_squared_to(points[1])<CMP_EPSILON2) + continue; //not valid to reuse point + + real_t d = cp.distance_to(gpoint); + if (d<closest_dist && d<grab_treshold) { + closest_dist=d; + closest_pos=cp; + closest_idx=i; + } + + + } + + if (closest_idx>=0) { + + pre_move_edit=poly; + poly.insert(closest_idx+1,xform.affine_inverse().xform(closest_pos)); + edited_point=closest_idx+1; + edited_point_pos=xform.affine_inverse().xform(closest_pos); + node->set_polygon(poly); + canvas_item_editor->get_viewport_control()->update(); + return true; + } + } else { + + //look for points to move + + int closest_idx=-1; + Vector2 closest_pos; + real_t closest_dist=1e10; + for(int i=0;i<poly.size();i++) { + + Vector2 cp =xform.xform(poly[i]); + + real_t d = cp.distance_to(gpoint); + if (d<closest_dist && d<grab_treshold) { + closest_dist=d; + closest_pos=cp; + closest_idx=i; + } + + } + + if (closest_idx>=0) { + + pre_move_edit=poly; + edited_point=closest_idx; + edited_point_pos=xform.affine_inverse().xform(closest_pos); + canvas_item_editor->get_viewport_control()->update(); + return true; + } + } + } else { + + if (edited_point!=-1) { + + //apply + + ERR_FAIL_INDEX_V(edited_point,poly.size(),false); + poly[edited_point]=edited_point_pos; + undo_redo->create_action("Edit Poly"); + undo_redo->add_do_method(node,"set_polygon",poly); + undo_redo->add_undo_method(node,"set_polygon",pre_move_edit); + undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); + undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update"); + undo_redo->commit_action(); + + edited_point=-1; + return true; + } + } + } if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) { + + + + int closest_idx=-1; + Vector2 closest_pos; + real_t closest_dist=1e10; + for(int i=0;i<poly.size();i++) { + + Vector2 cp =xform.xform(poly[i]); + + real_t d = cp.distance_to(gpoint); + if (d<closest_dist && d<grab_treshold) { + closest_dist=d; + closest_pos=cp; + closest_idx=i; + } + + } + + if (closest_idx>=0) { + + + undo_redo->create_action("Edit Poly (Remove Point)"); + undo_redo->add_undo_method(node,"set_polygon",poly); + poly.remove(closest_idx); + undo_redo->add_do_method(node,"set_polygon",poly); + undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); + undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update"); + undo_redo->commit_action(); + return true; + } + + } + + + + } break; + } + + + + } break; + case InputEvent::MOUSE_MOTION: { + + const InputEventMouseMotion &mm=p_event.mouse_motion; + + if (edited_point!=-1 && (wip_active || mm.button_mask&BUTTON_MASK_LEFT)) { + + Vector2 gpoint = Point2(mm.x,mm.y); + Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint); + cpoint=snap_point(cpoint); + edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint); + + canvas_item_editor->get_viewport_control()->update(); + + } + + } break; + } + + return false; +} +void CollisionPolygon2DEditor::_canvas_draw() { + + if (!node) + return; + + Control *vpc = canvas_item_editor->get_viewport_control(); + + Vector<Vector2> poly; + + if (wip_active) + poly=wip; + else + poly=node->get_polygon(); + + + Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); + Ref<Texture> handle= get_icon("EditorHandle","EditorIcons"); + + int len = poly.size(); + + for(int i=0;i<poly.size();i++) { + + + Vector2 p,p2; + p = i==edited_point ? edited_point_pos : poly[i]; + if ((wip_active && i==poly.size()-1) || (((i+1)%poly.size())==edited_point)) + p2=edited_point_pos; + else + p2 = poly[(i+1)%poly.size()]; + + Vector2 point = xform.xform(p); + Vector2 next_point = xform.xform(p2); + + Color col=Color(1,0.3,0.1,0.8); + vpc->draw_line(point,next_point,col,2); + vpc->draw_texture(handle,point-handle->get_size()*0.5); + } +} + + + +void CollisionPolygon2DEditor::edit(Node *p_collision_polygon) { + + if (!canvas_item_editor) { + canvas_item_editor=CanvasItemEditor::get_singleton(); + } + + if (p_collision_polygon) { + + node=p_collision_polygon->cast_to<CollisionPolygon2D>(); + if (!canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw")) + canvas_item_editor->get_viewport_control()->connect("draw",this,"_canvas_draw"); + wip.clear(); + wip_active=false; + edited_point=-1; + + } else { + node=NULL; + + if (canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw")) + canvas_item_editor->get_viewport_control()->disconnect("draw",this,"_canvas_draw"); + + } + +} + +void CollisionPolygon2DEditor::_bind_methods() { + + ObjectTypeDB::bind_method(_MD("_menu_option"),&CollisionPolygon2DEditor::_menu_option); + ObjectTypeDB::bind_method(_MD("_canvas_draw"),&CollisionPolygon2DEditor::_canvas_draw); + +} + +CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) { + + canvas_item_editor=NULL; + editor=p_editor; + undo_redo = editor->get_undo_redo(); + + add_child( memnew( VSeparator )); + button_create = memnew( ToolButton ); + add_child(button_create); + button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE)); + button_create->set_toggle_mode(true); + + button_edit = memnew( ToolButton ); + add_child(button_edit); + button_edit->connect("pressed",this,"_menu_option",varray(MODE_EDIT)); + button_edit->set_toggle_mode(true); + + //add_constant_override("separation",0); + +#if 0 + options = memnew( MenuButton ); + add_child(options); + options->set_area_as_parent_rect(); + options->set_text("Polygon"); + //options->get_popup()->add_item("Parse BBCODE",PARSE_BBCODE); + options->get_popup()->connect("item_pressed", this,"_menu_option"); +#endif + + mode = MODE_EDIT; + wip_active=false; + +} + + +void CollisionPolygon2DEditorPlugin::edit(Object *p_object) { + + collision_polygon_editor->edit(p_object->cast_to<Node>()); +} + +bool CollisionPolygon2DEditorPlugin::handles(Object *p_object) const { + + return p_object->is_type("CollisionPolygon2D"); +} + +void CollisionPolygon2DEditorPlugin::make_visible(bool p_visible) { + + if (p_visible) { + collision_polygon_editor->show(); + } else { + + collision_polygon_editor->hide(); + collision_polygon_editor->edit(NULL); + } + +} + +CollisionPolygon2DEditorPlugin::CollisionPolygon2DEditorPlugin(EditorNode *p_node) { + + editor=p_node; + collision_polygon_editor = memnew( CollisionPolygon2DEditor(p_node) ); + CanvasItemEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor); + + collision_polygon_editor->hide(); + + + +} + + +CollisionPolygon2DEditorPlugin::~CollisionPolygon2DEditorPlugin() +{ +} + diff --git a/tools/editor/plugins/collision_polygon_2d_editor_plugin.h b/tools/editor/plugins/collision_polygon_2d_editor_plugin.h new file mode 100644 index 0000000000..052019b6c5 --- /dev/null +++ b/tools/editor/plugins/collision_polygon_2d_editor_plugin.h @@ -0,0 +1,84 @@ +#ifndef COLLISION_POLYGON_2D_EDITOR_PLUGIN_H +#define COLLISION_POLYGON_2D_EDITOR_PLUGIN_H + + +#include "tools/editor/editor_plugin.h" +#include "tools/editor/editor_node.h" +#include "scene/2d/collision_polygon_2d.h" +#include "scene/gui/tool_button.h" +#include "scene/gui/button_group.h" + +/** + @author Juan Linietsky <reduzio@gmail.com> +*/ +class CanvasItemEditor; + +class CollisionPolygon2DEditor : public HBoxContainer { + + OBJ_TYPE(CollisionPolygon2DEditor, HBoxContainer ); + + UndoRedo *undo_redo; + enum Mode { + + MODE_CREATE, + MODE_EDIT, + + }; + + Mode mode; + + ToolButton *button_create; + ToolButton *button_edit; + + CanvasItemEditor *canvas_item_editor; + EditorNode *editor; + Panel *panel; + CollisionPolygon2D *node; + MenuButton *options; + + int edited_point; + Vector2 edited_point_pos; + Vector<Vector2> pre_move_edit; + Vector<Vector2> wip; + bool wip_active; + + + void _wip_close(); + void _canvas_draw(); + void _menu_option(int p_option); + +protected: + void _notification(int p_what); + void _node_removed(Node *p_node); + static void _bind_methods(); +public: + + Vector2 snap_point(const Vector2& p_point) const; + bool forward_input_event(const InputEvent& p_event); + void edit(Node *p_collision_polygon); + CollisionPolygon2DEditor(EditorNode *p_editor); +}; + +class CollisionPolygon2DEditorPlugin : public EditorPlugin { + + OBJ_TYPE( CollisionPolygon2DEditorPlugin, EditorPlugin ); + + CollisionPolygon2DEditor *collision_polygon_editor; + EditorNode *editor; + +public: + + virtual bool forward_input_event(const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); } + + virtual String get_name() const { return "CollisionPolygon2D"; } + bool has_main_screen() const { return false; } + virtual void edit(Object *p_node); + virtual bool handles(Object *p_node) const; + virtual void make_visible(bool p_visible); + + CollisionPolygon2DEditorPlugin(EditorNode *p_node); + ~CollisionPolygon2DEditorPlugin(); + +}; + +#endif // COLLISION_POLYGON_2D_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp index 93ad918b0e..16b9622312 100644 --- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp @@ -27,10 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "collision_polygon_editor_plugin.h" -#include "canvas_item_editor_plugin.h" +#include "spatial_editor_plugin.h" #include "os/file_access.h" #include "tools/editor/editor_settings.h" - +#include "scene/3d/camera.h" void CollisionPolygonEditor::_notification(int p_what) { switch(p_what) { @@ -40,11 +40,16 @@ void CollisionPolygonEditor::_notification(int p_what) { button_create->set_icon( get_icon("Edit","EditorIcons")); button_edit->set_icon( get_icon("MovePoint","EditorIcons")); button_edit->set_pressed(true); + get_scene()->connect("node_removed",this,"_node_removed"); } break; - case NOTIFICATION_FIXED_PROCESS: { + case NOTIFICATION_PROCESS: { + if (node->get_depth() != prev_depth) { + _polygon_draw(); + prev_depth=node->get_depth(); + } } break; } @@ -54,7 +59,10 @@ void CollisionPolygonEditor::_node_removed(Node *p_node) { if(p_node==node) { node=NULL; + if (imgeom->get_parent()==p_node) + p_node->remove_child(imgeom); hide(); + set_process(false); } } @@ -62,13 +70,15 @@ void CollisionPolygonEditor::_node_removed(Node *p_node) { Vector2 CollisionPolygonEditor::snap_point(const Vector2& p_point) const { + return p_point; + /* if (canvas_item_editor->is_snap_active()) { return p_point.snapped(Vector2(1,1)*canvas_item_editor->get_snap()); } else { return p_point; - } + } ??? */ } void CollisionPolygonEditor::_menu_option(int p_option) { @@ -93,21 +103,28 @@ void CollisionPolygonEditor::_menu_option(int p_option) { void CollisionPolygonEditor::_wip_close() { - undo_redo->create_action("Create Poly"); + undo_redo->create_action("Create Poly3D"); undo_redo->add_undo_method(node,"set_polygon",node->get_polygon()); undo_redo->add_do_method(node,"set_polygon",wip); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update"); - undo_redo->commit_action(); + undo_redo->add_do_method(this,"_polygon_draw"); + undo_redo->add_undo_method(this,"_polygon_draw"); wip.clear(); wip_active=false; mode=MODE_EDIT; button_edit->set_pressed(true); button_create->set_pressed(false); edited_point=-1; + undo_redo->commit_action(); + } -bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { +bool CollisionPolygonEditor::forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event) { + + + Transform gt = node->get_global_transform(); + float depth = node->get_depth()*0.5; + Vector3 n = gt.basis.get_axis(2).normalized(); + Plane p(gt.origin+n*depth,n); switch(p_event.type) { @@ -116,13 +133,20 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { const InputEventMouseButton &mb=p_event.mouse_button; - Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - Vector2 gpoint = Point2(mb.x,mb.y); - Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint); - cpoint=snap_point(cpoint); - cpoint = node->get_global_transform().affine_inverse().xform(cpoint); + Vector2 gpoint=Point2(mb.x,mb.y); + Vector3 ray_from = p_camera->project_ray_origin(gpoint); + Vector3 ray_dir = p_camera->project_ray_normal(gpoint); + + Vector3 spoint; + + if (!p.intersects_ray(ray_from,ray_dir,&spoint)) + break; + + Vector2 cpoint(spoint.x,spoint.y); + + //cpoint=snap_point(cpoint); snap? Vector<Vector2> poly = node->get_polygon(); @@ -143,13 +167,13 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { wip.push_back( cpoint ); wip_active=true; edited_point_pos=cpoint; - canvas_item_editor->get_viewport_control()->update(); + _polygon_draw(); edited_point=1; return true; } else { - if (wip.size()>1 && xform.xform(wip[0]).distance_to(gpoint)<grab_treshold) { + if (wip.size()>1 && p_camera->unproject_position(gt.xform(Vector3(wip[0].x,wip[0].y,depth))).distance_to(gpoint)<grab_treshold) { //wip closed _wip_close(); @@ -158,7 +182,7 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { wip.push_back( cpoint ); edited_point=wip.size(); - canvas_item_editor->get_viewport_control()->update(); + _polygon_draw(); return true; //add wip point @@ -186,8 +210,8 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { undo_redo->add_undo_method(node,"set_polygon",poly); poly.push_back(cpoint); undo_redo->add_do_method(node,"set_polygon",poly); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update"); + undo_redo->add_do_method(this,"_polygon_draw"); + undo_redo->add_undo_method(this,"_polygon_draw"); undo_redo->commit_action(); return true; } @@ -198,8 +222,10 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { real_t closest_dist=1e10; for(int i=0;i<poly.size();i++) { - Vector2 points[2] ={ xform.xform(poly[i]), - xform.xform(poly[(i+1)%poly.size()]) }; + Vector2 points[2] ={ + p_camera->unproject_position(gt.xform(Vector3(poly[i].x,poly[i].y,depth))), + p_camera->unproject_position(gt.xform(Vector3(poly[(i+1)%poly.size()].x,poly[(i+1)%poly.size()].y,depth))) + }; Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint,points); if (cp.distance_squared_to(points[0])<CMP_EPSILON2 || cp.distance_squared_to(points[1])<CMP_EPSILON2) @@ -218,11 +244,11 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { if (closest_idx>=0) { pre_move_edit=poly; - poly.insert(closest_idx+1,xform.affine_inverse().xform(closest_pos)); + poly.insert(closest_idx+1,cpoint); edited_point=closest_idx+1; - edited_point_pos=xform.affine_inverse().xform(closest_pos); + edited_point_pos=cpoint; node->set_polygon(poly); - canvas_item_editor->get_viewport_control()->update(); + _polygon_draw(); return true; } } else { @@ -234,7 +260,7 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { real_t closest_dist=1e10; for(int i=0;i<poly.size();i++) { - Vector2 cp =xform.xform(poly[i]); + Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x,poly[i].y,depth))); real_t d = cp.distance_to(gpoint); if (d<closest_dist && d<grab_treshold) { @@ -249,8 +275,8 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { pre_move_edit=poly; edited_point=closest_idx; - edited_point_pos=xform.affine_inverse().xform(closest_pos); - canvas_item_editor->get_viewport_control()->update(); + edited_point_pos=poly[closest_idx]; + _polygon_draw(); return true; } } @@ -265,8 +291,8 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { undo_redo->create_action("Edit Poly"); undo_redo->add_do_method(node,"set_polygon",poly); undo_redo->add_undo_method(node,"set_polygon",pre_move_edit); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update"); + undo_redo->add_do_method(this,"_polygon_draw"); + undo_redo->add_undo_method(this,"_polygon_draw"); undo_redo->commit_action(); edited_point=-1; @@ -282,7 +308,7 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { real_t closest_dist=1e10; for(int i=0;i<poly.size();i++) { - Vector2 cp =xform.xform(poly[i]); + Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x,poly[i].y,depth))); real_t d = cp.distance_to(gpoint); if (d<closest_dist && d<grab_treshold) { @@ -300,8 +326,8 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { undo_redo->add_undo_method(node,"set_polygon",poly); poly.remove(closest_idx); undo_redo->add_do_method(node,"set_polygon",poly); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update"); + undo_redo->add_do_method(this,"_polygon_draw"); + undo_redo->add_undo_method(this,"_polygon_draw"); undo_redo->commit_action(); return true; } @@ -323,11 +349,21 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { if (edited_point!=-1 && (wip_active || mm.button_mask&BUTTON_MASK_LEFT)) { Vector2 gpoint = Point2(mm.x,mm.y); - Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint); - cpoint=snap_point(cpoint); - edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint); - canvas_item_editor->get_viewport_control()->update(); + Vector3 ray_from = p_camera->project_ray_origin(gpoint); + Vector3 ray_dir = p_camera->project_ray_normal(gpoint); + + Vector3 spoint; + + if (!p.intersects_ray(ray_from,ray_dir,&spoint)) + break; + + Vector2 cpoint(spoint.x,spoint.y); + + //cpoint=snap_point(cpoint); + edited_point_pos = cpoint; + + _polygon_draw(); } @@ -336,13 +372,11 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { return false; } -void CollisionPolygonEditor::_canvas_draw() { +void CollisionPolygonEditor::_polygon_draw() { if (!node) return; - Control *vpc = canvas_item_editor->get_viewport_control(); - Vector<Vector2> poly; if (wip_active) @@ -351,10 +385,16 @@ void CollisionPolygonEditor::_canvas_draw() { poly=node->get_polygon(); - Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - Ref<Texture> handle= get_icon("EditorHandle","EditorIcons"); int len = poly.size(); + float depth = node->get_depth()*0.5; + + imgeom->clear(); + imgeom->set_material_override(line_material); + imgeom->begin(Mesh::PRIMITIVE_LINES,Ref<Texture>()); + + + Rect2 rect; for(int i=0;i<poly.size();i++) { @@ -366,38 +406,127 @@ void CollisionPolygonEditor::_canvas_draw() { else p2 = poly[(i+1)%poly.size()]; - Vector2 point = xform.xform(p); - Vector2 next_point = xform.xform(p2); + if (i==0) + rect.pos=p; + else + rect.expand_to(p); + + Vector3 point = Vector3(p.x,p.y,depth); + Vector3 next_point = Vector3(p2.x,p2.y,depth); + + imgeom->set_color(Color(1,0.3,0.1,0.8)); + imgeom->add_vertex(point); + imgeom->set_color(Color(1,0.3,0.1,0.8)); + imgeom->add_vertex(next_point); - Color col=Color(1,0.3,0.1,0.8); - vpc->draw_line(point,next_point,col,2); - vpc->draw_texture(handle,point-handle->get_size()*0.5); + //Color col=Color(1,0.3,0.1,0.8); + //vpc->draw_line(point,next_point,col,2); + //vpc->draw_texture(handle,point-handle->get_size()*0.5); } + + rect=rect.grow(1); + + AABB r; + r.pos.x=rect.pos.x; + r.pos.y=rect.pos.y; + r.pos.z=depth; + r.size.x=rect.size.x; + r.size.y=rect.size.y; + r.size.z=0; + + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+Vector3(0.3,0,0)); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+Vector3(0.0,0.3,0)); + + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0)); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0)-Vector3(0.3,0,0)); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0)); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0)+Vector3(0,0.3,0)); + + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0)); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0)-Vector3(0,0.3,0)); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0)); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0)+Vector3(0.3,0,0)); + + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+r.size); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+r.size-Vector3(0.3,0,0)); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+r.size); + imgeom->set_color(Color(0.8,0.8,0.8,0.2)); + imgeom->add_vertex(r.pos+r.size-Vector3(0.0,0.3,0)); + + imgeom->end(); + + + while(m->get_surface_count()) { + m->surface_remove(0); + } + + if (poly.size()==0) + return; + + Array a; + a.resize(Mesh::ARRAY_MAX); + DVector<Vector3> va; + { + + va.resize(poly.size()); + DVector<Vector3>::Write w=va.write(); + for(int i=0;i<poly.size();i++) { + + + Vector2 p,p2; + p = i==edited_point ? edited_point_pos : poly[i]; + + Vector3 point = Vector3(p.x,p.y,depth); + w[i]=point; + } + } + a[Mesh::ARRAY_VERTEX]=va; + m->add_surface(Mesh::PRIMITIVE_POINTS,a); + m->surface_set_material(0,handle_material); + } void CollisionPolygonEditor::edit(Node *p_collision_polygon) { - if (!canvas_item_editor) { - canvas_item_editor=CanvasItemEditor::get_singleton(); - } + if (p_collision_polygon) { - node=p_collision_polygon->cast_to<CollisionPolygon2D>(); - if (!canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw")) - canvas_item_editor->get_viewport_control()->connect("draw",this,"_canvas_draw"); + node=p_collision_polygon->cast_to<CollisionPolygon>(); wip.clear(); wip_active=false; edited_point=-1; + p_collision_polygon->add_child(imgeom); + _polygon_draw(); + set_process(true); + prev_depth=-1; } else { node=NULL; - if (canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw")) - canvas_item_editor->get_viewport_control()->disconnect("draw",this,"_canvas_draw"); + if (imgeom->get_parent()) + imgeom->get_parent()->remove_child(imgeom); + set_process(false); } } @@ -405,13 +534,14 @@ void CollisionPolygonEditor::edit(Node *p_collision_polygon) { void CollisionPolygonEditor::_bind_methods() { ObjectTypeDB::bind_method(_MD("_menu_option"),&CollisionPolygonEditor::_menu_option); - ObjectTypeDB::bind_method(_MD("_canvas_draw"),&CollisionPolygonEditor::_canvas_draw); + ObjectTypeDB::bind_method(_MD("_polygon_draw"),&CollisionPolygonEditor::_polygon_draw); + ObjectTypeDB::bind_method(_MD("_node_removed"),&CollisionPolygonEditor::_node_removed); } CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) { - canvas_item_editor=NULL; + editor=p_editor; undo_redo = editor->get_undo_redo(); @@ -439,7 +569,42 @@ CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) { mode = MODE_EDIT; wip_active=false; + imgeom = memnew( ImmediateGeometry ); + imgeom->set_transform(Transform(Matrix3(),Vector3(0,0,0.00001))); + + + line_material = Ref<FixedMaterial>( memnew( FixedMaterial )); + line_material->set_flag(Material::FLAG_UNSHADED, true); + line_material->set_line_width(3.0); + line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); + line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true); + line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1)); + + + + + handle_material = Ref<FixedMaterial>( memnew( FixedMaterial )); + handle_material->set_flag(Material::FLAG_UNSHADED, true); + handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_POINT_SIZE, true); + handle_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1)); + handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); + handle_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, false); + Ref<Texture> handle= SpatialEditor::get_singleton()->get_icon("Editor3DHandle","EditorIcons"); + handle_material->set_point_size(handle->get_width()); + handle_material->set_texture(FixedMaterial::PARAM_DIFFUSE,handle); + + pointsm = memnew( MeshInstance ); + imgeom->add_child(pointsm); + m = Ref<Mesh>( memnew( Mesh ) ); + pointsm->set_mesh(m); + pointsm->set_transform(Transform(Matrix3(),Vector3(0,0,0.00001))); + + +} + +CollisionPolygonEditor::~CollisionPolygonEditor() { + memdelete( imgeom ); } @@ -450,7 +615,7 @@ void CollisionPolygonEditorPlugin::edit(Object *p_object) { bool CollisionPolygonEditorPlugin::handles(Object *p_object) const { - return p_object->is_type("CollisionPolygon2D"); + return p_object->is_type("CollisionPolygon"); } void CollisionPolygonEditorPlugin::make_visible(bool p_visible) { @@ -469,7 +634,7 @@ CollisionPolygonEditorPlugin::CollisionPolygonEditorPlugin(EditorNode *p_node) { editor=p_node; collision_polygon_editor = memnew( CollisionPolygonEditor(p_node) ); - CanvasItemEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor); + SpatialEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor); collision_polygon_editor->hide(); diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.h b/tools/editor/plugins/collision_polygon_editor_plugin.h index a05ac0f8c8..54b0706149 100644 --- a/tools/editor/plugins/collision_polygon_editor_plugin.h +++ b/tools/editor/plugins/collision_polygon_editor_plugin.h @@ -31,7 +31,9 @@ #include "tools/editor/editor_plugin.h" #include "tools/editor/editor_node.h" -#include "scene/2d/collision_polygon_2d.h" +#include "scene/3d/collision_polygon.h" +#include "scene/3d/immediate_geometry.h" +#include "scene/3d/mesh_instance.h" #include "scene/gui/tool_button.h" #include "scene/gui/button_group.h" @@ -57,10 +59,17 @@ class CollisionPolygonEditor : public HBoxContainer { ToolButton *button_create; ToolButton *button_edit; - CanvasItemEditor *canvas_item_editor; + + Ref<FixedMaterial> line_material; + Ref<FixedMaterial> handle_material; + EditorNode *editor; Panel *panel; - CollisionPolygon2D *node; + CollisionPolygon *node; + ImmediateGeometry *imgeom; + MeshInstance *pointsm; + Ref<Mesh> m; + MenuButton *options; int edited_point; @@ -69,9 +78,10 @@ class CollisionPolygonEditor : public HBoxContainer { Vector<Vector2> wip; bool wip_active; + float prev_depth; void _wip_close(); - void _canvas_draw(); + void _polygon_draw(); void _menu_option(int p_option); protected: @@ -81,9 +91,10 @@ protected: public: Vector2 snap_point(const Vector2& p_point) const; - bool forward_input_event(const InputEvent& p_event); + virtual bool forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event); void edit(Node *p_collision_polygon); CollisionPolygonEditor(EditorNode *p_editor); + ~CollisionPolygonEditor(); }; class CollisionPolygonEditorPlugin : public EditorPlugin { @@ -95,7 +106,7 @@ class CollisionPolygonEditorPlugin : public EditorPlugin { public: - virtual bool forward_input_event(const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); } + virtual bool forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event) { return collision_polygon_editor->forward_spatial_input_event(p_camera,p_event); } virtual String get_name() const { return "CollisionPolygon"; } bool has_main_screen() const { return false; } diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index e9020c91f5..a097d7c211 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -38,7 +38,7 @@ #include "tools/editor/editor_settings.h" #include "scene/resources/surface_tool.h" #include "tools/editor/spatial_editor_gizmos.h" - +#include "globals.h" #define DISTANCE_DEFAULT 4 @@ -690,10 +690,16 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { case BUTTON_WHEEL_UP: { + cursor.distance/=1.08; + if (cursor.distance<0.001) + cursor.distance=0.001; + } break; case BUTTON_WHEEL_DOWN: { + if (cursor.distance<0.001) + cursor.distance=0.001; cursor.distance*=1.08; } break; @@ -1753,6 +1759,41 @@ void SpatialEditorViewport::_draw() { } + if (previewing) { + + + Size2 ss = Size2( Globals::get_singleton()->get("display/width"), Globals::get_singleton()->get("display/height") ); + float aspect = ss.get_aspect(); + Size2 s = get_size(); + + Rect2 draw_rect; + + + switch(previewing->get_keep_aspect_mode()) { + case Camera::KEEP_WIDTH: { + + draw_rect.size = Size2(s.width,s.width/aspect); + draw_rect.pos.x=0; + draw_rect.pos.y=(s.height-draw_rect.size.y)*0.5; + + } break; + case Camera::KEEP_HEIGHT: { + + draw_rect.size = Size2(s.height*aspect,s.height); + draw_rect.pos.y=0; + draw_rect.pos.x=(s.width-draw_rect.size.x)*0.5; + + } break; + } + + draw_rect = Rect2(Vector2(),s).clip(draw_rect); + + surface->draw_line(draw_rect.pos,draw_rect.pos+Vector2(draw_rect.size.x,0),Color(0.6,0.6,0.1,0.5),2.0); + surface->draw_line(draw_rect.pos+Vector2(draw_rect.size.x,0),draw_rect.pos+draw_rect.size,Color(0.6,0.6,0.1,0.5),2.0); + surface->draw_line(draw_rect.pos+draw_rect.size,draw_rect.pos+Vector2(0,draw_rect.size.y),Color(0.6,0.6,0.1,0.5),2.0); + surface->draw_line(draw_rect.pos,draw_rect.pos+Vector2(0,draw_rect.size.y),Color(0.6,0.6,0.1,0.5),2.0); + } + } @@ -1936,6 +1977,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { if (!preview) preview_camera->hide(); view_menu->show(); + surface->update(); } else { @@ -1943,6 +1985,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { previewing->connect("exit_scene",this,"_preview_exited_scene"); VS::get_singleton()->viewport_attach_camera( viewport->get_viewport(), preview->get_camera() ); //replace view_menu->hide(); + surface->update(); } } diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp index ddd27af2fb..082878655c 100644 --- a/tools/editor/spatial_editor_gizmos.cpp +++ b/tools/editor/spatial_editor_gizmos.cpp @@ -2066,7 +2066,39 @@ CollisionShapeSpatialGizmo::CollisionShapeSpatialGizmo(CollisionShape* p_cs) { +/////
+
+
+void CollisionPolygonSpatialGizmo::redraw() {
+
+ clear();
+
+ Vector<Vector2> points = polygon->get_polygon();
+ float depth = polygon->get_depth()*0.5;
+ Vector<Vector3> lines;
+ for(int i=0;i<points.size();i++) {
+
+ int n = (i+1)%points.size();
+ lines.push_back(Vector3(points[i].x,points[i].y,depth));
+ lines.push_back(Vector3(points[n].x,points[n].y,depth));
+ lines.push_back(Vector3(points[i].x,points[i].y,-depth));
+ lines.push_back(Vector3(points[n].x,points[n].y,-depth));
+ lines.push_back(Vector3(points[i].x,points[i].y,depth));
+ lines.push_back(Vector3(points[i].x,points[i].y,-depth));
+
+ }
+
+ add_lines(lines,SpatialEditorGizmos::singleton->shape_material);
+ add_collision_segments(lines);
+}
+
+CollisionPolygonSpatialGizmo::CollisionPolygonSpatialGizmo(CollisionPolygon* p_polygon){
+
+ set_spatial_node(p_polygon);
+ polygon=p_polygon;
+}
+///
String VisibilityNotifierGizmo::get_handle_name(int p_idx) const {
@@ -2901,6 +2933,13 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) { return misg;
}
+ if (p_spatial->cast_to<CollisionPolygon>()) {
+
+ Ref<CollisionPolygonSpatialGizmo> misg = memnew( CollisionPolygonSpatialGizmo(p_spatial->cast_to<CollisionPolygon>()) );
+ return misg;
+ }
+
+
return Ref<SpatialEditorGizmo>();
}
diff --git a/tools/editor/spatial_editor_gizmos.h b/tools/editor/spatial_editor_gizmos.h index c2aeeaf7a2..ac31eb19e9 100644 --- a/tools/editor/spatial_editor_gizmos.h +++ b/tools/editor/spatial_editor_gizmos.h @@ -46,6 +46,7 @@ #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"
@@ -302,6 +303,21 @@ public: };
+
+class CollisionPolygonSpatialGizmo : public SpatialGizmoTool {
+
+ OBJ_TYPE(CollisionPolygonSpatialGizmo,SpatialGizmoTool);
+
+ CollisionPolygon* polygon;
+
+public:
+
+ void redraw();
+ CollisionPolygonSpatialGizmo(CollisionPolygon* p_polygon=NULL);
+
+};
+
+
class RayCastSpatialGizmo : public SpatialGizmoTool {
OBJ_TYPE(RayCastSpatialGizmo,SpatialGizmoTool);
|