summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/audio/audio_driver_dummy.cpp2
-rw-r--r--servers/audio/audio_driver_dummy.h2
-rw-r--r--servers/audio/audio_filter_sw.cpp2
-rw-r--r--servers/audio/audio_filter_sw.h2
-rw-r--r--servers/audio/audio_mixer_sw.cpp2
-rw-r--r--servers/audio/audio_mixer_sw.h2
-rw-r--r--servers/audio/audio_server_sw.cpp2
-rw-r--r--servers/audio/audio_server_sw.h2
-rw-r--r--servers/audio/reverb_buffers_sw.cpp2
-rw-r--r--servers/audio/reverb_buffers_sw.h2
-rw-r--r--servers/audio/reverb_sw.cpp2
-rw-r--r--servers/audio/reverb_sw.h2
-rw-r--r--servers/audio/sample_manager_sw.cpp3
-rw-r--r--servers/audio/sample_manager_sw.h204
-rw-r--r--servers/audio/voice_rb_sw.cpp14
-rw-r--r--servers/audio/voice_rb_sw.h2
-rw-r--r--servers/audio_server.cpp2
-rw-r--r--servers/audio_server.h2
-rw-r--r--servers/physics/area_pair_sw.cpp71
-rw-r--r--servers/physics/area_pair_sw.h20
-rw-r--r--servers/physics/area_sw.cpp74
-rw-r--r--servers/physics/area_sw.h43
-rw-r--r--servers/physics/body_pair_sw.cpp2
-rw-r--r--servers/physics/body_pair_sw.h2
-rw-r--r--servers/physics/body_sw.cpp46
-rw-r--r--servers/physics/body_sw.h17
-rw-r--r--servers/physics/broad_phase_basic.cpp2
-rw-r--r--servers/physics/broad_phase_basic.h2
-rw-r--r--servers/physics/broad_phase_octree.cpp2
-rw-r--r--servers/physics/broad_phase_octree.h2
-rw-r--r--servers/physics/broad_phase_sw.cpp2
-rw-r--r--servers/physics/broad_phase_sw.h2
-rw-r--r--servers/physics/collision_object_sw.cpp2
-rw-r--r--servers/physics/collision_object_sw.h6
-rw-r--r--servers/physics/collision_solver_sat.cpp2
-rw-r--r--servers/physics/collision_solver_sat.h2
-rw-r--r--servers/physics/collision_solver_sw.cpp2
-rw-r--r--servers/physics/collision_solver_sw.h2
-rw-r--r--servers/physics/constraint_sw.cpp2
-rw-r--r--servers/physics/constraint_sw.h2
-rw-r--r--servers/physics/joints/generic_6dof_joint_sw.cpp2
-rw-r--r--servers/physics/joints_sw.cpp2
-rw-r--r--servers/physics/joints_sw.h2
-rw-r--r--servers/physics/physics_server_sw.cpp29
-rw-r--r--servers/physics/physics_server_sw.h5
-rw-r--r--servers/physics/shape_sw.cpp15
-rw-r--r--servers/physics/shape_sw.h2
-rw-r--r--servers/physics/space_sw.cpp17
-rw-r--r--servers/physics/space_sw.h2
-rw-r--r--servers/physics/step_sw.cpp2
-rw-r--r--servers/physics/step_sw.h2
-rw-r--r--servers/physics_2d/area_2d_sw.cpp5
-rw-r--r--servers/physics_2d/area_2d_sw.h6
-rw-r--r--servers/physics_2d/area_pair_2d_sw.cpp6
-rw-r--r--servers/physics_2d/area_pair_2d_sw.h2
-rw-r--r--servers/physics_2d/body_2d_sw.cpp52
-rw-r--r--servers/physics_2d/body_2d_sw.h26
-rw-r--r--servers/physics_2d/body_pair_2d_sw.cpp68
-rw-r--r--servers/physics_2d/body_pair_2d_sw.h3
-rw-r--r--servers/physics_2d/broad_phase_2d_basic.cpp2
-rw-r--r--servers/physics_2d/broad_phase_2d_basic.h2
-rw-r--r--servers/physics_2d/broad_phase_2d_hash_grid.cpp9
-rw-r--r--servers/physics_2d/broad_phase_2d_hash_grid.h2
-rw-r--r--servers/physics_2d/broad_phase_2d_sw.cpp2
-rw-r--r--servers/physics_2d/broad_phase_2d_sw.h2
-rw-r--r--servers/physics_2d/collision_object_2d_sw.cpp4
-rw-r--r--servers/physics_2d/collision_object_2d_sw.h13
-rw-r--r--servers/physics_2d/collision_solver_2d_sat.cpp2
-rw-r--r--servers/physics_2d/collision_solver_2d_sat.h2
-rw-r--r--servers/physics_2d/collision_solver_2d_sw.cpp2
-rw-r--r--servers/physics_2d/collision_solver_2d_sw.h2
-rw-r--r--servers/physics_2d/constraint_2d_sw.cpp2
-rw-r--r--servers/physics_2d/constraint_2d_sw.h2
-rw-r--r--servers/physics_2d/joints_2d_sw.cpp2
-rw-r--r--servers/physics_2d/joints_2d_sw.h2
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp63
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h18
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.cpp169
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.h297
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp2
-rw-r--r--servers/physics_2d/shape_2d_sw.h2
-rw-r--r--servers/physics_2d/space_2d_sw.cpp518
-rw-r--r--servers/physics_2d/space_2d_sw.h6
-rw-r--r--servers/physics_2d/step_2d_sw.cpp2
-rw-r--r--servers/physics_2d/step_2d_sw.h2
-rw-r--r--servers/physics_2d_server.cpp88
-rw-r--r--servers/physics_2d_server.h63
-rw-r--r--servers/physics_server.cpp7
-rw-r--r--servers/physics_server.h10
-rw-r--r--servers/register_server_types.cpp3
-rw-r--r--servers/register_server_types.h2
-rw-r--r--servers/server_wrap_mt_common.h700
-rw-r--r--servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp2
-rw-r--r--servers/spatial_sound_2d/spatial_sound_2d_server_sw.h2
-rw-r--r--servers/spatial_sound_2d_server.cpp2
-rw-r--r--servers/spatial_sound_2d_server.h2
-rw-r--r--servers/spatial_sound_server.cpp2
-rw-r--r--servers/spatial_sound_server.h2
-rw-r--r--servers/visual/particle_system_sw.cpp2
-rw-r--r--servers/visual/particle_system_sw.h2
-rw-r--r--servers/visual/rasterizer.cpp2
-rw-r--r--servers/visual/rasterizer.h17
-rw-r--r--servers/visual/rasterizer_dummy.cpp4
-rw-r--r--servers/visual/rasterizer_dummy.h4
-rw-r--r--servers/visual/shader_compiler.cpp2
-rw-r--r--servers/visual/shader_compiler.h2
-rw-r--r--servers/visual/shader_graph.cpp2
-rw-r--r--servers/visual/shader_graph.h2
-rw-r--r--servers/visual/shader_language.cpp20
-rw-r--r--servers/visual/shader_language.h2
-rw-r--r--servers/visual/visual_server_raster.cpp65
-rw-r--r--servers/visual/visual_server_raster.h8
-rw-r--r--servers/visual/visual_server_wrap_mt.cpp18
-rw-r--r--servers/visual/visual_server_wrap_mt.h568
-rw-r--r--servers/visual_server.cpp38
-rw-r--r--servers/visual_server.h10
116 files changed, 2687 insertions, 903 deletions
diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp
index 14d89cc216..dd5243e467 100644
--- a/servers/audio/audio_driver_dummy.cpp
+++ b/servers/audio/audio_driver_dummy.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/audio_driver_dummy.h b/servers/audio/audio_driver_dummy.h
index 6784edf594..04926b89eb 100644
--- a/servers/audio/audio_driver_dummy.h
+++ b/servers/audio/audio_driver_dummy.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/audio_filter_sw.cpp b/servers/audio/audio_filter_sw.cpp
index 5d8750ffdb..032d93b617 100644
--- a/servers/audio/audio_filter_sw.cpp
+++ b/servers/audio/audio_filter_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/audio_filter_sw.h b/servers/audio/audio_filter_sw.h
index 52315af686..e8540adea6 100644
--- a/servers/audio/audio_filter_sw.h
+++ b/servers/audio/audio_filter_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/audio_mixer_sw.cpp b/servers/audio/audio_mixer_sw.cpp
index 3af18cf3ae..788eec0d4a 100644
--- a/servers/audio/audio_mixer_sw.cpp
+++ b/servers/audio/audio_mixer_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/audio_mixer_sw.h b/servers/audio/audio_mixer_sw.h
index d3caf03089..cb38561c27 100644
--- a/servers/audio/audio_mixer_sw.h
+++ b/servers/audio/audio_mixer_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/audio_server_sw.cpp b/servers/audio/audio_server_sw.cpp
index 55dde1b35b..8a3ab7ce70 100644
--- a/servers/audio/audio_server_sw.cpp
+++ b/servers/audio/audio_server_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/audio_server_sw.h b/servers/audio/audio_server_sw.h
index d47c1b4b3f..77d2f2e8dd 100644
--- a/servers/audio/audio_server_sw.h
+++ b/servers/audio/audio_server_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/reverb_buffers_sw.cpp b/servers/audio/reverb_buffers_sw.cpp
index 6d09be9a3d..b840b9390b 100644
--- a/servers/audio/reverb_buffers_sw.cpp
+++ b/servers/audio/reverb_buffers_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/reverb_buffers_sw.h b/servers/audio/reverb_buffers_sw.h
index 64a9e4fe7d..817122b65d 100644
--- a/servers/audio/reverb_buffers_sw.h
+++ b/servers/audio/reverb_buffers_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/reverb_sw.cpp b/servers/audio/reverb_sw.cpp
index df36886db8..cc4b4bd778 100644
--- a/servers/audio/reverb_sw.cpp
+++ b/servers/audio/reverb_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/reverb_sw.h b/servers/audio/reverb_sw.h
index acf22f01b4..937824f907 100644
--- a/servers/audio/reverb_sw.h
+++ b/servers/audio/reverb_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio/sample_manager_sw.cpp b/servers/audio/sample_manager_sw.cpp
index a74c4372ca..9195136a5d 100644
--- a/servers/audio/sample_manager_sw.cpp
+++ b/servers/audio/sample_manager_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -135,6 +135,7 @@ void SampleManagerMallocSW::sample_set_data(RID p_sample, const DVector<uint8_t>
ERR_EXPLAIN("Sample buffer size does not match sample size.");
+ //print_line("len bytes: "+itos(s->length_bytes)+" bufsize: "+itos(buff_size));
ERR_FAIL_COND(s->length_bytes!=buff_size);
DVector<uint8_t>::Read buffer_r=p_buffer.read();
const uint8_t *src = buffer_r.ptr();
diff --git a/servers/audio/sample_manager_sw.h b/servers/audio/sample_manager_sw.h
index 5de1b40389..94254f99d5 100644
--- a/servers/audio/sample_manager_sw.h
+++ b/servers/audio/sample_manager_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,104 +26,104 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef SAMPLE_MANAGER_SW_H
-#define SAMPLE_MANAGER_SW_H
-
-#include "servers/audio_server.h"
-
-class SampleManagerSW {
-public:
-
- /* SAMPLE API */
-
- virtual RID sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length)=0;
-
- virtual void sample_set_description(RID p_sample, const String& p_description)=0;
- virtual String sample_get_description(RID p_sample) const=0;
-
- virtual AS::SampleFormat sample_get_format(RID p_sample) const=0;
- virtual bool sample_is_stereo(RID p_sample) const=0;
- virtual int sample_get_length(RID p_sample) const=0;
-
- virtual void sample_set_data(RID p_sample, const DVector<uint8_t>& p_buffer)=0;
- virtual const DVector<uint8_t> sample_get_data(RID p_sample) const=0;
-
- virtual void *sample_get_data_ptr(RID p_sample) const=0;
-
- virtual void sample_set_mix_rate(RID p_sample,int p_rate)=0;
- virtual int sample_get_mix_rate(RID p_sample) const=0;
-
- virtual void sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format)=0;
- virtual AS::SampleLoopFormat sample_get_loop_format(RID p_sample) const=0;
-
- virtual void sample_set_loop_begin(RID p_sample,int p_pos)=0;
- virtual int sample_get_loop_begin(RID p_sample) const=0;
-
- virtual void sample_set_loop_end(RID p_sample,int p_pos)=0;
- virtual int sample_get_loop_end(RID p_sample) const=0;
-
- virtual bool is_sample(RID) const=0;
- virtual void free(RID p_sample)=0;
-
-
-
- virtual ~SampleManagerSW();
-};
-
-
-class SampleManagerMallocSW : public SampleManagerSW {
-
-
- struct Sample {
-
- void *data;
- int length;
- int length_bytes;
- AS::SampleFormat format;
- bool stereo;
- AS::SampleLoopFormat loop_format;
- int loop_begin;
- int loop_end;
- int mix_rate;
- String description;
- };
-
- mutable RID_Owner<Sample> sample_owner;
-public:
-
- /* SAMPLE API */
-
- virtual RID sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length);
-
- virtual void sample_set_description(RID p_sample, const String& p_description);
- virtual String sample_get_description(RID p_sample) const;
-
- virtual AS::SampleFormat sample_get_format(RID p_sample) const;
- virtual bool sample_is_stereo(RID p_sample) const;
- virtual int sample_get_length(RID p_sample) const;
-
- virtual void sample_set_data(RID p_sample, const DVector<uint8_t>& p_buffer);
- virtual const DVector<uint8_t> sample_get_data(RID p_sample) const;
-
- virtual void *sample_get_data_ptr(RID p_sample) const;
-
- virtual void sample_set_mix_rate(RID p_sample,int p_rate);
- virtual int sample_get_mix_rate(RID p_sample) const;
-
- virtual void sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format);
- virtual AS::SampleLoopFormat sample_get_loop_format(RID p_sample) const;
-
- virtual void sample_set_loop_begin(RID p_sample,int p_pos);
- virtual int sample_get_loop_begin(RID p_sample) const;
-
- virtual void sample_set_loop_end(RID p_sample,int p_pos);
- virtual int sample_get_loop_end(RID p_sample) const;
-
- virtual bool is_sample(RID) const;
- virtual void free(RID p_sample);
-
- SampleManagerMallocSW();
- virtual ~SampleManagerMallocSW();
-};
-
-#endif // SAMPLE_MANAGER_SW_H
+#ifndef SAMPLE_MANAGER_SW_H
+#define SAMPLE_MANAGER_SW_H
+
+#include "servers/audio_server.h"
+
+class SampleManagerSW {
+public:
+
+ /* SAMPLE API */
+
+ virtual RID sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length)=0;
+
+ virtual void sample_set_description(RID p_sample, const String& p_description)=0;
+ virtual String sample_get_description(RID p_sample) const=0;
+
+ virtual AS::SampleFormat sample_get_format(RID p_sample) const=0;
+ virtual bool sample_is_stereo(RID p_sample) const=0;
+ virtual int sample_get_length(RID p_sample) const=0;
+
+ virtual void sample_set_data(RID p_sample, const DVector<uint8_t>& p_buffer)=0;
+ virtual const DVector<uint8_t> sample_get_data(RID p_sample) const=0;
+
+ virtual void *sample_get_data_ptr(RID p_sample) const=0;
+
+ virtual void sample_set_mix_rate(RID p_sample,int p_rate)=0;
+ virtual int sample_get_mix_rate(RID p_sample) const=0;
+
+ virtual void sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format)=0;
+ virtual AS::SampleLoopFormat sample_get_loop_format(RID p_sample) const=0;
+
+ virtual void sample_set_loop_begin(RID p_sample,int p_pos)=0;
+ virtual int sample_get_loop_begin(RID p_sample) const=0;
+
+ virtual void sample_set_loop_end(RID p_sample,int p_pos)=0;
+ virtual int sample_get_loop_end(RID p_sample) const=0;
+
+ virtual bool is_sample(RID) const=0;
+ virtual void free(RID p_sample)=0;
+
+
+
+ virtual ~SampleManagerSW();
+};
+
+
+class SampleManagerMallocSW : public SampleManagerSW {
+
+
+ struct Sample {
+
+ void *data;
+ int length;
+ int length_bytes;
+ AS::SampleFormat format;
+ bool stereo;
+ AS::SampleLoopFormat loop_format;
+ int loop_begin;
+ int loop_end;
+ int mix_rate;
+ String description;
+ };
+
+ mutable RID_Owner<Sample> sample_owner;
+public:
+
+ /* SAMPLE API */
+
+ virtual RID sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length);
+
+ virtual void sample_set_description(RID p_sample, const String& p_description);
+ virtual String sample_get_description(RID p_sample) const;
+
+ virtual AS::SampleFormat sample_get_format(RID p_sample) const;
+ virtual bool sample_is_stereo(RID p_sample) const;
+ virtual int sample_get_length(RID p_sample) const;
+
+ virtual void sample_set_data(RID p_sample, const DVector<uint8_t>& p_buffer);
+ virtual const DVector<uint8_t> sample_get_data(RID p_sample) const;
+
+ virtual void *sample_get_data_ptr(RID p_sample) const;
+
+ virtual void sample_set_mix_rate(RID p_sample,int p_rate);
+ virtual int sample_get_mix_rate(RID p_sample) const;
+
+ virtual void sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format);
+ virtual AS::SampleLoopFormat sample_get_loop_format(RID p_sample) const;
+
+ virtual void sample_set_loop_begin(RID p_sample,int p_pos);
+ virtual int sample_get_loop_begin(RID p_sample) const;
+
+ virtual void sample_set_loop_end(RID p_sample,int p_pos);
+ virtual int sample_get_loop_end(RID p_sample) const;
+
+ virtual bool is_sample(RID) const;
+ virtual void free(RID p_sample);
+
+ SampleManagerMallocSW();
+ virtual ~SampleManagerMallocSW();
+};
+
+#endif // SAMPLE_MANAGER_SW_H
diff --git a/servers/audio/voice_rb_sw.cpp b/servers/audio/voice_rb_sw.cpp
index 93f176b755..a385e15283 100644
--- a/servers/audio/voice_rb_sw.cpp
+++ b/servers/audio/voice_rb_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,9 +26,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "voice_rb_sw.h"
-/*
-VoiceRBSW::VoiceRBSW()
-{
-}
-*/
+#include "voice_rb_sw.h"
+/*
+VoiceRBSW::VoiceRBSW()
+{
+}
+*/
diff --git a/servers/audio/voice_rb_sw.h b/servers/audio/voice_rb_sw.h
index 7fcdebaa1a..cbebcdb86f 100644
--- a/servers/audio/voice_rb_sw.h
+++ b/servers/audio/voice_rb_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 81dab367c1..7c4f8b185a 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/audio_server.h b/servers/audio_server.h
index 511340678a..f54698a1e3 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/area_pair_sw.cpp b/servers/physics/area_pair_sw.cpp
index 5938e716e9..3eb96fb681 100644
--- a/servers/physics/area_pair_sw.cpp
+++ b/servers/physics/area_pair_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -93,3 +93,72 @@ AreaPairSW::~AreaPairSW() {
body->remove_constraint(this);
area->remove_constraint(this);
}
+
+////////////////////////////////////////////////////
+
+
+
+bool Area2PairSW::setup(float p_step) {
+
+// bool result = area_a->test_collision_mask(area_b) && CollisionSolverSW::solve(area_a->get_shape(shape_a),area_a->get_transform() * area_a->get_shape_transform(shape_a),Vector2(),area_b->get_shape(shape_b),area_b->get_transform() * area_b->get_shape_transform(shape_b),Vector2(),NULL,this);
+ bool result = CollisionSolverSW::solve_static(area_a->get_shape(shape_a),area_a->get_transform() * area_a->get_shape_transform(shape_a),area_b->get_shape(shape_b),area_b->get_transform() * area_b->get_shape_transform(shape_b),NULL,this);
+
+ if (result!=colliding) {
+
+ if (result) {
+
+ if (area_b->has_area_monitor_callback() && area_a->is_monitorable())
+ area_b->add_area_to_query(area_a,shape_a,shape_b);
+
+ if (area_a->has_area_monitor_callback() && area_b->is_monitorable())
+ area_a->add_area_to_query(area_b,shape_b,shape_a);
+
+ } else {
+
+ if (area_b->has_area_monitor_callback() && area_a->is_monitorable())
+ area_b->remove_area_from_query(area_a,shape_a,shape_b);
+
+ if (area_a->has_area_monitor_callback() && area_b->is_monitorable())
+ area_a->remove_area_from_query(area_b,shape_b,shape_a);
+ }
+
+ colliding=result;
+
+ }
+
+ return false; //never do any post solving
+}
+
+void Area2PairSW::solve(float p_step) {
+
+
+}
+
+
+Area2PairSW::Area2PairSW(AreaSW *p_area_a,int p_shape_a, AreaSW *p_area_b,int p_shape_b) {
+
+
+ area_a=p_area_a;
+ area_b=p_area_b;
+ shape_a=p_shape_a;
+ shape_b=p_shape_b;
+ colliding=false;
+ area_a->add_constraint(this);
+ area_b->add_constraint(this);
+
+}
+
+Area2PairSW::~Area2PairSW() {
+
+ if (colliding) {
+
+ if (area_b->has_area_monitor_callback() && area_a->is_monitorable())
+ area_b->remove_area_from_query(area_a,shape_a,shape_b);
+
+ if (area_a->has_area_monitor_callback() && area_b->is_monitorable())
+ area_a->remove_area_from_query(area_b,shape_b,shape_a);
+ }
+
+ area_a->remove_constraint(this);
+ area_b->remove_constraint(this);
+}
diff --git a/servers/physics/area_pair_sw.h b/servers/physics/area_pair_sw.h
index e5e2b5cf5e..4f8087280a 100644
--- a/servers/physics/area_pair_sw.h
+++ b/servers/physics/area_pair_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -49,5 +49,23 @@ public:
~AreaPairSW();
};
+
+class Area2PairSW : public ConstraintSW {
+
+ AreaSW *area_a;
+ AreaSW *area_b;
+ int shape_a;
+ int shape_b;
+ bool colliding;
+public:
+
+ bool setup(float p_step);
+ void solve(float p_step);
+
+ Area2PairSW(AreaSW *p_area_a,int p_shape_a, AreaSW *p_area_b,int p_shape_b);
+ ~Area2PairSW();
+};
+
+
#endif // AREA_PAIR__SW_H
diff --git a/servers/physics/area_sw.cpp b/servers/physics/area_sw.cpp
index 4c9ac814be..83be80f816 100644
--- a/servers/physics/area_sw.cpp
+++ b/servers/physics/area_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,6 +31,7 @@
#include "body_sw.h"
AreaSW::BodyKey::BodyKey(BodySW *p_body, uint32_t p_body_shape,uint32_t p_area_shape) { rid=p_body->get_self(); instance_id=p_body->get_instance_id(); body_shape=p_body_shape; area_shape=p_area_shape; }
+AreaSW::BodyKey::BodyKey(AreaSW *p_body, uint32_t p_body_shape,uint32_t p_area_shape) { rid=p_body->get_self(); instance_id=p_body->get_instance_id(); body_shape=p_body_shape; area_shape=p_area_shape; }
void AreaSW::_shapes_changed() {
@@ -57,6 +58,7 @@ void AreaSW::set_space(SpaceSW *p_space) {
}
monitored_bodies.clear();
+ monitored_areas.clear();
_set_space(p_space);
}
@@ -76,11 +78,32 @@ void AreaSW::set_monitor_callback(ObjectID p_id, const StringName& p_method) {
monitor_callback_method=p_method;
monitored_bodies.clear();
+ monitored_areas.clear();
+
_shape_changed();
}
+void AreaSW::set_area_monitor_callback(ObjectID p_id, const StringName& p_method) {
+
+
+ if (p_id==area_monitor_callback_id) {
+ area_monitor_callback_method=p_method;
+ return;
+ }
+
+ _unregister_shapes();
+
+ area_monitor_callback_id=p_id;
+ area_monitor_callback_method=p_method;
+
+ monitored_bodies.clear();
+ monitored_areas.clear();
+
+ _shape_changed();
+
+}
void AreaSW::set_space_override_mode(PhysicsServer::AreaSpaceOverrideMode p_mode) {
@@ -98,6 +121,7 @@ void AreaSW::set_param(PhysicsServer::AreaParameter p_param, const Variant& p_va
case PhysicsServer::AREA_PARAM_GRAVITY: gravity=p_value; ; break;
case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector=p_value; ; break;
case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point=p_value; ; break;
+ case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale=p_value; ; break;
case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation=p_value; ; break;
case PhysicsServer::AREA_PARAM_DENSITY: density=p_value; ; break;
case PhysicsServer::AREA_PARAM_PRIORITY: priority=p_value; ; break;
@@ -113,6 +137,7 @@ Variant AreaSW::get_param(PhysicsServer::AreaParameter p_param) const {
case PhysicsServer::AREA_PARAM_GRAVITY: return gravity;
case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: return gravity_vector;
case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: return gravity_is_point;
+ case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return gravity_distance_scale;
case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return point_attenuation;
case PhysicsServer::AREA_PARAM_DENSITY: return density;
case PhysicsServer::AREA_PARAM_PRIORITY: return priority;
@@ -132,6 +157,15 @@ void AreaSW::_queue_monitor_update() {
}
+void AreaSW::set_monitorable(bool p_monitorable) {
+
+ if (monitorable==p_monitorable)
+ return;
+
+ monitorable=p_monitorable;
+ _set_static(!monitorable);
+}
+
void AreaSW::call_queries() {
if (monitor_callback_id && !monitored_bodies.empty()) {
@@ -166,6 +200,41 @@ void AreaSW::call_queries() {
monitored_bodies.clear();
+ if (area_monitor_callback_id && !monitored_areas.empty()) {
+
+
+ Variant res[5];
+ Variant *resptr[5];
+ for(int i=0;i<5;i++)
+ resptr[i]=&res[i];
+
+ Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
+ if (!obj) {
+ monitored_areas.clear();
+ area_monitor_callback_id=0;
+ return;
+ }
+
+
+
+ for (Map<BodyKey,BodyState>::Element *E=monitored_areas.front();E;E=E->next()) {
+
+ if (E->get().state==0)
+ continue; //nothing happened
+
+ res[0]=E->get().state>0 ? PhysicsServer::AREA_BODY_ADDED : PhysicsServer::AREA_BODY_REMOVED;
+ res[1]=E->key().rid;
+ res[2]=E->key().instance_id;
+ res[3]=E->key().body_shape;
+ res[4]=E->key().area_shape;
+
+
+ Variant::CallError ce;
+ obj->call(area_monitor_callback_method,(const Variant**)resptr,5,ce);
+ }
+ }
+
+ monitored_areas.clear();
//get_space()->area_remove_from_monitor_query_list(&monitor_query_list);
}
@@ -177,11 +246,14 @@ AreaSW::AreaSW() : CollisionObjectSW(TYPE_AREA), monitor_query_list(this), move
gravity=9.80665;
gravity_vector=Vector3(0,-1,0);
gravity_is_point=false;
+ gravity_distance_scale=0;
point_attenuation=1;
density=0.1;
priority=0;
set_ray_pickable(false);
monitor_callback_id=0;
+ area_monitor_callback_id=0;
+ monitorable=false;
}
diff --git a/servers/physics/area_sw.h b/servers/physics/area_sw.h
index c0c6e5c2ae..26d6a177db 100644
--- a/servers/physics/area_sw.h
+++ b/servers/physics/area_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -45,13 +45,18 @@ class AreaSW : public CollisionObjectSW{
float gravity;
Vector3 gravity_vector;
bool gravity_is_point;
+ float gravity_distance_scale;
float point_attenuation;
float density;
int priority;
+ bool monitorable;
ObjectID monitor_callback_id;
StringName monitor_callback_method;
+ ObjectID area_monitor_callback_id;
+ StringName area_monitor_callback_method;
+
SelfList<AreaSW> monitor_query_list;
SelfList<AreaSW> moved_list;
@@ -78,6 +83,8 @@ class AreaSW : public CollisionObjectSW{
_FORCE_INLINE_ BodyKey() {}
BodyKey(BodySW *p_body, uint32_t p_body_shape,uint32_t p_area_shape);
+ BodyKey(AreaSW *p_body, uint32_t p_body_shape,uint32_t p_area_shape);
+
};
struct BodyState {
@@ -89,6 +96,7 @@ class AreaSW : public CollisionObjectSW{
};
Map<BodyKey,BodyState> monitored_bodies;
+ Map<BodyKey,BodyState> monitored_areas;
//virtual void shape_changed_notify(ShapeSW *p_shape);
//virtual void shape_deleted_notify(ShapeSW *p_shape);
@@ -107,9 +115,15 @@ public:
void set_monitor_callback(ObjectID p_id, const StringName& p_method);
_FORCE_INLINE_ bool has_monitor_callback() const { return monitor_callback_id; }
+ void set_area_monitor_callback(ObjectID p_id, const StringName& p_method);
+ _FORCE_INLINE_ bool has_area_monitor_callback() const { return area_monitor_callback_id; }
+
_FORCE_INLINE_ void add_body_to_query(BodySW *p_body, uint32_t p_body_shape,uint32_t p_area_shape);
_FORCE_INLINE_ void remove_body_from_query(BodySW *p_body, uint32_t p_body_shape,uint32_t p_area_shape);
+ _FORCE_INLINE_ void add_area_to_query(AreaSW *p_area, uint32_t p_area_shape,uint32_t p_self_shape);
+ _FORCE_INLINE_ void remove_area_from_query(AreaSW *p_area, uint32_t p_area_shape,uint32_t p_self_shape);
+
void set_param(PhysicsServer::AreaParameter p_param, const Variant& p_value);
Variant get_param(PhysicsServer::AreaParameter p_param) const;
@@ -125,6 +139,9 @@ public:
_FORCE_INLINE_ void set_gravity_as_point(bool p_enable) { gravity_is_point=p_enable; }
_FORCE_INLINE_ bool is_gravity_point() const { return gravity_is_point; }
+ _FORCE_INLINE_ void set_gravity_distance_scale(float scale) { gravity_distance_scale=scale; }
+ _FORCE_INLINE_ float get_gravity_distance_scale() const { return gravity_distance_scale; }
+
_FORCE_INLINE_ void set_point_attenuation(float p_point_attenuation) { point_attenuation=p_point_attenuation; }
_FORCE_INLINE_ float get_point_attenuation() const { return point_attenuation; }
@@ -138,8 +155,8 @@ public:
_FORCE_INLINE_ void remove_constraint( ConstraintSW* p_constraint) { constraints.erase(p_constraint); }
_FORCE_INLINE_ const Set<ConstraintSW*>& get_constraints() const { return constraints; }
-
-
+ void set_monitorable(bool p_monitorable);
+ _FORCE_INLINE_ bool is_monitorable() const { return monitorable; }
void set_transform(const Transform& p_transform);
@@ -168,6 +185,26 @@ void AreaSW::remove_body_from_query(BodySW *p_body, uint32_t p_body_shape,uint32
}
+void AreaSW::add_area_to_query(AreaSW *p_area, uint32_t p_area_shape,uint32_t p_self_shape) {
+
+
+ BodyKey bk(p_area,p_area_shape,p_self_shape);
+ monitored_areas[bk].inc();
+ if (!monitor_query_list.in_list())
+ _queue_monitor_update();
+
+
+}
+void AreaSW::remove_area_from_query(AreaSW *p_area, uint32_t p_area_shape,uint32_t p_self_shape) {
+
+
+ BodyKey bk(p_area,p_area_shape,p_self_shape);
+ monitored_areas[bk].dec();
+ if (!monitor_query_list.in_list())
+ _queue_monitor_update();
+}
+
+
diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics/body_pair_sw.cpp
index 5847b942fb..e2b2fa2051 100644
--- a/servers/physics/body_pair_sw.cpp
+++ b/servers/physics/body_pair_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/body_pair_sw.h b/servers/physics/body_pair_sw.h
index e64464e2c1..8ec7a9ccef 100644
--- a/servers/physics/body_pair_sw.h
+++ b/servers/physics/body_pair_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp
index c7c20a8bd1..5a528ecf94 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics/body_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -257,10 +257,13 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant& p_varian
Transform t = p_variant;
t.orthonormalize();
new_transform=get_transform(); //used as old to compute motion
+ if (new_transform==t)
+ break;
_set_transform(t);
_set_inv_transform(get_transform().inverse());
}
+ wakeup();
} break;
case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: {
@@ -268,11 +271,13 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant& p_varian
//if (mode==PhysicsServer::BODY_MODE_STATIC)
// break;
linear_velocity=p_variant;
+ wakeup();
} break;
case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: {
//if (mode!=PhysicsServer::BODY_MODE_RIGID)
// break;
angular_velocity=p_variant;
+ wakeup();
} break;
case PhysicsServer::BODY_STATE_SLEEPING: {
@@ -357,11 +362,14 @@ void BodySW::set_space(SpaceSW *p_space){
void BodySW::_compute_area_gravity(const AreaSW *p_area) {
if (p_area->is_gravity_point()) {
-
- gravity = (p_area->get_transform().xform(p_area->get_gravity_vector()) - get_transform().get_origin()).normalized() * p_area->get_gravity();
-
+ if(p_area->get_gravity_distance_scale() > 0) {
+ Vector3 v = p_area->get_transform().xform(p_area->get_gravity_vector()) - get_transform().get_origin();
+ gravity += v.normalized() * (p_area->get_gravity() / Math::pow(v.length() * p_area->get_gravity_distance_scale()+1, 2) );
+ } else {
+ gravity += (p_area->get_transform().xform(p_area->get_gravity_vector()) - get_transform().get_origin()).normalized() * p_area->get_gravity();
+ }
} else {
- gravity = p_area->get_gravity_vector() * p_area->get_gravity();
+ gravity += p_area->get_gravity_vector() * p_area->get_gravity();
}
}
@@ -371,23 +379,29 @@ void BodySW::integrate_forces(real_t p_step) {
if (mode==PhysicsServer::BODY_MODE_STATIC)
return;
- AreaSW *current_area = get_space()->get_default_area();
- ERR_FAIL_COND(!current_area);
+ AreaSW *def_area = get_space()->get_default_area();
+ ERR_FAIL_COND(!def_area);
- int prio = current_area->get_priority();
int ac = areas.size();
+ bool replace = false;
+ gravity=Vector3(0,0,0);
if (ac) {
+ areas.sort();
const AreaCMP *aa = &areas[0];
- for(int i=0;i<ac;i++) {
- if (aa[i].area->get_priority() > prio) {
- current_area=aa[i].area;
- prio=current_area->get_priority();
+ density = aa[ac-1].area->get_density();
+ for(int i=ac-1;i>=0;i--) {
+ _compute_area_gravity(aa[i].area);
+ if (aa[i].area->get_space_override_mode() == PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE) {
+ replace = true;
+ break;
}
}
+ } else {
+ density=def_area->get_density();
+ }
+ if( !replace ) {
+ _compute_area_gravity(def_area);
}
-
- _compute_area_gravity(current_area);
- density=current_area->get_density();
Vector3 motion;
bool do_motion=false;
@@ -455,7 +469,7 @@ void BodySW::integrate_forces(real_t p_step) {
}
- current_area=NULL; // clear the area, so it is set in the next frame
+ def_area=NULL; // clear the area, so it is set in the next frame
contact_count=0;
}
diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h
index ee3c76e455..6491ba8f18 100644
--- a/servers/physics/body_sw.h
+++ b/servers/physics/body_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -84,13 +84,13 @@ class BodySW : public CollisionObjectSW {
struct AreaCMP {
AreaSW *area;
- _FORCE_INLINE_ bool operator<(const AreaCMP& p_cmp) const { return area->get_self() < p_cmp.area->get_self() ; }
+ _FORCE_INLINE_ bool operator==(const AreaCMP& p_cmp) const { return area->get_self() == p_cmp.area->get_self();}
+ _FORCE_INLINE_ bool operator<(const AreaCMP& p_cmp) const { return area->get_priority() < p_cmp.area->get_priority();}
_FORCE_INLINE_ AreaCMP() {}
_FORCE_INLINE_ AreaCMP(AreaSW *p_area) { area=p_area;}
};
-
- VSet<AreaCMP> areas;
+ Vector<AreaCMP> areas;
struct Contact {
@@ -134,8 +134,7 @@ public:
void set_force_integration_callback(ObjectID p_id,const StringName& p_method,const Variant& p_udata=Variant());
-
- _FORCE_INLINE_ void add_area(AreaSW *p_area) { areas.insert(AreaCMP(p_area)); }
+ _FORCE_INLINE_ void add_area(AreaSW *p_area) { areas.ordered_insert(AreaCMP(p_area)); }
_FORCE_INLINE_ void remove_area(AreaSW *p_area) { areas.erase(AreaCMP(p_area)); }
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) { contacts.resize(p_size); contact_count=0; if (mode==PhysicsServer::BODY_MODE_KINEMATIC && p_size) set_active(true);}
@@ -201,6 +200,12 @@ public:
void set_active(bool p_active);
_FORCE_INLINE_ bool is_active() const { return active; }
+ _FORCE_INLINE_ void wakeup() {
+ if ((!get_space()) || mode==PhysicsServer::BODY_MODE_STATIC || mode==PhysicsServer::BODY_MODE_KINEMATIC)
+ return;
+ set_active(true);
+ }
+
void set_param(PhysicsServer::BodyParameter p_param, float);
float get_param(PhysicsServer::BodyParameter p_param) const;
diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics/broad_phase_basic.cpp
index 5db78e669f..c49caed795 100644
--- a/servers/physics/broad_phase_basic.cpp
+++ b/servers/physics/broad_phase_basic.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/broad_phase_basic.h b/servers/physics/broad_phase_basic.h
index 7b77466292..9848c4b16e 100644
--- a/servers/physics/broad_phase_basic.h
+++ b/servers/physics/broad_phase_basic.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics/broad_phase_octree.cpp
index edf4aae2b2..874ae29755 100644
--- a/servers/physics/broad_phase_octree.cpp
+++ b/servers/physics/broad_phase_octree.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/broad_phase_octree.h b/servers/physics/broad_phase_octree.h
index d365213966..200878f6df 100644
--- a/servers/physics/broad_phase_octree.h
+++ b/servers/physics/broad_phase_octree.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/broad_phase_sw.cpp b/servers/physics/broad_phase_sw.cpp
index 1211db141f..910be4e623 100644
--- a/servers/physics/broad_phase_sw.cpp
+++ b/servers/physics/broad_phase_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/broad_phase_sw.h b/servers/physics/broad_phase_sw.h
index 57301a2af9..2bf9f202e2 100644
--- a/servers/physics/broad_phase_sw.h
+++ b/servers/physics/broad_phase_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp
index c8e1fc4022..19b3f28a2f 100644
--- a/servers/physics/collision_object_sw.cpp
+++ b/servers/physics/collision_object_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h
index 788292ad2a..c018ab6224 100644
--- a/servers/physics/collision_object_sw.h
+++ b/servers/physics/collision_object_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,8 +34,10 @@
#include "self_list.h"
#include "broad_phase_sw.h"
-#define MAX_OBJECT_DISTANCE 10000000
+#ifdef DEBUG_ENABLED
+#define MAX_OBJECT_DISTANCE 10000000.0
#define MAX_OBJECT_DISTANCE_X2 (MAX_OBJECT_DISTANCE*MAX_OBJECT_DISTANCE)
+#endif
class SpaceSW;
diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp
index 750874f507..72e61f1456 100644
--- a/servers/physics/collision_solver_sat.cpp
+++ b/servers/physics/collision_solver_sat.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/collision_solver_sat.h b/servers/physics/collision_solver_sat.h
index eeba53f160..686b587243 100644
--- a/servers/physics/collision_solver_sat.h
+++ b/servers/physics/collision_solver_sat.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics/collision_solver_sw.cpp
index 86e3b679f2..b5a5c64660 100644
--- a/servers/physics/collision_solver_sw.cpp
+++ b/servers/physics/collision_solver_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/collision_solver_sw.h b/servers/physics/collision_solver_sw.h
index 764c32926c..5ed5260b7d 100644
--- a/servers/physics/collision_solver_sw.h
+++ b/servers/physics/collision_solver_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/constraint_sw.cpp b/servers/physics/constraint_sw.cpp
index f1179bdb5c..fb45485233 100644
--- a/servers/physics/constraint_sw.cpp
+++ b/servers/physics/constraint_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/constraint_sw.h b/servers/physics/constraint_sw.h
index 5e79c4b54c..1ec237f9c5 100644
--- a/servers/physics/constraint_sw.h
+++ b/servers/physics/constraint_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp
index 3d569df2c9..decc379461 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.cpp
+++ b/servers/physics/joints/generic_6dof_joint_sw.cpp
@@ -536,7 +536,7 @@ void Generic6DOFJointSW::set_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJoin
} break;
case PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: {
- m_angularLimits[p_axis].m_limitSoftness;
+ m_angularLimits[p_axis].m_limitSoftness=p_value;
} break;
case PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING: {
diff --git a/servers/physics/joints_sw.cpp b/servers/physics/joints_sw.cpp
index f9e22e1665..aa9d3265d2 100644
--- a/servers/physics/joints_sw.cpp
+++ b/servers/physics/joints_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/joints_sw.h b/servers/physics/joints_sw.h
index 30227f156b..d7ba6ef925 100644
--- a/servers/physics/joints_sw.h
+++ b/servers/physics/joints_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp
index cfe5a73ce1..521ffae0ea 100644
--- a/servers/physics/physics_server_sw.cpp
+++ b/servers/physics/physics_server_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -394,6 +394,14 @@ Transform PhysicsServerSW::area_get_transform(RID p_area) const {
return area->get_transform();
};
+void PhysicsServerSW::area_set_monitorable(RID p_area,bool p_monitorable) {
+
+ AreaSW *area = area_owner.get(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->set_monitorable(p_monitorable);
+}
+
void PhysicsServerSW::area_set_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method) {
AreaSW *area = area_owner.get(p_area);
@@ -423,6 +431,14 @@ bool PhysicsServerSW::area_is_ray_pickable(RID p_area) const{
}
+void PhysicsServerSW::area_set_area_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method) {
+
+
+ AreaSW *area = area_owner.get(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->set_area_monitor_callback(p_receiver?p_receiver->get_instance_ID():0,p_method);
+}
/* BODY API */
@@ -551,7 +567,7 @@ bool PhysicsServerSW::body_is_shape_set_as_trigger(RID p_body, int p_shape_idx)
ERR_FAIL_COND_V(!body,false);
ERR_FAIL_INDEX_V(p_shape_idx,body->get_shape_count(),false);
- body->is_shape_set_as_trigger(p_shape_idx);
+ return body->is_shape_set_as_trigger(p_shape_idx);
}
@@ -604,6 +620,7 @@ void PhysicsServerSW::body_set_layer_mask(RID p_body, uint32_t p_mask) {
ERR_FAIL_COND(!body);
body->set_layer_mask(p_mask);
+ body->wakeup();
}
@@ -674,6 +691,7 @@ void PhysicsServerSW::body_set_state(RID p_body, BodyState p_state, const Varian
ERR_FAIL_COND(!body);
body->set_state(p_state,p_variant);
+
};
Variant PhysicsServerSW::body_get_state(RID p_body, BodyState p_state) const {
@@ -691,6 +709,7 @@ void PhysicsServerSW::body_set_applied_force(RID p_body, const Vector3& p_force)
ERR_FAIL_COND(!body);
body->set_applied_force(p_force);
+ body->wakeup();
};
Vector3 PhysicsServerSW::body_get_applied_force(RID p_body) const {
@@ -706,6 +725,7 @@ void PhysicsServerSW::body_set_applied_torque(RID p_body, const Vector3& p_torqu
ERR_FAIL_COND(!body);
body->set_applied_torque(p_torque);
+ body->wakeup();
};
Vector3 PhysicsServerSW::body_get_applied_torque(RID p_body) const {
@@ -722,6 +742,7 @@ void PhysicsServerSW::body_apply_impulse(RID p_body, const Vector3& p_pos, const
ERR_FAIL_COND(!body);
body->apply_impulse(p_pos,p_impulse);
+ body->wakeup();
};
void PhysicsServerSW::body_set_axis_velocity(RID p_body, const Vector3& p_axis_velocity) {
@@ -734,6 +755,7 @@ void PhysicsServerSW::body_set_axis_velocity(RID p_body, const Vector3& p_axis_v
v-=axis*axis.dot(v);
v+=p_axis_velocity;
body->set_linear_velocity(v);
+ body->wakeup();
};
@@ -743,6 +765,7 @@ void PhysicsServerSW::body_set_axis_lock(RID p_body,BodyAxisLock p_lock) {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
body->set_axis_lock(p_lock);
+ body->wakeup();
}
@@ -762,6 +785,7 @@ void PhysicsServerSW::body_add_collision_exception(RID p_body, RID p_body_b) {
ERR_FAIL_COND(!body);
body->add_exception(p_body_b);
+ body->wakeup();
};
@@ -771,6 +795,7 @@ void PhysicsServerSW::body_remove_collision_exception(RID p_body, RID p_body_b)
ERR_FAIL_COND(!body);
body->remove_exception(p_body_b);
+ body->wakeup();
};
diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h
index 6609a78662..80007b8499 100644
--- a/servers/physics/physics_server_sw.h
+++ b/servers/physics/physics_server_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -128,7 +128,10 @@ public:
virtual void area_set_ray_pickable(RID p_area,bool p_enable);
virtual bool area_is_ray_pickable(RID p_area) const;
+ virtual void area_set_monitorable(RID p_area,bool p_monitorable);
+
virtual void area_set_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method);
+ virtual void area_set_area_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method);
/* BODY API */
diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp
index bd4be05bb9..fabfa88ee5 100644
--- a/servers/physics/shape_sw.cpp
+++ b/servers/physics/shape_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -997,6 +997,11 @@ DVector<Vector3> ConcavePolygonShapeSW::get_faces() const {
void ConcavePolygonShapeSW::project_range(const Vector3& p_normal, const Transform& p_transform, real_t &r_min, real_t &r_max) const {
int count=vertices.size();
+ if (count==0) {
+ r_min=0;
+ r_max=0;
+ return;
+ }
DVector<Vector3>::Read r=vertices.read();
const Vector3 *vptr=r.ptr();
@@ -1016,6 +1021,9 @@ Vector3 ConcavePolygonShapeSW::get_support(const Vector3& p_normal) const {
int count=vertices.size();
+ if (count==0)
+ return Vector3();
+
DVector<Vector3>::Read r=vertices.read();
const Vector3 *vptr=r.ptr();
@@ -1103,6 +1111,9 @@ void ConcavePolygonShapeSW::_cull_segment(int p_idx,_SegmentCullParams *p_params
bool ConcavePolygonShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const {
+ if (faces.size()==0)
+ return false;
+
// unlock data
DVector<Face>::Read fr=faces.read();
DVector<Vector3>::Read vr=vertices.read();
@@ -1171,6 +1182,8 @@ void ConcavePolygonShapeSW::_cull(int p_idx,_CullParams *p_params) const {
void ConcavePolygonShapeSW::cull(const AABB& p_local_aabb,Callback p_callback,void* p_userdata) const {
// make matrix local to concave
+ if (faces.size()==0)
+ return;
AABB local_aabb=p_local_aabb;
diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h
index bcf8fbdc8d..4826eaea4f 100644
--- a/servers/physics/shape_sw.h
+++ b/servers/physics/shape_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp
index 3fc34889f2..d329a10f04 100644
--- a/servers/physics/space_sw.cpp
+++ b/servers/physics/space_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -503,15 +503,18 @@ void* SpaceSW::_broadphase_pair(CollisionObjectSW *A,int p_subindex_A,CollisionO
if (type_A==CollisionObjectSW::TYPE_AREA) {
-
- ERR_FAIL_COND_V(type_B!=CollisionObjectSW::TYPE_BODY,NULL);
AreaSW *area=static_cast<AreaSW*>(A);
- BodySW *body=static_cast<BodySW*>(B);
-
+ if (type_B==CollisionObjectSW::TYPE_AREA) {
- AreaPairSW *area_pair = memnew(AreaPairSW(body,p_subindex_B,area,p_subindex_A) );
+ AreaSW *area_b=static_cast<AreaSW*>(B);
+ Area2PairSW *area2_pair = memnew(Area2PairSW(area_b,p_subindex_B,area,p_subindex_A) );
+ return area2_pair;
+ } else {
- return area_pair;
+ BodySW *body=static_cast<BodySW*>(B);
+ AreaPairSW *area_pair = memnew(AreaPairSW(body,p_subindex_B,area,p_subindex_A) );
+ return area_pair;
+ }
} else {
diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h
index 4bd9bc6f51..16f5ad3c81 100644
--- a/servers/physics/space_sw.h
+++ b/servers/physics/space_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/step_sw.cpp b/servers/physics/step_sw.cpp
index b7d06d207b..2424b36833 100644
--- a/servers/physics/step_sw.cpp
+++ b/servers/physics/step_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics/step_sw.h b/servers/physics/step_sw.h
index 9aaef97920..f089c041fc 100644
--- a/servers/physics/step_sw.h
+++ b/servers/physics/step_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/area_2d_sw.cpp b/servers/physics_2d/area_2d_sw.cpp
index 65f3b80dd3..1a41cda482 100644
--- a/servers/physics_2d/area_2d_sw.cpp
+++ b/servers/physics_2d/area_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -120,6 +120,7 @@ void Area2DSW::set_param(Physics2DServer::AreaParameter p_param, const Variant&
case Physics2DServer::AREA_PARAM_GRAVITY: gravity=p_value; ; break;
case Physics2DServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector=p_value; ; break;
case Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point=p_value; ; break;
+ case Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale=p_value; ; break;
case Physics2DServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation=p_value; ; break;
case Physics2DServer::AREA_PARAM_LINEAR_DAMP: linear_damp=p_value; ; break;
case Physics2DServer::AREA_PARAM_ANGULAR_DAMP: angular_damp=p_value; ; break;
@@ -136,6 +137,7 @@ Variant Area2DSW::get_param(Physics2DServer::AreaParameter p_param) const {
case Physics2DServer::AREA_PARAM_GRAVITY: return gravity;
case Physics2DServer::AREA_PARAM_GRAVITY_VECTOR: return gravity_vector;
case Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT: return gravity_is_point;
+ case Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return gravity_distance_scale;
case Physics2DServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return point_attenuation;
case Physics2DServer::AREA_PARAM_LINEAR_DAMP: return linear_damp;
case Physics2DServer::AREA_PARAM_ANGULAR_DAMP: return angular_damp;
@@ -248,6 +250,7 @@ Area2DSW::Area2DSW() : CollisionObject2DSW(TYPE_AREA), monitor_query_list(this),
gravity=9.80665;
gravity_vector=Vector2(0,-1);
gravity_is_point=false;
+ gravity_distance_scale=0;
point_attenuation=1;
angular_damp=1.0;
diff --git a/servers/physics_2d/area_2d_sw.h b/servers/physics_2d/area_2d_sw.h
index 26b7b2516c..6d99764c68 100644
--- a/servers/physics_2d/area_2d_sw.h
+++ b/servers/physics_2d/area_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -46,6 +46,7 @@ class Area2DSW : public CollisionObject2DSW{
float gravity;
Vector2 gravity_vector;
bool gravity_is_point;
+ float gravity_distance_scale;
float point_attenuation;
float linear_damp;
float angular_damp;
@@ -139,6 +140,9 @@ public:
_FORCE_INLINE_ void set_gravity_as_point(bool p_enable) { gravity_is_point=p_enable; }
_FORCE_INLINE_ bool is_gravity_point() const { return gravity_is_point; }
+ _FORCE_INLINE_ void set_gravity_distance_scale(float scale) { gravity_distance_scale=scale; }
+ _FORCE_INLINE_ float get_gravity_distance_scale() const { return gravity_distance_scale; }
+
_FORCE_INLINE_ void set_point_attenuation(float p_point_attenuation) { point_attenuation=p_point_attenuation; }
_FORCE_INLINE_ float get_point_attenuation() const { return point_attenuation; }
diff --git a/servers/physics_2d/area_pair_2d_sw.cpp b/servers/physics_2d/area_pair_2d_sw.cpp
index ed2e34c972..3b1705bd56 100644
--- a/servers/physics_2d/area_pair_2d_sw.cpp
+++ b/servers/physics_2d/area_pair_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
bool AreaPair2DSW::setup(float p_step) {
- bool result = CollisionSolver2DSW::solve(body->get_shape(body_shape),body->get_transform() * body->get_shape_transform(body_shape),Vector2(),area->get_shape(area_shape),area->get_transform() * area->get_shape_transform(area_shape),Vector2(),NULL,this);
+ bool result = area->test_collision_mask(body) && CollisionSolver2DSW::solve(body->get_shape(body_shape),body->get_transform() * body->get_shape_transform(body_shape),Vector2(),area->get_shape(area_shape),area->get_transform() * area->get_shape_transform(area_shape),Vector2(),NULL,this);
if (result!=colliding) {
@@ -102,7 +102,7 @@ AreaPair2DSW::~AreaPair2DSW() {
bool Area2Pair2DSW::setup(float p_step) {
- bool result = CollisionSolver2DSW::solve(area_a->get_shape(shape_a),area_a->get_transform() * area_a->get_shape_transform(shape_a),Vector2(),area_b->get_shape(shape_b),area_b->get_transform() * area_b->get_shape_transform(shape_b),Vector2(),NULL,this);
+ bool result = area_a->test_collision_mask(area_b) && CollisionSolver2DSW::solve(area_a->get_shape(shape_a),area_a->get_transform() * area_a->get_shape_transform(shape_a),Vector2(),area_b->get_shape(shape_b),area_b->get_transform() * area_b->get_shape_transform(shape_b),Vector2(),NULL,this);
if (result!=colliding) {
diff --git a/servers/physics_2d/area_pair_2d_sw.h b/servers/physics_2d/area_pair_2d_sw.h
index 575490b109..59113c9162 100644
--- a/servers/physics_2d/area_pair_2d_sw.h
+++ b/servers/physics_2d/area_pair_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index 06d466ace8..38835c9a82 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -275,10 +275,13 @@ void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant& p_va
Matrix32 t = p_variant;
t.orthonormalize();
new_transform=get_transform(); //used as old to compute motion
+ if (t==new_transform)
+ break;
_set_transform(t);
_set_inv_transform(get_transform().inverse());
}
+ wakeup();
} break;
case Physics2DServer::BODY_STATE_LINEAR_VELOCITY: {
@@ -286,12 +289,14 @@ void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant& p_va
//if (mode==Physics2DServer::BODY_MODE_STATIC)
// break;
linear_velocity=p_variant;
+ wakeup();
} break;
case Physics2DServer::BODY_STATE_ANGULAR_VELOCITY: {
//if (mode!=Physics2DServer::BODY_MODE_RIGID)
// break;
angular_velocity=p_variant;
+ wakeup();
} break;
case Physics2DServer::BODY_STATE_SLEEPING: {
@@ -378,14 +383,16 @@ void Body2DSW::set_space(Space2DSW *p_space){
void Body2DSW::_compute_area_gravity(const Area2DSW *p_area) {
if (p_area->is_gravity_point()) {
-
- gravity = (p_area->get_transform().xform(p_area->get_gravity_vector()) - get_transform().get_origin()).normalized() * p_area->get_gravity();
-
+ if(p_area->get_gravity_distance_scale() > 0) {
+ Vector2 v = p_area->get_transform().xform(p_area->get_gravity_vector()) - get_transform().get_origin();
+ gravity += v.normalized() * (p_area->get_gravity() / Math::pow(v.length() * p_area->get_gravity_distance_scale()+1, 2) );
+ } else {
+ gravity += (p_area->get_transform().xform(p_area->get_gravity_vector()) - get_transform().get_origin()).normalized() * p_area->get_gravity();
+ }
} else {
- gravity = p_area->get_gravity_vector() * p_area->get_gravity();
+ gravity += p_area->get_gravity_vector() * p_area->get_gravity();
}
- gravity*=gravity_scale;
}
void Body2DSW::integrate_forces(real_t p_step) {
@@ -393,32 +400,39 @@ void Body2DSW::integrate_forces(real_t p_step) {
if (mode==Physics2DServer::BODY_MODE_STATIC)
return;
- Area2DSW *current_area = get_space()->get_default_area();
- ERR_FAIL_COND(!current_area);
+ Area2DSW *def_area = get_space()->get_default_area();
+ Area2DSW *damp_area = def_area;
+ ERR_FAIL_COND(!def_area);
- int prio = current_area->get_priority();
int ac = areas.size();
+ bool replace = false;
+ gravity=Vector2(0,0);
if (ac) {
+ areas.sort();
const AreaCMP *aa = &areas[0];
- for(int i=0;i<ac;i++) {
- if (aa[i].area->get_priority() > prio) {
- current_area=aa[i].area;
- prio=current_area->get_priority();
+ damp_area = aa[ac-1].area;
+ for(int i=ac-1;i>=0;i--) {
+ _compute_area_gravity(aa[i].area);
+ if (aa[i].area->get_space_override_mode() == Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE) {
+ replace = true;
+ break;
}
}
}
-
- _compute_area_gravity(current_area);
+ if( !replace ) {
+ _compute_area_gravity(def_area);
+ }
+ gravity*=gravity_scale;
if (angular_damp>=0)
area_angular_damp=angular_damp;
else
- area_angular_damp=current_area->get_angular_damp();
+ area_angular_damp=damp_area->get_angular_damp();
if (linear_damp>=0)
area_linear_damp=linear_damp;
else
- area_linear_damp=current_area->get_linear_damp();
+ area_linear_damp=damp_area->get_linear_damp();
Vector2 motion;
bool do_motion=false;
@@ -482,7 +496,8 @@ void Body2DSW::integrate_forces(real_t p_step) {
_update_shapes_with_motion(motion);
}
- current_area=NULL; // clear the area, so it is set in the next frame
+ damp_area=NULL; // clear the area, so it is set in the next frame
+ def_area=NULL; // clear the area, so it is set in the next frame
contact_count=0;
}
@@ -647,6 +662,7 @@ Body2DSW::Body2DSW() : CollisionObject2DSW(TYPE_BODY), active_list(this), inerti
area_linear_damp=0;
contact_count=0;
gravity_scale=1.0;
+ using_one_way_cache=false;
one_way_collision_max_depth=0.1;
still_time=0;
diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h
index 3b87be2737..c86bb51f1d 100644
--- a/servers/physics_2d/body_2d_sw.h
+++ b/servers/physics_2d/body_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -81,6 +81,7 @@ class Body2DSW : public CollisionObject2DSW {
bool active;
bool can_sleep;
bool first_time_kinematic;
+ bool using_one_way_cache;
void _update_inertia();
virtual void _shapes_changed();
Matrix32 new_transform;
@@ -91,13 +92,14 @@ class Body2DSW : public CollisionObject2DSW {
struct AreaCMP {
Area2DSW *area;
- _FORCE_INLINE_ bool operator<(const AreaCMP& p_cmp) const { return area->get_self() < p_cmp.area->get_self() ; }
+ _FORCE_INLINE_ bool operator==(const AreaCMP& p_cmp) const { return area->get_self() == p_cmp.area->get_self();}
+ _FORCE_INLINE_ bool operator<(const AreaCMP& p_cmp) const { return area->get_priority() < p_cmp.area->get_priority();}
_FORCE_INLINE_ AreaCMP() {}
_FORCE_INLINE_ AreaCMP(Area2DSW *p_area) { area=p_area;}
};
- VSet<AreaCMP> areas;
+ Vector<AreaCMP> areas;
struct Contact {
@@ -140,7 +142,7 @@ public:
void set_force_integration_callback(ObjectID p_id, const StringName& p_method, const Variant &p_udata=Variant());
- _FORCE_INLINE_ void add_area(Area2DSW *p_area) { areas.insert(AreaCMP(p_area)); }
+ _FORCE_INLINE_ void add_area(Area2DSW *p_area) { areas.ordered_insert(AreaCMP(p_area)); }
_FORCE_INLINE_ void remove_area(Area2DSW *p_area) { areas.erase(AreaCMP(p_area)); }
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) { contacts.resize(p_size); contact_count=0; if (mode==Physics2DServer::BODY_MODE_KINEMATIC && p_size) set_active(true);}
@@ -200,6 +202,15 @@ public:
void set_active(bool p_active);
_FORCE_INLINE_ bool is_active() const { return active; }
+ _FORCE_INLINE_ void wakeup() {
+ if ((!get_space()) || mode==Physics2DServer::BODY_MODE_STATIC || mode==Physics2DServer::BODY_MODE_KINEMATIC)
+ return;
+ set_active(true);
+ }
+
+
+
+
void set_param(Physics2DServer::BodyParameter p_param, float);
float get_param(Physics2DServer::BodyParameter p_param) const;
@@ -219,12 +230,17 @@ public:
_FORCE_INLINE_ void set_continuous_collision_detection_mode(Physics2DServer::CCDMode p_mode) { continuous_cd_mode=p_mode; }
_FORCE_INLINE_ Physics2DServer::CCDMode get_continuous_collision_detection_mode() const { return continuous_cd_mode; }
- void set_one_way_collision_direction(const Vector2& p_dir) { one_way_collision_direction=p_dir; }
+ void set_one_way_collision_direction(const Vector2& p_dir) {
+ one_way_collision_direction=p_dir;
+ using_one_way_cache=one_way_collision_direction!=Vector2();
+ }
Vector2 get_one_way_collision_direction() const { return one_way_collision_direction; }
void set_one_way_collision_max_depth(float p_depth) { one_way_collision_max_depth=p_depth; }
float get_one_way_collision_max_depth() const { return one_way_collision_max_depth; }
+ _FORCE_INLINE_ bool is_using_one_way_collision() const { return using_one_way_cache; }
+
void set_space(Space2DSW *p_space);
void update_inertias();
diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp
index c4d6abe5ac..6bfed134e6 100644
--- a/servers/physics_2d/body_pair_2d_sw.cpp
+++ b/servers/physics_2d/body_pair_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -234,7 +234,7 @@ bool BodyPair2DSW::setup(float p_step) {
//cannot collide
- if ((A->get_layer_mask()&B->get_layer_mask())==0 || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && B->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported()==0 && B->get_max_contacts_reported()==0)) {
+ if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && B->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported()==0 && B->get_max_contacts_reported()==0)) {
collided=false;
return false;
}
@@ -265,6 +265,8 @@ bool BodyPair2DSW::setup(float p_step) {
}
//faster to set than to check..
+ //bool prev_collided=collided;
+
collided = CollisionSolver2DSW::solve(shape_A_ptr,xform_A,motion_A,shape_B_ptr,xform_B,motion_B,_add_contact,this,&sep_axis);
if (!collided) {
@@ -280,9 +282,68 @@ bool BodyPair2DSW::setup(float p_step) {
collided=true;
}
- if (!collided)
+ if (!collided) {
+ oneway_disabled=false;
return false;
+ }
+
+ }
+
+ if (oneway_disabled)
+ return false;
+
+ //if (!prev_collided) {
+ {
+
+ if (A->is_using_one_way_collision()) {
+ Vector2 direction = A->get_one_way_collision_direction();
+ bool valid=false;
+ for(int i=0;i<contact_count;i++) {
+ Contact& c = contacts[i];
+
+ if (c.normal.dot(direction)<0)
+ continue;
+ if (B->get_linear_velocity().dot(direction)<0)
+ continue;
+
+ if (!c.reused) {
+ continue;
+ }
+
+ valid=true;
+ }
+
+ if (!valid) {
+ collided=false;
+ oneway_disabled=true;
+ return false;
+ }
+ }
+
+ if (B->is_using_one_way_collision()) {
+ Vector2 direction = B->get_one_way_collision_direction();
+ bool valid=false;
+ for(int i=0;i<contact_count;i++) {
+
+ Contact& c = contacts[i];
+ if (c.normal.dot(direction)<0)
+ continue;
+ if (A->get_linear_velocity().dot(direction)<0)
+ continue;
+
+ if (!c.reused) {
+ continue;
+ }
+
+ valid=true;
+ }
+ if (!valid) {
+ collided=false;
+ oneway_disabled=true;
+ return false;
+ }
+ }
}
real_t max_penetration = space->get_contact_max_allowed_penetration();
@@ -472,6 +533,7 @@ BodyPair2DSW::BodyPair2DSW(Body2DSW *p_A, int p_shape_A,Body2DSW *p_B, int p_sha
B->add_constraint(this,1);
contact_count=0;
collided=false;
+ oneway_disabled=false;
}
diff --git a/servers/physics_2d/body_pair_2d_sw.h b/servers/physics_2d/body_pair_2d_sw.h
index 15d7e62d3a..a7fa287be4 100644
--- a/servers/physics_2d/body_pair_2d_sw.h
+++ b/servers/physics_2d/body_pair_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -76,6 +76,7 @@ class BodyPair2DSW : public Constraint2DSW {
Contact contacts[MAX_CONTACTS];
int contact_count;
bool collided;
+ bool oneway_disabled;
int cc;
diff --git a/servers/physics_2d/broad_phase_2d_basic.cpp b/servers/physics_2d/broad_phase_2d_basic.cpp
index 9641a986e8..e61b4735b9 100644
--- a/servers/physics_2d/broad_phase_2d_basic.cpp
+++ b/servers/physics_2d/broad_phase_2d_basic.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/broad_phase_2d_basic.h b/servers/physics_2d/broad_phase_2d_basic.h
index ce15752251..cdee77ffd7 100644
--- a/servers/physics_2d/broad_phase_2d_basic.h
+++ b/servers/physics_2d/broad_phase_2d_basic.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
index 0f08f63937..4651d485c2 100644
--- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp
+++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -467,9 +467,10 @@ int BroadPhase2DHashGrid::cull_segment(const Vector2& p_from, const Vector2& p_t
delta.x=cell_size/delta.x;
delta.y=cell_size/delta.y;
- Point2i pos = p_from.floor() / cell_size;
- Point2i end = p_to.floor() / cell_size;
- Point2i step = Vector2( SGN(dir.x), SGN(dir.y));
+ Point2i pos = (p_from/cell_size).floor();
+ Point2i end = (p_to/cell_size).floor();
+
+ Point2i step = Vector2( SGN(dir.x), SGN(dir.y) );
Vector2 max;
diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.h b/servers/physics_2d/broad_phase_2d_hash_grid.h
index d530b35d5d..a2eecf7bbf 100644
--- a/servers/physics_2d/broad_phase_2d_hash_grid.h
+++ b/servers/physics_2d/broad_phase_2d_hash_grid.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/broad_phase_2d_sw.cpp b/servers/physics_2d/broad_phase_2d_sw.cpp
index 7ded6ed01e..fd8e7254b6 100644
--- a/servers/physics_2d/broad_phase_2d_sw.cpp
+++ b/servers/physics_2d/broad_phase_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/broad_phase_2d_sw.h b/servers/physics_2d/broad_phase_2d_sw.h
index 510f7db112..283d6941e1 100644
--- a/servers/physics_2d/broad_phase_2d_sw.h
+++ b/servers/physics_2d/broad_phase_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp
index eefc598b39..7c8e223c57 100644
--- a/servers/physics_2d/collision_object_2d_sw.cpp
+++ b/servers/physics_2d/collision_object_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -226,7 +226,7 @@ CollisionObject2DSW::CollisionObject2DSW(Type p_type) {
type=p_type;
space=NULL;
instance_id=0;
- user_mask=0;
+ collision_mask=1;
layer_mask=1;
pickable=true;
}
diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h
index 0c91237876..f3432060b9 100644
--- a/servers/physics_2d/collision_object_2d_sw.h
+++ b/servers/physics_2d/collision_object_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -65,7 +65,7 @@ private:
Space2DSW *space;
Matrix32 transform;
Matrix32 inv_transform;
- uint32_t user_mask;
+ uint32_t collision_mask;
uint32_t layer_mask;
bool _static;
@@ -117,8 +117,8 @@ public:
_FORCE_INLINE_ bool is_shape_set_as_trigger(int p_idx) const { return shapes[p_idx].trigger; }
- void set_user_mask(uint32_t p_mask) {user_mask=p_mask;}
- _FORCE_INLINE_ uint32_t get_user_mask() const { return user_mask; }
+ void set_collision_mask(uint32_t p_mask) {collision_mask=p_mask;}
+ _FORCE_INLINE_ uint32_t get_collision_mask() const { return collision_mask; }
void set_layer_mask(uint32_t p_mask) {layer_mask=p_mask;}
_FORCE_INLINE_ uint32_t get_layer_mask() const { return layer_mask; }
@@ -133,6 +133,11 @@ public:
void set_pickable(bool p_pickable) { pickable=p_pickable; }
_FORCE_INLINE_ bool is_pickable() const { return pickable; }
+ _FORCE_INLINE_ bool test_collision_mask(CollisionObject2DSW* p_other) const {
+
+ return layer_mask&p_other->collision_mask || p_other->layer_mask&collision_mask;
+ }
+
virtual ~CollisionObject2DSW() {}
};
diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp
index 9ed594e0eb..2525c6e942 100644
--- a/servers/physics_2d/collision_solver_2d_sat.cpp
+++ b/servers/physics_2d/collision_solver_2d_sat.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/collision_solver_2d_sat.h b/servers/physics_2d/collision_solver_2d_sat.h
index be5a3dc79f..554f756738 100644
--- a/servers/physics_2d/collision_solver_2d_sat.h
+++ b/servers/physics_2d/collision_solver_2d_sat.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp
index 4c7e68d643..134ad04222 100644
--- a/servers/physics_2d/collision_solver_2d_sw.cpp
+++ b/servers/physics_2d/collision_solver_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/collision_solver_2d_sw.h b/servers/physics_2d/collision_solver_2d_sw.h
index 07141b0d09..0cdd54f8b6 100644
--- a/servers/physics_2d/collision_solver_2d_sw.h
+++ b/servers/physics_2d/collision_solver_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/constraint_2d_sw.cpp b/servers/physics_2d/constraint_2d_sw.cpp
index e97b5d794e..24d56ce9fe 100644
--- a/servers/physics_2d/constraint_2d_sw.cpp
+++ b/servers/physics_2d/constraint_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/constraint_2d_sw.h b/servers/physics_2d/constraint_2d_sw.h
index 7abe49f5b4..a9145c382f 100644
--- a/servers/physics_2d/constraint_2d_sw.h
+++ b/servers/physics_2d/constraint_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp
index fea58b6e8d..b4c149e7e0 100644
--- a/servers/physics_2d/joints_2d_sw.cpp
+++ b/servers/physics_2d/joints_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/joints_2d_sw.h b/servers/physics_2d/joints_2d_sw.h
index 0a9bf34250..2093be88c9 100644
--- a/servers/physics_2d/joints_2d_sw.h
+++ b/servers/physics_2d/joints_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index 883acd0200..b446f4928a 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,7 +30,7 @@
#include "broad_phase_2d_basic.h"
#include "broad_phase_2d_hash_grid.h"
#include "collision_solver_2d_sw.h"
-
+#include "globals.h"
RID Physics2DServerSW::shape_create(ShapeType p_shape) {
Shape2DSW *shape=NULL;
@@ -261,7 +261,7 @@ Physics2DDirectSpaceState* Physics2DServerSW::space_get_direct_state(RID p_space
Space2DSW *space = space_owner.get(p_space);
ERR_FAIL_COND_V(!space,NULL);
- if (/*doing_sync ||*/ space->is_locked()) {
+ if ((using_threads && !doing_sync) || space->is_locked()) {
ERR_EXPLAIN("Space state is inaccesible right now, wait for iteration or fixed process notification.");
ERR_FAIL_V(NULL);
@@ -480,6 +480,22 @@ void Physics2DServerSW::area_set_monitorable(RID p_area,bool p_monitorable) {
}
+void Physics2DServerSW::area_set_collision_mask(RID p_area,uint32_t p_mask) {
+
+ Area2DSW *area = area_owner.get(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->set_collision_mask(p_mask);
+}
+
+void Physics2DServerSW::area_set_layer_mask(RID p_area,uint32_t p_mask) {
+
+ Area2DSW *area = area_owner.get(p_area);
+ ERR_FAIL_COND(!area);
+
+ area->set_layer_mask(p_mask);
+}
+
void Physics2DServerSW::area_set_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method) {
@@ -717,7 +733,7 @@ void Physics2DServerSW::body_set_layer_mask(RID p_body, uint32_t p_flags) {
};
-uint32_t Physics2DServerSW::body_get_layer_mask(RID p_body, uint32_t p_flags) const {
+uint32_t Physics2DServerSW::body_get_layer_mask(RID p_body) const {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
@@ -726,20 +742,20 @@ uint32_t Physics2DServerSW::body_get_layer_mask(RID p_body, uint32_t p_flags) co
};
-void Physics2DServerSW::body_set_user_mask(RID p_body, uint32_t p_flags) {
+void Physics2DServerSW::body_set_collision_mask(RID p_body, uint32_t p_flags) {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
- body->set_user_mask(p_flags);
+ body->set_collision_mask(p_flags);
};
-uint32_t Physics2DServerSW::body_get_user_mask(RID p_body, uint32_t p_flags) const {
+uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body) const {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
- return body->get_user_mask();
+ return body->get_collision_mask();
};
void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, float p_value) {
@@ -783,6 +799,8 @@ void Physics2DServerSW::body_set_applied_force(RID p_body, const Vector2& p_forc
ERR_FAIL_COND(!body);
body->set_applied_force(p_force);
+ body->wakeup();
+
};
Vector2 Physics2DServerSW::body_get_applied_force(RID p_body) const {
@@ -798,6 +816,7 @@ void Physics2DServerSW::body_set_applied_torque(RID p_body, float p_torque) {
ERR_FAIL_COND(!body);
body->set_applied_torque(p_torque);
+ body->wakeup();
};
float Physics2DServerSW::body_get_applied_torque(RID p_body) const {
@@ -814,6 +833,7 @@ void Physics2DServerSW::body_apply_impulse(RID p_body, const Vector2& p_pos, con
ERR_FAIL_COND(!body);
body->apply_impulse(p_pos,p_impulse);
+ body->wakeup();
};
void Physics2DServerSW::body_set_axis_velocity(RID p_body, const Vector2& p_axis_velocity) {
@@ -826,7 +846,7 @@ void Physics2DServerSW::body_set_axis_velocity(RID p_body, const Vector2& p_axis
v-=axis*axis.dot(v);
v+=p_axis_velocity;
body->set_linear_velocity(v);
-
+ body->wakeup();
};
void Physics2DServerSW::body_add_collision_exception(RID p_body, RID p_body_b) {
@@ -835,7 +855,7 @@ void Physics2DServerSW::body_add_collision_exception(RID p_body, RID p_body_b) {
ERR_FAIL_COND(!body);
body->add_exception(p_body_b);
-
+ body->wakeup();
};
void Physics2DServerSW::body_remove_collision_exception(RID p_body, RID p_body_b) {
@@ -844,6 +864,7 @@ void Physics2DServerSW::body_remove_collision_exception(RID p_body, RID p_body_b
ERR_FAIL_COND(!body);
body->remove_exception(p_body_b);
+ body->wakeup();
};
@@ -959,6 +980,18 @@ void Physics2DServerSW::body_set_pickable(RID p_body,bool p_pickable) {
}
+bool Physics2DServerSW::body_test_motion(RID p_body,const Vector2& p_motion,float p_margin,MotionResult *r_result) {
+
+ Body2DSW *body = body_owner.get(p_body);
+ ERR_FAIL_COND_V(!body,false);
+ ERR_FAIL_COND_V(!body->get_space(),false);
+ ERR_FAIL_COND_V(body->get_space()->is_locked(),false);
+
+ return body->get_space()->test_body_motion(body,p_motion,p_margin,r_result);
+
+}
+
+
/* JOINT API */
void Physics2DServerSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) {
@@ -1163,7 +1196,7 @@ void Physics2DServerSW::set_active(bool p_active) {
void Physics2DServerSW::init() {
- doing_sync=true;
+ doing_sync=false;
last_step=0.001;
iterations=8;// 8?
stepper = memnew( Step2DSW );
@@ -1195,6 +1228,7 @@ void Physics2DServerSW::step(float p_step) {
void Physics2DServerSW::sync() {
+ doing_sync=true;
};
void Physics2DServerSW::flush_queries() {
@@ -1202,7 +1236,7 @@ void Physics2DServerSW::flush_queries() {
if (!active)
return;
- doing_sync=true;
+
for( Set<const Space2DSW*>::Element *E=active_spaces.front();E;E=E->next()) {
Space2DSW *space=(Space2DSW *)E->get();
@@ -1211,6 +1245,10 @@ void Physics2DServerSW::flush_queries() {
};
+void Physics2DServerSW::end_sync() {
+ doing_sync=false;
+}
+
void Physics2DServerSW::finish() {
@@ -1250,6 +1288,7 @@ Physics2DServerSW::Physics2DServerSW() {
island_count=0;
active_objects=0;
collision_pairs=0;
+ using_threads=int(Globals::get_singleton()->get("physics_2d/thread_model"))==2;
};
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index 58fc4eeb33..6e875701b8 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -51,6 +51,8 @@ friend class Physics2DDirectSpaceStateSW;
int active_objects;
int collision_pairs;
+ bool using_threads;
+
Step2DSW *stepper;
Set<const Space2DSW*> active_spaces;
@@ -134,6 +136,8 @@ public:
virtual Variant area_get_param(RID p_parea,AreaParameter p_param) const;
virtual Matrix32 area_get_transform(RID p_area) const;
virtual void area_set_monitorable(RID p_area,bool p_monitorable);
+ virtual void area_set_collision_mask(RID p_area,uint32_t p_mask);
+ virtual void area_set_layer_mask(RID p_area,uint32_t p_mask);
virtual void area_set_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method);
virtual void area_set_area_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method);
@@ -177,10 +181,10 @@ public:
virtual CCDMode body_get_continuous_collision_detection_mode(RID p_body) const;
virtual void body_set_layer_mask(RID p_body, uint32_t p_mask);
- virtual uint32_t body_get_layer_mask(RID p_body, uint32_t p_mask) const;
+ virtual uint32_t body_get_layer_mask(RID p_body) const;
- virtual void body_set_user_mask(RID p_body, uint32_t p_mask);
- virtual uint32_t body_get_user_mask(RID p_body, uint32_t p_mask) const;
+ virtual void body_set_collision_mask(RID p_body, uint32_t p_mask);
+ virtual uint32_t body_get_collision_mask(RID p_) const;
virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value);
virtual float body_get_param(RID p_body, BodyParameter p_param) const;
@@ -223,6 +227,9 @@ public:
virtual void body_set_pickable(RID p_body,bool p_pickable);
+ virtual bool body_test_motion(RID p_body,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL);
+
+
/* JOINT API */
virtual void joint_set_param(RID p_joint, JointParam p_param, real_t p_value);
@@ -243,8 +250,9 @@ public:
virtual void set_active(bool p_active);
virtual void init();
virtual void step(float p_step);
- virtual void sync();
+ virtual void sync();
virtual void flush_queries();
+ virtual void end_sync();
virtual void finish();
int get_process_info(ProcessInfo p_info);
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
new file mode 100644
index 0000000000..c5f023f162
--- /dev/null
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
@@ -0,0 +1,169 @@
+#include "physics_2d_server_wrap_mt.h"
+
+#include "os/os.h"
+
+void Physics2DServerWrapMT::thread_exit() {
+
+ exit=true;
+}
+
+void Physics2DServerWrapMT::thread_step(float p_delta) {
+
+ physics_2d_server->step(p_delta);
+ step_sem->post();
+
+}
+
+void Physics2DServerWrapMT::_thread_callback(void *_instance) {
+
+ Physics2DServerWrapMT *vsmt = reinterpret_cast<Physics2DServerWrapMT*>(_instance);
+
+
+ vsmt->thread_loop();
+}
+
+void Physics2DServerWrapMT::thread_loop() {
+
+ server_thread=Thread::get_caller_ID();
+
+ OS::get_singleton()->make_rendering_thread();
+
+ physics_2d_server->init();
+
+ exit=false;
+ step_thread_up=true;
+ while(!exit) {
+ // flush commands one by one, until exit is requested
+ command_queue.wait_and_flush_one();
+ }
+
+ command_queue.flush_all(); // flush all
+
+ physics_2d_server->finish();
+
+}
+
+
+/* EVENT QUEUING */
+
+
+void Physics2DServerWrapMT::step(float p_step) {
+
+ if (create_thread) {
+
+ command_queue.push( this, &Physics2DServerWrapMT::thread_step,p_step);
+ } else {
+
+ command_queue.flush_all(); //flush all pending from other threads
+ physics_2d_server->step(p_step);
+ }
+}
+
+void Physics2DServerWrapMT::sync() {
+
+ if (step_sem) {
+ if (first_frame)
+ first_frame=false;
+ else
+ step_sem->wait(); //must not wait if a step was not issued
+ }
+ physics_2d_server->sync();;
+}
+
+void Physics2DServerWrapMT::flush_queries(){
+
+ physics_2d_server->flush_queries();
+}
+
+void Physics2DServerWrapMT::end_sync() {
+
+ physics_2d_server->end_sync();;
+}
+
+void Physics2DServerWrapMT::init() {
+
+ if (create_thread) {
+
+ step_sem = Semaphore::create();
+ print_line("CREATING PHYSICS 2D THREAD");
+ //OS::get_singleton()->release_rendering_thread();
+ if (create_thread) {
+ thread = Thread::create( _thread_callback, this );
+ print_line("STARTING PHYISICS 2D THREAD");
+ }
+ while(!step_thread_up) {
+ OS::get_singleton()->delay_usec(1000);
+ }
+ print_line("DONE PHYSICS 2D THREAD");
+ } else {
+
+ physics_2d_server->init();
+ }
+
+}
+
+void Physics2DServerWrapMT::finish() {
+
+
+ if (thread) {
+
+ command_queue.push( this, &Physics2DServerWrapMT::thread_exit);
+ Thread::wait_to_finish( thread );
+ memdelete(thread);
+
+/*
+ shape_free_cached_ids();
+ area_free_cached_ids();
+ body_free_cached_ids();
+ pin_joint_free_cached_ids();
+ groove_joint_free_cached_ids();
+ damped_string_free_cached_ids();
+*/
+ thread=NULL;
+ } else {
+ physics_2d_server->finish();
+ }
+
+ if (step_sem)
+ memdelete(step_sem);
+
+}
+
+
+Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer* p_contained,bool p_create_thread) : command_queue(p_create_thread) {
+
+ physics_2d_server=p_contained;
+ create_thread=p_create_thread;
+ thread=NULL;
+ step_sem=NULL;
+ step_pending=0;
+ step_thread_up=false;
+ alloc_mutex=Mutex::create();
+
+ shape_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
+ area_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
+ body_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
+ pin_joint_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
+ groove_joint_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
+ damped_spring_joint_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
+
+ if (!p_create_thread) {
+ server_thread=Thread::get_caller_ID();
+ } else {
+ server_thread=0;
+ }
+
+ main_thread = Thread::get_caller_ID();
+ first_frame=true;
+}
+
+
+Physics2DServerWrapMT::~Physics2DServerWrapMT() {
+
+ memdelete(physics_2d_server);
+ memdelete(alloc_mutex);
+ //finish();
+
+}
+
+
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h
new file mode 100644
index 0000000000..0ddc8f16ec
--- /dev/null
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.h
@@ -0,0 +1,297 @@
+#ifndef PHYSICS2DSERVERWRAPMT_H
+#define PHYSICS2DSERVERWRAPMT_H
+
+
+#include "servers/physics_2d_server.h"
+#include "command_queue_mt.h"
+#include "os/thread.h"
+#include "globals.h"
+
+#ifdef DEBUG_SYNC
+#define SYNC_DEBUG print_line("sync on: "+String(__FUNCTION__));
+#else
+#define SYNC_DEBUG
+#endif
+
+
+class Physics2DServerWrapMT : public Physics2DServer {
+
+ mutable Physics2DServer *physics_2d_server;
+
+ mutable CommandQueueMT command_queue;
+
+ static void _thread_callback(void *_instance);
+ void thread_loop();
+
+ Thread::ID server_thread;
+ Thread::ID main_thread;
+ volatile bool exit;
+ Thread *thread;
+ volatile bool step_thread_up;
+ bool create_thread;
+
+ Semaphore *step_sem;
+ int step_pending;
+ void thread_step(float p_delta);
+ void thread_flush();
+
+ void thread_exit();
+
+ Mutex*alloc_mutex;
+ bool first_frame;
+
+ int shape_pool_max_size;
+ List<RID> shape_id_pool;
+ int area_pool_max_size;
+ List<RID> area_id_pool;
+ int body_pool_max_size;
+ List<RID> body_id_pool;
+ int pin_joint_pool_max_size;
+ List<RID> pin_joint_id_pool;
+ int groove_joint_pool_max_size;
+ List<RID> groove_joint_id_pool;
+ int damped_spring_joint_pool_max_size;
+ List<RID> damped_spring_joint_id_pool;
+
+
+public:
+
+#define ServerName Physics2DServer
+#define ServerNameWrapMT Physics2DServerWrapMT
+#define server_name physics_2d_server
+#include "servers/server_wrap_mt_common.h"
+
+ //FUNC1RID(shape,ShapeType); todo fix
+ FUNC1R(RID,shape_create,ShapeType);
+ FUNC2(shape_set_data,RID,const Variant& );
+ FUNC2(shape_set_custom_solver_bias,RID,real_t );
+
+ FUNC1RC(ShapeType,shape_get_type,RID );
+ FUNC1RC(Variant,shape_get_data,RID);
+ FUNC1RC(real_t,shape_get_custom_solver_bias,RID);
+
+
+ //these work well, but should be used from the main thread only
+ bool shape_collide(RID p_shape_A, const Matrix32& p_xform_A,const Vector2& p_motion_A,RID p_shape_B, const Matrix32& p_xform_B, const Vector2& p_motion_B,Vector2 *r_results,int p_result_max,int &r_result_count) {
+
+ ERR_FAIL_COND_V(main_thread!=Thread::get_caller_ID(),false);
+ return physics_2d_server->shape_collide(p_shape_A,p_xform_A,p_motion_A,p_shape_B,p_xform_B,p_motion_B,r_results,p_result_max,r_result_count);
+ }
+
+ /* SPACE API */
+
+ FUNC0R(RID,space_create);
+ FUNC2(space_set_active,RID,bool);
+ FUNC1RC(bool,space_is_active,RID);
+
+ FUNC3(space_set_param,RID,SpaceParameter,real_t);
+ FUNC2RC(real_t,space_get_param,RID,SpaceParameter);
+
+ // this function only works on fixed process, errors and returns null otherwise
+ Physics2DDirectSpaceState* space_get_direct_state(RID p_space) {
+
+ ERR_FAIL_COND_V(main_thread!=Thread::get_caller_ID(),NULL);
+ return physics_2d_server->space_get_direct_state(p_space);
+ }
+
+
+ /* AREA API */
+
+ //FUNC0RID(area);
+ FUNC0R(RID,area_create);
+
+ FUNC2(area_set_space,RID,RID);
+ FUNC1RC(RID,area_get_space,RID);
+
+ FUNC2(area_set_space_override_mode,RID,AreaSpaceOverrideMode);
+ FUNC1RC(AreaSpaceOverrideMode,area_get_space_override_mode,RID);
+
+ FUNC3(area_add_shape,RID,RID,const Matrix32&);
+ FUNC3(area_set_shape,RID,int,RID);
+ FUNC3(area_set_shape_transform,RID,int,const Matrix32&);
+
+ FUNC1RC(int,area_get_shape_count,RID);
+ FUNC2RC(RID,area_get_shape,RID,int);
+ FUNC2RC(Matrix32,area_get_shape_transform,RID,int);
+ FUNC2(area_remove_shape,RID,int);
+ FUNC1(area_clear_shapes,RID);
+
+ FUNC2(area_attach_object_instance_ID,RID,ObjectID);
+ FUNC1RC(ObjectID,area_get_object_instance_ID,RID);
+
+ FUNC3(area_set_param,RID,AreaParameter,const Variant&);
+ FUNC2(area_set_transform,RID,const Matrix32&);
+
+ FUNC2RC(Variant,area_get_param,RID,AreaParameter);
+ FUNC1RC(Matrix32,area_get_transform,RID);
+
+ FUNC2(area_set_collision_mask,RID,uint32_t);
+ FUNC2(area_set_layer_mask,RID,uint32_t);
+
+ FUNC2(area_set_monitorable,RID,bool);
+ FUNC2(area_set_pickable,RID,bool);
+
+ FUNC3(area_set_monitor_callback,RID,Object*,const StringName&);
+ FUNC3(area_set_area_monitor_callback,RID,Object*,const StringName&);
+
+
+ /* BODY API */
+
+ //FUNC2RID(body,BodyMode,bool);
+ FUNC2R(RID,body_create,BodyMode,bool)
+
+ FUNC2(body_set_space,RID,RID);
+ FUNC1RC(RID,body_get_space,RID);
+
+ FUNC2(body_set_mode,RID,BodyMode);
+ FUNC1RC(BodyMode,body_get_mode,RID);
+
+
+ FUNC3(body_add_shape,RID,RID,const Matrix32&);
+ FUNC3(body_set_shape,RID,int,RID);
+ FUNC3(body_set_shape_transform,RID,int,const Matrix32&);
+ FUNC3(body_set_shape_metadata,RID,int,const Variant&);
+
+ FUNC1RC(int,body_get_shape_count,RID);
+ FUNC2RC(Matrix32,body_get_shape_transform,RID,int);
+ FUNC2RC(Variant,body_get_shape_metadata,RID,int);
+ FUNC2RC(RID,body_get_shape,RID,int);
+
+ FUNC3(body_set_shape_as_trigger,RID,int,bool);
+ FUNC2RC(bool,body_is_shape_set_as_trigger,RID,int);
+
+ FUNC2(body_remove_shape,RID,int);
+ FUNC1(body_clear_shapes,RID);
+
+ FUNC2(body_attach_object_instance_ID,RID,uint32_t);
+ FUNC1RC(uint32_t,body_get_object_instance_ID,RID);
+
+ FUNC2(body_set_continuous_collision_detection_mode,RID,CCDMode);
+ FUNC1RC(CCDMode,body_get_continuous_collision_detection_mode,RID);
+
+ FUNC2(body_set_layer_mask,RID,uint32_t);
+ FUNC1RC(uint32_t,body_get_layer_mask,RID);
+
+ FUNC2(body_set_collision_mask,RID,uint32_t);
+ FUNC1RC(uint32_t,body_get_collision_mask,RID);
+
+
+ FUNC3(body_set_param,RID,BodyParameter,float);
+ FUNC2RC(float,body_get_param,RID,BodyParameter);
+
+
+ FUNC3(body_set_state,RID,BodyState,const Variant&);
+ FUNC2RC(Variant,body_get_state,RID,BodyState);
+
+ FUNC2(body_set_applied_force,RID,const Vector2&);
+ FUNC1RC(Vector2,body_get_applied_force,RID);
+
+ FUNC2(body_set_applied_torque,RID,float);
+ FUNC1RC(float,body_get_applied_torque,RID);
+
+ FUNC3(body_apply_impulse,RID,const Vector2&,const Vector2&);
+ FUNC2(body_set_axis_velocity,RID,const Vector2&);
+
+ FUNC2(body_add_collision_exception,RID,RID);
+ FUNC2(body_remove_collision_exception,RID,RID);
+ FUNC2S(body_get_collision_exceptions,RID,List<RID>*);
+
+ FUNC2(body_set_max_contacts_reported,RID,int);
+ FUNC1RC(int,body_get_max_contacts_reported,RID);
+
+ FUNC2(body_set_one_way_collision_direction,RID,const Vector2&);
+ FUNC1RC(Vector2,body_get_one_way_collision_direction,RID);
+
+ FUNC2(body_set_one_way_collision_max_depth,RID,float);
+ FUNC1RC(float,body_get_one_way_collision_max_depth,RID);
+
+
+ FUNC2(body_set_contacts_reported_depth_treshold,RID,float);
+ FUNC1RC(float,body_get_contacts_reported_depth_treshold,RID);
+
+ FUNC2(body_set_omit_force_integration,RID,bool);
+ FUNC1RC(bool,body_is_omitting_force_integration,RID);
+
+ FUNC4(body_set_force_integration_callback,RID ,Object *,const StringName& ,const Variant& );
+
+
+ bool body_collide_shape(RID p_body, int p_body_shape,RID p_shape, const Matrix32& p_shape_xform,const Vector2& p_motion,Vector2 *r_results,int p_result_max,int &r_result_count) {
+ return physics_2d_server->body_collide_shape(p_body,p_body_shape,p_shape,p_shape_xform,p_motion,r_results,p_result_max,r_result_count);
+ }
+
+ FUNC2(body_set_pickable,RID,bool);
+
+ bool body_test_motion(RID p_body,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL) {
+
+ ERR_FAIL_COND_V(main_thread!=Thread::get_caller_ID(),false);
+ return physics_2d_server->body_test_motion(p_body,p_motion,p_margin,r_result);
+ }
+
+ /* JOINT API */
+
+
+ FUNC3(joint_set_param,RID,JointParam,real_t);
+ FUNC2RC(real_t,joint_get_param,RID,JointParam);
+
+
+ ///FUNC3RID(pin_joint,const Vector2&,RID,RID);
+ ///FUNC5RID(groove_joint,const Vector2&,const Vector2&,const Vector2&,RID,RID);
+ ///FUNC4RID(damped_spring_joint,const Vector2&,const Vector2&,RID,RID);
+
+ FUNC3R(RID,pin_joint_create,const Vector2&,RID,RID);
+ FUNC5R(RID,groove_joint_create,const Vector2&,const Vector2&,const Vector2&,RID,RID);
+ FUNC4R(RID,damped_spring_joint_create,const Vector2&,const Vector2&,RID,RID);
+
+ FUNC3(damped_string_joint_set_param,RID,DampedStringParam,real_t);
+ FUNC2RC(real_t,damped_string_joint_get_param,RID,DampedStringParam);
+
+ FUNC1RC(JointType,joint_get_type,RID);
+
+
+ /* MISC */
+
+
+ FUNC1(free,RID);
+ FUNC1(set_active,bool);
+
+ virtual void init();
+ virtual void step(float p_step);
+ virtual void sync();
+ virtual void end_sync();
+ virtual void flush_queries();
+ virtual void finish();
+
+ int get_process_info(ProcessInfo p_info) {
+ return physics_2d_server->get_process_info(p_info);
+ }
+
+ Physics2DServerWrapMT(Physics2DServer* p_contained,bool p_create_thread);
+ ~Physics2DServerWrapMT();
+
+
+ template<class T>
+ static Physics2DServer* init_server() {
+
+ int tm = GLOBAL_DEF("physics_2d/thread_model",1);
+ if (tm==0) //single unsafe
+ return memnew( T );
+ else if (tm==1) //single saef
+ return memnew( Physics2DServerWrapMT( memnew( T ), false ));
+ else //single unsafe
+ return memnew( Physics2DServerWrapMT( memnew( T ), true ));
+
+
+ }
+
+#undef ServerNameWrapMT
+#undef ServerName
+#undef server_name
+
+};
+
+#ifdef DEBUG_SYNC
+#undef DEBUG_SYNC
+#endif
+#undef SYNC_DEBUG
+
+#endif // PHYSICS2DSERVERWRAPMT_H
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index 9a4b52d563..d3591ec744 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h
index 05ea5b21cd..6d5473aa17 100644
--- a/servers/physics_2d/shape_2d_sw.h
+++ b/servers/physics_2d/shape_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index 5aaf9a7613..767ad9038d 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -555,8 +555,524 @@ Physics2DDirectSpaceStateSW::Physics2DDirectSpaceStateSW() {
+int Space2DSW::_cull_aabb_for_body(Body2DSW *p_body,const Rect2& p_aabb) {
+ int amount = broadphase->cull_aabb(p_aabb,intersection_query_results,INTERSECTION_QUERY_MAX,intersection_query_subindex_results);
+
+ for(int i=0;i<amount;i++) {
+
+ bool keep=true;
+
+ if (intersection_query_results[i]==p_body)
+ keep=false;
+ else if (intersection_query_results[i]->get_type()==CollisionObject2DSW::TYPE_AREA)
+ keep=false;
+ else if ((static_cast<Body2DSW*>(intersection_query_results[i])->test_collision_mask(p_body))==0)
+ keep=false;
+ else if (static_cast<Body2DSW*>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self()))
+ keep=false;
+ else if (static_cast<Body2DSW*>(intersection_query_results[i])->is_shape_set_as_trigger(intersection_query_subindex_results[i]))
+ keep=false;
+
+ if (!keep) {
+
+ if (i<amount-1) {
+ SWAP(intersection_query_results[i],intersection_query_results[amount-1]);
+ SWAP(intersection_query_subindex_results[i],intersection_query_subindex_results[amount-1]);
+
+ }
+
+ amount--;
+ i--;
+
+ }
+ }
+
+ return amount;
+}
+
+bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p_margin,Physics2DServer::MotionResult *r_result) {
+
+ //give me back regular physics engine logic
+ //this is madness
+ //and most people using this function will think
+ //what it does is simpler than using physics
+ //this took about a week to get right..
+ //but is it right? who knows at this point..
+
+ Rect2 body_aabb;
+
+ for(int i=0;i<p_body->get_shape_count();i++) {
+
+ if (i==0)
+ body_aabb=p_body->get_shape_aabb(i);
+ else
+ body_aabb=body_aabb.merge(p_body->get_shape_aabb(i));
+ }
+
+ body_aabb=body_aabb.grow(p_margin);
+
+
+ Matrix32 body_transform = p_body->get_transform();
+
+ {
+ //STEP 1, FREE BODY IF STUCK
+
+ const int max_results = 32;
+ int recover_attempts=4;
+ Vector2 sr[max_results*2];
+
+ do {
+
+ Physics2DServerSW::CollCbkData cbk;
+ cbk.max=max_results;
+ cbk.amount=0;
+ cbk.ptr=sr;
+
+
+ CollisionSolver2DSW::CallbackResult cbkres=NULL;
+
+ Physics2DServerSW::CollCbkData *cbkptr=NULL;
+ cbkptr=&cbk;
+ cbkres=Physics2DServerSW::_shape_col_cbk;
+
+ bool collided=false;
+
+ int amount = _cull_aabb_for_body(p_body,body_aabb);
+
+ for(int j=0;j<p_body->get_shape_count();j++) {
+ if (p_body->is_shape_set_as_trigger(j))
+ continue;
+
+ Matrix32 body_shape_xform = body_transform * p_body->get_shape_transform(j);
+ Shape2DSW *body_shape = p_body->get_shape(j);
+ for(int i=0;i<amount;i++) {
+
+ const CollisionObject2DSW *col_obj=intersection_query_results[i];
+ int shape_idx=intersection_query_subindex_results[i];
+
+ if (col_obj->get_type()==CollisionObject2DSW::TYPE_BODY) {
+
+ const Body2DSW *body=static_cast<const Body2DSW*>(col_obj);
+
+ Vector2 cdir = body->get_one_way_collision_direction();
+ //if (cdir!=Vector2() && p_motion.dot(cdir)<0)
+ // continue;
+
+ cbk.valid_dir=cdir;
+ cbk.valid_depth=body->get_one_way_collision_max_depth();
+ } else {
+ cbk.valid_dir=Vector2();
+ cbk.valid_depth=0;
+ }
+
+ if (CollisionSolver2DSW::solve(body_shape,body_shape_xform,Vector2(),col_obj->get_shape(shape_idx),col_obj->get_transform() * col_obj->get_shape_transform(shape_idx),Vector2(),cbkres,cbkptr,NULL,p_margin)) {
+ collided=cbk.amount>0;
+ }
+ }
+ }
+
+
+ if (!collided)
+ break;
+
+ Vector2 recover_motion;
+
+ for(int i=0;i<cbk.amount;i++) {
+
+ Vector2 a = sr[i*2+0];
+ Vector2 b = sr[i*2+1];
+
+ // float d = a.distance_to(b);
+
+ //if (d<margin)
+ /// continue;
+ recover_motion+=(b-a)*0.4;
+ }
+
+ if (recover_motion==Vector2()) {
+ collided=false;
+ break;
+ }
+
+ body_transform.elements[2]+=recover_motion;
+ body_aabb.pos+=recover_motion;
+
+ recover_attempts--;
+
+ } while (recover_attempts);
+ }
+
+
+
+ float safe = 1.0;
+ float unsafe = 1.0;
+ int best_shape=-1;
+
+ {
+ // STEP 2 ATTEMPT MOTION
+
+ Rect2 motion_aabb=body_aabb;
+ motion_aabb.pos+=p_motion;
+ motion_aabb=motion_aabb.merge(body_aabb);
+
+ int amount = _cull_aabb_for_body(p_body,motion_aabb);
+
+ for(int j=0;j<p_body->get_shape_count();j++) {
+
+ if (p_body->is_shape_set_as_trigger(j))
+ continue;
+
+ Matrix32 body_shape_xform = body_transform * p_body->get_shape_transform(j);
+ Shape2DSW *body_shape = p_body->get_shape(j);
+
+ bool stuck=false;
+
+ float best_safe=1;
+ float best_unsafe=1;
+
+ for(int i=0;i<amount;i++) {
+
+ const CollisionObject2DSW *col_obj=intersection_query_results[i];
+ int shape_idx=intersection_query_subindex_results[i];
+
+
+ Matrix32 col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx);
+ //test initial overlap, does it collide if going all the way?
+ if (!CollisionSolver2DSW::solve(body_shape,body_shape_xform,p_motion,col_obj->get_shape(shape_idx),col_obj_xform,Vector2() ,NULL,NULL,NULL,0)) {
+ continue;
+ }
+
+
+ //test initial overlap
+ if (CollisionSolver2DSW::solve(body_shape,body_shape_xform,Vector2(),col_obj->get_shape(shape_idx),col_obj_xform,Vector2() ,NULL,NULL,NULL,0)) {
+
+ if (col_obj->get_type()==CollisionObject2DSW::TYPE_BODY) {
+ //if one way collision direction ignore initial overlap
+ const Body2DSW *body=static_cast<const Body2DSW*>(col_obj);
+ if (body->get_one_way_collision_direction()!=Vector2()) {
+ continue;
+ }
+ }
+
+ stuck=true;
+ break;
+ }
+
+
+ //just do kinematic solving
+ float low=0;
+ float hi=1;
+ Vector2 mnormal=p_motion.normalized();
+
+ for(int i=0;i<8;i++) { //steps should be customizable..
+
+ //Matrix32 xfa = p_xform;
+ float ofs = (low+hi)*0.5;
+
+ Vector2 sep=mnormal; //important optimization for this to work fast enough
+ bool collided = CollisionSolver2DSW::solve(body_shape,body_shape_xform,p_motion*ofs,col_obj->get_shape(shape_idx),col_obj_xform,Vector2(),NULL,NULL,&sep,0);
+
+ if (collided) {
+
+ hi=ofs;
+ } else {
+
+ low=ofs;
+ }
+ }
+
+ if (col_obj->get_type()==CollisionObject2DSW::TYPE_BODY) {
+
+ const Body2DSW *body=static_cast<const Body2DSW*>(col_obj);
+ if (body->get_one_way_collision_direction()!=Vector2()) {
+
+ Vector2 cd[2];
+ Physics2DServerSW::CollCbkData cbk;
+ cbk.max=1;
+ cbk.amount=0;
+ cbk.ptr=cd;
+ cbk.valid_dir=body->get_one_way_collision_direction();
+ cbk.valid_depth=body->get_one_way_collision_max_depth();
+
+ Vector2 sep=mnormal; //important optimization for this to work fast enough
+ bool collided = CollisionSolver2DSW::solve(body_shape,body_shape_xform,p_motion*(hi+contact_max_allowed_penetration),col_obj->get_shape(shape_idx),col_obj_xform,Vector2(),Physics2DServerSW::_shape_col_cbk,&cbk,&sep,0);
+ if (!collided || cbk.amount==0) {
+ continue;
+ }
+
+ }
+ }
+
+
+ if (low<best_safe) {
+ best_safe=low;
+ best_unsafe=hi;
+ }
+ }
+
+ if (stuck) {
+
+ safe=0;
+ unsafe=0;
+ best_shape=j; //sadly it's the best
+ break;
+ }
+ if (best_safe==1.0) {
+ continue;
+ }
+ if (best_safe < safe) {
+
+ safe=best_safe;
+ unsafe=best_unsafe;
+ best_shape=j;
+ }
+ }
+ }
+
+ bool collided=false;
+ if (safe>=1) {
+ //not collided
+ collided=false;
+ if (r_result) {
+
+ r_result->motion=p_motion+(body_transform.elements[2]-p_body->get_transform().elements[2]);
+ r_result->remainder=Vector2();
+ }
+
+ } else {
+
+ //it collided, let's get the rest info in unsafe advance
+ Matrix32 ugt = body_transform;
+ ugt.elements[2]+=p_motion*unsafe;
+
+ _RestCallbackData2D rcd;
+ rcd.best_len=0;
+ rcd.best_object=NULL;
+ rcd.best_shape=0;
+
+ Matrix32 body_shape_xform = ugt * p_body->get_shape_transform(best_shape);
+ Shape2DSW *body_shape = p_body->get_shape(best_shape);
+
+ body_aabb.pos+=p_motion*unsafe;
+
+ int amount = _cull_aabb_for_body(p_body,body_aabb);
+
+
+ for(int i=0;i<amount;i++) {
+
+
+ const CollisionObject2DSW *col_obj=intersection_query_results[i];
+ int shape_idx=intersection_query_subindex_results[i];
+
+ if (col_obj->get_type()==CollisionObject2DSW::TYPE_BODY) {
+
+ const Body2DSW *body=static_cast<const Body2DSW*>(col_obj);
+ rcd.valid_dir=body->get_one_way_collision_direction();
+ rcd.valid_depth=body->get_one_way_collision_max_depth();
+ } else {
+ rcd.valid_dir=Vector2();
+ rcd.valid_depth=0;
+ }
+
+
+ rcd.object=col_obj;
+ rcd.shape=shape_idx;
+ bool sc = CollisionSolver2DSW::solve(body_shape,body_shape_xform,Vector2(),col_obj->get_shape(shape_idx),col_obj->get_transform() * col_obj->get_shape_transform(shape_idx),Vector2() ,_rest_cbk_result,&rcd,NULL,p_margin);
+ if (!sc)
+ continue;
+
+ }
+
+ if (rcd.best_len!=0) {
+
+ if (r_result) {
+ r_result->collider=rcd.best_object->get_self();
+ r_result->collider_id=rcd.best_object->get_instance_id();
+ r_result->collider_shape=rcd.best_shape;
+ r_result->collision_normal=rcd.best_normal;
+ r_result->collision_point=rcd.best_contact;
+ r_result->collider_metadata=rcd.best_object->get_shape_metadata(rcd.best_shape);
+
+ const Body2DSW *body = static_cast<const Body2DSW*>(rcd.best_object);
+ Vector2 rel_vec = r_result->collision_point-body->get_transform().get_origin();
+ r_result->collider_velocity = Vector2(-body->get_angular_velocity() * rel_vec.y, body->get_angular_velocity() * rel_vec.x) + body->get_linear_velocity();
+
+ r_result->motion=safe*p_motion+(body_transform.elements[2]-p_body->get_transform().elements[2]);
+ r_result->remainder=p_motion - safe * p_motion;
+ }
+
+ collided=true;
+ } else {
+ if (r_result) {
+
+ r_result->motion=p_motion+(body_transform.elements[2]-p_body->get_transform().elements[2]);
+ r_result->remainder=Vector2();
+ }
+
+ collided=false;
+
+ }
+ }
+
+ return collided;
+
+
+#if 0
+ //give me back regular physics engine logic
+ //this is madness
+ //and most people using this function will think
+ //what it does is simpler than using physics
+ //this took about a week to get right..
+ //but is it right? who knows at this point..
+
+
+ colliding=false;
+ ERR_FAIL_COND_V(!is_inside_tree(),Vector2());
+ Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(get_world_2d()->get_space());
+ ERR_FAIL_COND_V(!dss,Vector2());
+ const int max_shapes=32;
+ Vector2 sr[max_shapes*2];
+ int res_shapes;
+
+ Set<RID> exclude;
+ exclude.insert(get_rid());
+
+
+ //recover first
+ int recover_attempts=4;
+
+ bool collided=false;
+ uint32_t mask=0;
+ if (collide_static)
+ mask|=Physics2DDirectSpaceState::TYPE_MASK_STATIC_BODY;
+ if (collide_kinematic)
+ mask|=Physics2DDirectSpaceState::TYPE_MASK_KINEMATIC_BODY;
+ if (collide_rigid)
+ mask|=Physics2DDirectSpaceState::TYPE_MASK_RIGID_BODY;
+ if (collide_character)
+ mask|=Physics2DDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
+
+// print_line("motion: "+p_motion+" margin: "+rtos(margin));
+
+ //print_line("margin: "+rtos(margin));
+ do {
+
+ //motion recover
+ for(int i=0;i<get_shape_count();i++) {
+
+ if (is_shape_set_as_trigger(i))
+ continue;
+ if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i),Vector2(),margin,sr,max_shapes,res_shapes,exclude,get_layer_mask(),mask))
+ collided=true;
+
+ }
+
+ if (!collided)
+ break;
+
+ Vector2 recover_motion;
+
+ for(int i=0;i<res_shapes;i++) {
+
+ Vector2 a = sr[i*2+0];
+ Vector2 b = sr[i*2+1];
+
+ float d = a.distance_to(b);
+
+ //if (d<margin)
+ /// continue;
+ recover_motion+=(b-a)*0.4;
+ }
+
+ if (recover_motion==Vector2()) {
+ collided=false;
+ break;
+ }
+
+ Matrix32 gt = get_global_transform();
+ gt.elements[2]+=recover_motion;
+ set_global_transform(gt);
+
+ recover_attempts--;
+
+ } while (recover_attempts);
+
+
+ //move second
+ float safe = 1.0;
+ float unsafe = 1.0;
+ int best_shape=-1;
+
+ for(int i=0;i<get_shape_count();i++) {
+
+ if (is_shape_set_as_trigger(i))
+ continue;
+
+ float lsafe,lunsafe;
+ bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion, 0,lsafe,lunsafe,exclude,get_layer_mask(),mask);
+ //print_line("shape: "+itos(i)+" travel:"+rtos(ltravel));
+ if (!valid) {
+
+ safe=0;
+ unsafe=0;
+ best_shape=i; //sadly it's the best
+ break;
+ }
+ if (lsafe==1.0) {
+ continue;
+ }
+ if (lsafe < safe) {
+
+ safe=lsafe;
+ unsafe=lunsafe;
+ best_shape=i;
+ }
+ }
+
+
+ //print_line("best shape: "+itos(best_shape)+" motion "+p_motion);
+
+ if (safe>=1) {
+ //not collided
+ colliding=false;
+ } else {
+
+ //it collided, let's get the rest info in unsafe advance
+ Matrix32 ugt = get_global_transform();
+ ugt.elements[2]+=p_motion*unsafe;
+ Physics2DDirectSpaceState::ShapeRestInfo rest_info;
+ bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), Vector2(), margin,&rest_info,exclude,get_layer_mask(),mask);
+ if (!c2) {
+ //should not happen, but floating point precision is so weird..
+
+ colliding=false;
+ } else {
+
+
+ //print_line("Travel: "+rtos(travel));
+ colliding=true;
+ collision=rest_info.point;
+ normal=rest_info.normal;
+ collider=rest_info.collider_id;
+ collider_vel=rest_info.linear_velocity;
+ collider_shape=rest_info.shape;
+ collider_metadata=rest_info.metadata;
+ }
+
+ }
+
+ Vector2 motion=p_motion*safe;
+ Matrix32 gt = get_global_transform();
+ gt.elements[2]+=motion;
+ set_global_transform(gt);
+
+ return p_motion-motion;
+
+#endif
+ return false;
+}
diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h
index 05b55fe807..abee8628fc 100644
--- a/servers/physics_2d/space_2d_sw.h
+++ b/servers/physics_2d/space_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -101,6 +101,8 @@ class Space2DSW {
int active_objects;
int collision_pairs;
+ int _cull_aabb_for_body(Body2DSW *p_body,const Rect2& p_aabb);
+
friend class Physics2DDirectSpaceStateSW;
public:
@@ -165,6 +167,8 @@ public:
int get_collision_pairs() const { return collision_pairs; }
+ bool test_body_motion(Body2DSW *p_body, const Vector2&p_motion, float p_margin, Physics2DServer::MotionResult *r_result);
+
Physics2DDirectSpaceStateSW *get_direct_state();
Space2DSW();
diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp
index e75f9300ce..bc87789937 100644
--- a/servers/physics_2d/step_2d_sw.cpp
+++ b/servers/physics_2d/step_2d_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d/step_2d_sw.h b/servers/physics_2d/step_2d_sw.h
index 91ac9d8584..d5e919836c 100644
--- a/servers/physics_2d/step_2d_sw.h
+++ b/servers/physics_2d/step_2d_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp
index 098f890222..b9d15d6e35 100644
--- a/servers/physics_2d_server.cpp
+++ b/servers/physics_2d_server.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -285,7 +285,7 @@ Array Physics2DDirectSpaceState::_cast_motion(const Ref<Physics2DShapeQueryParam
Array ret(true);
ret.resize(2);
ret[0]=closest_safe;
- ret[0]=closest_unsafe;
+ ret[1]=closest_unsafe;
return ret;
}
@@ -421,13 +421,86 @@ void Physics2DShapeQueryResult::_bind_methods() {
}
+///////////////////////////////
+/*bool Physics2DTestMotionResult::is_colliding() const {
+ return colliding;
+}*/
+Vector2 Physics2DTestMotionResult::get_motion() const{
+ return result.motion;
+}
+Vector2 Physics2DTestMotionResult::get_motion_remainder() const{
+
+ return result.remainder;
+}
+
+Vector2 Physics2DTestMotionResult::get_collision_point() const{
+
+ return result.collision_point;
+}
+Vector2 Physics2DTestMotionResult::get_collision_normal() const{
+
+ return result.collision_normal;
+}
+Vector2 Physics2DTestMotionResult::get_collider_velocity() const{
+
+ return result.collider_velocity;
+}
+ObjectID Physics2DTestMotionResult::get_collider_id() const{
+
+ return result.collider_id;
+}
+RID Physics2DTestMotionResult::get_collider_rid() const{
+
+ return result.collider;
+}
+
+Object* Physics2DTestMotionResult::get_collider() const {
+ return ObjectDB::get_instance(result.collider_id);
+}
+
+int Physics2DTestMotionResult::get_collider_shape() const{
+
+ return result.collider_shape;
+}
+
+void Physics2DTestMotionResult::_bind_methods() {
+
+ //ObjectTypeDB::bind_method(_MD("is_colliding"),&Physics2DTestMotionResult::is_colliding);
+ ObjectTypeDB::bind_method(_MD("get_motion"),&Physics2DTestMotionResult::get_motion);
+ ObjectTypeDB::bind_method(_MD("get_motion_remainder"),&Physics2DTestMotionResult::get_motion_remainder);
+ ObjectTypeDB::bind_method(_MD("get_collision_point"),&Physics2DTestMotionResult::get_collision_point);
+ ObjectTypeDB::bind_method(_MD("get_collision_normal"),&Physics2DTestMotionResult::get_collision_normal);
+ ObjectTypeDB::bind_method(_MD("get_collider_velocity"),&Physics2DTestMotionResult::get_collider_velocity);
+ ObjectTypeDB::bind_method(_MD("get_collider_id"),&Physics2DTestMotionResult::get_collider_id);
+ ObjectTypeDB::bind_method(_MD("get_collider_rid"),&Physics2DTestMotionResult::get_collider_rid);
+ ObjectTypeDB::bind_method(_MD("get_collider"),&Physics2DTestMotionResult::get_collider);
+ ObjectTypeDB::bind_method(_MD("get_collider_shape"),&Physics2DTestMotionResult::get_collider_shape);
+
+}
+
+Physics2DTestMotionResult::Physics2DTestMotionResult(){
+
+ colliding=false;
+ result.collider_id=0;
+ result.collider_shape=0;
+}
///////////////////////////////////////
+
+
+bool Physics2DServer::_body_test_motion(RID p_body,const Vector2& p_motion,float p_margin,const Ref<Physics2DTestMotionResult>& p_result) {
+
+ MotionResult *r=NULL;
+ if (p_result.is_valid())
+ r=p_result->get_result_ptr();
+ return body_test_motion(p_body,p_motion,p_margin,r);
+}
+
void Physics2DServer::_bind_methods() {
@@ -463,6 +536,8 @@ void Physics2DServer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("area_remove_shape","area","shape_idx"),&Physics2DServer::area_remove_shape);
ObjectTypeDB::bind_method(_MD("area_clear_shapes","area"),&Physics2DServer::area_clear_shapes);
+ ObjectTypeDB::bind_method(_MD("area_set_layer_mask","area","mask"),&Physics2DServer::area_set_layer_mask);
+ ObjectTypeDB::bind_method(_MD("area_set_collision_mask","area","mask"),&Physics2DServer::area_set_collision_mask);
ObjectTypeDB::bind_method(_MD("area_set_param","area","param","value"),&Physics2DServer::area_set_param);
ObjectTypeDB::bind_method(_MD("area_set_transform","area","transform"),&Physics2DServer::area_set_transform);
@@ -511,8 +586,8 @@ void Physics2DServer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("body_set_layer_mask","body","mask"),&Physics2DServer::body_set_layer_mask);
ObjectTypeDB::bind_method(_MD("body_get_layer_mask","body"),&Physics2DServer::body_get_layer_mask);
- ObjectTypeDB::bind_method(_MD("body_set_user_mask","body","mask"),&Physics2DServer::body_set_user_mask);
- ObjectTypeDB::bind_method(_MD("body_get_user_mask","body"),&Physics2DServer::body_get_user_mask);
+ ObjectTypeDB::bind_method(_MD("body_set_collision_mask","body","mask"),&Physics2DServer::body_set_collision_mask);
+ ObjectTypeDB::bind_method(_MD("body_get_collision_mask","body"),&Physics2DServer::body_get_collision_mask);
ObjectTypeDB::bind_method(_MD("body_set_param","body","param","value"),&Physics2DServer::body_set_param);
@@ -543,6 +618,8 @@ void Physics2DServer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("body_set_force_integration_callback","body","receiver","method"),&Physics2DServer::body_set_force_integration_callback);
+ ObjectTypeDB::bind_method(_MD("body_test_motion","body","motion","margin","result:Physics2DTestMotionResult"),&Physics2DServer::_body_test_motion,DEFVAL(0.08),DEFVAL(Variant()));
+
/* JOINT API */
ObjectTypeDB::bind_method(_MD("joint_set_param","joint","param","value"),&Physics2DServer::joint_set_param);
@@ -580,6 +657,7 @@ void Physics2DServer::_bind_methods() {
BIND_CONSTANT( AREA_PARAM_GRAVITY );
BIND_CONSTANT( AREA_PARAM_GRAVITY_VECTOR );
BIND_CONSTANT( AREA_PARAM_GRAVITY_IS_POINT );
+ BIND_CONSTANT( AREA_PARAM_GRAVITY_DISTANCE_SCALE );
BIND_CONSTANT( AREA_PARAM_GRAVITY_POINT_ATTENUATION );
BIND_CONSTANT( AREA_PARAM_LINEAR_DAMP);
BIND_CONSTANT( AREA_PARAM_ANGULAR_DAMP);
@@ -636,7 +714,7 @@ void Physics2DServer::_bind_methods() {
Physics2DServer::Physics2DServer() {
- ERR_FAIL_COND( singleton!=NULL );
+ //ERR_FAIL_COND( singleton!=NULL );
singleton=this;
}
diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h
index 01670ace7e..b24496880e 100644
--- a/servers/physics_2d_server.h
+++ b/servers/physics_2d_server.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -230,6 +230,7 @@ public:
Physics2DShapeQueryResult();
};
+class Physics2DTestMotionResult;
class Physics2DServer : public Object {
@@ -237,6 +238,8 @@ class Physics2DServer : public Object {
static Physics2DServer * singleton;
+ virtual bool _body_test_motion(RID p_body,const Vector2& p_motion,float p_margin=0.08,const Ref<Physics2DTestMotionResult>& p_result=Ref<Physics2DTestMotionResult>());
+
protected:
static void _bind_methods();
@@ -303,6 +306,7 @@ public:
AREA_PARAM_GRAVITY,
AREA_PARAM_GRAVITY_VECTOR,
AREA_PARAM_GRAVITY_IS_POINT,
+ AREA_PARAM_GRAVITY_DISTANCE_SCALE,
AREA_PARAM_GRAVITY_POINT_ATTENUATION,
AREA_PARAM_LINEAR_DAMP,
AREA_PARAM_ANGULAR_DAMP,
@@ -344,6 +348,9 @@ public:
virtual Variant area_get_param(RID p_parea,AreaParameter p_param) const=0;
virtual Matrix32 area_get_transform(RID p_area) const=0;
+ virtual void area_set_collision_mask(RID p_area,uint32_t p_mask)=0;
+ virtual void area_set_layer_mask(RID p_area,uint32_t p_mask)=0;
+
virtual void area_set_monitorable(RID p_area,bool p_monitorable)=0;
virtual void area_set_pickable(RID p_area,bool p_pickable)=0;
@@ -399,10 +406,10 @@ public:
virtual CCDMode body_get_continuous_collision_detection_mode(RID p_body) const=0;
virtual void body_set_layer_mask(RID p_body, uint32_t p_mask)=0;
- virtual uint32_t body_get_layer_mask(RID p_body, uint32_t p_mask) const=0;
+ virtual uint32_t body_get_layer_mask(RID p_body) const=0;
- virtual void body_set_user_mask(RID p_body, uint32_t p_mask)=0;
- virtual uint32_t body_get_user_mask(RID p_body, uint32_t p_mask) const=0;
+ virtual void body_set_collision_mask(RID p_body, uint32_t p_mask)=0;
+ virtual uint32_t body_get_collision_mask(RID p_body) const=0;
// common body variables
enum BodyParameter {
@@ -468,6 +475,22 @@ public:
virtual void body_set_pickable(RID p_body,bool p_pickable)=0;
+ struct MotionResult {
+
+ Vector2 motion;
+ Vector2 remainder;
+
+ Vector2 collision_point;
+ Vector2 collision_normal;
+ Vector2 collider_velocity;
+ ObjectID collider_id;
+ RID collider;
+ int collider_shape;
+ Variant collider_metadata;
+ };
+
+ virtual bool body_test_motion(RID p_body,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL)=0;
+
/* JOINT API */
enum JointType {
@@ -517,6 +540,7 @@ public:
virtual void step(float p_step)=0;
virtual void sync()=0;
virtual void flush_queries()=0;
+ virtual void end_sync()=0;
virtual void finish()=0;
enum ProcessInfo {
@@ -532,6 +556,37 @@ public:
~Physics2DServer();
};
+
+class Physics2DTestMotionResult : public Reference {
+
+ OBJ_TYPE( Physics2DTestMotionResult, Reference );
+
+ Physics2DServer::MotionResult result;
+ bool colliding;
+friend class Physics2DServer;
+
+protected:
+ static void _bind_methods();
+public:
+
+ Physics2DServer::MotionResult* get_result_ptr() const { return const_cast<Physics2DServer::MotionResult*>(&result); }
+
+ //bool is_colliding() const;
+ Vector2 get_motion() const;
+ Vector2 get_motion_remainder() const;
+
+ Vector2 get_collision_point() const;
+ Vector2 get_collision_normal() const;
+ Vector2 get_collider_velocity() const;
+ ObjectID get_collider_id() const;
+ RID get_collider_rid() const;
+ Object* get_collider() const;
+ int get_collider_shape() const;
+
+ Physics2DTestMotionResult();
+};
+
+
VARIANT_ENUM_CAST( Physics2DServer::ShapeType );
VARIANT_ENUM_CAST( Physics2DServer::SpaceParameter );
VARIANT_ENUM_CAST( Physics2DServer::AreaParameter );
diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp
index 79de253d3b..e02601af41 100644
--- a/servers/physics_server.cpp
+++ b/servers/physics_server.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -221,7 +221,7 @@ PhysicsShapeQueryParameters::PhysicsShapeQueryParameters() {
/////////////////////////////////////
/*
-Variant PhysicsDirectSpaceState::_intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max,const Vector<RID>& p_exclude,uint32_t p_user_mask) {
+Variant PhysicsDirectSpaceState::_intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max,const Vector<RID>& p_exclude,uint32_t p_collision_mask) {
@@ -303,7 +303,7 @@ Array PhysicsDirectSpaceState::_cast_motion(const Ref<PhysicsShapeQueryParameter
Array ret(true);
ret.resize(2);
ret[0]=closest_safe;
- ret[0]=closest_unsafe;
+ ret[1]=closest_unsafe;
return ret;
}
@@ -681,6 +681,7 @@ void PhysicsServer::_bind_methods() {
BIND_CONSTANT( AREA_PARAM_GRAVITY );
BIND_CONSTANT( AREA_PARAM_GRAVITY_VECTOR );
BIND_CONSTANT( AREA_PARAM_GRAVITY_IS_POINT );
+ BIND_CONSTANT( AREA_PARAM_GRAVITY_DISTANCE_SCALE );
BIND_CONSTANT( AREA_PARAM_GRAVITY_POINT_ATTENUATION );
BIND_CONSTANT( AREA_PARAM_DENSITY );
BIND_CONSTANT( AREA_PARAM_PRIORITY );
diff --git a/servers/physics_server.h b/servers/physics_server.h
index 0c2542a66c..f66ea590b8 100644
--- a/servers/physics_server.h
+++ b/servers/physics_server.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -131,8 +131,8 @@ class PhysicsDirectSpaceState : public Object {
OBJ_TYPE( PhysicsDirectSpaceState, Object );
-// Variant _intersect_ray(const Vector3& p_from, const Vector3& p_to,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_user_mask=0);
-// Variant _intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max=64,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_user_mask=0);
+// Variant _intersect_ray(const Vector3& p_from, const Vector3& p_to,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_collision_mask=0);
+// Variant _intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max=64,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_collision_mask=0);
public:
enum ObjectTypeMask {
@@ -298,6 +298,7 @@ public:
AREA_PARAM_GRAVITY,
AREA_PARAM_GRAVITY_VECTOR,
AREA_PARAM_GRAVITY_IS_POINT,
+ AREA_PARAM_GRAVITY_DISTANCE_SCALE,
AREA_PARAM_GRAVITY_POINT_ATTENUATION,
AREA_PARAM_DENSITY,
AREA_PARAM_PRIORITY
@@ -338,7 +339,10 @@ public:
virtual Variant area_get_param(RID p_parea,AreaParameter p_param) const=0;
virtual Transform area_get_transform(RID p_area) const=0;
+ virtual void area_set_monitorable(RID p_area,bool p_monitorable)=0;
+
virtual void area_set_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method)=0;
+ virtual void area_set_area_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method)=0;
virtual void area_set_ray_pickable(RID p_area,bool p_enable)=0;
virtual bool area_is_ray_pickable(RID p_area) const=0;
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index a2b1b71f99..3634a03dbc 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -55,6 +55,7 @@ void register_server_types() {
ObjectTypeDB::register_virtual_type<Physics2DDirectBodyState>();
ObjectTypeDB::register_virtual_type<Physics2DDirectSpaceState>();
ObjectTypeDB::register_virtual_type<Physics2DShapeQueryResult>();
+ ObjectTypeDB::register_type<Physics2DTestMotionResult>();
ObjectTypeDB::register_type<Physics2DShapeQueryParameters>();
ObjectTypeDB::register_type<PhysicsShapeQueryParameters>();
diff --git a/servers/register_server_types.h b/servers/register_server_types.h
index b0a01fc0a5..d3d6c6b566 100644
--- a/servers/register_server_types.h
+++ b/servers/register_server_types.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/server_wrap_mt_common.h b/servers/server_wrap_mt_common.h
new file mode 100644
index 0000000000..cbb75129d0
--- /dev/null
+++ b/servers/server_wrap_mt_common.h
@@ -0,0 +1,700 @@
+
+#define FUNC0R(m_r,m_type)\
+ virtual m_r m_type() { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type();\
+ }\
+ }
+
+
+#define FUNCRID(m_type)\
+ int m_type##allocn() {\
+ for(int i=0;i<m_type##_pool_max_size;i++) {\
+ m_type##_id_pool.push_back( server_name->m_type##_create() );\
+ }\
+ return 0;\
+ }\
+ void m_type##_free_cached_ids() {\
+ while (m_type##_id_pool.size()) {\
+ free(m_type##_id_pool.front()->get());\
+ m_type##_id_pool.pop_front();\
+ }\
+ }\
+ virtual RID m_type##_create() { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ RID rid;\
+ alloc_mutex->lock();\
+ if (m_type##_id_pool.size()==0) {\
+ int ret;\
+ command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,&ret);\
+ }\
+ rid=m_type##_id_pool.front()->get();\
+ m_type##_id_pool.pop_front();\
+ alloc_mutex->unlock();\
+ return rid;\
+ } else {\
+ return server_name->m_type##_create();\
+ }\
+ }
+
+#define FUNC1RID(m_type,m_arg1)\
+ int m_type##allocn() {\
+ for(int i=0;i<m_type##_pool_max_size;i++) {\
+ m_type##_id_pool.push_back( server_name->m_type##_create() );\
+ }\
+ return 0;\
+ }\
+ void m_type##_free_cached_ids() {\
+ while (m_type##_id_pool.size()) {\
+ free(m_type##_id_pool.front()->get());\
+ m_type##_id_pool.pop_front();\
+ }\
+ }\
+ virtual RID m_type##_create(m_arg1 p1) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ RID rid;\
+ alloc_mutex->lock();\
+ if (m_type##_id_pool.size()==0) {\
+ int ret;\
+ command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,p1,&ret);\
+ }\
+ rid=m_type##_id_pool.front()->get();\
+ m_type##_id_pool.pop_front();\
+ alloc_mutex->unlock();\
+ return rid;\
+ } else {\
+ return server_name->m_type##_create(p1);\
+ }\
+ }
+
+#define FUNC2RID(m_type,m_arg1,m_arg2)\
+ int m_type##allocn() {\
+ for(int i=0;i<m_type##_pool_max_size;i++) {\
+ m_type##_id_pool.push_back( server_name->m_type##_create() );\
+ }\
+ return 0;\
+ }\
+ void m_type##_free_cached_ids() {\
+ while (m_type##_id_pool.size()) {\
+ free(m_type##_id_pool.front()->get());\
+ m_type##_id_pool.pop_front();\
+ }\
+ }\
+ virtual RID m_type##_create(m_arg1 p1,m_arg2 p2) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ RID rid;\
+ alloc_mutex->lock();\
+ if (m_type##_id_pool.size()==0) {\
+ int ret;\
+ command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,p1,p2,&ret);\
+ }\
+ rid=m_type##_id_pool.front()->get();\
+ m_type##_id_pool.pop_front();\
+ alloc_mutex->unlock();\
+ return rid;\
+ } else {\
+ return server_name->m_type##_create(p1,p2);\
+ }\
+ }
+
+#define FUNC3RID(m_type,m_arg1,m_arg2,m_arg3)\
+ int m_type##allocn() {\
+ for(int i=0;i<m_type##_pool_max_size;i++) {\
+ m_type##_id_pool.push_back( server_name->m_type##_create() );\
+ }\
+ return 0;\
+ }\
+ void m_type##_free_cached_ids() {\
+ while (m_type##_id_pool.size()) {\
+ free(m_type##_id_pool.front()->get());\
+ m_type##_id_pool.pop_front();\
+ }\
+ }\
+ virtual RID m_type##_create(m_arg1 p1,m_arg2 p2,m_arg3 p3) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ RID rid;\
+ alloc_mutex->lock();\
+ if (m_type##_id_pool.size()==0) {\
+ int ret;\
+ command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,p1,p2,p3,&ret);\
+ }\
+ rid=m_type##_id_pool.front()->get();\
+ m_type##_id_pool.pop_front();\
+ alloc_mutex->unlock();\
+ return rid;\
+ } else {\
+ return server_name->m_type##_create(p1,p2,p3);\
+ }\
+ }
+
+
+#define FUNC4RID(m_type,m_arg1,m_arg2,m_arg3,m_arg4)\
+ int m_type##allocn() {\
+ for(int i=0;i<m_type##_pool_max_size;i++) {\
+ m_type##_id_pool.push_back( server_name->m_type##_create() );\
+ }\
+ return 0;\
+ }\
+ void m_type##_free_cached_ids() {\
+ while (m_type##_id_pool.size()) {\
+ free(m_type##_id_pool.front()->get());\
+ m_type##_id_pool.pop_front();\
+ }\
+ }\
+ virtual RID m_type##_create(m_arg1 p1,m_arg2 p2,m_arg3 p3,m_arg4 p4) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ RID rid;\
+ alloc_mutex->lock();\
+ if (m_type##_id_pool.size()==0) {\
+ int ret;\
+ command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,p1,p2,p3,p4,&ret);\
+ }\
+ rid=m_type##_id_pool.front()->get();\
+ m_type##_id_pool.pop_front();\
+ alloc_mutex->unlock();\
+ return rid;\
+ } else {\
+ return server_name->m_type##_create(p1,p2,p3,p4);\
+ }\
+ }
+
+
+#define FUNC5RID(m_type,m_arg1,m_arg2,m_arg3,m_arg4,m_arg5)\
+ int m_type##allocn() {\
+ for(int i=0;i<m_type##_pool_max_size;i++) {\
+ m_type##_id_pool.push_back( server_name->m_type##_create() );\
+ }\
+ return 0;\
+ }\
+ void m_type##_free_cached_ids() {\
+ while (m_type##_id_pool.size()) {\
+ free(m_type##_id_pool.front()->get());\
+ m_type##_id_pool.pop_front();\
+ }\
+ }\
+ virtual RID m_type##_create(m_arg1 p1,m_arg2 p2,m_arg3 p3,m_arg4 p4,m_arg5 p5) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ RID rid;\
+ alloc_mutex->lock();\
+ if (m_type##_id_pool.size()==0) {\
+ int ret;\
+ command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,p1,p2,p3,p4,p5,&ret);\
+ }\
+ rid=m_type##_id_pool.front()->get();\
+ m_type##_id_pool.pop_front();\
+ alloc_mutex->unlock();\
+ return rid;\
+ } else {\
+ return server_name->m_type##_create(p1,p2,p3,p4,p5);\
+ }\
+ }
+
+#define FUNC0RC(m_r,m_type)\
+ virtual m_r m_type() const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type();\
+ }\
+ }
+
+
+#define FUNC0(m_type)\
+ virtual void m_type() { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type);\
+ } else {\
+ server_name->m_type();\
+ }\
+ }
+
+#define FUNC0C(m_type)\
+ virtual void m_type() const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type);\
+ } else {\
+ server_name->m_type();\
+ }\
+ }
+
+
+#define FUNC0S(m_type)\
+ virtual void m_type() { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type);\
+ } else {\
+ server_name->m_type();\
+ }\
+ }
+
+#define FUNC0SC(m_type)\
+ virtual void m_type() const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type);\
+ } else {\
+ server_name->m_type();\
+ }\
+ }
+
+
+///////////////////////////////////////////////
+
+
+#define FUNC1R(m_r,m_type,m_arg1)\
+ virtual m_r m_type(m_arg1 p1) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1);\
+ }\
+ }
+
+#define FUNC1RC(m_r,m_type,m_arg1)\
+ virtual m_r m_type(m_arg1 p1) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1);\
+ }\
+ }
+
+
+#define FUNC1S(m_type,m_arg1)\
+ virtual void m_type(m_arg1 p1) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1);\
+ } else {\
+ server_name->m_type(p1);\
+ }\
+ }
+
+#define FUNC1SC(m_type,m_arg1)\
+ virtual void m_type(m_arg1 p1) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1);\
+ } else {\
+ server_name->m_type(p1);\
+ }\
+ }
+
+
+#define FUNC1(m_type,m_arg1)\
+ virtual void m_type(m_arg1 p1) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1);\
+ } else {\
+ server_name->m_type(p1);\
+ }\
+ }
+
+#define FUNC1C(m_type,m_arg1)\
+ virtual void m_type(m_arg1 p1) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1);\
+ } else {\
+ server_name->m_type(p1);\
+ }\
+ }
+
+
+
+
+#define FUNC2R(m_r,m_type,m_arg1, m_arg2)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2);\
+ }\
+ }
+
+#define FUNC2RC(m_r,m_type,m_arg1, m_arg2)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2);\
+ }\
+ }
+
+
+#define FUNC2S(m_type,m_arg1, m_arg2)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2);\
+ } else {\
+ server_name->m_type(p1, p2);\
+ }\
+ }
+
+#define FUNC2SC(m_type,m_arg1, m_arg2)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2);\
+ } else {\
+ server_name->m_type(p1, p2);\
+ }\
+ }
+
+
+#define FUNC2(m_type,m_arg1, m_arg2)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2);\
+ } else {\
+ server_name->m_type(p1, p2);\
+ }\
+ }
+
+#define FUNC2C(m_type,m_arg1, m_arg2)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2);\
+ } else {\
+ server_name->m_type(p1, p2);\
+ }\
+ }
+
+
+
+
+#define FUNC3R(m_r,m_type,m_arg1, m_arg2, m_arg3)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2, p3);\
+ }\
+ }
+
+#define FUNC3RC(m_r,m_type,m_arg1, m_arg2, m_arg3)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3,&ret);\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2, p3);\
+ }\
+ }
+
+
+#define FUNC3S(m_type,m_arg1, m_arg2, m_arg3)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3);\
+ } else {\
+ server_name->m_type(p1, p2, p3);\
+ }\
+ }
+
+#define FUNC3SC(m_type,m_arg1, m_arg2, m_arg3)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3);\
+ } else {\
+ server_name->m_type(p1, p2, p3);\
+ }\
+ }
+
+
+#define FUNC3(m_type,m_arg1, m_arg2, m_arg3)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2, p3);\
+ } else {\
+ server_name->m_type(p1, p2, p3);\
+ }\
+ }
+
+#define FUNC3C(m_type,m_arg1, m_arg2, m_arg3)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2, p3);\
+ } else {\
+ server_name->m_type(p1, p2, p3);\
+ }\
+ }
+
+
+
+
+#define FUNC4R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2, p3, p4);\
+ }\
+ }
+
+#define FUNC4RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2, p3, p4);\
+ }\
+ }
+
+
+#define FUNC4S(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4);\
+ }\
+ }
+
+#define FUNC4SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4);\
+ }\
+ }
+
+
+#define FUNC4(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4);\
+ }\
+ }
+
+#define FUNC4C(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4);\
+ }\
+ }
+
+
+
+
+#define FUNC5R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2, p3, p4, p5);\
+ }\
+ }
+
+#define FUNC5RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2, p3, p4, p5);\
+ }\
+ }
+
+
+#define FUNC5S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5);\
+ }\
+ }
+
+#define FUNC5SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5);\
+ }\
+ }
+
+
+#define FUNC5(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5);\
+ }\
+ }
+
+#define FUNC5C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5);\
+ }\
+ }
+
+
+
+
+#define FUNC6R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2, p3, p4, p5, p6);\
+ }\
+ }
+
+#define FUNC6RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6,&ret);\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2, p3, p4, p5, p6);\
+ }\
+ }
+
+
+#define FUNC6S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5, p6);\
+ }\
+ }
+
+#define FUNC6SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5, p6);\
+ }\
+ }
+
+
+#define FUNC6(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5, p6);\
+ }\
+ }
+
+#define FUNC6C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5, p6);\
+ }\
+ }
+
+
+
+
+#define FUNC7R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
+ }\
+ }
+
+#define FUNC7RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
+ virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ m_r ret;\
+ command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7,&ret);\
+ SYNC_DEBUG\
+ return ret;\
+ } else {\
+ return server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
+ }\
+ }
+
+
+#define FUNC7S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
+ }\
+ }
+
+#define FUNC7SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
+ }\
+ }
+
+
+#define FUNC7(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
+ }\
+ }
+
+#define FUNC7C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
+ virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
+ if (Thread::get_caller_ID()!=server_thread) {\
+ command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7);\
+ } else {\
+ server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
+ }\
+ }
+
diff --git a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp
index 2aab0e7dc9..439149b1a2 100644
--- a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp
+++ b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h
index 6e7ac2157d..ed305d25de 100644
--- a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h
+++ b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/spatial_sound_2d_server.cpp b/servers/spatial_sound_2d_server.cpp
index d27803559e..574c3d761f 100644
--- a/servers/spatial_sound_2d_server.cpp
+++ b/servers/spatial_sound_2d_server.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/spatial_sound_2d_server.h b/servers/spatial_sound_2d_server.h
index e3ed4ce00c..9917b36be1 100644
--- a/servers/spatial_sound_2d_server.h
+++ b/servers/spatial_sound_2d_server.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/spatial_sound_server.cpp b/servers/spatial_sound_server.cpp
index 1fcfb0008b..f5f5925483 100644
--- a/servers/spatial_sound_server.cpp
+++ b/servers/spatial_sound_server.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/spatial_sound_server.h b/servers/spatial_sound_server.h
index ff4342a42b..1cc323b370 100644
--- a/servers/spatial_sound_server.h
+++ b/servers/spatial_sound_server.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/visual/particle_system_sw.cpp b/servers/visual/particle_system_sw.cpp
index 49a68f8e80..aa9b737459 100644
--- a/servers/visual/particle_system_sw.cpp
+++ b/servers/visual/particle_system_sw.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/visual/particle_system_sw.h b/servers/visual/particle_system_sw.h
index 2b18c7f4e3..b7ff5e9bb5 100644
--- a/servers/visual/particle_system_sw.h
+++ b/servers/visual/particle_system_sw.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/visual/rasterizer.cpp b/servers/visual/rasterizer.cpp
index 5088000022..5984e6e35c 100644
--- a/servers/visual/rasterizer.cpp
+++ b/servers/visual/rasterizer.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 62563a0771..0b115a4d1d 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -502,7 +502,7 @@ public:
virtual void begin_scene(RID p_viewport_data,RID p_env,VS::ScenarioDebugMode p_debug)=0;
virtual void begin_shadow_map( RID p_light_instance, int p_shadow_pass )=0;
- virtual void set_camera(const Transform& p_world,const CameraMatrix& p_projection)=0;
+ virtual void set_camera(const Transform& p_world,const CameraMatrix& p_projection,bool p_ortho_hint)=0;
virtual void add_light( RID p_light_instance )=0; ///< all "add_light" calls happen before add_geometry calls
@@ -592,6 +592,7 @@ public:
RID shadow_buffer;
int shadow_buffer_size;
float shadow_esm_mult;
+ Color shadow_color;
void *texture_cache; // implementation dependent
@@ -610,6 +611,7 @@ public:
CanvasLight() {
enabled=true;
color=Color(1,1,1);
+ shadow_color=Color(0,0,0,0);
height=0;
z_min=-1024;
z_max=1024;
@@ -661,6 +663,7 @@ public:
};
Type type;
+ virtual ~Command(){}
};
struct CommandLine : public Command {
@@ -862,17 +865,17 @@ public:
if (polygon->indices != NULL) {
r.pos=polygon->points[polygon->indices[0]];
- for (int i=1; i<polygon->count; i++) {
+ for (int i=1; i<l; i++) {
r.expand_to(polygon->points[polygon->indices[i]]);
- };
+ }
} else {
r.pos=polygon->points[0];
- for (int i=1; i<polygon->count; i++) {
+ for (int i=1; i<l; i++) {
r.expand_to(polygon->points[i]);
- };
- };
+ }
+ }
} break;
case CanvasItem::Command::TYPE_CIRCLE: {
diff --git a/servers/visual/rasterizer_dummy.cpp b/servers/visual/rasterizer_dummy.cpp
index 45b29f5484..e32f47b3d8 100644
--- a/servers/visual/rasterizer_dummy.cpp
+++ b/servers/visual/rasterizer_dummy.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -1497,7 +1497,7 @@ void RasterizerDummy::begin_shadow_map( RID p_light_instance, int p_shadow_pass
}
-void RasterizerDummy::set_camera(const Transform& p_world,const CameraMatrix& p_projection) {
+void RasterizerDummy::set_camera(const Transform& p_world, const CameraMatrix& p_projection, bool p_ortho_hint) {
}
diff --git a/servers/visual/rasterizer_dummy.h b/servers/visual/rasterizer_dummy.h
index 99c76a1917..cc3c1724a4 100644
--- a/servers/visual/rasterizer_dummy.h
+++ b/servers/visual/rasterizer_dummy.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -679,7 +679,7 @@ public:
virtual void begin_scene(RID p_viewport_data,RID p_env,VS::ScenarioDebugMode p_debug);
virtual void begin_shadow_map( RID p_light_instance, int p_shadow_pass );
- virtual void set_camera(const Transform& p_world,const CameraMatrix& p_projection);
+ virtual void set_camera(const Transform& p_world,const CameraMatrix& p_projection,bool p_ortho_hint);
virtual void add_light( RID p_light_instance ); ///< all "add_light" calls happen before add_geometry calls
diff --git a/servers/visual/shader_compiler.cpp b/servers/visual/shader_compiler.cpp
index df2ffa6889..d7b171f5a7 100644
--- a/servers/visual/shader_compiler.cpp
+++ b/servers/visual/shader_compiler.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/visual/shader_compiler.h b/servers/visual/shader_compiler.h
index 6bb523fbce..69d9eedf9c 100644
--- a/servers/visual/shader_compiler.h
+++ b/servers/visual/shader_compiler.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/visual/shader_graph.cpp b/servers/visual/shader_graph.cpp
index 8fb7196276..1346ec9253 100644
--- a/servers/visual/shader_graph.cpp
+++ b/servers/visual/shader_graph.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/visual/shader_graph.h b/servers/visual/shader_graph.h
index fe305f3955..807dbb3719 100644
--- a/servers/visual/shader_graph.h
+++ b/servers/visual/shader_graph.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 4ad8aa6c71..ea56306241 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -118,13 +118,17 @@ ShaderLanguage::Token ShaderLanguage::read_token(const CharType* p_text,int p_le
while(true) {
- if (GETCHAR(r_chars+1)=='0')
+ if (GETCHAR(r_chars+1)==0) {
+ r_chars+=1;
break;
- if (GETCHAR(r_chars+1)=='*' && GETCHAR(r_chars+2)=='/')
+ } if (GETCHAR(r_chars+1)=='*' && GETCHAR(r_chars+2)=='/') {
+ r_chars+=3;
break;
- if (GETCHAR(r_chars+1)=='\n')
+ } if (GETCHAR(r_chars+1)=='\n') {
r_line++;
- r_chars++;
+ }
+
+ r_chars++;
}
return Token();
@@ -1141,6 +1145,8 @@ const ShaderLanguage::BuiltinsDef ShaderLanguage::ci_fragment_builtins_defs[]={
{ "SRC_COLOR", TYPE_VEC4},
{ "POSITION", TYPE_VEC4},
{ "NORMAL", TYPE_VEC3},
+ { "NORMALMAP", TYPE_VEC3},
+ { "NORMALMAP_DEPTH", TYPE_FLOAT},
{ "UV", TYPE_VEC2},
{ "COLOR", TYPE_VEC4},
{ "TEXTURE", TYPE_TEXTURE},
@@ -1273,7 +1279,7 @@ ShaderLanguage::Node* ShaderLanguage::validate_function_call(Parser&parser, Oper
if (p_func->op==OP_CONSTRUCT && all_const) {
- bool all_const=false;
+
Vector<float> cdata;
for(int i=0;i<argcount;i++) {
@@ -1708,7 +1714,7 @@ Error ShaderLanguage::parse_expression(Parser& parser,Node *p_parent,Node **r_ex
if (!existing) {
- parser.set_error("Unexisting identifier in expression: "+identifier);
+ parser.set_error("Nonexistent identifier in expression: "+identifier);
return ERR_PARSE_ERROR;
}
diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h
index 7777c8bcf3..9fd070ee2e 100644
--- a/servers/visual/shader_language.h
+++ b/servers/visual/shader_language.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 7a9db4ba11..b51f59050d 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -4071,6 +4071,15 @@ void VisualServerRaster::canvas_light_set_shadow_esm_multiplier(RID p_light, flo
}
+void VisualServerRaster::canvas_light_set_shadow_color(RID p_light, const Color& p_color) {
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->shadow_color=p_color;
+
+}
+
+
/****** CANVAS LIGHT OCCLUDER ******/
RID VisualServerRaster::canvas_light_occluder_create() {
@@ -4393,7 +4402,7 @@ void VisualServerRaster::free( RID p_rid ) {
VS_CHANGED;
- if (rasterizer->is_texture(p_rid) || rasterizer->is_material(p_rid) || rasterizer->is_shader(p_rid)) {
+ if (rasterizer->is_texture(p_rid) || rasterizer->is_material(p_rid) || rasterizer->is_shader(p_rid) || rasterizer->is_environment(p_rid)) {
rasterizer->free(p_rid);
} else if (rasterizer->is_skeleton(p_rid)) {
@@ -4410,7 +4419,7 @@ void VisualServerRaster::free( RID p_rid ) {
}
rasterizer->free(p_rid);
- } else if (rasterizer->is_mesh(p_rid) || rasterizer->is_multimesh(p_rid) || rasterizer->is_light(p_rid) || rasterizer->is_particles(p_rid) ) {
+ } else if (rasterizer->is_mesh(p_rid) || rasterizer->is_multimesh(p_rid) || rasterizer->is_light(p_rid) || rasterizer->is_particles(p_rid) || rasterizer->is_immediate(p_rid)) {
//delete the resource
_free_attached_instances(p_rid);
@@ -6302,7 +6311,7 @@ void VisualServerRaster::_render_no_camera(Viewport *p_viewport,Camera *p_camera
else
environment=p_scenario->fallback_environment;
- rasterizer->set_camera(Transform(),CameraMatrix());
+ rasterizer->set_camera(Transform(),CameraMatrix(),false);
rasterizer->begin_scene(p_viewport->viewport_data,environment,p_scenario->debug);
rasterizer->set_viewport(viewport_rect);
rasterizer->end_scene();
@@ -6318,7 +6327,8 @@ void VisualServerRaster::_render_camera(Viewport *p_viewport,Camera *p_camera, S
/* STEP 1 - SETUP CAMERA */
CameraMatrix camera_matrix;
-
+ bool ortho=false;
+
switch(p_camera->type) {
case Camera::ORTHOGONAL: {
@@ -6330,6 +6340,7 @@ void VisualServerRaster::_render_camera(Viewport *p_viewport,Camera *p_camera, S
p_camera->vaspect
);
+ ortho=true;
} break;
case Camera::PERSPECTIVE: {
@@ -6341,12 +6352,13 @@ void VisualServerRaster::_render_camera(Viewport *p_viewport,Camera *p_camera, S
p_camera->vaspect
);
+ ortho=false;
} break;
}
- rasterizer->set_camera(p_camera->transform, camera_matrix);
+ rasterizer->set_camera(p_camera->transform, camera_matrix,ortho);
Vector<Plane> planes = camera_matrix.get_projection_planes(p_camera->transform);
@@ -6839,6 +6851,7 @@ void VisualServerRaster::_render_canvas_item(CanvasItem *p_canvas_item,const Mat
ci->final_transform=xform;
ci->final_opacity=opacity * ci->self_opacity;
ci->global_rect_cache=global_rect;
+ ci->global_rect_cache.pos-=p_clip_rect.pos;
int zidx = p_z-CANVAS_ITEM_Z_MIN;
@@ -7046,17 +7059,20 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_
for(Set<Rasterizer::CanvasLight*>::Element *F=E->get().canvas->lights.front();F;F=F->next()) {
+
Rasterizer::CanvasLight* cl=F->get();
if (cl->enabled && cl->texture.is_valid()) {
//not super efficient..
Size2 tsize(rasterizer->texture_get_width(cl->texture),rasterizer->texture_get_height(cl->texture));
tsize*=cl->scale;
+
Vector2 offset=tsize/2.0;
cl->rect_cache=Rect2(-offset+cl->texture_offset,tsize);
cl->xform_cache=xf * cl->xform;
if (clip_rect.intersects_transformed(cl->xform_cache,cl->rect_cache)) {
+
cl->filter_next_ptr=lights;
lights=cl;
cl->texture_cache=NULL;
@@ -7066,6 +7082,7 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_
cl->light_shader_xform = (cl->xform_cache * scale).affine_inverse();
cl->light_shader_pos=cl->xform_cache[2];
if (cl->shadow_buffer.is_valid()) {
+
cl->shadows_next_ptr=lights_with_shadow;
if (lights_with_shadow==NULL) {
shadow_rect = cl->xform_cache.xform(cl->rect_cache);
@@ -7276,7 +7293,7 @@ void VisualServerRaster::_draw_viewports() {
if (r.size.width==0)
r.size.width=window_w;
if (r.size.height==0)
- r.size.height=window_w;
+ r.size.height=window_h;
_draw_viewport(vp,r.pos.x,r.pos.y,r.size.width,r.size.height);
@@ -7353,7 +7370,7 @@ void VisualServerRaster::_draw_cursors_and_margins() {
rasterizer->canvas_end_rect();
};
-void VisualServerRaster::flush() {
+void VisualServerRaster::sync() {
//do none
}
@@ -7391,7 +7408,7 @@ void VisualServerRaster::set_default_clear_color(const Color& p_color) {
clear_color=p_color;
}
-void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_color) {
+void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_color,bool p_scale) {
if (p_image.empty())
return;
@@ -7413,9 +7430,27 @@ void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_col
texture_set_data(texture,p_image);
rasterizer->canvas_begin_rect(Matrix32());
Rect2 imgrect(0,0,p_image.get_width(),p_image.get_height());
- Rect2 screenrect=imgrect;
- screenrect.pos+=((Size2(vr.width,vr.height)-screenrect.size)/2.0).floor();
- rasterizer->canvas_draw_rect(screenrect,0,imgrect,texture,Color(1,1,1,0));
+ Rect2 screenrect;
+ if (p_scale) {
+
+ if (window_w > window_h) {
+ //scale horizontally
+ screenrect.size.y = window_h;
+ screenrect.size.x = imgrect.size.x * window_h / imgrect.size.y;
+ screenrect.pos.x = (window_w - screenrect.size.x)/2;
+
+ } else {
+ //scale vertically
+ screenrect.size.x = window_w;
+ screenrect.size.y = imgrect.size.y * window_w / imgrect.size.x;
+ screenrect.pos.y = (window_h - screenrect.size.y)/2;
+ }
+ } else {
+
+ screenrect=imgrect;
+ screenrect.pos+=((Size2(vr.width,vr.height)-screenrect.size)/2.0).floor();
+
+ }
rasterizer->canvas_draw_rect(screenrect,0,imgrect,texture,Color(1,1,1,1));
rasterizer->canvas_end_rect();
@@ -7470,6 +7505,10 @@ void VisualServerRaster::finish() {
free(default_cursor_texture);
+ if (test_cube.is_valid())
+ free(test_cube);
+
+ _free_internal_rids();
_clean_up_owner( &room_owner,"Room" );
_clean_up_owner( &portal_owner,"Portal" );
@@ -7487,7 +7526,7 @@ void VisualServerRaster::finish() {
octree_allocator.clear();
if (instance_dependency_map.size()) {
- print_line("base resources missing "+itos(instance_dependency_map.size()));
+ print_line("Base resources missing amount: "+itos(instance_dependency_map.size()));
}
ERR_FAIL_COND( instance_dependency_map.size() );
}
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index a89a685e30..73298d58cd 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -1180,6 +1180,8 @@ public:
virtual void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled);
virtual void canvas_light_set_shadow_buffer_size(RID p_light, int p_size);
virtual void canvas_light_set_shadow_esm_multiplier(RID p_light, float p_multiplier);
+ virtual void canvas_light_set_shadow_color(RID p_light, const Color& p_color);
+
virtual RID canvas_light_occluder_create();
@@ -1237,7 +1239,7 @@ public:
/* EVENT QUEUING */
virtual void draw();
- virtual void flush();
+ virtual void sync();
virtual void init();
virtual void finish();
@@ -1251,7 +1253,7 @@ public:
RID get_test_cube();
- virtual void set_boot_image(const Image& p_image, const Color& p_color);
+ 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);
VisualServerRaster(Rasterizer *p_rasterizer);
diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp
index 62f18b9e81..19dff3d36c 100644
--- a/servers/visual/visual_server_wrap_mt.cpp
+++ b/servers/visual/visual_server_wrap_mt.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -96,16 +96,19 @@ void VisualServerWrapMT::thread_loop() {
/* EVENT QUEUING */
-void VisualServerWrapMT::flush() {
+void VisualServerWrapMT::sync() {
if (create_thread) {
+ /* TODO: sync with the thread */
+
+ /*
ERR_FAIL_COND(!draw_mutex);
draw_mutex->lock();
draw_pending++; //cambiar por un saferefcount
draw_mutex->unlock();
-
- command_queue.push( this, &VisualServerWrapMT::thread_flush);
+ */
+ //command_queue.push( this, &VisualServerWrapMT::thread_flush);
} else {
command_queue.flush_all(); //flush all pending from other threads
@@ -118,15 +121,16 @@ void VisualServerWrapMT::draw() {
if (create_thread) {
+ /* TODO: Make it draw
ERR_FAIL_COND(!draw_mutex);
draw_mutex->lock();
draw_pending++; //cambiar por un saferefcount
draw_mutex->unlock();
command_queue.push( this, &VisualServerWrapMT::thread_draw);
+ */
} else {
- command_queue.flush_all(); //flush all pending from other threads
visual_server->draw();
}
}
@@ -187,8 +191,8 @@ VisualServerWrapMT::VisualServerWrapMT(VisualServer* p_contained,bool p_create_t
draw_pending=0;
draw_thread_up=false;
alloc_mutex=Mutex::create();
- texture_pool_max_size=GLOBAL_DEF("render/thread_textures_prealloc",20);
- mesh_pool_max_size=GLOBAL_DEF("render/thread_meshes_prealloc",20);
+ texture_pool_max_size=GLOBAL_DEF("render/thread_textures_prealloc",5);
+ mesh_pool_max_size=GLOBAL_DEF("core/rid_pool_prealloc",20);
if (!p_create_thread) {
server_thread=Thread::get_caller_ID();
} else {
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index 6cd374aa08..db03d82829 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -79,554 +79,10 @@ class VisualServerWrapMT : public VisualServer {
public:
-#define FUNC0R(m_r,m_type)\
- virtual m_r m_type() { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type();\
- }\
- }
-
-#define FUNCRID(m_type)\
- int m_type##allocn() {\
- for(int i=0;i<m_type##_pool_max_size;i++) {\
- m_type##_id_pool.push_back( visual_server->m_type##_create() );\
- }\
- return 0;\
- }\
- void m_type##_free_cached_ids() {\
- while (m_type##_id_pool.size()) {\
- free(m_type##_id_pool.front()->get());\
- m_type##_id_pool.pop_front();\
- }\
- }\
- virtual RID m_type##_create() { \
- if (Thread::get_caller_ID()!=server_thread) {\
- RID rid;\
- alloc_mutex->lock();\
- if (m_type##_id_pool.size()==0) {\
- int ret;\
- command_queue.push_and_ret( this, &VisualServerWrapMT::m_type##allocn,&ret);\
- }\
- rid=m_type##_id_pool.front()->get();\
- m_type##_id_pool.pop_front();\
- alloc_mutex->unlock();\
- return rid;\
- } else {\
- return visual_server->m_type##_create();\
- }\
- }
-
-#define FUNC0RC(m_r,m_type)\
- virtual m_r m_type() const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type();\
- }\
- }
-
-
-#define FUNC0(m_type)\
- virtual void m_type() { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type);\
- } else {\
- visual_server->m_type();\
- }\
- }
-
-#define FUNC0C(m_type)\
- virtual void m_type() const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type);\
- } else {\
- visual_server->m_type();\
- }\
- }
-
-
-#define FUNC0S(m_type)\
- virtual void m_type() { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type);\
- } else {\
- visual_server->m_type();\
- }\
- }
-
-#define FUNC0SC(m_type)\
- virtual void m_type() const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type);\
- } else {\
- visual_server->m_type();\
- }\
- }
-
-
-///////////////////////////////////////////////
-
-
-#define FUNC1R(m_r,m_type,m_arg1)\
- virtual m_r m_type(m_arg1 p1) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1);\
- }\
- }
-
-#define FUNC1RC(m_r,m_type,m_arg1)\
- virtual m_r m_type(m_arg1 p1) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1);\
- }\
- }
-
-
-#define FUNC1S(m_type,m_arg1)\
- virtual void m_type(m_arg1 p1) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1);\
- } else {\
- visual_server->m_type(p1);\
- }\
- }
-
-#define FUNC1SC(m_type,m_arg1)\
- virtual void m_type(m_arg1 p1) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1);\
- } else {\
- visual_server->m_type(p1);\
- }\
- }
-
-
-#define FUNC1(m_type,m_arg1)\
- virtual void m_type(m_arg1 p1) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1);\
- } else {\
- visual_server->m_type(p1);\
- }\
- }
-
-#define FUNC1C(m_type,m_arg1)\
- virtual void m_type(m_arg1 p1) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1);\
- } else {\
- visual_server->m_type(p1);\
- }\
- }
-
-
-
-
-#define FUNC2R(m_r,m_type,m_arg1, m_arg2)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2);\
- }\
- }
-
-#define FUNC2RC(m_r,m_type,m_arg1, m_arg2)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2);\
- }\
- }
-
-
-#define FUNC2S(m_type,m_arg1, m_arg2)\
- virtual void m_type(m_arg1 p1, m_arg2 p2) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2);\
- } else {\
- visual_server->m_type(p1, p2);\
- }\
- }
-
-#define FUNC2SC(m_type,m_arg1, m_arg2)\
- virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2);\
- } else {\
- visual_server->m_type(p1, p2);\
- }\
- }
-
-
-#define FUNC2(m_type,m_arg1, m_arg2)\
- virtual void m_type(m_arg1 p1, m_arg2 p2) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2);\
- } else {\
- visual_server->m_type(p1, p2);\
- }\
- }
-
-#define FUNC2C(m_type,m_arg1, m_arg2)\
- virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2);\
- } else {\
- visual_server->m_type(p1, p2);\
- }\
- }
-
-
-
-
-#define FUNC3R(m_r,m_type,m_arg1, m_arg2, m_arg3)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2, p3);\
- }\
- }
-
-#define FUNC3RC(m_r,m_type,m_arg1, m_arg2, m_arg3)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3,&ret);\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2, p3);\
- }\
- }
-
-
-#define FUNC3S(m_type,m_arg1, m_arg2, m_arg3)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3);\
- } else {\
- visual_server->m_type(p1, p2, p3);\
- }\
- }
-
-#define FUNC3SC(m_type,m_arg1, m_arg2, m_arg3)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3);\
- } else {\
- visual_server->m_type(p1, p2, p3);\
- }\
- }
-
-
-#define FUNC3(m_type,m_arg1, m_arg2, m_arg3)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3);\
- } else {\
- visual_server->m_type(p1, p2, p3);\
- }\
- }
-
-#define FUNC3C(m_type,m_arg1, m_arg2, m_arg3)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3);\
- } else {\
- visual_server->m_type(p1, p2, p3);\
- }\
- }
-
-
-
-
-#define FUNC4R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2, p3, p4);\
- }\
- }
-
-#define FUNC4RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2, p3, p4);\
- }\
- }
-
-
-#define FUNC4S(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4);\
- }\
- }
-
-#define FUNC4SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4);\
- }\
- }
-
-
-#define FUNC4(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4);\
- }\
- }
-
-#define FUNC4C(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4);\
- }\
- }
-
-
-
-
-#define FUNC5R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2, p3, p4, p5);\
- }\
- }
-
-#define FUNC5RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2, p3, p4, p5);\
- }\
- }
-
-
-#define FUNC5S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5);\
- }\
- }
-
-#define FUNC5SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5);\
- }\
- }
-
-
-#define FUNC5(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5);\
- }\
- }
-
-#define FUNC5C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5);\
- }\
- }
-
-
-
-
-#define FUNC6R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2, p3, p4, p5, p6);\
- }\
- }
-
-#define FUNC6RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6,&ret);\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2, p3, p4, p5, p6);\
- }\
- }
-
-
-#define FUNC6S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5, p6);\
- }\
- }
-
-#define FUNC6SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5, p6);\
- }\
- }
-
-
-#define FUNC6(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5, p6);\
- }\
- }
-
-#define FUNC6C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5, p6);\
- }\
- }
-
-
-
-
-#define FUNC7R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
- }\
- }
-
-#define FUNC7RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
- virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- m_r ret;\
- command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7,&ret);\
- SYNC_DEBUG\
- return ret;\
- } else {\
- return visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
- }\
- }
-
-
-#define FUNC7S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
- }\
- }
-
-#define FUNC7SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
- }\
- }
-
-
-#define FUNC7(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
- }\
- }
-
-#define FUNC7C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
- virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
- if (Thread::get_caller_ID()!=server_thread) {\
- command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
- } else {\
- visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
- }\
- }
-
-
-
+#define ServerName VisualServer
+#define ServerNameWrapMT VisualServerWrapMT
+#define server_name visual_server
+#include "servers/server_wrap_mt_common.h"
//FUNC0R(RID,texture_create);
FUNCRID(texture);
@@ -1170,6 +626,8 @@ public:
FUNC2(canvas_light_set_shadow_enabled,RID,bool);
FUNC2(canvas_light_set_shadow_buffer_size,RID,int);
FUNC2(canvas_light_set_shadow_esm_multiplier,RID,float);
+ FUNC2(canvas_light_set_shadow_color,RID,const Color&);
+
/* CANVAS OCCLUDER */
@@ -1225,7 +683,7 @@ public:
virtual void init();
virtual void finish();
virtual void draw();
- virtual void flush();
+ virtual void sync();
FUNC0RC(bool,has_changed);
/* RENDER INFO */
@@ -1233,7 +691,7 @@ public:
FUNC1R(int,get_render_info,RenderInfo );
virtual bool has_feature(Features p_feature) const { return visual_server->has_feature(p_feature); }
- FUNC2(set_boot_image,const Image& , const Color& );
+ FUNC3(set_boot_image,const Image& , const Color&,bool );
FUNC1(set_default_clear_color,const Color& );
FUNC0R(RID,get_test_cube );
@@ -1242,7 +700,15 @@ public:
VisualServerWrapMT(VisualServer* p_contained,bool p_create_thread);
~VisualServerWrapMT();
+#undef ServerName
+#undef ServerNameWrapMT
+#undef server_name
+
};
+#ifdef DEBUG_SYNC
+#undef DEBUG_SYNC
+#endif
+#undef SYNC_DEBUG
#endif
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index 5ddfaf7967..25e6a68469 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -130,6 +130,24 @@ RID VisualServer::get_test_texture() {
return test_texture;
};
+void VisualServer::_free_internal_rids() {
+
+ if (test_texture.is_valid())
+ free(test_texture);
+ if (white_texture.is_valid())
+ free(white_texture);
+ if (test_material.is_valid())
+ free(test_material);
+
+ for(int i=0;i<16;i++) {
+ if (material_2d[i].is_valid())
+ free(material_2d[i]);
+ }
+
+
+
+}
+
RID VisualServer::_make_test_cube() {
DVector<Vector3> vertices;
@@ -146,7 +164,6 @@ RID VisualServer::_make_test_cube() {
tangents.push_back( normal_points[m_idx][0] );\
tangents.push_back( 1.0 );\
uvs.push_back( Vector3(uv_points[m_idx*2+0],uv_points[m_idx*2+1],0) );\
- print_line(itos( (face_points[m_idx][0]>0?1:0)|(face_points[m_idx][1]>0?2:0)|(face_points[m_idx][2]>0?4:0)));\
vtx_idx++;\
for (int i=0;i<6;i++) {
@@ -203,16 +220,17 @@ RID VisualServer::_make_test_cube() {
mesh_add_surface( test_cube, PRIMITIVE_TRIANGLES,d );
- RID material = fixed_material_create();
+
+ test_material = fixed_material_create();
//material_set_flag(material, MATERIAL_FLAG_BILLBOARD_TOGGLE,true);
- fixed_material_set_texture( material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() );
- fixed_material_set_param( material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 );
- fixed_material_set_param( material, FIXED_MATERIAL_PARAM_EMISSION, Vector3(0.2,0.2,0.2) );
+ fixed_material_set_texture( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() );
+ fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 );
+ fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) );
- fixed_material_set_param( material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) );
- fixed_material_set_param( material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) );
+ fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) );
+ fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) );
- mesh_surface_set_material(test_cube, 0, material );
+ mesh_surface_set_material(test_cube, 0, test_material );
return test_cube;
}
@@ -536,7 +554,7 @@ void VisualServer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("mesh_add_surface_from_planes"),&VisualServer::mesh_add_surface_from_planes);
ObjectTypeDB::bind_method(_MD("draw"),&VisualServer::draw);
- ObjectTypeDB::bind_method(_MD("flush"),&VisualServer::flush);
+ ObjectTypeDB::bind_method(_MD("sync"),&VisualServer::sync);
ObjectTypeDB::bind_method(_MD("free"),&VisualServer::free);
ObjectTypeDB::bind_method(_MD("set_default_clear_color"),&VisualServer::set_default_clear_color);
diff --git a/servers/visual_server.h b/servers/visual_server.h
index e9425afbab..dd71650801 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -55,8 +55,10 @@ class VisualServer : public Object {
void _canvas_item_add_style_box(RID p_item, const Rect2& p_rect, RID p_texture,const Vector<float>& p_margins, const Color& p_modulate=Color(1,1,1));
protected:
RID _make_test_cube();
+ void _free_internal_rids();
RID test_texture;
RID white_texture;
+ RID test_material;
RID material_2d[16];
static VisualServer* (*create_func)();
@@ -102,6 +104,7 @@ public:
TEXTURE_FLAG_FILTER=4, /// Create texure with linear (or available) filter
TEXTURE_FLAG_ANISOTROPIC_FILTER=8,
TEXTURE_FLAG_CONVERT_TO_LINEAR=16,
+ TEXTURE_FLAG_MIRRORED_REPEAT=32, /// Repeat texture, with alternate sections mirrored
TEXTURE_FLAG_CUBEMAP=2048,
TEXTURE_FLAG_VIDEO_SURFACE=4096,
TEXTURE_FLAGS_DEFAULT=TEXTURE_FLAG_REPEAT|TEXTURE_FLAG_MIPMAPS|TEXTURE_FLAG_FILTER
@@ -1030,6 +1033,7 @@ public:
virtual void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled)=0;
virtual void canvas_light_set_shadow_buffer_size(RID p_light, int p_size)=0;
virtual void canvas_light_set_shadow_esm_multiplier(RID p_light, float p_multiplier)=0;
+ virtual void canvas_light_set_shadow_color(RID p_light, const Color& p_color)=0;
@@ -1095,7 +1099,7 @@ public:
/* EVENT QUEUING */
virtual void draw()=0;
- virtual void flush()=0;
+ virtual void sync()=0;
virtual bool has_changed() const=0;
virtual void init()=0;
virtual void finish()=0;
@@ -1137,7 +1141,7 @@ public:
virtual void mesh_add_surface_from_mesh_data( RID p_mesh, const Geometry::MeshData& p_mesh_data);
virtual void mesh_add_surface_from_planes( RID p_mesh, const DVector<Plane>& p_planes);
- virtual void set_boot_image(const Image& p_image, const Color& p_color)=0;
+ 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;
enum Features {