diff options
Diffstat (limited to 'scene')
37 files changed, 237 insertions, 130 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 39d3f2d6bf..d2a8e3315a 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -217,13 +217,15 @@ void AudioStreamPlayer2D::_notification(int p_what) { setseek = setplay; active = true; setplay = -1; - _change_notify("playing"); //update property in editor + //do not update, this makes it easier to animate (will shut off otherise) + //_change_notify("playing"); //update property in editor } //stop playing if no longer active if (!active) { set_fixed_process_internal(false); - _change_notify("playing"); //update property in editor + //do not update, this makes it easier to animate (will shut off otherise) + //_change_notify("playing"); //update property in editor emit_signal("finished"); } } @@ -252,8 +254,6 @@ void AudioStreamPlayer2D::set_stream(Ref<AudioStream> p_stream) { stream.unref(); ERR_FAIL_COND(stream_playback.is_null()); } - - } Ref<AudioStream> AudioStreamPlayer2D::get_stream() const { @@ -439,7 +439,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, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); 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"); @@ -447,7 +447,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/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 a69bec2fc8..2073ebf94e 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -530,13 +530,15 @@ void AudioStreamPlayer3D::_notification(int p_what) { setseek = setplay; active = true; setplay = -1; - _change_notify("playing"); //update property in editor + //do not update, this makes it easier to animate (will shut off otherise) + ///_change_notify("playing"); //update property in editor } //stop playing if no longer active if (!active) { set_fixed_process_internal(false); - _change_notify("playing"); //update property in editor + //do not update, this makes it easier to animate (will shut off otherise) + //_change_notify("playing"); //update property in editor emit_signal("finished"); } } @@ -877,7 +879,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, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); 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/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 bb54a43028..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 @@ -1092,7 +1076,7 @@ void GIProbe::_plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_b void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) { MeshInstance *mi = Object::cast_to<MeshInstance>(p_at_node); - if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT)) { + if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT) && mi->is_visible_in_tree()) { Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_valid()) { @@ -1113,25 +1097,29 @@ 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) { - Array meshes = p_at_node->call("get_meshes"); - for (int i = 0; i < meshes.size(); i += 2) { + if (s->is_visible_in_tree()) { - Transform mxf = meshes[i]; - Ref<Mesh> mesh = meshes[i + 1]; - if (!mesh.is_valid()) - continue; + Array meshes = p_at_node->call("get_meshes"); + for (int i = 0; i < meshes.size(); i += 2) { - Rect3 aabb = mesh->get_aabb(); + Transform mxf = meshes[i]; + Ref<Mesh> mesh = meshes[i + 1]; + if (!mesh.is_valid()) + continue; - Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf); + Rect3 aabb = mesh->get_aabb(); - if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) { - Baker::PlotMesh pm; - pm.local_xform = xf; - pm.mesh = mesh; - p_baker->mesh_list.push_back(pm); + Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf); + + if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) { + Baker::PlotMesh pm; + pm.local_xform = xf; + pm.mesh = mesh; + p_baker->mesh_list.push_back(pm); + } } } } 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 09b253b309..096f787873 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -230,7 +230,6 @@ void Light::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_shadow_color", "get_shadow_color"); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_bias", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_contact", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_CONTACT_SHADOW_SIZE); - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_max_distance", PROPERTY_HINT_RANGE, "0,65536,0.1"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_reverse_cull_face"), "set_shadow_reverse_cull_face", "get_shadow_reverse_cull_face"); ADD_GROUP("Editor", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only"); @@ -308,6 +307,16 @@ DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const { return shadow_mode; } +void DirectionalLight::set_shadow_depth_range(ShadowDepthRange 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 { + + return shadow_depth_range; +} + void DirectionalLight::set_blend_splits(bool p_enable) { blend_splits = p_enable; @@ -324,6 +333,9 @@ void DirectionalLight::_bind_methods() { ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &DirectionalLight::set_shadow_mode); ClassDB::bind_method(D_METHOD("get_shadow_mode"), &DirectionalLight::get_shadow_mode); + ClassDB::bind_method(D_METHOD("set_shadow_depth_range", "mode"), &DirectionalLight::set_shadow_depth_range); + ClassDB::bind_method(D_METHOD("get_shadow_depth_range"), &DirectionalLight::get_shadow_depth_range); + ClassDB::bind_method(D_METHOD("set_blend_splits", "enabled"), &DirectionalLight::set_blend_splits); ClassDB::bind_method(D_METHOD("is_blend_splits_enabled"), &DirectionalLight::is_blend_splits_enabled); @@ -335,10 +347,15 @@ void DirectionalLight::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "directional_shadow_blend_splits"), "set_blend_splits", "is_blend_splits_enabled"); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_normal_bias", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_SHADOW_NORMAL_BIAS); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_bias_split_scale", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS_SPLIT_SCALE); + ADD_PROPERTY(PropertyInfo(Variant::INT, "directional_shadow_depth_range", PROPERTY_HINT_ENUM, "Stable,Optimized"), "set_shadow_depth_range", "get_shadow_depth_range"); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_max_distance", PROPERTY_HINT_RANGE, "0,65536,0.1"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE); BIND_ENUM_CONSTANT(SHADOW_ORTHOGONAL); 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); } DirectionalLight::DirectionalLight() @@ -349,6 +366,7 @@ DirectionalLight::DirectionalLight() set_param(PARAM_SHADOW_MAX_DISTANCE, 200); set_param(PARAM_SHADOW_BIAS_SPLIT_SCALE, 0.25); set_shadow_mode(SHADOW_PARALLEL_4_SPLITS); + set_shadow_depth_range(SHADOW_DEPTH_RANGE_STABLE); blend_splits = false; } diff --git a/scene/3d/light.h b/scene/3d/light.h index 5d589d33e5..6aa0220265 100644 --- a/scene/3d/light.h +++ b/scene/3d/light.h @@ -133,9 +133,15 @@ public: SHADOW_PARALLEL_4_SPLITS }; + enum ShadowDepthRange { + SHADOW_DEPTH_RANGE_STABLE = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE, + SHADOW_DEPTH_RANGE_OPTIMIZED = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED, + }; + private: bool blend_splits; ShadowMode shadow_mode; + ShadowDepthRange shadow_depth_range; protected: static void _bind_methods(); @@ -144,6 +150,9 @@ public: void set_shadow_mode(ShadowMode p_mode); ShadowMode get_shadow_mode() const; + void set_shadow_depth_range(ShadowDepthRange p_mode); + ShadowDepthRange get_shadow_depth_range() const; + void set_blend_splits(bool p_enable); bool is_blend_splits_enabled() const; @@ -151,6 +160,7 @@ public: }; VARIANT_ENUM_CAST(DirectionalLight::ShadowMode) +VARIANT_ENUM_CAST(DirectionalLight::ShadowDepthRange) class OmniLight : public Light { 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/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 8bd924e7ce..341ae45ce8 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -304,7 +304,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, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active"); 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 961fccc804..87dfd95724 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1249,6 +1249,10 @@ void Control::_size_changed() { new_size_cache.height = MAX(minimum_size.height, new_size_cache.height); } + if (get_viewport()->is_snap_controls_to_pixels_enabled()) { + new_size_cache = new_size_cache.floor(); + new_pos_cache = new_pos_cache.floor(); + } bool pos_changed = new_pos_cache != data.pos_cache; bool size_changed = new_size_cache != data.size_cache; 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..db282262ec 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2304,7 +2304,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 +2478,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) { 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 c71a280755..567b1dd7a1 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2578,6 +2578,16 @@ int Viewport::get_render_info(RenderInfo p_info) { return VS::get_singleton()->viewport_get_render_info(viewport, VS::ViewportRenderInfo(p_info)); } +void Viewport::set_snap_controls_to_pixels(bool p_enable) { + + snap_controls_to_pixels = p_enable; +} + +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); @@ -2680,6 +2690,9 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_shadow_atlas_size", "size"), &Viewport::set_shadow_atlas_size); ClassDB::bind_method(D_METHOD("get_shadow_atlas_size"), &Viewport::get_shadow_atlas_size); + ClassDB::bind_method(D_METHOD("set_snap_controls_to_pixels", "enabled"), &Viewport::set_snap_controls_to_pixels); + ClassDB::bind_method(D_METHOD("is_snap_controls_to_pixels_enabled"), &Viewport::is_snap_controls_to_pixels_enabled); + ClassDB::bind_method(D_METHOD("set_shadow_atlas_quadrant_subdiv", "quadrant", "subdiv"), &Viewport::set_shadow_atlas_quadrant_subdiv); ClassDB::bind_method(D_METHOD("get_shadow_atlas_quadrant_subdiv", "quadrant"), &Viewport::get_shadow_atlas_quadrant_subdiv); @@ -2707,6 +2720,7 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "physics_object_picking"), "set_physics_object_picking", "get_physics_object_picking"); ADD_GROUP("GUI", "gui_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_disable_input"), "set_disable_input", "is_input_disabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_snap_controls_to_pixels"), "set_snap_controls_to_pixels", "is_snap_controls_to_pixels_enabled"); ADD_GROUP("Shadow Atlas", "shadow_atlas_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_atlas_size"), "set_shadow_atlas_size", "get_shadow_atlas_size"); ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_0", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 0); @@ -2822,6 +2836,8 @@ Viewport::Viewport() { usage = USAGE_3D; debug_draw = DEBUG_DRAW_DISABLED; clear_mode = CLEAR_MODE_ALWAYS; + + snap_controls_to_pixels = true; } Viewport::~Viewport() { diff --git a/scene/main/viewport.h b/scene/main/viewport.h index ce2bc991f5..6bbd4b26b5 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -1,3 +1,4 @@ + /*************************************************************************/ /* viewport.h */ /*************************************************************************/ @@ -193,6 +194,8 @@ private: bool filter; bool gen_mipmaps; + bool snap_controls_to_pixels; + bool physics_object_picking; List<Ref<InputEvent> > physics_picking_events; ObjectID physics_object_capture; @@ -463,6 +466,9 @@ public: int get_render_info(RenderInfo p_info); + void set_snap_controls_to_pixels(bool p_enable); + bool is_snap_controls_to_pixels_enabled() const; + Viewport(); ~Viewport(); }; 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/environment.cpp b/scene/resources/environment.cpp index 14225d945d..da3bc6a95b 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -269,13 +269,13 @@ Ref<Texture> Environment::get_adjustment_color_correction() const { void Environment::_validate_property(PropertyInfo &property) const { if (property.name == "background_sky" || property.name == "background_sky_scale" || property.name == "ambient_light/sky_contribution") { - if (bg_mode != BG_SKY) { + if (bg_mode != BG_SKY && bg_mode != BG_COLOR_SKY) { property.usage = PROPERTY_USAGE_NOEDITOR; } } if (property.name == "background_color") { - if (bg_mode != BG_COLOR) { + if (bg_mode != BG_COLOR && bg_mode != BG_COLOR_SKY) { property.usage = PROPERTY_USAGE_NOEDITOR; } } @@ -839,7 +839,7 @@ void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("get_ambient_light_sky_contribution"), &Environment::get_ambient_light_sky_contribution); ADD_GROUP("Background", "background_"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Sky,Canvas,Keep"), "set_background", "get_background"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Sky,Color+Sky,Canvas,Keep"), "set_background", "get_background"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "background_sky", PROPERTY_HINT_RESOURCE_TYPE, "Sky"), "set_sky", "get_sky"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_sky_scale", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_sky_scale", "get_sky_scale"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_bg_color", "get_bg_color"); @@ -1118,6 +1118,7 @@ void Environment::_bind_methods() { BIND_ENUM_CONSTANT(BG_CLEAR_COLOR); BIND_ENUM_CONSTANT(BG_COLOR); BIND_ENUM_CONSTANT(BG_SKY); + BIND_ENUM_CONSTANT(BG_COLOR_SKY); BIND_ENUM_CONSTANT(BG_CANVAS); BIND_ENUM_CONSTANT(BG_MAX); diff --git a/scene/resources/environment.h b/scene/resources/environment.h index 6337981b95..9046ec1e49 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -45,6 +45,7 @@ public: BG_CLEAR_COLOR, BG_COLOR, BG_SKY, + BG_COLOR_SKY, BG_CANVAS, BG_KEEP, BG_MAX 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(); }; |