summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/canvas_item.h4
-rw-r--r--scene/2d/navigation2d.cpp26
-rw-r--r--scene/2d/tile_map.cpp30
-rw-r--r--scene/2d/tile_map.h7
-rw-r--r--scene/3d/arvr_nodes.cpp2
-rw-r--r--scene/3d/light.cpp6
-rw-r--r--scene/3d/light.h1
-rw-r--r--scene/animation/tween.cpp24
-rw-r--r--scene/resources/material.cpp12
-rw-r--r--scene/resources/material.h4
10 files changed, 77 insertions, 39 deletions
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 3a99e917eb..5a0a9c6e6a 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -291,10 +291,10 @@ public:
RID get_canvas() const;
Ref<World2D> get_world_2d() const;
- void set_material(const Ref<Material> &p_material);
+ virtual void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
- void set_use_parent_material(bool p_use_parent_material);
+ virtual void set_use_parent_material(bool p_use_parent_material);
bool get_use_parent_material() const;
Ref<InputEvent> make_input_local(const Ref<InputEvent> &p_event) const;
diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp
index fa488b6b23..74d835dfb2 100644
--- a/scene/2d/navigation2d.cpp
+++ b/scene/2d/navigation2d.cpp
@@ -476,7 +476,6 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
Polygon *left_poly = end_poly;
Polygon *right_poly = end_poly;
Polygon *p = end_poly;
- path.push_back(end_point);
while (p) {
@@ -534,7 +533,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
left_poly = p;
portal_left = apex_point;
portal_right = apex_point;
- if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON)
+ if (!path.size() || path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON)
path.push_back(apex_point);
skip = true;
//print_line("addpoint left");
@@ -555,7 +554,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
right_poly = p;
portal_right = apex_point;
portal_left = apex_point;
- if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON)
+ if (!path.size() || path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON)
path.push_back(apex_point);
//print_line("addpoint right");
//print_line("***CLIP RIGHT");
@@ -568,16 +567,10 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
p = NULL;
}
- if (path[path.size() - 1].distance_to(begin_point) > CMP_EPSILON)
- path.push_back(begin_point);
-
- path.invert();
-
} else {
//midpoints
Polygon *p = end_poly;
- path.push_back(end_point);
while (true) {
int prev = p->prev_edge;
int prev_n = (p->prev_edge + 1) % p->edges.size();
@@ -587,11 +580,20 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
if (p == begin_poly)
break;
}
+ }
- if (path[path.size() - 1].distance_to(begin_point) > CMP_EPSILON)
- path.push_back(begin_point);
+ if (!path.size() || path[path.size() - 1].distance_squared_to(begin_point) > CMP_EPSILON) {
+ path.push_back(begin_point); // Add the begin point
+ } else {
+ path[path.size() - 1] = begin_point; // Replace first midpoint by the exact begin point
+ }
+
+ path.invert();
- path.invert();
+ if (path.size() <= 1 || path[path.size() - 1].distance_squared_to(end_point) > CMP_EPSILON) {
+ path.push_back(end_point); // Add the end point
+ } else {
+ path[path.size() - 1] = end_point; // Replace last midpoint by the exact end point
}
return path;
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index d41db1dce5..b1cc8c226a 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -336,6 +336,7 @@ void TileMap::_update_dirty_quadrants() {
if (mat.is_valid())
vs->canvas_item_set_material(canvas_item, mat->get_rid());
vs->canvas_item_set_parent(canvas_item, get_canvas_item());
+ _update_item_material_state(canvas_item);
Transform2D xform;
xform.set_origin(q.pos);
vs->canvas_item_set_transform(canvas_item, xform);
@@ -780,6 +781,35 @@ void TileMap::_clear_quadrants() {
}
}
+void TileMap::set_material(const Ref<Material> &p_material) {
+
+ CanvasItem::set_material(p_material);
+ _update_all_items_material_state();
+}
+
+void TileMap::set_use_parent_material(bool p_use_parent_material) {
+
+ CanvasItem::set_use_parent_material(p_use_parent_material);
+ _update_all_items_material_state();
+}
+
+void TileMap::_update_all_items_material_state() {
+
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+
+ Quadrant &q = E->get();
+ for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) {
+
+ _update_item_material_state(E->get());
+ }
+ }
+}
+
+void TileMap::_update_item_material_state(const RID &p_canvas_item) {
+
+ VS::get_singleton()->canvas_item_set_use_parent_material(p_canvas_item, get_use_parent_material() || get_material().is_valid());
+}
+
void TileMap::clear() {
_clear_quadrants();
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index f401d51eeb..c9d14e09d1 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -183,6 +183,9 @@ private:
void _update_quadrant_transform();
void _recompute_rect_cache();
+ void _update_all_items_material_state();
+ _FORCE_INLINE_ void _update_item_material_state(const RID &p_canvas_item);
+
_FORCE_INLINE_ int _get_quadrant_size() const;
void _set_tile_data(const PoolVector<int> &p_data);
@@ -278,6 +281,10 @@ public:
virtual void set_light_mask(int p_light_mask);
+ virtual void set_material(const Ref<Material> &p_material);
+
+ virtual void set_use_parent_material(bool p_use_parent_material);
+
void clear();
TileMap();
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index 545be8bc5f..caf313190b 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -264,7 +264,7 @@ void ARVRAnchor::_notification(int p_what) {
// our basis is scaled to the size of the plane the anchor is tracking
// extract the size from our basis and reset the scale
size = transform.basis.get_scale() * world_scale;
- transform.basis.set_scale(Vector3(1.0, 1.0, 1.0));
+ transform.basis.orthonormalize();
// apply our reference frame and set our transform
set_transform(arvr_server->get_reference_frame() * transform);
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 5b48ee4af8..09b253b309 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -334,6 +334,7 @@ void DirectionalLight::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_split_3", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_3_OFFSET);
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);
BIND_ENUM_CONSTANT(SHADOW_ORTHOGONAL);
BIND_ENUM_CONSTANT(SHADOW_PARALLEL_2_SPLITS);
@@ -343,9 +344,10 @@ void DirectionalLight::_bind_methods() {
DirectionalLight::DirectionalLight()
: Light(VisualServer::LIGHT_DIRECTIONAL) {
- set_param(PARAM_SHADOW_NORMAL_BIAS, 0.2);
- set_param(PARAM_SHADOW_BIAS, 1.0);
+ set_param(PARAM_SHADOW_NORMAL_BIAS, 0.8);
+ set_param(PARAM_SHADOW_BIAS, 0.1);
set_param(PARAM_SHADOW_MAX_DISTANCE, 200);
+ set_param(PARAM_SHADOW_BIAS_SPLIT_SCALE, 0.25);
set_shadow_mode(SHADOW_PARALLEL_4_SPLITS);
blend_splits = false;
diff --git a/scene/3d/light.h b/scene/3d/light.h
index 93dd4828da..5d589d33e5 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -58,6 +58,7 @@ public:
PARAM_SHADOW_SPLIT_3_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET,
PARAM_SHADOW_NORMAL_BIAS = VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS,
PARAM_SHADOW_BIAS = VS::LIGHT_PARAM_SHADOW_BIAS,
+ PARAM_SHADOW_BIAS_SPLIT_SCALE = VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE,
PARAM_MAX = VS::LIGHT_PARAM_MAX
};
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 3cd953773f..fb61c43d5c 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -560,12 +560,16 @@ void Tween::_tween_process(float p_delta) {
switch (data.type) {
case INTER_PROPERTY:
- case INTER_METHOD:
- break;
+ case INTER_METHOD: {
+ Variant result = _run_equation(data);
+ emit_signal("tween_step", object, data.key, data.elapsed, result);
+ _apply_tween_value(data, result);
+ if (data.finish)
+ _apply_tween_value(data, data.final_val);
+ } break;
+
case INTER_CALLBACK:
if (data.finish) {
-
- Variant::CallError error;
if (data.call_deferred) {
switch (data.args) {
@@ -588,8 +592,8 @@ void Tween::_tween_process(float p_delta) {
object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]);
break;
}
-
} else {
+ Variant::CallError error;
Variant *arg[5] = {
&data.arg[0],
&data.arg[1],
@@ -599,19 +603,11 @@ void Tween::_tween_process(float p_delta) {
};
object->call(data.key, (const Variant **)arg, data.args, error);
}
- if (!repeat)
- call_deferred("_remove", object, data.key, true);
}
- continue;
+ break;
}
- Variant result = _run_equation(data);
- emit_signal("tween_step", object, data.key, data.elapsed, result);
-
- _apply_tween_value(data, result);
-
if (data.finish) {
- _apply_tween_value(data, data.final_val);
emit_signal("tween_completed", object, data.key);
// not repeat mode, remove completed action
if (!repeat)
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 77563121df..5236461ad3 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -227,8 +227,8 @@ void SpatialMaterial::init_shaders() {
shader_names->uv1_blend_sharpness = "uv1_blend_sharpness";
shader_names->uv2_blend_sharpness = "uv2_blend_sharpness";
- shader_names->particle_h_frames = "particle_h_frames";
- shader_names->particle_v_frames = "particle_v_frames";
+ shader_names->particles_anim_h_frames = "particles_anim_h_frames";
+ shader_names->particles_anim_v_frames = "particles_anim_v_frames";
shader_names->particles_anim_loop = "particles_anim_loop";
shader_names->depth_min_layers = "depth_min_layers";
shader_names->depth_max_layers = "depth_max_layers";
@@ -503,8 +503,8 @@ void SpatialMaterial::_update_shader() {
code += "\tint particle_total_frames = particles_anim_h_frames * particles_anim_v_frames;\n";
code += "\tint particle_frame = int(INSTANCE_CUSTOM.y * float(particle_total_frames));\n";
code += "\tif (particles_anim_loop) particle_frame=clamp(particle_frame,0,particle_total_frames-1); else particle_frame=abs(particle_frame)%particle_total_frames;\n";
- //code += "\tUV /= vec2(float(particles_anim_h_frames),float(particles_anim_v_frames));\n";
- //code += "\tUV+= UV * vec2(float(particle_frame % particles_anim_h_frames),float(particle_frame / particles_anim_v_frames));\n";
+ code += "\tUV /= vec2(float(particles_anim_h_frames),float(particles_anim_v_frames));\n";
+ code += "\tUV += vec2(float(particle_frame % particles_anim_h_frames) / float(particles_anim_h_frames),float(particle_frame / particles_anim_h_frames) / float(particles_anim_v_frames));\n";
//handle rotation
// code += "\tmat4 rotation = mat4("
} break;
@@ -1281,7 +1281,7 @@ SpatialMaterial::BillboardMode SpatialMaterial::get_billboard_mode() const {
void SpatialMaterial::set_particles_anim_h_frames(int p_frames) {
particles_anim_h_frames = p_frames;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->particle_h_frames, p_frames);
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames);
}
int SpatialMaterial::get_particles_anim_h_frames() const {
@@ -1291,7 +1291,7 @@ int SpatialMaterial::get_particles_anim_h_frames() const {
void SpatialMaterial::set_particles_anim_v_frames(int p_frames) {
particles_anim_v_frames = p_frames;
- VS::get_singleton()->material_set_param(_get_material(), shader_names->particle_v_frames, p_frames);
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames);
}
int SpatialMaterial::get_particles_anim_v_frames() const {
diff --git a/scene/resources/material.h b/scene/resources/material.h
index b82e8d8cbd..6a0eead708 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -283,8 +283,8 @@ private:
StringName uv1_offset;
StringName uv2_scale;
StringName uv2_offset;
- StringName particle_h_frames;
- StringName particle_v_frames;
+ StringName particles_anim_h_frames;
+ StringName particles_anim_v_frames;
StringName particles_anim_loop;
StringName depth_min_layers;
StringName depth_max_layers;