summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/bind/core_bind.cpp74
-rw-r--r--core/bind/core_bind.h46
-rw-r--r--core/register_core_types.cpp6
-rw-r--r--doc/classes/AudioStreamPlayer3D.xml32
-rw-r--r--servers/physics_2d/space_2d_sw.cpp12
-rw-r--r--servers/physics_2d/space_2d_sw.h6
6 files changed, 172 insertions, 4 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index ab9c107d7a..cfd7677d6b 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -33,6 +33,7 @@
#include "geometry.h"
#include "io/file_access_compressed.h"
#include "io/file_access_encrypted.h"
+#include "io/json.h"
#include "io/marshalls.h"
#include "os/keyboard.h"
#include "os/os.h"
@@ -2600,3 +2601,76 @@ _Engine *_Engine::singleton = NULL;
_Engine::_Engine() {
singleton = this;
}
+
+void JSONParseResult::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_error"), &JSONParseResult::get_error);
+ ClassDB::bind_method(D_METHOD("get_error_string"), &JSONParseResult::get_error_string);
+ ClassDB::bind_method(D_METHOD("get_error_line"), &JSONParseResult::get_error_line);
+ ClassDB::bind_method(D_METHOD("get_result"), &JSONParseResult::get_result);
+
+ ClassDB::bind_method(D_METHOD("set_error", "error"), &JSONParseResult::set_error);
+ ClassDB::bind_method(D_METHOD("set_error_string", "error_string"), &JSONParseResult::set_error_string);
+ ClassDB::bind_method(D_METHOD("set_error_line", "error_line"), &JSONParseResult::set_error_line);
+ ClassDB::bind_method(D_METHOD("set_result", "result"), &JSONParseResult::set_result);
+
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "error", PROPERTY_HINT_NONE, "Error", PROPERTY_USAGE_CLASS_IS_ENUM), "set_error", "get_error");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "error_string"), "set_error_string", "get_error_string");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "error_line"), "set_error_line", "get_error_line");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::NIL, "result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "set_result", "get_result");
+}
+
+void JSONParseResult::set_error(Error p_error) {
+ error = p_error;
+}
+
+Error JSONParseResult::get_error() const {
+ return error;
+}
+
+void JSONParseResult::set_error_string(const String &p_error_string) {
+ error_string = p_error_string;
+}
+
+String JSONParseResult::get_error_string() const {
+ return error_string;
+}
+
+void JSONParseResult::set_error_line(int p_error_line) {
+ error_line = p_error_line;
+}
+
+int JSONParseResult::get_error_line() const {
+ return error_line;
+}
+
+void JSONParseResult::set_result(const Variant &p_result) {
+ result = p_result;
+}
+
+Variant JSONParseResult::get_result() const {
+ return result;
+}
+
+void _JSON::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("print", "value"), &_JSON::print);
+ ClassDB::bind_method(D_METHOD("parse", "json"), &_JSON::parse);
+}
+
+String _JSON::print(const Variant &p_value) {
+ return JSON::print(p_value);
+}
+
+Ref<JSONParseResult> _JSON::parse(const String &p_json) {
+ Ref<JSONParseResult> result;
+ result.instance();
+
+ result->error = JSON::parse(p_json, result->result, result->error_string, result->error_line);
+
+ return result;
+}
+
+_JSON *_JSON::singleton = NULL;
+
+_JSON::_JSON() {
+ singleton = this;
+}
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index fc28ada0f8..721acf657f 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -669,4 +669,50 @@ public:
_Engine();
};
+class _JSON;
+
+class JSONParseResult : public Reference {
+ GDCLASS(JSONParseResult, Reference)
+
+ friend class _JSON;
+
+ Error error;
+ String error_string;
+ int error_line;
+
+ Variant result;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_error(Error p_error);
+ Error get_error() const;
+
+ void set_error_string(const String &p_error_string);
+ String get_error_string() const;
+
+ void set_error_line(int p_error_line);
+ int get_error_line() const;
+
+ void set_result(const Variant &p_result);
+ Variant get_result() const;
+};
+
+class _JSON : public Object {
+ GDCLASS(_JSON, Object)
+
+protected:
+ static void _bind_methods();
+ static _JSON *singleton;
+
+public:
+ static _JSON *get_singleton() { return singleton; }
+
+ String print(const Variant &p_value);
+ Ref<JSONParseResult> parse(const String &p_json);
+
+ _JSON();
+};
+
#endif // CORE_BIND_H
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 27c31127a4..0e34a3eea5 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -68,6 +68,7 @@ static _Engine *_engine = NULL;
static _ClassDB *_classdb = NULL;
static _Marshalls *_marshalls = NULL;
static TranslationLoaderPO *resource_format_po = NULL;
+static _JSON *_json = NULL;
static IP *ip = NULL;
@@ -162,6 +163,8 @@ void register_core_types() {
ClassDB::register_class<AStar>();
ClassDB::register_class<EncodedObjectAsID>();
+ ClassDB::register_class<JSONParseResult>();
+
ip = IP::create();
_geometry = memnew(_Geometry);
@@ -172,6 +175,7 @@ void register_core_types() {
_engine = memnew(_Engine);
_classdb = memnew(_ClassDB);
_marshalls = memnew(_Marshalls);
+ _json = memnew(_JSON);
}
void register_core_settings() {
@@ -193,6 +197,7 @@ void register_core_singletons() {
ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("TranslationServer", TranslationServer::get_singleton()));
ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Input", Input::get_singleton()));
ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("InputMap", InputMap::get_singleton()));
+ ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("JSON", _JSON::get_singleton()));
}
void unregister_core_types() {
@@ -203,6 +208,7 @@ void unregister_core_types() {
memdelete(_engine);
memdelete(_classdb);
memdelete(_marshalls);
+ memdelete(_json);
memdelete(_geometry);
diff --git a/doc/classes/AudioStreamPlayer3D.xml b/doc/classes/AudioStreamPlayer3D.xml
index 668e0cc0d2..3aad0ea87a 100644
--- a/doc/classes/AudioStreamPlayer3D.xml
+++ b/doc/classes/AudioStreamPlayer3D.xml
@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AudioStreamPlayer3D" inherits="Spatial" category="Core" version="3.0.alpha.custom_build">
<brief_description>
+ Plays 3D sound in 3D space
</brief_description>
<description>
+ Plays a sound effect with directed sound effects, dampens with distance if needed, generates effect of hearable position in space.
</description>
<tutorials>
+ http://docs.godotengine.org/en/latest/learning/features/audio/index.html
</tutorials>
<demos>
</demos>
@@ -123,6 +126,7 @@
<argument index="0" name="from_pos" type="float" default="0.0">
</argument>
<description>
+ Plays the audio from the given position 'from_pos', in seconds.
</description>
</method>
<method name="seek">
@@ -131,6 +135,7 @@
<argument index="0" name="to_pos" type="float">
</argument>
<description>
+ Sets the position from which audio will be played, in seconds.
</description>
</method>
<method name="set_area_mask">
@@ -265,67 +270,94 @@
<return type="void">
</return>
<description>
+ Stops the audio.
</description>
</method>
</methods>
<members>
<member name="area_mask" type="int" setter="set_area_mask" getter="get_area_mask">
+ Areas in which this sound plays.
</member>
<member name="attenuation_filter_cutoff_hz" type="float" setter="set_attenuation_filter_cutoff_hz" getter="get_attenuation_filter_cutoff_hz">
+ Dampens audio above this frequency, in Hz.
</member>
<member name="attenuation_filter_db" type="float" setter="set_attenuation_filter_db" getter="get_attenuation_filter_db">
+ Amount how much the filter affects the loudness, in dB.
</member>
<member name="attenuation_model" type="int" setter="set_attenuation_model" getter="get_attenuation_model" enum="AudioStreamPlayer3D.AttenuationModel">
+ Decides if audio should get quieter with distance linearly, quadratically or logarithmically.
</member>
<member name="autoplay" type="bool" setter="set_autoplay" getter="is_autoplay_enabled">
+ If [code]true[/code], audio plays audio plays when added to scene tree. Default value: [code]false[/code].
</member>
<member name="bus" type="String" setter="set_bus" getter="get_bus">
+ Bus on which this audio is playing.
</member>
<member name="doppler_tracking" type="int" setter="set_doppler_tracking" getter="get_doppler_tracking" enum="AudioStreamPlayer3D.DopplerTracking">
+ Decides in which step the Doppler effect should be calculated.
</member>
<member name="emission_angle_degrees" type="float" setter="set_emission_angle" getter="get_emission_angle">
+ The angle in which the audio reaches cameras undampened.
</member>
<member name="emission_angle_enabled" type="bool" setter="set_emission_angle_enabled" getter="is_emission_angle_enabled">
+ If [code]true[/code], the audio should be dampened according to the direction of the sound.
</member>
<member name="emission_angle_filter_attenuation_db" type="float" setter="set_emission_angle_filter_attenuation_db" getter="get_emission_angle_filter_attenuation_db">
+ dampens audio if camera is outside of 'emission_angle_degrees' and 'emission_angle_enabled' is set by this factor, in dB.
</member>
<member name="max_db" type="float" setter="set_max_db" getter="get_max_db">
+ Sets the absolute maximum of the soundlevel, in dB.
</member>
<member name="max_distance" type="float" setter="set_max_distance" getter="get_max_distance">
+ Sets the distance from wich the 'out_of_range_mode' takes effect. Has no effect if set to 0.
</member>
<member name="out_of_range_mode" type="int" setter="set_out_of_range_mode" getter="get_out_of_range_mode" enum="AudioStreamPlayer3D.OutOfRangeMode">
+ Decides if audio should pause when source is outside of 'max_distance' range.
</member>
<member name="playing" type="bool" setter="_set_playing" getter="is_playing">
+ If [code]true[/code], audio is playing.
</member>
<member name="stream" type="AudioStream" setter="set_stream" getter="get_stream">
+ The [AudioStream] object to be played.
</member>
<member name="unit_db" type="float" setter="set_unit_db" getter="get_unit_db">
+ Base sound level unaffected by dampening, in dB.
</member>
<member name="unit_size" type="float" setter="set_unit_size" getter="get_unit_size">
+ Factor for the attenuation effect.
</member>
</members>
<signals>
<signal name="finished">
<description>
+ Fires when the audio stops playing.
</description>
</signal>
</signals>
<constants>
<constant name="ATTENUATION_INVERSE_DISTANCE" value="0">
+ Linear dampening of loudness according to distance.
</constant>
<constant name="ATTENUATION_INVERSE_SQUARE_DISTANCE" value="1">
+ Squared dampening of loudness according to distance.
</constant>
<constant name="ATTENUATION_LOGARITHMIC" value="2">
+ Logarithmic dampening of loudness according to distance.
</constant>
<constant name="OUT_OF_RANGE_MIX" value="0">
+ Mix this audio in, even when it's out of range.
</constant>
<constant name="OUT_OF_RANGE_PAUSE" value="1">
+ Pause this audio when it gets out of range.
</constant>
<constant name="DOPPLER_TRACKING_DISABLED" value="0">
+ Disables doppler tracking.
</constant>
<constant name="DOPPLER_TRACKING_IDLE_STEP" value="1">
+ Executes doppler trackin in idle step.
</constant>
<constant name="DOPPLER_TRACKING_FIXED_STEP" value="2">
+ Executes doppler tracking in fixed step.
</constant>
</constants>
</class>
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index 779f0d54ac..8f22d1cd44 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -518,7 +518,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
body_aabb = body_aabb.grow(p_margin);
static const int max_excluded_shape_pairs = 32;
- Pair<Shape2DSW *, Shape2DSW *> excluded_shape_pairs[max_excluded_shape_pairs];
+ ExcludedShapeSW excluded_shape_pairs[max_excluded_shape_pairs];
int excluded_shape_pair_count = 0;
Transform2D body_transform = p_from;
@@ -577,7 +577,11 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (!collided && cbk.invalid_by_dir > 0) {
//this shape must be excluded
if (excluded_shape_pair_count < max_excluded_shape_pairs) {
- excluded_shape_pairs[excluded_shape_pair_count++] = Pair<Shape2DSW *, Shape2DSW *>(body_shape, against_shape);
+ ExcludedShapeSW esp;
+ esp.local_shape = body_shape;
+ esp.against_object = col_obj;
+ esp.against_shape_index = shape_idx;
+ excluded_shape_pairs[excluded_shape_pair_count++] = esp;
}
}
}
@@ -645,7 +649,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
for (int k = 0; k < excluded_shape_pair_count; k++) {
- if (excluded_shape_pairs[k].first == body_shape && excluded_shape_pairs[k].second == against_shape) {
+ if (excluded_shape_pairs[k].local_shape == body_shape && excluded_shape_pairs[k].against_object == col_obj && excluded_shape_pairs[k].against_shape_index == shape_idx) {
excluded = true;
break;
}
@@ -776,7 +780,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
bool excluded = false;
for (int k = 0; k < excluded_shape_pair_count; k++) {
- if (excluded_shape_pairs[k].first == body_shape && excluded_shape_pairs[k].second == against_shape) {
+ if (excluded_shape_pairs[k].local_shape == body_shape && excluded_shape_pairs[k].against_object == col_obj && excluded_shape_pairs[k].against_shape_index == shape_idx) {
excluded = true;
break;
}
diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h
index ed6136e372..c7e7497397 100644
--- a/servers/physics_2d/space_2d_sw.h
+++ b/servers/physics_2d/space_2d_sw.h
@@ -71,6 +71,12 @@ public:
};
private:
+ struct ExcludedShapeSW {
+ Shape2DSW *local_shape;
+ const CollisionObject2DSW *against_object;
+ int against_shape_index;
+ };
+
uint64_t elapsed_time[ELAPSED_TIME_MAX];
Physics2DDirectSpaceStateSW *direct_access;