summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct3
-rw-r--r--doc/base/classes.xml14
-rw-r--r--drivers/SCsub2
-rw-r--r--drivers/xaudio2/SCsub9
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.cpp (renamed from platform/winrt/audio_driver_winrt.cpp)51
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.h (renamed from platform/winrt/audio_driver_winrt.h)26
-rw-r--r--modules/gdscript/gd_compiler.cpp6
-rw-r--r--platform/windows/os_windows.cpp3
-rw-r--r--platform/windows/os_windows.h6
-rw-r--r--platform/winrt/SCsub1
-rw-r--r--platform/winrt/detect.py2
-rw-r--r--platform/winrt/os_winrt.h4
-rw-r--r--scene/2d/ray_cast_2d.cpp48
-rw-r--r--scene/2d/ray_cast_2d.h3
-rw-r--r--scene/3d/ray_cast.cpp48
-rw-r--r--scene/3d/ray_cast.h2
-rw-r--r--servers/visual/visual_server_raster.cpp5
-rw-r--r--servers/visual/visual_server_raster.h1
-rw-r--r--servers/visual/visual_server_wrap_mt.h1
-rw-r--r--servers/visual_server.cpp1
-rw-r--r--servers/visual_server.h1
-rw-r--r--tools/editor/editor_settings.cpp28
-rw-r--r--tools/editor/editor_settings.h3
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp1
-rw-r--r--tools/editor/script_create_dialog.cpp14
-rw-r--r--tools/editor/script_create_dialog.h2
26 files changed, 193 insertions, 92 deletions
diff --git a/SConstruct b/SConstruct
index 361d20e346..2cd38325ee 100644
--- a/SConstruct
+++ b/SConstruct
@@ -136,6 +136,7 @@ opts.Add('openssl','OpenSSL library for openssl module (system/builtin)','builti
opts.Add('libmpcdec','libmpcdec library for mpc module (system/builtin)','builtin')
opts.Add('enet','ENet library (system/builtin)','builtin')
opts.Add('glew','GLEW library for the gl_context (system/builtin)','builtin')
+opts.Add('xaudio2','XAudio2 audio driver (yes/no)','no')
opts.Add("CXX", "C++ Compiler")
opts.Add("CC", "C Compiler")
opts.Add("CCFLAGS", "Custom flags for the C++ compiler");
@@ -263,6 +264,8 @@ if selected_platform in platform_list:
sys.exit(255)
suffix+=".opt"
+ env.Append(CCFLAGS=['-DNDEBUG']);
+
elif (env["target"]=="release_debug"):
if (env["tools"]=="yes"):
suffix+=".opt.tools"
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 4e0ba53f48..5eb021f6c0 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -31871,6 +31871,8 @@
RayCast can ignore some objects by adding them to the exception list via [code]add_exception[/code], setting proper filtering with layers, or by filtering object types with type masks.
Only enabled raycasts will be able to query the space and report collisions!
+
+ RayCast calculates intersection every fixed frame (see [Node]), and the result is cached so it can be used later until the next frame. If multiple queries are required between fixed frames (or during the same frame) use [method force_raycast_update] after adjusting the raycast.
</description>
<methods>
<method name="add_exception">
@@ -31891,6 +31893,11 @@
Removes all collision exception for this ray.
</description>
</method>
+ <method name="force_raycast_update">
+ <description>
+ Updates the collision information in case if this object's properties changed during the current frame (for example position, rotation or the cast_point). Note, [code]set_enabled[/code] is not required for this to work.
+ </description>
+ </method>
<method name="get_cast_to" qualifiers="const">
<return type="Vector3">
</return>
@@ -32009,6 +32016,8 @@
RayCast2D can ignore some objects by adding them to the exception list via [code]add_exception[/code], setting proper filtering with layers, or by filtering object types with type masks.
Only enabled raycasts will be able to query the space and report collisions!
+
+ RayCast2D calculates intersection every fixed frame (see [Node]), and the result is cached so it can be used later until the next frame. If multiple queries are required between fixed frames (or during the same frame) use [method force_raycast_update] after adjusting the raycast.
</description>
<methods>
<method name="add_exception">
@@ -32029,6 +32038,11 @@
Removes all collision exception for this ray.
</description>
</method>
+ <method name="force_raycast_update">
+ <description>
+ Updates the collision information in case if this object's properties changed during the current frame (for example position, rotation or the cast_point). Note, [code]set_enabled[/code] is not required for this to work.
+ </description>
+ </method>
<method name="get_cast_to" qualifiers="const">
<return type="Vector2">
</return>
diff --git a/drivers/SCsub b/drivers/SCsub
index 255f143902..1f1509efa8 100644
--- a/drivers/SCsub
+++ b/drivers/SCsub
@@ -16,6 +16,8 @@ SConscript('alsa/SCsub');
SConscript('pulseaudio/SCsub');
if (env["platform"] == "windows"):
SConscript("rtaudio/SCsub");
+if (env["xaudio2"] == "yes"):
+ SConscript("xaudio2/SCsub");
# Graphics drivers
SConscript('gles2/SCsub');
diff --git a/drivers/xaudio2/SCsub b/drivers/xaudio2/SCsub
new file mode 100644
index 0000000000..cb780a893b
--- /dev/null
+++ b/drivers/xaudio2/SCsub
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+Import('env')
+
+env.add_source_files(env.drivers_sources, "*.cpp")
+env.Append(CXXFLAGS=['-DXAUDIO2_ENABLED'])
+env.Append(LINKFLAGS=['xaudio2_8.lib'])
+
+Export('env')
diff --git a/platform/winrt/audio_driver_winrt.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp
index ff46244ac3..c7a8962102 100644
--- a/platform/winrt/audio_driver_winrt.cpp
+++ b/drivers/xaudio2/audio_driver_xaudio2.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* audio_driver_winrt.cpp */
+/* audio_driver_xaudio2.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,23 +26,17 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "audio_driver_winrt.h"
+#include "audio_driver_xaudio2.h"
#include "globals.h"
#include "os/os.h"
-using namespace Windows::Media;
-using namespace Windows::Media::Core;
-using namespace Windows::Media::MediaProperties;
-using namespace Windows::Media::Editing;
-using namespace Windows::Foundation;
-
-const char * AudioDriverWinRT::get_name() const
+const char * AudioDriverXAudio2::get_name() const
{
- return "WinRT";
+ return "XAudio2";
}
-Error AudioDriverWinRT::init() {
+Error AudioDriverXAudio2::init() {
active = false;
thread_exited = false;
@@ -86,23 +80,21 @@ Error AudioDriverWinRT::init() {
wave_format.nBlockAlign = channels * wave_format.wBitsPerSample >> 3;
wave_format.nAvgBytesPerSec = mix_rate * wave_format.nBlockAlign;
- voice_callback = memnew(XAudio2DriverVoiceCallback);
-
- hr = xaudio->CreateSourceVoice(&source_voice, &wave_format, 0, XAUDIO2_MAX_FREQ_RATIO, voice_callback);
+ hr = xaudio->CreateSourceVoice(&source_voice, &wave_format, 0, XAUDIO2_MAX_FREQ_RATIO, &voice_callback);
if (hr != S_OK) {
ERR_EXPLAIN("Error creating XAudio2 source voice. " + itos(hr));
ERR_FAIL_V(ERR_UNAVAILABLE);
}
mutex = Mutex::create();
- thread = Thread::create(AudioDriverWinRT::thread_func, this);
+ thread = Thread::create(AudioDriverXAudio2::thread_func, this);
return OK;
};
-void AudioDriverWinRT::thread_func(void* p_udata) {
+void AudioDriverXAudio2::thread_func(void* p_udata) {
- AudioDriverWinRT* ad = (AudioDriverWinRT*)p_udata;
+ AudioDriverXAudio2* ad = (AudioDriverXAudio2*)p_udata;
uint64_t usdelay = (ad->buffer_size / float(ad->mix_rate)) * 1000000;
@@ -139,7 +131,7 @@ void AudioDriverWinRT::thread_func(void* p_udata) {
XAUDIO2_VOICE_STATE state;
while (ad->source_voice->GetState(&state), state.BuffersQueued > AUDIO_BUFFERS - 1)
{
- WaitForSingleObject(ad->voice_callback->buffer_end_event, INFINITE);
+ WaitForSingleObject(ad->voice_callback.buffer_end_event, INFINITE);
}
}
@@ -149,7 +141,7 @@ void AudioDriverWinRT::thread_func(void* p_udata) {
};
-void AudioDriverWinRT::start() {
+void AudioDriverXAudio2::start() {
active = true;
HRESULT hr = source_voice->Start(0);
@@ -159,17 +151,17 @@ void AudioDriverWinRT::start() {
}
};
-int AudioDriverWinRT::get_mix_rate() const {
+int AudioDriverXAudio2::get_mix_rate() const {
return mix_rate;
};
-AudioDriverSW::OutputFormat AudioDriverWinRT::get_output_format() const {
+AudioDriverSW::OutputFormat AudioDriverXAudio2::get_output_format() const {
return output_format;
};
-float AudioDriverWinRT::get_latency() {
+float AudioDriverXAudio2::get_latency() {
XAUDIO2_PERFORMANCE_DATA perf_data;
xaudio->GetPerformanceData(&perf_data);
@@ -180,20 +172,20 @@ float AudioDriverWinRT::get_latency() {
}
}
-void AudioDriverWinRT::lock() {
+void AudioDriverXAudio2::lock() {
if (!thread || !mutex)
return;
mutex->lock();
};
-void AudioDriverWinRT::unlock() {
+void AudioDriverXAudio2::unlock() {
if (!thread || !mutex)
return;
mutex->unlock();
};
-void AudioDriverWinRT::finish() {
+void AudioDriverXAudio2::finish() {
if (!thread)
return;
@@ -203,7 +195,7 @@ void AudioDriverWinRT::finish() {
if (source_voice) {
source_voice->Stop(0);
- memdelete(source_voice);
+ source_voice->DestroyVoice();
}
if (samples_in) {
@@ -215,8 +207,7 @@ void AudioDriverWinRT::finish() {
}
};
- memdelete(voice_callback);
- memdelete(mastering_voice);
+ mastering_voice->DestroyVoice();
memdelete(thread);
if (mutex)
@@ -224,7 +215,7 @@ void AudioDriverWinRT::finish() {
thread = NULL;
};
-AudioDriverWinRT::AudioDriverWinRT() {
+AudioDriverXAudio2::AudioDriverXAudio2() {
mutex = NULL;
thread = NULL;
@@ -236,7 +227,7 @@ AudioDriverWinRT::AudioDriverWinRT() {
current_buffer = 0;
};
-AudioDriverWinRT::~AudioDriverWinRT() {
+AudioDriverXAudio2::~AudioDriverXAudio2() {
};
diff --git a/platform/winrt/audio_driver_winrt.h b/drivers/xaudio2/audio_driver_xaudio2.h
index d7a69994f8..1c6a90500d 100644
--- a/platform/winrt/audio_driver_winrt.h
+++ b/drivers/xaudio2/audio_driver_xaudio2.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* audio_driver_winrt.h */
+/* audio_driver_xaudio2.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,8 +26,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef AUDIO_DRIVER_WINRT_H
-#define AUDIO_DRIVER_WINRT_H
+#ifndef AUDIO_DRIVER_XAUDIO2_H
+#define AUDIO_DRIVER_XAUDIO2_H
#include "servers/audio/audio_server_sw.h"
@@ -40,7 +40,7 @@
#include <xaudio2.h>
#include <wrl/client.h>
-class AudioDriverWinRT : public AudioDriverSW {
+class AudioDriverXAudio2 : public AudioDriverSW {
enum {
AUDIO_BUFFERS = 2
@@ -53,12 +53,12 @@ class AudioDriverWinRT : public AudioDriverSW {
void STDMETHODCALLTYPE OnBufferEnd(void* pBufferContext) { /*print_line("buffer ended");*/ SetEvent(buffer_end_event); }
//Unused methods are stubs
- void STDMETHODCALLTYPE OnStreamEnd() { }
- void STDMETHODCALLTYPE OnVoiceProcessingPassEnd() { }
- void STDMETHODCALLTYPE OnVoiceProcessingPassStart(UINT32 SamplesRequired) { }
- void STDMETHODCALLTYPE OnBufferStart(void * pBufferContext) { }
- void STDMETHODCALLTYPE OnLoopEnd(void * pBufferContext) { }
- void STDMETHODCALLTYPE OnVoiceError(void * pBufferContext, HRESULT Error) { }
+ void STDMETHODCALLTYPE OnStreamEnd() {}
+ void STDMETHODCALLTYPE OnVoiceProcessingPassEnd() {}
+ void STDMETHODCALLTYPE OnVoiceProcessingPassStart(UINT32 SamplesRequired) {}
+ void STDMETHODCALLTYPE OnBufferStart(void * pBufferContext) {}
+ void STDMETHODCALLTYPE OnLoopEnd(void * pBufferContext) {}
+ void STDMETHODCALLTYPE OnVoiceError(void * pBufferContext, HRESULT Error) {}
};
@@ -87,7 +87,7 @@ class AudioDriverWinRT : public AudioDriverSW {
IXAudio2MasteringVoice* mastering_voice;
XAUDIO2_BUFFER xaudio_buffer[AUDIO_BUFFERS];
IXAudio2SourceVoice* source_voice;
- XAudio2DriverVoiceCallback* voice_callback;
+ XAudio2DriverVoiceCallback voice_callback;
public:
@@ -102,8 +102,8 @@ public:
virtual void unlock();
virtual void finish();
- AudioDriverWinRT();
- ~AudioDriverWinRT();
+ AudioDriverXAudio2();
+ ~AudioDriverXAudio2();
};
#endif
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp
index 2e2cbe7b29..b75b13551e 100644
--- a/modules/gdscript/gd_compiler.cpp
+++ b/modules/gdscript/gd_compiler.cpp
@@ -1005,12 +1005,12 @@ Error GDCompiler::_parse_block(CodeGen& codegen,const GDParser::BlockNode *p_blo
switch(s->type) {
case GDParser::Node::TYPE_NEWLINE: {
-
+#ifdef DEBUG_ENABLED
const GDParser::NewLineNode *nl = static_cast<const GDParser::NewLineNode*>(s);
codegen.opcodes.push_back(GDFunction::OPCODE_LINE);
codegen.opcodes.push_back(nl->line);
codegen.current_line=nl->line;
-
+#endif
} break;
case GDParser::Node::TYPE_CONTROL_FLOW: {
// try subblocks
@@ -1201,8 +1201,10 @@ Error GDCompiler::_parse_block(CodeGen& codegen,const GDParser::BlockNode *p_blo
codegen.opcodes.push_back(ret);
} break;
case GDParser::Node::TYPE_BREAKPOINT: {
+#ifdef DEBUG_ENABLED
// try subblocks
codegen.opcodes.push_back(GDFunction::OPCODE_BREAKPOINT);
+#endif
} break;
case GDParser::Node::TYPE_LOCAL_VAR: {
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 0ca5d3bd0f..38e738a414 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -2418,6 +2418,9 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) {
#ifdef RTAUDIO_ENABLED
AudioDriverManagerSW::add_driver(&driver_rtaudio);
#endif
+#ifdef XAUDIO2_ENABLED
+ AudioDriverManagerSW::add_driver(&driver_xaudio2);
+#endif
}
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 70ef694957..903dd10c70 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -41,6 +41,9 @@
#include "servers/audio/audio_server_sw.h"
#include "servers/audio/sample_manager_sw.h"
#include "drivers/rtaudio/audio_driver_rtaudio.h"
+#ifdef XAUDIO2_ENABLED
+#include "drivers/xaudio2/audio_driver_xaudio2.h"
+#endif
#include "servers/spatial_sound/spatial_sound_server_sw.h"
#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
#include "drivers/unix/ip_unix.h"
@@ -137,6 +140,9 @@ class OS_Windows : public OS {
#ifdef RTAUDIO_ENABLED
AudioDriverRtAudio driver_rtaudio;
#endif
+#ifdef XAUDIO2_ENABLED
+ AudioDriverXAudio2 driver_xaudio2;
+#endif
void _drag_event(int p_x, int p_y, int idx);
void _touch_event(bool p_pressed, int p_x, int p_y, int idx);
diff --git a/platform/winrt/SCsub b/platform/winrt/SCsub
index e34d948c37..91a179084d 100644
--- a/platform/winrt/SCsub
+++ b/platform/winrt/SCsub
@@ -10,7 +10,6 @@ files = [
'#platform/windows/key_mapping_win.cpp',
'joystick_winrt.cpp',
'gl_context_egl.cpp',
- 'audio_driver_winrt.cpp',
'app.cpp',
'os_winrt.cpp',
]
diff --git a/platform/winrt/detect.py b/platform/winrt/detect.py
index 79fc3651e9..a7bc62f685 100644
--- a/platform/winrt/detect.py
+++ b/platform/winrt/detect.py
@@ -31,6 +31,7 @@ def get_flags():
('tools', 'no'),
('builtin_zlib', 'yes'),
('openssl', 'builtin'),
+ ('xaudio2', 'yes'),
]
@@ -145,7 +146,6 @@ def configure(env):
env.Append(CCFLAGS=['/DGLES2_ENABLED','/DGL_GLEXT_PROTOTYPES','/DEGL_EGLEXT_PROTOTYPES','/DANGLE_ENABLED'])
LIBS = [
- 'xaudio2',
'WindowsApp',
'mincore',
'libANGLE',
diff --git a/platform/winrt/os_winrt.h b/platform/winrt/os_winrt.h
index 1816e0cec7..a4667f213d 100644
--- a/platform/winrt/os_winrt.h
+++ b/platform/winrt/os_winrt.h
@@ -40,7 +40,7 @@
#include "servers/spatial_sound/spatial_sound_server_sw.h"
#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
-#include "audio_driver_winrt.h"
+#include "drivers/xaudio2/audio_driver_xaudio2.h"
#include "gl_context_egl.h"
@@ -118,7 +118,7 @@ private:
MainLoop *main_loop;
- AudioDriverWinRT audio_driver;
+ AudioDriverXAudio2 audio_driver;
AudioServerSW *audio_server;
SampleManagerMallocSW *sample_manager;
SpatialSoundServerSW *spatial_sound_server;
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index b5d62adfb4..bd7f4faae5 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -187,39 +187,44 @@ void RayCast2D::_notification(int p_what) {
if (!enabled)
break;
+ _update_raycast_state();
- Ref<World2D> w2d = get_world_2d();
- ERR_BREAK( w2d.is_null() );
-
- Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space());
- ERR_BREAK( !dss );
-
- Matrix32 gt = get_global_transform();
+ } break;
+ }
+}
- Vector2 to = cast_to;
- if (to==Vector2())
- to=Vector2(0,0.01);
+void RayCast2D::_update_raycast_state() {
+ Ref<World2D> w2d = get_world_2d();
+ ERR_FAIL_COND( w2d.is_null() );
- Physics2DDirectSpaceState::RayResult rr;
+ Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space());
+ ERR_FAIL_COND( !dss );
- if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask,type_mask)) {
+ Matrix32 gt = get_global_transform();
- collided=true;
- against=rr.collider_id;
- collision_point=rr.position;
- collision_normal=rr.normal;
- against_shape=rr.shape;
- } else {
- collided=false;
- }
+ Vector2 to = cast_to;
+ if (to==Vector2())
+ to=Vector2(0,0.01);
+ Physics2DDirectSpaceState::RayResult rr;
+ if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask,type_mask)) {
- } break;
+ collided=true;
+ against=rr.collider_id;
+ collision_point=rr.position;
+ collision_normal=rr.normal;
+ against_shape=rr.shape;
+ } else {
+ collided=false;
}
}
+void RayCast2D::force_raycast_update() {
+ _update_raycast_state();
+}
+
void RayCast2D::add_exception_rid(const RID& p_rid) {
exclude.insert(p_rid);
@@ -265,6 +270,7 @@ void RayCast2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_cast_to"),&RayCast2D::get_cast_to);
ObjectTypeDB::bind_method(_MD("is_colliding"),&RayCast2D::is_colliding);
+ ObjectTypeDB::bind_method(_MD("force_raycast_update"),&RayCast2D::force_raycast_update);
ObjectTypeDB::bind_method(_MD("get_collider"),&RayCast2D::get_collider);
ObjectTypeDB::bind_method(_MD("get_collider_shape"),&RayCast2D::get_collider_shape);
diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h
index e1caa8b63e..9bdcc2e199 100644
--- a/scene/2d/ray_cast_2d.h
+++ b/scene/2d/ray_cast_2d.h
@@ -52,6 +52,7 @@ class RayCast2D : public Node2D {
protected:
void _notification(int p_what);
+ void _update_raycast_state();
static void _bind_methods();
public:
@@ -70,6 +71,8 @@ public:
void set_exclude_parent_body(bool p_exclude_parent_body);
bool get_exclude_parent_body() const;
+ void force_raycast_update();
+
bool is_colliding() const;
Object *get_collider() const;
int get_collider_shape() const;
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index 1acda8d1f8..2b8df8265e 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -134,39 +134,44 @@ void RayCast::_notification(int p_what) {
if (!enabled)
break;
+ _update_raycast_state();
- Ref<World> w3d = get_world();
- ERR_BREAK( w3d.is_null() );
-
- PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(w3d->get_space());
- ERR_BREAK( !dss );
-
- Transform gt = get_global_transform();
+ } break;
+ }
+}
- Vector3 to = cast_to;
- if (to==Vector3())
- to=Vector3(0,0.01,0);
+void RayCast::_update_raycast_state(){
+ Ref<World> w3d = get_world();
+ ERR_FAIL_COND( w3d.is_null() );
- PhysicsDirectSpaceState::RayResult rr;
+ PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(w3d->get_space());
+ ERR_FAIL_COND( !dss );
- if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude, layer_mask, type_mask)) {
+ Transform gt = get_global_transform();
- collided=true;
- against=rr.collider_id;
- collision_point=rr.position;
- collision_normal=rr.normal;
- against_shape=rr.shape;
- } else {
- collided=false;
- }
+ Vector3 to = cast_to;
+ if (to==Vector3())
+ to=Vector3(0,0.01,0);
+ PhysicsDirectSpaceState::RayResult rr;
+ if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude, layer_mask, type_mask)) {
- } break;
+ collided=true;
+ against=rr.collider_id;
+ collision_point=rr.position;
+ collision_normal=rr.normal;
+ against_shape=rr.shape;
+ } else {
+ collided=false;
}
}
+void RayCast::force_raycast_update() {
+ _update_raycast_state();
+}
+
void RayCast::add_exception_rid(const RID& p_rid) {
exclude.insert(p_rid);
@@ -212,6 +217,7 @@ void RayCast::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_cast_to"),&RayCast::get_cast_to);
ObjectTypeDB::bind_method(_MD("is_colliding"),&RayCast::is_colliding);
+ ObjectTypeDB::bind_method(_MD("force_raycast_update"),&RayCast::force_raycast_update);
ObjectTypeDB::bind_method(_MD("get_collider"),&RayCast::get_collider);
ObjectTypeDB::bind_method(_MD("get_collider_shape"),&RayCast::get_collider_shape);
diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h
index 4f6514e61b..47553f08ed 100644
--- a/scene/3d/ray_cast.h
+++ b/scene/3d/ray_cast.h
@@ -53,6 +53,7 @@ class RayCast : public Spatial {
protected:
void _notification(int p_what);
+ void _update_raycast_state();
static void _bind_methods();
public:
@@ -68,6 +69,7 @@ public:
void set_type_mask(uint32_t p_mask);
uint32_t get_type_mask() const;
+ void force_raycast_update();
bool is_colliding() const;
Object *get_collider() const;
int get_collider_shape() const;
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 8d228ad859..1df0aafb23 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -7612,6 +7612,11 @@ void VisualServerRaster::set_default_clear_color(const Color& p_color) {
clear_color=p_color;
}
+Color VisualServerRaster::get_default_clear_color() const {
+
+ return clear_color;
+}
+
void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_color,bool p_scale) {
if (p_image.empty())
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 496820f4a8..1f22e31ab0 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -1283,6 +1283,7 @@ public:
virtual void set_boot_image(const Image& p_image, const Color& p_color, bool p_scale);
virtual void set_default_clear_color(const Color& p_color);
+ virtual Color get_default_clear_color() const;
VisualServerRaster(Rasterizer *p_rasterizer);
~VisualServerRaster();
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index b4e374dd6f..f0fe80d100 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -718,6 +718,7 @@ public:
FUNC3(set_boot_image,const Image& , const Color&,bool );
FUNC1(set_default_clear_color,const Color& );
+ FUNC0RC(Color,get_default_clear_color );
FUNC0R(RID,get_test_cube );
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index dfa0c91c7f..6099a86b96 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -564,6 +564,7 @@ void VisualServer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("free_rid"),&VisualServer::free);
ObjectTypeDB::bind_method(_MD("set_default_clear_color"),&VisualServer::set_default_clear_color);
+ ObjectTypeDB::bind_method(_MD("get_default_clear_color"),&VisualServer::get_default_clear_color);
ObjectTypeDB::bind_method(_MD("get_render_info"),&VisualServer::get_render_info);
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 2f3d8371f6..844da2d245 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -1181,6 +1181,7 @@ public:
virtual void set_boot_image(const Image& p_image, const Color& p_color,bool p_scale)=0;
virtual void set_default_clear_color(const Color& p_color)=0;
+ virtual Color get_default_clear_color() const=0;
enum Features {
FEATURE_SHADERS,
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index bdbf20e348..f5741c4a9e 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -1026,6 +1026,34 @@ void EditorSettings::set_optimize_save(bool p_optimize) {
optimize_save=p_optimize;
}
+String EditorSettings::get_last_selected_language()
+{
+ Ref<ConfigFile> cf = memnew( ConfigFile );
+ String path = get_project_settings_path().plus_file("project_metadata.cfg");
+ Error err = cf->load(path);
+ if (err != OK) {
+ WARN_PRINTS("Can't load config file: " + path);
+ return "";
+ }
+ Variant last_selected_language = cf->get_value("script_setup", "last_selected_language");
+ if (last_selected_language.get_type() != Variant::STRING)
+ return "";
+ return static_cast<String>(last_selected_language);
+}
+
+void EditorSettings::set_last_selected_language(String p_language)
+{
+ Ref<ConfigFile> cf = memnew( ConfigFile );
+ String path = get_project_settings_path().plus_file("project_metadata.cfg");
+ Error err = cf->load(path);
+ if (err != OK) {
+ WARN_PRINTS("Can't load config file: " + path);
+ return;
+ }
+ cf->set_value("script_setup", "last_selected_language", p_language);
+ cf->save(path);
+}
+
void EditorSettings::_bind_methods() {
ObjectTypeDB::bind_method(_MD("erase","property"),&EditorSettings::erase);
diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h
index 2a7d3bb4f0..a976602304 100644
--- a/tools/editor/editor_settings.h
+++ b/tools/editor/editor_settings.h
@@ -160,6 +160,9 @@ public:
void set_optimize_save(bool p_optimize);
+ String get_last_selected_language();
+ void set_last_selected_language(String p_language);
+
EditorSettings();
~EditorSettings();
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 3cd6d8336a..99c50efd2f 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -1620,6 +1620,7 @@ void ScriptEditor::apply_scripts() const {
void ScriptEditor::_editor_play() {
debugger->start();
+ debug_menu->get_popup()->grab_focus();
debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true );
debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_STEP), true );
debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_BREAK), false );
diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp
index 749198314a..62d5c7cd84 100644
--- a/tools/editor/script_create_dialog.cpp
+++ b/tools/editor/script_create_dialog.cpp
@@ -121,6 +121,8 @@ void ScriptCreateDialog::ok_pressed() {
Ref<Script> scr = ScriptServer::get_language( language_menu->get_selected() )->get_template(cname,parent_name->get_text());
//scr->set_source_code(text);
+ String selected_language = language_menu->get_item_text(language_menu->get_selected());
+ editor_settings->set_last_selected_language(selected_language);
if (cname!="")
scr->set_name(cname);
@@ -330,7 +332,17 @@ ScriptCreateDialog::ScriptCreateDialog() {
language_menu->add_item(ScriptServer::get_language(i)->get_name());
}
- language_menu->select(0);
+ editor_settings = EditorSettings::get_singleton();
+ String last_selected_language = editor_settings->get_last_selected_language();
+ if (last_selected_language != "")
+ for (int i = 0; i < language_menu->get_item_count(); i++)
+ if (language_menu->get_item_text(i) == last_selected_language)
+ {
+ language_menu->select(i);
+ break;
+ }
+ else language_menu->select(0);
+
language_menu->connect("item_selected",this,"_lang_changed");
//parent_name->set_text();
diff --git a/tools/editor/script_create_dialog.h b/tools/editor/script_create_dialog.h
index 181989402e..c71ea16d39 100644
--- a/tools/editor/script_create_dialog.h
+++ b/tools/editor/script_create_dialog.h
@@ -33,6 +33,7 @@
#include "scene/gui/line_edit.h"
#include "scene/gui/option_button.h"
#include "tools/editor/editor_file_dialog.h"
+#include "tools/editor/editor_settings.h"
#include "scene/gui/check_button.h"
class ScriptCreateDialog : public ConfirmationDialog {
@@ -50,6 +51,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
AcceptDialog *alert;
bool path_valid;
String initial_bp;
+ EditorSettings *editor_settings;
void _path_changed(const String& p_path=String());