summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/area_2d.cpp8
-rw-r--r--scene/2d/audio_stream_player_2d.cpp61
-rw-r--r--scene/2d/canvas_item.cpp1
-rw-r--r--scene/2d/line_builder.cpp55
-rw-r--r--scene/2d/path_2d.cpp3
-rw-r--r--scene/2d/physics_body_2d.cpp224
-rw-r--r--scene/2d/physics_body_2d.h52
-rw-r--r--scene/3d/arvr_nodes.cpp15
-rw-r--r--scene/3d/arvr_nodes.h2
-rw-r--r--scene/3d/audio_stream_player_3d.cpp156
-rw-r--r--scene/3d/audio_stream_player_3d.h4
-rw-r--r--scene/3d/bone_attachment.cpp6
-rw-r--r--scene/3d/collision_shape.cpp3
-rw-r--r--scene/3d/gi_probe.cpp19
-rw-r--r--scene/3d/interpolated_camera.cpp4
-rw-r--r--scene/3d/light.cpp9
-rw-r--r--scene/3d/navigation_mesh.cpp230
-rw-r--r--scene/3d/navigation_mesh.h81
-rw-r--r--scene/3d/path.cpp4
-rw-r--r--scene/3d/physics_body.cpp2
-rw-r--r--scene/3d/spatial.cpp2
-rw-r--r--scene/3d/vehicle_body.cpp8
-rw-r--r--scene/3d/vehicle_body.h2
-rw-r--r--scene/animation/animation_tree_player.cpp1
-rw-r--r--scene/audio/audio_player.cpp18
-rw-r--r--scene/gui/control.cpp2
-rw-r--r--scene/gui/dialogs.cpp2
-rw-r--r--scene/gui/file_dialog.cpp4
-rw-r--r--scene/gui/tree.cpp21
-rw-r--r--scene/gui/tree.h4
-rwxr-xr-xscene/main/node.cpp28
-rw-r--r--scene/main/scene_tree.cpp1
-rw-r--r--scene/main/viewport.cpp3
-rw-r--r--scene/register_scene_types.cpp1
-rw-r--r--scene/resources/curve.cpp34
-rw-r--r--scene/resources/default_theme/default_theme.cpp2
-rw-r--r--scene/resources/material.cpp8
-rw-r--r--scene/resources/mesh.cpp4
-rw-r--r--scene/resources/mesh.h3
-rw-r--r--scene/resources/packed_scene.cpp8
-rw-r--r--scene/resources/primitive_meshes.cpp19
-rw-r--r--scene/resources/primitive_meshes.h3
42 files changed, 754 insertions, 363 deletions
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 1124904963..9fc6c8d23a 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -596,7 +596,7 @@ void Area2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("_area_enter_tree", "id"), &Area2D::_area_enter_tree);
ClassDB::bind_method(D_METHOD("_area_exit_tree", "id"), &Area2D::_area_exit_tree);
- ClassDB::bind_method(D_METHOD("set_space_override_mode", "enable"), &Area2D::set_space_override_mode);
+ ClassDB::bind_method(D_METHOD("set_space_override_mode", "space_override_mode"), &Area2D::set_space_override_mode);
ClassDB::bind_method(D_METHOD("get_space_override_mode"), &Area2D::get_space_override_mode);
ClassDB::bind_method(D_METHOD("set_gravity_is_point", "enable"), &Area2D::set_gravity_is_point);
@@ -680,6 +680,12 @@ void Area2D::_bind_methods() {
ADD_GROUP("Audio Bus", "audio_bus_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_bus_override"), "set_audio_bus_override", "is_overriding_audio_bus");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "audio_bus_name", PROPERTY_HINT_ENUM, ""), "set_audio_bus", "get_audio_bus");
+
+ BIND_ENUM_CONSTANT(SPACE_OVERRIDE_DISABLED);
+ BIND_ENUM_CONSTANT(SPACE_OVERRIDE_COMBINE);
+ BIND_ENUM_CONSTANT(SPACE_OVERRIDE_COMBINE_REPLACE);
+ BIND_ENUM_CONSTANT(SPACE_OVERRIDE_REPLACE);
+ BIND_ENUM_CONSTANT(SPACE_OVERRIDE_REPLACE_COMBINE);
}
Area2D::Area2D()
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index ea2e77fc47..b6abe90035 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -57,52 +57,32 @@ void AudioStreamPlayer2D::_mix_audio() {
AudioFrame vol_inc = (current.vol - prev_outputs[i].vol) / float(buffer_size);
AudioFrame vol = current.vol;
- switch (AudioServer::get_singleton()->get_speaker_mode()) {
+ int cc = AudioServer::get_singleton()->get_channel_count();
- case AudioServer::SPEAKER_MODE_STEREO: {
- AudioFrame *target = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, 0);
+ if (cc == 1) {
+ AudioFrame *target = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, 0);
- for (int j = 0; j < buffer_size; j++) {
+ for (int j = 0; j < buffer_size; j++) {
- target[j] += buffer[j] * vol;
- vol += vol_inc;
- }
-
- } break;
- case AudioServer::SPEAKER_SURROUND_51: {
-
- AudioFrame *targets[2] = {
- AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, 1),
- AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, 2),
- };
-
- for (int j = 0; j < buffer_size; j++) {
-
- AudioFrame frame = buffer[j] * vol;
- targets[0][j] += frame;
- targets[1][j] += frame;
- vol += vol_inc;
- }
+ target[j] += buffer[j] * vol;
+ vol += vol_inc;
+ }
- } break;
- case AudioServer::SPEAKER_SURROUND_71: {
+ } else {
+ AudioFrame *targets[4];
- AudioFrame *targets[3] = {
- AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, 1),
- AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, 2),
- AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, 3)
- };
+ for (int k = 0; k < cc; k++) {
+ targets[k] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, k);
+ }
- for (int j = 0; j < buffer_size; j++) {
+ for (int j = 0; j < buffer_size; j++) {
- AudioFrame frame = buffer[j] * vol;
- targets[0][j] += frame;
- targets[1][j] += frame;
- targets[2][j] += frame;
- vol += vol_inc;
+ AudioFrame frame = buffer[j] * vol;
+ for (int k = 0; k < cc; k++) {
+ targets[k][j] += frame;
}
-
- } break;
+ vol += vol_inc;
+ }
}
prev_outputs[i] = current;
@@ -254,8 +234,6 @@ void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) {
stream.unref();
ERR_FAIL_COND(stream_playback.is_null());
}
-
-
}
Ref<AudioStream> AudioStreamPlayer2D::get_stream() const {
@@ -441,7 +419,7 @@ void AudioStreamPlayer2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE, "-80,24"), "set_volume_db", "get_volume_db");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "is_playing");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_RANGE, "1,65536,1"), "set_max_distance", "get_max_distance");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "attenuation", PROPERTY_HINT_EXP_EASING), "set_attenuation", "get_attenuation");
@@ -449,7 +427,6 @@ void AudioStreamPlayer2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "area_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_area_mask", "get_area_mask");
ADD_SIGNAL(MethodInfo("finished"));
-
}
AudioStreamPlayer2D::AudioStreamPlayer2D() {
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index a7c5d1adbb..ec1ea7df38 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -338,7 +338,6 @@ void CanvasItem::_update_callback() {
notification(NOTIFICATION_DRAW);
emit_signal(SceneStringNames::get_singleton()->draw);
if (get_script_instance()) {
- Variant::CallError err;
get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_draw, NULL, 0);
}
drawing = false;
diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp
index 1235013af4..53db30e3ce 100644
--- a/scene/2d/line_builder.cpp
+++ b/scene/2d/line_builder.cpp
@@ -173,13 +173,15 @@ void LineBuilder::build() {
strip_begin(pos_up0, pos_down0, color0, uvx0);
- // pos_up0 ------------- pos_up1 --------------------
- // | |
- // pos0 - - - - - - - - - pos1 - - - - - - - - - pos2
- // | |
- // pos_down0 ------------ pos_down1 ------------------
- //
- // i-1 i i+1
+ /*
+ * pos_up0 ------------- pos_up1 --------------------
+ * | |
+ * pos0 - - - - - - - - - pos1 - - - - - - - - - pos2
+ * | |
+ * pos_down0 ------------ pos_down1 ------------------
+ *
+ * i-1 i i+1
+ */
// http://labs.hyperandroid.com/tag/opengl-lines
// (not the same implementation but visuals help a lot)
@@ -206,17 +208,19 @@ void LineBuilder::build() {
inner_normal1 = -u1 * hw;
}
- // ---------------------------
- // /
- // 0 / 1
- // / /
- // --------------------x------ /
- // / / (here shown with orientation == DOWN)
- // / /
- // / /
- // / /
- // 2 /
- // /
+ /*
+ * ---------------------------
+ * /
+ * 0 / 1
+ * / /
+ * --------------------x------ /
+ * / / (here shown with orientation == DOWN)
+ * / /
+ * / /
+ * / /
+ * 2 /
+ * /
+ */
// Find inner intersection at the joint
Vector2 corner_pos_in, corner_pos_out;
@@ -315,13 +319,14 @@ void LineBuilder::build() {
// Add joint geometry
if (current_joint_mode != LINE_JOINT_SHARP) {
- // ________________ cbegin
- // / \
- // / \
- // ____________/_ _ _\ cend
- // | |
- // | |
- // | |
+ /* ________________ cbegin
+ * / \
+ * / \
+ * ____________/_ _ _\ cend
+ * | |
+ * | |
+ * | |
+ */
Vector2 cbegin, cend;
if (orientation == UP) {
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 1d7bd8fc2a..9bd5576d91 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -137,7 +137,8 @@ void PathFollow2D::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- if ((path = Object::cast_to<Path2D>(get_parent()))) {
+ path = Object::cast_to<Path2D>(get_parent());
+ if (path) {
_update_transform();
}
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index b1eb2ba267..c6cd3677cd 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -955,35 +955,25 @@ RigidBody2D::~RigidBody2D() {
//////////////////////////
-Dictionary KinematicBody2D::_move(const Vector2 &p_motion) {
+Ref<KinematicCollision2D> KinematicBody2D::_move(const Vector2 &p_motion) {
Collision col;
- if (move(p_motion, col)) {
- Dictionary d;
- d["position"] = col.collision;
- d["normal"] = col.normal;
- d["local_shape"] = col.local_shape;
- d["travel"] = col.travel;
- d["remainder"] = col.remainder;
- d["collider_id"] = col.collider;
- d["collider_velocity"] = col.collider_vel;
- if (col.collider) {
- d["collider"] = ObjectDB::get_instance(col.collider);
- } else {
- d["collider"] = Variant();
- }
- d["collider_shape_index"] = col.collider_shape;
- d["collider_metadata"] = col.collider_metadata;
+ if (move_and_collide(p_motion, col)) {
+ if (motion_cache.is_null()) {
+ motion_cache.instance();
+ motion_cache->owner = this;
+ }
- return d;
+ motion_cache->collision = col;
- } else {
- return Dictionary();
+ return motion_cache;
}
+
+ return Ref<KinematicCollision2D>();
}
-bool KinematicBody2D::move(const Vector2 &p_motion, Collision &r_collision) {
+bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, Collision &r_collision) {
Transform2D gt = get_global_transform();
Physics2DServer::MotionResult result;
@@ -1007,7 +997,7 @@ bool KinematicBody2D::move(const Vector2 &p_motion, Collision &r_collision) {
return colliding;
}
-Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_floor_direction, float p_slope_stop_min_velocity, int p_max_bounces, float p_floor_max_angle) {
+Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_floor_direction, float p_slope_stop_min_velocity, int p_max_slides, float p_floor_max_angle) {
Vector2 motion = (floor_velocity + p_linear_velocity) * get_fixed_process_delta_time();
Vector2 lv = p_linear_velocity;
@@ -1018,11 +1008,11 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
colliders.clear();
floor_velocity = Vector2();
- while (p_max_bounces) {
+ while (p_max_slides) {
Collision collision;
- bool collided = move(motion, collision);
+ bool collided = move_and_collide(motion, collision);
if (collided) {
@@ -1060,7 +1050,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
break;
}
- p_max_bounces--;
+ p_max_slides--;
if (motion == Vector2())
break;
}
@@ -1103,75 +1093,35 @@ float KinematicBody2D::get_safe_margin() const {
return margin;
}
-int KinematicBody2D::get_collision_count() const {
+int KinematicBody2D::get_slide_count() const {
return colliders.size();
}
-Vector2 KinematicBody2D::get_collision_position(int p_collision) const {
-
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector2());
- return colliders[p_collision].collision;
-}
-Vector2 KinematicBody2D::get_collision_normal(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector2());
- return colliders[p_collision].normal;
+KinematicBody2D::Collision KinematicBody2D::get_slide_collision(int p_bounce) const {
+ ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Collision());
+ return colliders[p_bounce];
}
-Vector2 KinematicBody2D::get_collision_travel(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector2());
- return colliders[p_collision].travel;
-}
-Vector2 KinematicBody2D::get_collision_remainder(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector2());
- return colliders[p_collision].remainder;
-}
-Object *KinematicBody2D::get_collision_local_shape(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
- uint32_t owner = shape_find_owner(colliders[p_collision].local_shape);
- return shape_owner_get_owner(owner);
-}
-Object *KinematicBody2D::get_collision_collider(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
+Ref<KinematicCollision2D> KinematicBody2D::_get_slide_collision(int p_bounce) {
- if (colliders[p_collision].collider) {
- return ObjectDB::get_instance(colliders[p_collision].collider);
+ ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Ref<KinematicCollision2D>());
+ if (p_bounce >= slide_colliders.size()) {
+ slide_colliders.resize(p_bounce + 1);
}
- return NULL;
-}
-ObjectID KinematicBody2D::get_collision_collider_id(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), 0);
-
- return colliders[p_collision].collider;
-}
-Object *KinematicBody2D::get_collision_collider_shape(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
- Object *collider = get_collision_collider(p_collision);
- CollisionObject2D *obj2d = Object::cast_to<CollisionObject2D>(collider);
- if (obj2d) {
- uint32_t owner = shape_find_owner(colliders[p_collision].collider_shape);
- return obj2d->shape_owner_get_owner(owner);
+ if (slide_colliders[p_bounce].is_null()) {
+ slide_colliders[p_bounce].instance();
+ slide_colliders[p_bounce]->owner = this;
}
- return NULL;
-}
-int KinematicBody2D::get_collision_collider_shape_index(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), -1);
- return colliders[p_collision].collider_shape;
-}
-Vector2 KinematicBody2D::get_collision_collider_velocity(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector2());
- return colliders[p_collision].collider_vel;
-}
-Variant KinematicBody2D::get_collision_collider_metadata(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Variant());
- return colliders[p_collision].collider_metadata;
+ slide_colliders[p_bounce]->collision = colliders[p_bounce];
+ return slide_colliders[p_bounce];
}
void KinematicBody2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("move", "rel_vec"), &KinematicBody2D::_move);
+ ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec"), &KinematicBody2D::_move);
ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "slope_stop_min_velocity", "max_bounces", "floor_max_angle"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(5), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)));
ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec"), &KinematicBody2D::test_move);
@@ -1184,18 +1134,8 @@ void KinematicBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_safe_margin", "pixels"), &KinematicBody2D::set_safe_margin);
ClassDB::bind_method(D_METHOD("get_safe_margin"), &KinematicBody2D::get_safe_margin);
- ClassDB::bind_method(D_METHOD("get_collision_count"), &KinematicBody2D::get_collision_count);
- ClassDB::bind_method(D_METHOD("get_collision_position", "collision"), &KinematicBody2D::get_collision_position);
- ClassDB::bind_method(D_METHOD("get_collision_normal", "collision"), &KinematicBody2D::get_collision_normal);
- ClassDB::bind_method(D_METHOD("get_collision_travel", "collision"), &KinematicBody2D::get_collision_travel);
- ClassDB::bind_method(D_METHOD("get_collision_remainder", "collision"), &KinematicBody2D::get_collision_remainder);
- ClassDB::bind_method(D_METHOD("get_collision_local_shape", "collision"), &KinematicBody2D::get_collision_local_shape);
- ClassDB::bind_method(D_METHOD("get_collision_collider", "collision"), &KinematicBody2D::get_collision_collider);
- ClassDB::bind_method(D_METHOD("get_collision_collider_id", "collision"), &KinematicBody2D::get_collision_collider_id);
- ClassDB::bind_method(D_METHOD("get_collision_collider_shape", "collision"), &KinematicBody2D::get_collision_collider_shape);
- ClassDB::bind_method(D_METHOD("get_collision_collider_shape_index", "collision"), &KinematicBody2D::get_collision_collider_shape_index);
- ClassDB::bind_method(D_METHOD("get_collision_collider_velocity", "collision"), &KinematicBody2D::get_collision_collider_velocity);
- ClassDB::bind_method(D_METHOD("get_collision_collider_metadata", "collision"), &KinematicBody2D::get_collision_collider_metadata);
+ ClassDB::bind_method(D_METHOD("get_slide_count"), &KinematicBody2D::get_slide_count);
+ ClassDB::bind_method(D_METHOD("get_slide_collision", "slide_idx"), &KinematicBody2D::_get_slide_collision);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision/safe_margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_safe_margin", "get_safe_margin");
}
@@ -1210,4 +1150,106 @@ KinematicBody2D::KinematicBody2D()
on_wall = false;
}
KinematicBody2D::~KinematicBody2D() {
+ if (motion_cache.is_valid()) {
+ motion_cache->owner = NULL;
+ }
+
+ for (int i = 0; i < slide_colliders.size(); i++) {
+ if (slide_colliders[i].is_valid()) {
+ slide_colliders[i]->owner = NULL;
+ }
+ }
+}
+
+////////////////////////
+
+Vector2 KinematicCollision2D::get_position() const {
+
+ return collision.collision;
+}
+Vector2 KinematicCollision2D::get_normal() const {
+ return collision.normal;
+}
+Vector2 KinematicCollision2D::get_travel() const {
+ return collision.travel;
+}
+Vector2 KinematicCollision2D::get_remainder() const {
+ return collision.remainder;
+}
+Object *KinematicCollision2D::get_local_shape() const {
+ ERR_FAIL_COND_V(!owner, NULL);
+ uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
+ return owner->shape_owner_get_owner(ownerid);
+}
+
+Object *KinematicCollision2D::get_collider() const {
+
+ if (collision.collider) {
+ return ObjectDB::get_instance(collision.collider);
+ }
+
+ return NULL;
+}
+ObjectID KinematicCollision2D::get_collider_id() const {
+
+ return collision.collider;
+}
+Object *KinematicCollision2D::get_collider_shape() const {
+
+ Object *collider = get_collider();
+ if (collider) {
+ CollisionObject2D *obj2d = Object::cast_to<CollisionObject2D>(collider);
+ if (obj2d) {
+ uint32_t ownerid = obj2d->shape_find_owner(collision.collider_shape);
+ return obj2d->shape_owner_get_owner(ownerid);
+ }
+ }
+
+ return NULL;
+}
+int KinematicCollision2D::get_collider_shape_index() const {
+
+ return collision.collider_shape;
+}
+Vector2 KinematicCollision2D::get_collider_velocity() const {
+
+ return collision.collider_vel;
+}
+Variant KinematicCollision2D::get_collider_metadata() const {
+
+ return Variant();
+}
+
+void KinematicCollision2D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("get_position"), &KinematicCollision2D::get_position);
+ ClassDB::bind_method(D_METHOD("get_normal"), &KinematicCollision2D::get_normal);
+ ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision2D::get_travel);
+ ClassDB::bind_method(D_METHOD("get_remainder"), &KinematicCollision2D::get_remainder);
+ ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision2D::get_local_shape);
+ ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision2D::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision2D::get_collider_id);
+ ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision2D::get_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision2D::get_collider_shape_index);
+ ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision2D::get_collider_velocity);
+ ClassDB::bind_method(D_METHOD("get_collider_metadata"), &KinematicCollision2D::get_collider_metadata);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "", "get_position");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "normal"), "", "get_normal");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "travel"), "", "get_travel");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "remainder"), "", "get_remainder");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "local_shape"), "", "get_local_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider"), "", "get_collider");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider_shape"), "", "get_collider_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape_index"), "", "get_collider_shape_index");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "collider_velocity"), "", "get_collider_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::NIL, "collider_metadata", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "", "get_collider_metadata");
+}
+
+KinematicCollision2D::KinematicCollision2D() {
+ collision.collider = 0;
+ collision.collider_shape = 0;
+ collision.local_shape = 0;
+ owner = NULL;
}
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 1a4b0c0f5c..b82771a8f4 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -34,6 +34,8 @@
#include "servers/physics_2d_server.h"
#include "vset.h"
+class KinematicCollision2D;
+
class PhysicsBody2D : public CollisionObject2D {
GDCLASS(PhysicsBody2D, CollisionObject2D);
@@ -288,42 +290,62 @@ private:
bool on_ceiling;
bool on_wall;
Vector<Collision> colliders;
+ Vector<Ref<KinematicCollision2D> > slide_colliders;
+ Ref<KinematicCollision2D> motion_cache;
_FORCE_INLINE_ bool _ignores_mode(Physics2DServer::BodyMode) const;
- Dictionary _move(const Vector2 &p_motion);
+ Ref<KinematicCollision2D> _move(const Vector2 &p_motion);
+ Ref<KinematicCollision2D> _get_slide_collision(int p_bounce);
protected:
static void _bind_methods();
public:
- bool move(const Vector2 &p_motion, Collision &r_collision);
+ bool move_and_collide(const Vector2 &p_motion, Collision &r_collision);
bool test_move(const Transform2D &p_from, const Vector2 &p_motion);
void set_safe_margin(float p_margin);
float get_safe_margin() const;
- Vector2 move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_floor_direction = Vector2(0, 0), float p_slope_stop_min_velocity = 5, int p_max_bounces = 4, float p_floor_max_angle = Math::deg2rad((float)45));
+ Vector2 move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_floor_direction = Vector2(0, 0), float p_slope_stop_min_velocity = 5, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45));
bool is_on_floor() const;
bool is_on_wall() const;
bool is_on_ceiling() const;
Vector2 get_floor_velocity() const;
- int get_collision_count() const;
- Vector2 get_collision_position(int p_collision) const;
- Vector2 get_collision_normal(int p_collision) const;
- Vector2 get_collision_travel(int p_collision) const;
- Vector2 get_collision_remainder(int p_collision) const;
- Object *get_collision_local_shape(int p_collision) const;
- Object *get_collision_collider(int p_collision) const;
- ObjectID get_collision_collider_id(int p_collision) const;
- Object *get_collision_collider_shape(int p_collision) const;
- int get_collision_collider_shape_index(int p_collision) const;
- Vector2 get_collision_collider_velocity(int p_collision) const;
- Variant get_collision_collider_metadata(int p_collision) const;
+ int get_slide_count() const;
+ Collision get_slide_collision(int p_bounce) const;
KinematicBody2D();
~KinematicBody2D();
};
+class KinematicCollision2D : public Reference {
+
+ GDCLASS(KinematicCollision2D, Reference);
+
+ KinematicBody2D *owner;
+ friend class KinematicBody2D;
+ KinematicBody2D::Collision collision;
+
+protected:
+ static void _bind_methods();
+
+public:
+ Vector2 get_position() const;
+ Vector2 get_normal() const;
+ Vector2 get_travel() const;
+ Vector2 get_remainder() const;
+ Object *get_local_shape() const;
+ Object *get_collider() const;
+ ObjectID get_collider_id() const;
+ Object *get_collider_shape() const;
+ int get_collider_shape_index() const;
+ Vector2 get_collider_velocity() const;
+ Variant get_collider_metadata() const;
+
+ KinematicCollision2D();
+};
+
#endif // PHYSICS_BODY_2D_H
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index caf313190b..966dd88a2c 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -31,7 +31,6 @@
#include "arvr_nodes.h"
#include "core/os/input.h"
#include "servers/arvr/arvr_interface.h"
-#include "servers/arvr/arvr_positional_tracker.h"
#include "servers/arvr_server.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -142,6 +141,7 @@ void ARVRController::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_joystick_axis", "axis"), &ARVRController::get_joystick_axis);
ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRController::get_is_active);
+ ClassDB::bind_method(D_METHOD("get_hand"), &ARVRController::get_hand);
ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::INT, "button")));
ADD_SIGNAL(MethodInfo("button_release", PropertyInfo(Variant::INT, "button")));
@@ -204,6 +204,19 @@ bool ARVRController::get_is_active() const {
return is_active;
};
+ARVRPositionalTracker::TrackerHand ARVRController::get_hand() const {
+ // get our ARVRServer
+ ARVRServer *arvr_server = ARVRServer::get_singleton();
+ ERR_FAIL_NULL_V(arvr_server, ARVRPositionalTracker::TRACKER_HAND_UNKNOWN);
+
+ ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
+ if (tracker == NULL) {
+ return ARVRPositionalTracker::TRACKER_HAND_UNKNOWN;
+ };
+
+ return tracker->get_hand();
+};
+
String ARVRController::get_configuration_warning() const {
if (!is_visible() || !is_inside_tree())
return String();
diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h
index 4c14be71b5..5269ec0248 100644
--- a/scene/3d/arvr_nodes.h
+++ b/scene/3d/arvr_nodes.h
@@ -33,6 +33,7 @@
#include "scene/3d/camera.h"
#include "scene/3d/spatial.h"
+#include "servers/arvr/arvr_positional_tracker.h"
/**
@author Bastiaan Olij <mux213@gmail.com>
@@ -84,6 +85,7 @@ public:
float get_joystick_axis(int p_axis) const;
bool get_is_active() const;
+ ARVRPositionalTracker::TrackerHand get_hand() const;
String get_configuration_warning() const;
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index 2073ebf94e..b8c6a86f55 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -72,34 +72,13 @@ void AudioStreamPlayer3D::_mix_audio() {
//mix!
- int buffers = 0;
- int first = 0;
-
- switch (AudioServer::get_singleton()->get_speaker_mode()) {
-
- case AudioServer::SPEAKER_MODE_STEREO: {
- buffers = 1;
- first = 0;
-
- } break;
- case AudioServer::SPEAKER_SURROUND_51: {
- buffers = 2;
- first = 1;
-
- } break;
- case AudioServer::SPEAKER_SURROUND_71: {
-
- buffers = 3;
- first = 1;
-
- } break;
- }
+ int buffers = AudioServer::get_singleton()->get_channel_count();
for (int k = 0; k < buffers; k++) {
AudioFrame vol_inc = (current.vol[k] - prev_outputs[i].vol[k]) / float(buffer_size);
AudioFrame vol = current.vol[k];
- AudioFrame *target = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, first + k);
+ AudioFrame *target = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, k);
current.filter.set_mode(AudioFilterSW::HIGHSHELF);
current.filter.set_sampling_rate(AudioServer::get_singleton()->get_mix_rate());
@@ -146,7 +125,7 @@ void AudioStreamPlayer3D::_mix_audio() {
if (current.reverb_bus_index >= 0) {
- AudioFrame *rtarget = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.reverb_bus_index, first + k);
+ AudioFrame *rtarget = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.reverb_bus_index, k);
if (current.reverb_bus_index == prev_outputs[i].reverb_bus_index) {
AudioFrame rvol_inc = (current.reverb_vol[k] - prev_outputs[i].reverb_vol[k]) / float(buffer_size);
@@ -341,49 +320,57 @@ void AudioStreamPlayer3D::_notification(int p_what) {
flat_pos.y = 0;
flat_pos.normalize();
- switch (AudioServer::get_singleton()->get_speaker_mode()) {
+ unsigned int cc = AudioServer::get_singleton()->get_channel_count();
+ if (cc == 1) {
+ // Stereo pair
+ float c = flat_pos.x * 0.5 + 0.5;
- case AudioServer::SPEAKER_MODE_STEREO: {
-
- float c = flat_pos.x * 0.5 + 0.5;
- output.vol[0].l = 1.0 - c;
- output.vol[0].r = c;
-
- output.vol[0] *= multiplier;
+ output.vol[0].l = 1.0 - c;
+ output.vol[0].r = c;
+ } else {
+ Vector3 camtopos = global_pos - camera->get_global_transform().origin;
+ float c = camtopos.normalized().dot(get_global_transform().basis.get_axis(2).normalized()); //it's z negative
+ float angle = Math::rad2deg(Math::acos(c));
+ float av = angle * (flat_pos.x < 0 ? -1 : 1) / 180.0;
- } break;
- case AudioServer::SPEAKER_SURROUND_51: {
+ if (cc >= 1) {
+ // Stereo pair
+ float fl = Math::abs(1.0 - Math::abs(-0.8 - av));
+ float fr = Math::abs(1.0 - Math::abs(0.8 - av));
- float xl = Vector3(-1, 0, -1).normalized().dot(flat_pos) * 0.5 + 0.5;
- float xr = Vector3(1, 0, -1).normalized().dot(flat_pos) * 0.5 + 0.5;
+ output.vol[0].l = fl;
+ output.vol[0].r = fr;
+ }
- output.vol[0].l = xl;
- output.vol[1].r = 1.0 - xl;
- output.vol[0].r = xr;
- output.vol[1].l = 1.0 - xr;
+ if (cc >= 2) {
+ // Center pair
+ float center = 1.0 - Math::sin(Math::acos(c));
- output.vol[0] *= multiplier;
- output.vol[1] *= multiplier;
- } break;
- case AudioServer::SPEAKER_SURROUND_71: {
+ output.vol[1].l = center;
+ output.vol[1].r = center;
+ }
- float xl = Vector3(-1, 0, -1).normalized().dot(flat_pos) * 0.5 + 0.5;
- float xr = Vector3(1, 0, -1).normalized().dot(flat_pos) * 0.5 + 0.5;
+ if (cc >= 3) {
+ // Side pair
+ float sl = Math::abs(1.0 - Math::abs(-0.4 - av));
+ float sr = Math::abs(1.0 - Math::abs(0.4 - av));
- output.vol[0].l = xl;
- output.vol[1].r = 1.0 - xl;
- output.vol[0].r = xr;
- output.vol[1].l = 1.0 - xr;
+ output.vol[2].l = sl;
+ output.vol[2].r = sr;
+ }
- float c = flat_pos.x * 0.5 + 0.5;
- output.vol[2].l = 1.0 - c;
- output.vol[2].r = c;
+ if (cc >= 4) {
+ // Rear pair
+ float rl = Math::abs(1.0 - Math::abs(-0.2 - av));
+ float rr = Math::abs(1.0 - Math::abs(0.2 - av));
- output.vol[0] *= multiplier;
- output.vol[1] *= multiplier;
- output.vol[2] *= multiplier;
+ output.vol[3].l = rl;
+ output.vol[3].r = rr;
+ }
+ }
- } break;
+ for (int k = 0; k < cc; k++) {
+ output.vol[k] *= multiplier;
}
bool filled_reverb = false;
@@ -422,41 +409,30 @@ void AudioStreamPlayer3D::_notification(int p_what) {
rev_pos.y = 0;
rev_pos.normalize();
- switch (AudioServer::get_singleton()->get_speaker_mode()) {
-
- case AudioServer::SPEAKER_MODE_STEREO: {
-
- float c = rev_pos.x * 0.5 + 0.5;
- output.reverb_vol[0].l = 1.0 - c;
- output.reverb_vol[0].r = c;
-
- } break;
- case AudioServer::SPEAKER_SURROUND_51: {
-
- float xl = Vector3(-1, 0, -1).normalized().dot(rev_pos) * 0.5 + 0.5;
- float xr = Vector3(1, 0, -1).normalized().dot(rev_pos) * 0.5 + 0.5;
-
- output.reverb_vol[0].l = xl;
- output.reverb_vol[1].r = 1.0 - xl;
- output.reverb_vol[0].r = xr;
- output.reverb_vol[1].l = 1.0 - xr;
-
- } break;
- case AudioServer::SPEAKER_SURROUND_71: {
-
- float xl = Vector3(-1, 0, -1).normalized().dot(rev_pos) * 0.5 + 0.5;
- float xr = Vector3(1, 0, -1).normalized().dot(rev_pos) * 0.5 + 0.5;
+ if (cc >= 1) {
+ // Stereo pair
+ float c = rev_pos.x * 0.5 + 0.5;
+ output.reverb_vol[0].l = 1.0 - c;
+ output.reverb_vol[0].r = c;
+ }
- output.reverb_vol[0].l = xl;
- output.reverb_vol[1].r = 1.0 - xl;
- output.reverb_vol[0].r = xr;
- output.reverb_vol[1].l = 1.0 - xr;
+ if (cc >= 3) {
+ // Center pair + Side pair
+ float xl = Vector3(-1, 0, -1).normalized().dot(rev_pos) * 0.5 + 0.5;
+ float xr = Vector3(1, 0, -1).normalized().dot(rev_pos) * 0.5 + 0.5;
- float c = rev_pos.x * 0.5 + 0.5;
- output.reverb_vol[2].l = 1.0 - c;
- output.reverb_vol[2].r = c;
+ output.reverb_vol[1].l = xl;
+ output.reverb_vol[1].r = xr;
+ output.reverb_vol[2].l = 1.0 - xr;
+ output.reverb_vol[2].r = 1.0 - xl;
+ }
- } break;
+ if (cc >= 4) {
+ // Rear pair
+ // FIXME: Not sure what math should be done here
+ float c = rev_pos.x * 0.5 + 0.5;
+ output.reverb_vol[3].l = 1.0 - c;
+ output.reverb_vol[3].r = c;
}
for (int i = 0; i < vol_index_max; i++) {
@@ -879,7 +855,7 @@ void AudioStreamPlayer3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_db", PROPERTY_HINT_RANGE, "-80,80"), "set_unit_db", "get_unit_db");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_size", PROPERTY_HINT_RANGE, "0.1,100,0.1"), "set_unit_size", "get_unit_size");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_db", PROPERTY_HINT_RANGE, "-24,6"), "set_max_db", "get_max_db");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "is_playing");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_RANGE, "0,65536,1"), "set_max_distance", "get_max_distance");
ADD_PROPERTY(PropertyInfo(Variant::INT, "out_of_range_mode", PROPERTY_HINT_ENUM, "Mix,Pause"), "set_out_of_range_mode", "get_out_of_range_mode");
diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h
index 8603cab5a4..b729b55f7e 100644
--- a/scene/3d/audio_stream_player_3d.h
+++ b/scene/3d/audio_stream_player_3d.h
@@ -40,12 +40,12 @@ private:
AudioFilterSW filter;
AudioFilterSW::Processor filter_process[6];
- AudioFrame vol[3];
+ AudioFrame vol[4];
float filter_gain;
float pitch_scale;
int bus_index;
int reverb_bus_index;
- AudioFrame reverb_vol[3];
+ AudioFrame reverb_vol[4];
Viewport *viewport; //pointer only used for reference to previous mix
Output() {
diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp
index e1a5329fb0..2580b645e2 100644
--- a/scene/3d/bone_attachment.cpp
+++ b/scene/3d/bone_attachment.cpp
@@ -71,7 +71,8 @@ void BoneAttachment::_get_property_list(List<PropertyInfo> *p_list) const {
void BoneAttachment::_check_bind() {
- if (Skeleton *sk = Object::cast_to<Skeleton>(get_parent())) {
+ Skeleton *sk = Object::cast_to<Skeleton>(get_parent());
+ if (sk) {
int idx = sk->find_bone(bone_name);
if (idx != -1) {
@@ -86,7 +87,8 @@ void BoneAttachment::_check_unbind() {
if (bound) {
- if (Skeleton *sk = Object::cast_to<Skeleton>(get_parent())) {
+ Skeleton *sk = Object::cast_to<Skeleton>(get_parent());
+ if (sk) {
int idx = sk->find_bone(bone_name);
if (idx != -1) {
diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp
index 5f1151f8e9..f49d89122d 100644
--- a/scene/3d/collision_shape.cpp
+++ b/scene/3d/collision_shape.cpp
@@ -50,7 +50,8 @@ void CollisionShape::make_convex_from_brothers() {
for (int i = 0; i < p->get_child_count(); i++) {
Node *n = p->get_child(i);
- if (MeshInstance *mi = Object::cast_to<MeshInstance>(n)) {
+ MeshInstance *mi = Object::cast_to<MeshInstance>(n);
+ if (mi) {
Ref<Mesh> m = mi->get_mesh();
if (m.is_valid()) {
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index 7792a86b4a..66364d40f9 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -696,22 +696,6 @@ void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, cons
p_baker->bake_cells[p_idx].normal[2] += normal_accum.z;
p_baker->bake_cells[p_idx].alpha += alpha;
- static const Vector3 side_normals[6] = {
- Vector3(-1, 0, 0),
- Vector3(1, 0, 0),
- Vector3(0, -1, 0),
- Vector3(0, 1, 0),
- Vector3(0, 0, -1),
- Vector3(0, 0, 1),
- };
-
- /*
- for(int i=0;i<6;i++) {
- if (normal.dot(side_normals[i])>CMP_EPSILON) {
- p_baker->bake_cells[p_idx].used_sides|=(1<<i);
- }
- }*/
-
} else {
//go down
@@ -1113,7 +1097,8 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
}
}
- if (Spatial *s = Object::cast_to<Spatial>(p_at_node)) {
+ Spatial *s = Object::cast_to<Spatial>(p_at_node);
+ if (s) {
if (s->is_visible_in_tree()) {
diff --git a/scene/3d/interpolated_camera.cpp b/scene/3d/interpolated_camera.cpp
index 157ae42571..0f281b694d 100644
--- a/scene/3d/interpolated_camera.cpp
+++ b/scene/3d/interpolated_camera.cpp
@@ -55,8 +55,8 @@ void InterpolatedCamera::_notification(int p_what) {
Transform local_transform = get_global_transform();
local_transform = local_transform.interpolate_with(target_xform, delta);
set_global_transform(local_transform);
-
- if (Camera *cam = Object::cast_to<Camera>(node)) {
+ Camera *cam = Object::cast_to<Camera>(node);
+ if (cam) {
if (cam->get_projection() == get_projection()) {
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index d410ba1e2a..096f787873 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -308,9 +308,8 @@ DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const {
}
void DirectionalLight::set_shadow_depth_range(ShadowDepthRange p_range) {
- shadow_depth_range=p_range;
+ shadow_depth_range = p_range;
VS::get_singleton()->light_directional_set_shadow_depth_range_mode(light, VS::LightDirectionalShadowDepthRangeMode(p_range));
-
}
DirectionalLight::ShadowDepthRange DirectionalLight::get_shadow_depth_range() const {
@@ -318,7 +317,6 @@ DirectionalLight::ShadowDepthRange DirectionalLight::get_shadow_depth_range() co
return shadow_depth_range;
}
-
void DirectionalLight::set_blend_splits(bool p_enable) {
blend_splits = p_enable;
@@ -356,8 +354,8 @@ void DirectionalLight::_bind_methods() {
BIND_ENUM_CONSTANT(SHADOW_PARALLEL_2_SPLITS);
BIND_ENUM_CONSTANT(SHADOW_PARALLEL_4_SPLITS);
- BIND_ENUM_CONSTANT( SHADOW_DEPTH_RANGE_STABLE );
- BIND_ENUM_CONSTANT( SHADOW_DEPTH_RANGE_OPTIMIZED );
+ BIND_ENUM_CONSTANT(SHADOW_DEPTH_RANGE_STABLE);
+ BIND_ENUM_CONSTANT(SHADOW_DEPTH_RANGE_OPTIMIZED);
}
DirectionalLight::DirectionalLight()
@@ -370,7 +368,6 @@ DirectionalLight::DirectionalLight()
set_shadow_mode(SHADOW_PARALLEL_4_SPLITS);
set_shadow_depth_range(SHADOW_DEPTH_RANGE_STABLE);
-
blend_splits = false;
}
diff --git a/scene/3d/navigation_mesh.cpp b/scene/3d/navigation_mesh.cpp
index 7a55f956e0..40750cdfe8 100644
--- a/scene/3d/navigation_mesh.cpp
+++ b/scene/3d/navigation_mesh.cpp
@@ -63,6 +63,143 @@ void NavigationMesh::create_from_mesh(const Ref<Mesh> &p_mesh) {
}
}
+void NavigationMesh::set_sample_partition_type(int p_value) {
+ ERR_FAIL_COND(p_value >= SAMPLE_PARTITION_MAX);
+ partition_type = static_cast<SamplePartitionType>(p_value);
+}
+
+int NavigationMesh::get_sample_partition_type() const {
+ return static_cast<int>(partition_type);
+}
+
+void NavigationMesh::set_cell_size(float p_value) {
+ cell_size = p_value;
+}
+
+float NavigationMesh::get_cell_size() const {
+ return cell_size;
+}
+
+void NavigationMesh::set_cell_height(float p_value) {
+ cell_height = p_value;
+}
+
+float NavigationMesh::get_cell_height() const {
+ return cell_height;
+}
+
+void NavigationMesh::set_agent_height(float p_value) {
+ agent_height = p_value;
+}
+
+float NavigationMesh::get_agent_height() const {
+ return agent_height;
+}
+
+void NavigationMesh::set_agent_radius(float p_value) {
+ agent_radius = p_value;
+}
+
+float NavigationMesh::get_agent_radius() {
+ return agent_radius;
+}
+
+void NavigationMesh::set_agent_max_climb(float p_value) {
+ agent_max_climb = p_value;
+}
+
+float NavigationMesh::get_agent_max_climb() const {
+ return agent_max_climb;
+}
+
+void NavigationMesh::set_agent_max_slope(float p_value) {
+ agent_max_slope = p_value;
+}
+
+float NavigationMesh::get_agent_max_slope() const {
+ return agent_max_slope;
+}
+
+void NavigationMesh::set_region_min_size(float p_value) {
+ region_min_size = p_value;
+}
+
+float NavigationMesh::get_region_min_size() const {
+ return region_min_size;
+}
+
+void NavigationMesh::set_region_merge_size(float p_value) {
+ region_merge_size = p_value;
+}
+
+float NavigationMesh::get_region_merge_size() const {
+ return region_merge_size;
+}
+
+void NavigationMesh::set_edge_max_length(float p_value) {
+ edge_max_length = p_value;
+}
+
+float NavigationMesh::get_edge_max_length() const {
+ return edge_max_length;
+}
+
+void NavigationMesh::set_edge_max_error(float p_value) {
+ edge_max_error = p_value;
+}
+
+float NavigationMesh::get_edge_max_error() const {
+ return edge_max_error;
+}
+
+void NavigationMesh::set_verts_per_poly(float p_value) {
+ verts_per_poly = p_value;
+}
+
+float NavigationMesh::get_verts_per_poly() const {
+ return verts_per_poly;
+}
+
+void NavigationMesh::set_detail_sample_distance(float p_value) {
+ detail_sample_distance = p_value;
+}
+
+float NavigationMesh::get_detail_sample_distance() const {
+ return detail_sample_distance;
+}
+
+void NavigationMesh::set_detail_sample_max_error(float p_value) {
+ detail_sample_max_error = p_value;
+}
+
+float NavigationMesh::get_detail_sample_max_error() const {
+ return detail_sample_max_error;
+}
+
+void NavigationMesh::set_filter_low_hanging_obstacles(bool p_value) {
+ filter_low_hanging_obstacles = p_value;
+}
+
+bool NavigationMesh::get_filter_low_hanging_obstacles() const {
+ return filter_low_hanging_obstacles;
+}
+
+void NavigationMesh::set_filter_ledge_spans(bool p_value) {
+ filter_ledge_spans = p_value;
+}
+
+bool NavigationMesh::get_filter_ledge_spans() const {
+ return filter_ledge_spans;
+}
+
+void NavigationMesh::set_filter_walkable_low_height_spans(bool p_value) {
+ filter_walkable_low_height_spans = p_value;
+}
+
+bool NavigationMesh::get_filter_walkable_low_height_spans() const {
+ return filter_walkable_low_height_spans;
+}
+
void NavigationMesh::set_vertices(const PoolVector<Vector3> &p_vertices) {
vertices = p_vertices;
@@ -199,6 +336,56 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() {
}
void NavigationMesh::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_sample_partition_type", "sample_partition_type"), &NavigationMesh::set_sample_partition_type);
+ ClassDB::bind_method(D_METHOD("get_sample_partition_type"), &NavigationMesh::get_sample_partition_type);
+
+ ClassDB::bind_method(D_METHOD("set_cell_size", "cell_size"), &NavigationMesh::set_cell_size);
+ ClassDB::bind_method(D_METHOD("get_cell_size"), &NavigationMesh::get_cell_size);
+
+ ClassDB::bind_method(D_METHOD("set_cell_height", "cell_height"), &NavigationMesh::set_cell_height);
+ ClassDB::bind_method(D_METHOD("get_cell_height"), &NavigationMesh::get_cell_height);
+
+ ClassDB::bind_method(D_METHOD("set_agent_height", "agent_height"), &NavigationMesh::set_agent_height);
+ ClassDB::bind_method(D_METHOD("get_agent_height"), &NavigationMesh::get_agent_height);
+
+ ClassDB::bind_method(D_METHOD("set_agent_radius", "agent_radius"), &NavigationMesh::set_agent_radius);
+ ClassDB::bind_method(D_METHOD("get_agent_radius"), &NavigationMesh::get_agent_radius);
+
+ ClassDB::bind_method(D_METHOD("set_agent_max_climb", "agent_max_climb"), &NavigationMesh::set_agent_max_climb);
+ ClassDB::bind_method(D_METHOD("get_agent_max_climb"), &NavigationMesh::get_agent_max_climb);
+
+ ClassDB::bind_method(D_METHOD("set_agent_max_slope", "agent_max_slope"), &NavigationMesh::set_agent_max_slope);
+ ClassDB::bind_method(D_METHOD("get_agent_max_slope"), &NavigationMesh::get_agent_max_slope);
+
+ ClassDB::bind_method(D_METHOD("set_region_min_size", "region_min_size"), &NavigationMesh::set_region_min_size);
+ ClassDB::bind_method(D_METHOD("get_region_min_size"), &NavigationMesh::get_region_min_size);
+
+ ClassDB::bind_method(D_METHOD("set_region_merge_size", "region_merge_size"), &NavigationMesh::set_region_merge_size);
+ ClassDB::bind_method(D_METHOD("get_region_merge_size"), &NavigationMesh::get_region_merge_size);
+
+ ClassDB::bind_method(D_METHOD("set_edge_max_length", "edge_max_length"), &NavigationMesh::set_edge_max_length);
+ ClassDB::bind_method(D_METHOD("get_edge_max_length"), &NavigationMesh::get_edge_max_length);
+
+ ClassDB::bind_method(D_METHOD("set_edge_max_error", "edge_max_error"), &NavigationMesh::set_edge_max_error);
+ ClassDB::bind_method(D_METHOD("get_edge_max_error"), &NavigationMesh::get_edge_max_error);
+
+ ClassDB::bind_method(D_METHOD("set_verts_per_poly", "verts_per_poly"), &NavigationMesh::set_verts_per_poly);
+ ClassDB::bind_method(D_METHOD("get_verts_per_poly"), &NavigationMesh::get_verts_per_poly);
+
+ ClassDB::bind_method(D_METHOD("set_detail_sample_distance", "detail_sample_dist"), &NavigationMesh::set_detail_sample_distance);
+ ClassDB::bind_method(D_METHOD("get_detail_sample_distance"), &NavigationMesh::get_detail_sample_distance);
+
+ ClassDB::bind_method(D_METHOD("set_detail_sample_max_error", "detail_sample_max_error"), &NavigationMesh::set_detail_sample_max_error);
+ ClassDB::bind_method(D_METHOD("get_detail_sample_max_error"), &NavigationMesh::get_detail_sample_max_error);
+
+ ClassDB::bind_method(D_METHOD("set_filter_low_hanging_obstacles", "filter_low_hanging_obstacles"), &NavigationMesh::set_filter_low_hanging_obstacles);
+ ClassDB::bind_method(D_METHOD("get_filter_low_hanging_obstacles"), &NavigationMesh::get_filter_low_hanging_obstacles);
+
+ ClassDB::bind_method(D_METHOD("set_filter_ledge_spans", "filter_ledge_spans"), &NavigationMesh::set_filter_ledge_spans);
+ ClassDB::bind_method(D_METHOD("get_filter_ledge_spans"), &NavigationMesh::get_filter_ledge_spans);
+
+ ClassDB::bind_method(D_METHOD("set_filter_walkable_low_height_spans", "filter_walkable_low_height_spans"), &NavigationMesh::set_filter_walkable_low_height_spans);
+ ClassDB::bind_method(D_METHOD("get_filter_walkable_low_height_spans"), &NavigationMesh::get_filter_walkable_low_height_spans);
ClassDB::bind_method(D_METHOD("set_vertices", "vertices"), &NavigationMesh::set_vertices);
ClassDB::bind_method(D_METHOD("get_vertices"), &NavigationMesh::get_vertices);
@@ -213,11 +400,54 @@ void NavigationMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("_set_polygons", "polygons"), &NavigationMesh::_set_polygons);
ClassDB::bind_method(D_METHOD("_get_polygons"), &NavigationMesh::_get_polygons);
+ BIND_CONSTANT(SAMPLE_PARTITION_WATERSHED);
+ BIND_CONSTANT(SAMPLE_PARTITION_MONOTONE);
+ BIND_CONSTANT(SAMPLE_PARTITION_LAYERS);
+
ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY, "vertices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_vertices", "get_vertices");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "polygons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_polygons", "_get_polygons");
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "sample_partition_type/sample_partition_type", PROPERTY_HINT_ENUM, "Watershed,Monotone,Layers"), "set_sample_partition_type", "get_sample_partition_type");
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "cell/size", PROPERTY_HINT_RANGE, "0.1,1.0,0.01"), "set_cell_size", "get_cell_size");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "cell/height", PROPERTY_HINT_RANGE, "0.1,1.0,0.01"), "set_cell_height", "get_cell_height");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "agent/height", PROPERTY_HINT_RANGE, "0.1,5.0,0.01"), "set_agent_height", "get_agent_height");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "agent/radius", PROPERTY_HINT_RANGE, "0.1,5.0,0.01"), "set_agent_radius", "get_agent_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "agent/max_climb", PROPERTY_HINT_RANGE, "0.1,5.0,0.01"), "set_agent_max_climb", "get_agent_max_climb");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "agent/max_slope", PROPERTY_HINT_RANGE, "0.0,90.0,0.1"), "set_agent_max_slope", "get_agent_max_slope");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "region/min_size", PROPERTY_HINT_RANGE, "0.0,150.0,0.01"), "set_region_min_size", "get_region_min_size");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "region/merge_size", PROPERTY_HINT_RANGE, "0.0,150.0,0.01"), "set_region_merge_size", "get_region_merge_size");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "edge/max_length", PROPERTY_HINT_RANGE, "0.0,50.0,0.01"), "set_edge_max_length", "get_edge_max_length");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "edge/max_error", PROPERTY_HINT_RANGE, "0.1,3.0,0.01"), "set_edge_max_error", "get_edge_max_error");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "polygon/verts_per_poly", PROPERTY_HINT_RANGE, "3.0,12.0,1.0"), "set_verts_per_poly", "get_verts_per_poly");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "detail/sample_distance", PROPERTY_HINT_RANGE, "0.0,16.0,0.01"), "set_detail_sample_distance", "get_detail_sample_distance");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "detail/sample_max_error", PROPERTY_HINT_RANGE, "0.0,16.0,0.01"), "set_detail_sample_max_error", "get_detail_sample_max_error");
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter/low_hanging_obstacles"), "set_filter_low_hanging_obstacles", "get_filter_low_hanging_obstacles");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter/ledge_spans"), "set_filter_ledge_spans", "get_filter_ledge_spans");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter/filter_walkable_low_height_spans"), "set_filter_walkable_low_height_spans", "get_filter_walkable_low_height_spans");
}
NavigationMesh::NavigationMesh() {
+ cell_size = 0.3f;
+ cell_height = 0.2f;
+ agent_height = 2.0f;
+ agent_radius = 0.6f;
+ agent_max_climb = 0.9f;
+ agent_max_slope = 45.0f;
+ region_min_size = 8.0f;
+ region_merge_size = 20.0f;
+ edge_max_length = 12.0f;
+ edge_max_error = 1.3f;
+ verts_per_poly = 6.0f;
+ detail_sample_distance = 6.0f;
+ detail_sample_max_error = 1.0f;
+
+ partition_type = SAMPLE_PARTITION_WATERSHED;
+
+ filter_low_hanging_obstacles = false;
+ filter_ledge_spans = false;
+ filter_walkable_low_height_spans = false;
}
void NavigationMeshInstance::set_enabled(bool p_enabled) {
diff --git a/scene/3d/navigation_mesh.h b/scene/3d/navigation_mesh.h
index 36fe3ee34b..dd5ed79500 100644
--- a/scene/3d/navigation_mesh.h
+++ b/scene/3d/navigation_mesh.h
@@ -61,6 +61,87 @@ protected:
Array _get_polygons() const;
public:
+ enum SamplePartitionType {
+ SAMPLE_PARTITION_WATERSHED = 0,
+ SAMPLE_PARTITION_MONOTONE,
+ SAMPLE_PARTITION_LAYERS,
+ SAMPLE_PARTITION_MAX
+ };
+
+protected:
+ float cell_size;
+ float cell_height;
+ float agent_height;
+ float agent_radius;
+ float agent_max_climb;
+ float agent_max_slope;
+ float region_min_size;
+ float region_merge_size;
+ float edge_max_length;
+ float edge_max_error;
+ float verts_per_poly;
+ float detail_sample_distance;
+ float detail_sample_max_error;
+
+ SamplePartitionType partition_type;
+
+ bool filter_low_hanging_obstacles;
+ bool filter_ledge_spans;
+ bool filter_walkable_low_height_spans;
+
+public:
+ // Recast settings
+ void set_sample_partition_type(int p_value);
+ int get_sample_partition_type() const;
+
+ void set_cell_size(float p_value);
+ float get_cell_size() const;
+
+ void set_cell_height(float p_value);
+ float get_cell_height() const;
+
+ void set_agent_height(float p_value);
+ float get_agent_height() const;
+
+ void set_agent_radius(float p_value);
+ float get_agent_radius();
+
+ void set_agent_max_climb(float p_value);
+ float get_agent_max_climb() const;
+
+ void set_agent_max_slope(float p_value);
+ float get_agent_max_slope() const;
+
+ void set_region_min_size(float p_value);
+ float get_region_min_size() const;
+
+ void set_region_merge_size(float p_value);
+ float get_region_merge_size() const;
+
+ void set_edge_max_length(float p_value);
+ float get_edge_max_length() const;
+
+ void set_edge_max_error(float p_value);
+ float get_edge_max_error() const;
+
+ void set_verts_per_poly(float p_value);
+ float get_verts_per_poly() const;
+
+ void set_detail_sample_distance(float p_value);
+ float get_detail_sample_distance() const;
+
+ void set_detail_sample_max_error(float p_value);
+ float get_detail_sample_max_error() const;
+
+ void set_filter_low_hanging_obstacles(bool p_value);
+ bool get_filter_low_hanging_obstacles() const;
+
+ void set_filter_ledge_spans(bool p_value);
+ bool get_filter_ledge_spans() const;
+
+ void set_filter_walkable_low_height_spans(bool p_value);
+ bool get_filter_walkable_low_height_spans() const;
+
void create_from_mesh(const Ref<Mesh> &p_mesh);
void set_vertices(const PoolVector<Vector3> &p_vertices);
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index ed4d88417c..60245fe6ce 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path.cpp
@@ -155,8 +155,8 @@ void PathFollow::_notification(int p_what) {
Node *parent = get_parent();
if (parent) {
-
- if ((path = Object::cast_to<Path>(parent))) {
+ path = Object::cast_to<Path>(parent);
+ if (path) {
_update_transform();
}
}
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 6a8226c0e1..7525eb5069 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -1061,7 +1061,7 @@ KinematicBody::Collision KinematicBody::get_slide_collision(int p_bounce) const
Ref<KinematicCollision> KinematicBody::_get_slide_collision(int p_bounce) {
ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Ref<KinematicCollision>());
- if (p_bounce > slide_colliders.size()) {
+ if (p_bounce >= slide_colliders.size()) {
slide_colliders.resize(p_bounce + 1);
}
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index 7db3bb18bd..91fe426b99 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -175,7 +175,6 @@ void Spatial::_notification(int p_what) {
if (get_script_instance()) {
- Variant::CallError err;
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world, NULL, 0);
}
#ifdef TOOLS_ENABLED
@@ -207,7 +206,6 @@ void Spatial::_notification(int p_what) {
if (get_script_instance()) {
- Variant::CallError err;
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_world, NULL, 0);
}
diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp
index d6b3206fbf..3518113130 100644
--- a/scene/3d/vehicle_body.cpp
+++ b/scene/3d/vehicle_body.cpp
@@ -102,6 +102,14 @@ void VehicleWheel::_notification(int p_what) {
}
}
+String VehicleWheel::get_configuration_warning() const {
+ if (!Object::cast_to<VehicleBody>(get_parent())) {
+ return TTR("VehicleWheel serves to provide a wheel system to a VehicleBody. Please use it as a child of a VehicleBody.");
+ }
+
+ return String();
+}
+
void VehicleWheel::_update(PhysicsDirectBodyState *s) {
if (m_raycastInfo.m_isInContact)
diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h
index d67209c58f..eb661adb90 100644
--- a/scene/3d/vehicle_body.h
+++ b/scene/3d/vehicle_body.h
@@ -131,6 +131,8 @@ public:
void set_roll_influence(float p_value);
float get_roll_influence() const;
+ String get_configuration_warning() const;
+
VehicleWheel();
};
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index e2330eb0d4..7a5c7e450b 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -1156,6 +1156,7 @@ void AnimationTreePlayer::transition_node_set_xfade_time(const StringName &p_nod
}
void AnimationTreePlayer::TransitionNode::set_current(int p_current) {
+
ERR_FAIL_INDEX(p_current, inputs.size());
if (current == p_current)
diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp
index 341ae45ce8..6a582c9a3d 100644
--- a/scene/audio/audio_player.cpp
+++ b/scene/audio/audio_player.cpp
@@ -66,29 +66,27 @@ void AudioStreamPlayer::_mix_audio() {
//set volume for next mix
mix_volume_db = volume_db;
- AudioFrame *targets[3] = { NULL, NULL, NULL };
+ AudioFrame *targets[4] = { NULL, NULL, NULL, NULL };
if (AudioServer::get_singleton()->get_speaker_mode() == AudioServer::SPEAKER_MODE_STEREO) {
targets[0] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 0);
} else {
switch (mix_target) {
case MIX_TARGET_STEREO: {
- targets[0] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 1);
+ targets[0] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 0);
} break;
case MIX_TARGET_SURROUND: {
- targets[0] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 1);
- targets[1] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 2);
- if (AudioServer::get_singleton()->get_speaker_mode() == AudioServer::SPEAKER_SURROUND_71) {
- targets[2] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 3);
+ for (int i = 0; i < AudioServer::get_singleton()->get_channel_count(); i++) {
+ targets[i] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, i);
}
} break;
case MIX_TARGET_CENTER: {
- targets[0] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 0);
+ targets[0] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 1);
} break;
}
}
- for (int c = 0; c < 3; c++) {
+ for (int c = 0; c < 4; c++) {
if (!targets[c])
break;
for (int i = 0; i < buffer_size; i++) {
@@ -189,7 +187,7 @@ void AudioStreamPlayer::stop() {
bool AudioStreamPlayer::is_playing() const {
if (stream_playback.is_valid()) {
- return active && stream_playback->is_playing();
+ return active; //&& stream_playback->is_playing();
}
return false;
@@ -304,7 +302,7 @@ void AudioStreamPlayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE, "-80,24"), "set_volume_db", "get_volume_db");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "is_playing");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_target", PROPERTY_HINT_ENUM, "Stereo,Surround,Center"), "set_mix_target", "get_mix_target");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus");
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 7bf11e6712..87dfd95724 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1250,7 +1250,7 @@ void Control::_size_changed() {
}
if (get_viewport()->is_snap_controls_to_pixels_enabled()) {
- new_size_cache =new_size_cache.floor();
+ new_size_cache = new_size_cache.floor();
new_pos_cache = new_pos_cache.floor();
}
bool pos_changed = new_pos_cache != data.pos_cache;
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 140d002387..d4912339da 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -195,7 +195,7 @@ void WindowDialog::_notification(int p_what) {
RID canvas = get_canvas_item();
// Draw the background.
- Ref<StyleBox> panel = get_stylebox("panel", "WindowDialog");
+ Ref<StyleBox> panel = get_stylebox("panel");
Size2 size = get_size();
panel->draw(canvas, Rect2(0, 0, size.x, size.y));
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 990c0f3d96..87a232e766 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -183,8 +183,8 @@ void FileDialog::_action_pressed() {
String path = dir_access->get_current_dir();
path = path.replace("\\", "/");
-
- if (TreeItem *item = tree->get_selected()) {
+ TreeItem *item = tree->get_selected();
+ if (item) {
Dictionary d = item->get_metadata(0);
if (d["dir"]) {
path = path.plus_file(d["name"]);
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index de17416d8e..4975b66744 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -333,6 +333,15 @@ bool TreeItem::is_collapsed() {
return collapsed;
}
+void TreeItem::set_custom_minimum_height(int p_height) {
+ custom_min_height = p_height;
+ _changed_notify();
+}
+
+int TreeItem::get_custom_minimum_height() const {
+ return custom_min_height;
+}
+
TreeItem *TreeItem::get_next() {
return next;
@@ -703,6 +712,9 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_collapsed", "enable"), &TreeItem::set_collapsed);
ClassDB::bind_method(D_METHOD("is_collapsed"), &TreeItem::is_collapsed);
+ ClassDB::bind_method(D_METHOD("set_custom_minimum_height", "height"), &TreeItem::set_custom_minimum_height);
+ ClassDB::bind_method(D_METHOD("get_custom_minimum_height"), &TreeItem::get_custom_minimum_height);
+
ClassDB::bind_method(D_METHOD("get_next"), &TreeItem::get_next);
ClassDB::bind_method(D_METHOD("get_prev"), &TreeItem::get_prev);
ClassDB::bind_method(D_METHOD("get_parent"), &TreeItem::get_parent);
@@ -780,6 +792,7 @@ TreeItem::TreeItem(Tree *p_tree) {
tree = p_tree;
collapsed = false;
disable_folding = false;
+ custom_min_height = 0;
parent = 0; // parent item
next = 0; // next in list
@@ -921,6 +934,9 @@ int Tree::compute_item_height(TreeItem *p_item) const {
default: {}
}
}
+ int item_min_height = p_item->get_custom_minimum_height();
+ if (height < item_min_height)
+ height = item_min_height;
height += cache.vseparation;
@@ -2304,7 +2320,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
int col, h, section;
TreeItem *it = _find_item_at_pos(root, mpos, col, h, section);
- if (drop_mode_flags && it != drop_mode_over || section != drop_mode_section) {
+ if ((drop_mode_flags && it != drop_mode_over) || section != drop_mode_section) {
drop_mode_over = it;
drop_mode_section = section;
update();
@@ -2478,7 +2494,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
pressing_for_editor = false;
blocked++;
- bool handled = propagate_mouse_event(pos + cache.offset, 0, 0, b->is_doubleclick(), root, b->get_button_index(), b);
+ propagate_mouse_event(pos + cache.offset, 0, 0, b->is_doubleclick(), root, b->get_button_index(), b);
blocked--;
if (pressing_for_editor) {
@@ -3593,6 +3609,7 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_area_rect", "item", "column"), &Tree::_get_item_rect, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("get_item_at_pos", "pos"), &Tree::get_item_at_pos);
ClassDB::bind_method(D_METHOD("get_column_at_pos", "pos"), &Tree::get_column_at_pos);
+ ClassDB::bind_method(D_METHOD("get_drop_section_at_pos", "pos"), &Tree::get_drop_section_at_pos);
ClassDB::bind_method(D_METHOD("ensure_cursor_is_visible"), &Tree::ensure_cursor_is_visible);
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 06d6d3ad5a..5f19558597 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -145,6 +145,7 @@ private:
bool collapsed; // wont show childs
bool disable_folding;
+ int custom_min_height;
TreeItem *parent; // parent item
TreeItem *next; // next in list
@@ -230,6 +231,9 @@ public:
void set_collapsed(bool p_collapsed);
bool is_collapsed();
+ void set_custom_minimum_height(int p_height);
+ int get_custom_minimum_height() const;
+
TreeItem *get_prev();
TreeItem *get_next();
TreeItem *get_parent();
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index c3d9d97c5a..a30fc03aa9 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -50,7 +50,6 @@ void Node::_notification(int p_notification) {
Variant time = get_process_delta_time();
const Variant *ptr[1] = { &time };
- Variant::CallError err;
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_process, ptr, 1);
}
} break;
@@ -60,7 +59,6 @@ void Node::_notification(int p_notification) {
Variant time = get_fixed_process_delta_time();
const Variant *ptr[1] = { &time };
- Variant::CallError err;
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_fixed_process, ptr, 1);
}
@@ -134,7 +132,6 @@ void Node::_notification(int p_notification) {
set_fixed_process(true);
}
- Variant::CallError err;
get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_ready, NULL, 0);
}
//emit_signal(SceneStringNames::get_singleton()->enter_tree);
@@ -209,7 +206,6 @@ void Node::_propagate_enter_tree() {
if (get_script_instance()) {
- Variant::CallError err;
get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_enter_tree, NULL, 0);
}
@@ -273,7 +269,6 @@ void Node::_propagate_exit_tree() {
if (get_script_instance()) {
- Variant::CallError err;
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_tree, NULL, 0);
}
emit_signal(SceneStringNames::get_singleton()->tree_exited);
@@ -2117,7 +2112,15 @@ Node *Node::_duplicate(int p_flags) const {
if (!(p_flags & DUPLICATE_SCRIPTS) && name == "script/script")
continue;
- node->set(name, get(name));
+ Variant value = get(name);
+ // Duplicate dictionaries and arrays, mainly needed for __meta__
+ if (value.get_type() == Variant::DICTIONARY) {
+ value = Dictionary(value).copy();
+ } else if (value.get_type() == Variant::ARRAY) {
+ value = Array(value).duplicate();
+ }
+
+ node->set(name, value);
}
node->set_name(get_name());
@@ -2199,7 +2202,16 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
- node->set(name, get(name));
+
+ Variant value = get(name);
+ // Duplicate dictionaries and arrays, mainly needed for __meta__
+ if (value.get_type() == Variant::DICTIONARY) {
+ value = Dictionary(value).copy();
+ } else if (value.get_type() == Variant::ARRAY) {
+ value = Array(value).duplicate();
+ }
+
+ node->set(name, value);
}
node->set_name(get_name());
@@ -2657,7 +2669,7 @@ void Node::_bind_methods() {
GLOBAL_DEF("node/name_casing", NAME_CASING_PASCAL_CASE);
ProjectSettings::get_singleton()->set_custom_property_info("node/name_casing", PropertyInfo(Variant::INT, "node/name_casing", PROPERTY_HINT_ENUM, "PascalCase,camelCase,snake_case"));
- ClassDB::bind_method(D_METHOD("_add_child_below_node", "node", "child_node", "legible_unique_name"), &Node::add_child_below_node, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("add_child_below_node", "node", "child_node", "legible_unique_name"), &Node::add_child_below_node, DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_name", "name"), &Node::set_name);
ClassDB::bind_method(D_METHOD("get_name"), &Node::get_name);
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index a71b491bae..4f62d88934 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -870,7 +870,6 @@ void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p
if (!n->can_process())
continue;
- Variant::CallError ce;
n->call_multilevel(p_method, (const Variant **)v, 1);
//ERR_FAIL_COND(node_count != g.nodes.size());
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 434d594bbb..567b1dd7a1 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2580,7 +2580,7 @@ int Viewport::get_render_info(RenderInfo p_info) {
void Viewport::set_snap_controls_to_pixels(bool p_enable) {
- snap_controls_to_pixels=p_enable;
+ snap_controls_to_pixels = p_enable;
}
bool Viewport::is_snap_controls_to_pixels_enabled() const {
@@ -2588,7 +2588,6 @@ bool Viewport::is_snap_controls_to_pixels_enabled() const {
return snap_controls_to_pixels;
}
-
void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_use_arvr", "use"), &Viewport::set_use_arvr);
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 9ed3734a36..b9dfbd6bb0 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -430,6 +430,7 @@ void register_scene_types() {
ClassDB::register_class<StaticBody2D>();
ClassDB::register_class<RigidBody2D>();
ClassDB::register_class<KinematicBody2D>();
+ ClassDB::register_class<KinematicCollision2D>();
ClassDB::register_class<Area2D>();
ClassDB::register_class<CollisionShape2D>();
ClassDB::register_class<CollisionPolygon2D>();
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index 7fbaa1f73c..2e89a739bd 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -84,15 +84,6 @@ int Curve::add_point(Vector2 p_pos, real_t left_tangent, real_t right_tangent, T
int i = get_index(p_pos.x);
- int nearest_index = i;
- if (i + 1 < _points.size()) {
- real_t diff0 = p_pos.x - _points[i].pos.x;
- real_t diff1 = _points[i + 1].pos.x - p_pos.x;
-
- if (diff1 < diff0)
- nearest_index = i + 1;
- }
-
if (i == 0 && p_pos.x < _points[0].pos.x) {
// Insert before anything else
_points.insert(0, Point(p_pos, left_tangent, right_tangent, left_mode, right_mode));
@@ -331,18 +322,19 @@ real_t Curve::interpolate_local_nocheck(int index, real_t local_offset) const {
const Point a = _points[index];
const Point b = _points[index + 1];
- // Cubic bezier
-
- // ac-----bc
- // / \
- // / \ Here with a.right_tangent > 0
- // / \ and b.left_tangent < 0
- // / \
- // a b
- //
- // |-d1--|-d2--|-d3--|
- //
- // d1 == d2 == d3 == d / 3
+ /* Cubic bezier
+ *
+ * ac-----bc
+ * / \
+ * / \ Here with a.right_tangent > 0
+ * / \ and b.left_tangent < 0
+ * / \
+ * a b
+ *
+ * |-d1--|-d2--|-d3--|
+ *
+ * d1 == d2 == d3 == d / 3
+ */
// Control points are chosen at equal distances
real_t d = b.pos.x - a.pos.x;
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index fdea5960e5..1272e5a946 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -794,7 +794,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// RichTextLabel
theme->set_stylebox("focus", "RichTextLabel", focus);
- theme->set_stylebox("normal", "RichTextLabel", make_stylebox(tree_bg_png, 3, 3, 3, 3));
+ theme->set_stylebox("normal", "RichTextLabel", make_empty_stylebox(0, 0, 0, 0));
theme->set_font("normal_font", "RichTextLabel", default_font);
theme->set_font("bold_font", "RichTextLabel", default_font);
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index a187692bcb..abe9a00c3f 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -67,8 +67,8 @@ RID Material::get_rid() const {
}
void Material::_validate_property(PropertyInfo &property) const {
- if (!_can_do_next_pass() && property.name=="next_pass") {
- property.usage=0;
+ if (!_can_do_next_pass() && property.name == "next_pass") {
+ property.usage = 0;
}
}
@@ -80,7 +80,7 @@ void Material::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_render_priority", "priority"), &Material::set_render_priority);
ClassDB::bind_method(D_METHOD("get_render_priority"), &Material::get_render_priority);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "render_priority", PROPERTY_HINT_RANGE, itos(RENDER_PRIORITY_MIN) + "," + itos(RENDER_PRIORITY_MAX) + ",1"), "set_render_priority", "get_render_priority");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "render_priority", PROPERTY_HINT_RANGE, itos(RENDER_PRIORITY_MIN) + "," + itos(RENDER_PRIORITY_MAX) + ",1"), "set_render_priority", "get_render_priority");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_pass", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_next_pass", "get_next_pass");
BIND_CONSTANT(RENDER_PRIORITY_MAX);
@@ -212,7 +212,7 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id
bool ShaderMaterial::_can_do_next_pass() const {
- return shader.is_valid() && shader->get_mode()==Shader::MODE_SPATIAL;
+ return shader.is_valid() && shader->get_mode() == Shader::MODE_SPATIAL;
}
ShaderMaterial::ShaderMaterial() {
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index aa7827a61a..04efe88102 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -761,7 +761,7 @@ Array ArrayMesh::surface_get_arrays(int p_surface) const {
Array ArrayMesh::surface_get_blend_shape_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array());
- return Array();
+ return VisualServer::get_singleton()->mesh_surface_get_blend_shape_arrays(mesh, p_surface);
}
int ArrayMesh::get_surface_count() const {
@@ -1010,6 +1010,8 @@ void ArrayMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("surface_get_material", "surf_idx"), &ArrayMesh::surface_get_material);
ClassDB::bind_method(D_METHOD("surface_set_name", "surf_idx", "name"), &ArrayMesh::surface_set_name);
ClassDB::bind_method(D_METHOD("surface_get_name", "surf_idx"), &ArrayMesh::surface_get_name);
+ ClassDB::bind_method(D_METHOD("surface_get_arrays", "surf_idx"), &ArrayMesh::surface_get_arrays);
+ ClassDB::bind_method(D_METHOD("surface_get_blend_shape_arrays", "surf_idx"), &ArrayMesh::surface_get_blend_shape_arrays);
ClassDB::bind_method(D_METHOD("create_trimesh_shape"), &ArrayMesh::create_trimesh_shape);
ClassDB::bind_method(D_METHOD("create_convex_shape"), &ArrayMesh::create_convex_shape);
ClassDB::bind_method(D_METHOD("create_outline", "margin"), &ArrayMesh::create_outline);
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index 53c6eb2d89..f4edb258b6 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -120,6 +120,7 @@ public:
virtual int surface_get_array_len(int p_idx) const = 0;
virtual int surface_get_array_index_len(int p_idx) const = 0;
virtual Array surface_get_arrays(int p_surface) const = 0;
+ virtual Array surface_get_blend_shape_arrays(int p_surface) const = 0;
virtual uint32_t surface_get_format(int p_idx) const = 0;
virtual PrimitiveType surface_get_primitive_type(int p_idx) const = 0;
virtual Ref<Material> surface_get_material(int p_idx) const = 0;
@@ -174,7 +175,7 @@ public:
void add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>());
Array surface_get_arrays(int p_surface) const;
- virtual Array surface_get_blend_shape_arrays(int p_surface) const;
+ Array surface_get_blend_shape_arrays(int p_surface) const;
void add_blend_shape(const StringName &p_name);
int get_blend_shape_count() const;
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index c525ca600a..5d6f44dfef 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -92,7 +92,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
NODE_FROM_ID(nparent, n.parent);
#ifdef DEBUG_ENABLED
- if (!nparent && n.parent & FLAG_ID_IS_PATH) {
+ if (!nparent && (n.parent & FLAG_ID_IS_PATH)) {
WARN_PRINT(String("Parent path '" + String(node_paths[n.parent & FLAG_MASK]) + "' for node '" + String(snames[n.name]) + "' has vanished when instancing: '" + get_path() + "'.").ascii().get_data());
}
@@ -489,7 +489,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
// only save what has been changed
// only save changed properties in instance
- if (E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE || E->get().name == "__meta__") {
+ if ((E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE) || E->get().name == "__meta__") {
//property has requested that no instance state is saved, sorry
//also, meta won't be overridden or saved
continue;
@@ -1288,7 +1288,7 @@ bool SceneState::is_node_instance_placeholder(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, nodes.size(), false);
- return nodes[p_idx].instance >= 0 && nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER;
+ return nodes[p_idx].instance >= 0 && (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER);
}
Ref<PackedScene> SceneState::get_node_instance(int p_idx) const {
@@ -1313,7 +1313,7 @@ String SceneState::get_node_instance_placeholder(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, nodes.size(), String());
- if (nodes[p_idx].instance >= 0 && nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER) {
+ if (nodes[p_idx].instance >= 0 && (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER)) {
return variants[nodes[p_idx].instance & FLAG_MASK];
}
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index cfc1468533..ba356d89b1 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -105,6 +105,15 @@ Array PrimitiveMesh::surface_get_arrays(int p_surface) const {
return VisualServer::get_singleton()->mesh_surface_get_arrays(mesh, 0);
}
+Array PrimitiveMesh::surface_get_blend_shape_arrays(int p_surface) const {
+ ERR_FAIL_INDEX_V(p_surface, 1, Array());
+ if (pending_request) {
+ _update();
+ }
+
+ return Array();
+}
+
uint32_t PrimitiveMesh::surface_get_format(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, 1, 0);
if (pending_request) {
@@ -119,6 +128,8 @@ Mesh::PrimitiveType PrimitiveMesh::surface_get_primitive_type(int p_idx) const {
}
Ref<Material> PrimitiveMesh::surface_get_material(int p_idx) const {
+ ERR_FAIL_INDEX_V(p_idx, 1, NULL);
+
return material;
}
@@ -151,6 +162,8 @@ void PrimitiveMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_material", "material"), &PrimitiveMesh::set_material);
ClassDB::bind_method(D_METHOD("get_material"), &PrimitiveMesh::get_material);
+ ClassDB::bind_method(D_METHOD("get_mesh_arrays"), &PrimitiveMesh::get_mesh_arrays);
+
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_material", "get_material");
}
@@ -168,6 +181,10 @@ Ref<Material> PrimitiveMesh::get_material() const {
return material;
}
+Array PrimitiveMesh::get_mesh_arrays() const {
+ return surface_get_arrays(0);
+}
+
PrimitiveMesh::PrimitiveMesh() {
// defaults
mesh = VisualServer::get_singleton()->mesh_create();
@@ -213,7 +230,6 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
prevrow = 0;
for (j = 0; j <= (rings + 1); j++) {
v = j;
- w;
v /= (rings + 1);
w = sin(0.5 * Math_PI * v);
@@ -292,7 +308,6 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
prevrow = 0;
for (j = 0; j <= (rings + 1); j++) {
v = j;
- w;
v /= (rings + 1);
v += 1.0;
diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h
index 34fb75a196..38a5695883 100644
--- a/scene/resources/primitive_meshes.h
+++ b/scene/resources/primitive_meshes.h
@@ -67,6 +67,7 @@ public:
virtual int surface_get_array_len(int p_idx) const;
virtual int surface_get_array_index_len(int p_idx) const;
virtual Array surface_get_arrays(int p_surface) const;
+ virtual Array surface_get_blend_shape_arrays(int p_surface) const;
virtual uint32_t surface_get_format(int p_idx) const;
virtual Mesh::PrimitiveType surface_get_primitive_type(int p_idx) const;
virtual Ref<Material> surface_get_material(int p_idx) const;
@@ -78,6 +79,8 @@ public:
void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
+ Array get_mesh_arrays() const;
+
PrimitiveMesh();
~PrimitiveMesh();
};