summaryrefslogtreecommitdiffstats
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/bone_attachment_3d.cpp10
-rw-r--r--scene/3d/bone_attachment_3d.h4
-rw-r--r--scene/3d/soft_body_3d.cpp1
-rw-r--r--scene/gui/rich_text_label.cpp27
-rw-r--r--scene/resources/mesh.cpp2
-rw-r--r--scene/resources/particle_process_material.cpp43
-rw-r--r--scene/resources/particle_process_material.h4
-rw-r--r--scene/resources/primitive_meshes.cpp35
-rw-r--r--scene/resources/theme.cpp5
9 files changed, 94 insertions, 37 deletions
diff --git a/scene/3d/bone_attachment_3d.cpp b/scene/3d/bone_attachment_3d.cpp
index 60fb6f87c9..45de9b907c 100644
--- a/scene/3d/bone_attachment_3d.cpp
+++ b/scene/3d/bone_attachment_3d.cpp
@@ -349,6 +349,16 @@ void BoneAttachment3D::notify_skeleton_bones_renamed(Node *p_base_scene, Skeleto
}
}
}
+
+void BoneAttachment3D::notify_rebind_required() {
+ // Ensures bindings are properly updated after a scene reload.
+ _check_unbind();
+ if (use_external_skeleton) {
+ _update_external_skeleton_cache();
+ }
+ bone_idx = -1;
+ _check_bind();
+}
#endif // TOOLS_ENABLED
BoneAttachment3D::BoneAttachment3D() {
diff --git a/scene/3d/bone_attachment_3d.h b/scene/3d/bone_attachment_3d.h
index bfa3db476d..1bf44c2756 100644
--- a/scene/3d/bone_attachment_3d.h
+++ b/scene/3d/bone_attachment_3d.h
@@ -89,6 +89,10 @@ public:
virtual void on_bone_pose_update(int p_bone_index);
+#ifdef TOOLS_ENABLED
+ virtual void notify_rebind_required();
+#endif
+
BoneAttachment3D();
};
diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp
index 1f12f96fb3..db2c0e1387 100644
--- a/scene/3d/soft_body_3d.cpp
+++ b/scene/3d/soft_body_3d.cpp
@@ -471,6 +471,7 @@ void SoftBody3D::_become_mesh_owner() {
uint32_t surface_format = mesh->surface_get_format(0);
surface_format |= Mesh::ARRAY_FLAG_USE_DYNAMIC_UPDATE;
+ surface_format &= ~Mesh::ARRAY_FLAG_COMPRESS_ATTRIBUTES;
Ref<ArrayMesh> soft_mesh;
soft_mesh.instantiate();
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 7768c2d84e..1e2f010aad 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -1219,7 +1219,14 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
Item *it = _get_item_at_pos(it_from, it_to, glyphs[i].start);
Color font_color = _find_color(it, p_base_color);
if (_find_underline(it) || (_find_meta(it, nullptr) && underline_meta)) {
- if (!ul_started) {
+ if (ul_started && font_color != ul_color) {
+ float y_off = TS->shaped_text_get_underline_position(rid);
+ float underline_width = MAX(1.0, TS->shaped_text_get_underline_thickness(rid) * theme_cache.base_scale);
+ draw_line(ul_start + Vector2(0, y_off), p_ofs + Vector2(off.x, off.y + y_off), ul_color, underline_width);
+ ul_start = p_ofs + Vector2(off.x, off.y);
+ ul_color = font_color;
+ ul_color.a *= 0.5;
+ } else if (!ul_started) {
ul_started = true;
ul_start = p_ofs + Vector2(off.x, off.y);
ul_color = font_color;
@@ -1232,7 +1239,14 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
draw_line(ul_start + Vector2(0, y_off), p_ofs + Vector2(off.x, off.y + y_off), ul_color, underline_width);
}
if (_find_hint(it, nullptr) && underline_hint) {
- if (!dot_ul_started) {
+ if (dot_ul_started && font_color != dot_ul_color) {
+ float y_off = TS->shaped_text_get_underline_position(rid);
+ float underline_width = MAX(1.0, TS->shaped_text_get_underline_thickness(rid) * theme_cache.base_scale);
+ draw_dashed_line(dot_ul_start + Vector2(0, y_off), p_ofs + Vector2(off.x, off.y + y_off), dot_ul_color, underline_width, MAX(2.0, underline_width * 2));
+ dot_ul_start = p_ofs + Vector2(off.x, off.y);
+ dot_ul_color = font_color;
+ dot_ul_color.a *= 0.5;
+ } else if (!dot_ul_started) {
dot_ul_started = true;
dot_ul_start = p_ofs + Vector2(off.x, off.y);
dot_ul_color = font_color;
@@ -1245,7 +1259,14 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
draw_dashed_line(dot_ul_start + Vector2(0, y_off), p_ofs + Vector2(off.x, off.y + y_off), dot_ul_color, underline_width, MAX(2.0, underline_width * 2));
}
if (_find_strikethrough(it)) {
- if (!st_started) {
+ if (st_started && font_color != st_color) {
+ float y_off = -TS->shaped_text_get_ascent(rid) + TS->shaped_text_get_size(rid).y / 2;
+ float underline_width = MAX(1.0, TS->shaped_text_get_underline_thickness(rid) * theme_cache.base_scale);
+ draw_line(st_start + Vector2(0, y_off), p_ofs + Vector2(off.x, off.y + y_off), st_color, underline_width);
+ st_start = p_ofs + Vector2(off.x, off.y);
+ st_color = font_color;
+ st_color.a *= 0.5;
+ } else if (!st_started) {
st_started = true;
st_start = p_ofs + Vector2(off.x, off.y);
st_color = font_color;
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index b122189558..6f12539a6d 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -870,6 +870,8 @@ void Mesh::_bind_methods() {
BIND_BITFIELD_FLAG(ARRAY_FLAG_USE_8_BONE_WEIGHTS);
BIND_BITFIELD_FLAG(ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY);
+ BIND_BITFIELD_FLAG(ARRAY_FLAG_COMPRESS_ATTRIBUTES);
+
BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_NORMALIZED);
BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_RELATIVE);
diff --git a/scene/resources/particle_process_material.cpp b/scene/resources/particle_process_material.cpp
index 968ec77d1d..b58c3ad433 100644
--- a/scene/resources/particle_process_material.cpp
+++ b/scene/resources/particle_process_material.cpp
@@ -31,7 +31,6 @@
#include "particle_process_material.h"
#include "core/version.h"
-#include "scene/resources/curve_texture.h"
Mutex ParticleProcessMaterial::material_mutex;
SelfList<ParticleProcessMaterial>::List *ParticleProcessMaterial::dirty_materials = nullptr;
@@ -672,13 +671,18 @@ void ParticleProcessMaterial::_update_shader() {
code += " float orbit_amount = param.orbit_velocity;\n";
if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid()) {
- code += " orbit_amount *= texture(orbit_velocity_curve, vec2(lifetime)).r;\n";
+ CurveTexture *texture = Object::cast_to<CurveTexture>(tex_parameters[PARAM_ORBIT_VELOCITY].ptr());
+ if (texture) {
+ code += " orbit_amount *= texture(orbit_velocity_curve, vec2(lifetime)).r;\n";
+ } else {
+ code += " orbit_amount *= texture(orbit_velocity_curve, vec2(lifetime)).b;\n";
+ }
}
code += " if (orbit_amount != 0.0) {\n";
code += " vec3 pos = transform[3].xyz;\n";
code += " vec3 org = emission_transform[3].xyz;\n";
code += " vec3 diff = pos - org;\n";
- code += " float ang = orbit_amount * pi * 2.0;\n";
+ code += " float ang = orbit_amount * pi * 2.0 * delta;\n";
code += " mat2 rot = mat2(vec2(cos(ang), -sin(ang)), vec2(sin(ang), cos(ang)));\n";
code += " displacement.xy -= diff.xy;\n";
code += " displacement.xy += rot * diff.xy;\n";
@@ -687,8 +691,8 @@ void ParticleProcessMaterial::_update_shader() {
code += " vec3 orbit_velocities = vec3(param.orbit_velocity);\n";
code += " orbit_velocities *= texture(orbit_velocity_curve, vec2(lifetime)).rgb;\n";
- code += " orbit_velocities *= degree_to_rad;\n";
- code += " orbit_velocities *= delta/total_lifetime; // we wanna process those by the delta angle\n";
+ code += " orbit_velocities *= pi * 2.0;\n";
+ code += " orbit_velocities *= delta; // we wanna process those by the delta angle\n";
code += " //vec3 local_velocity_pivot = ((emission_transform) * vec4(velocity_pivot,1.0)).xyz;\n";
code += " // X axis\n";
code += " vec3 local_pos = (inverse(emission_transform) * transform[3]).xyz;\n";
@@ -719,7 +723,7 @@ void ParticleProcessMaterial::_update_shader() {
code += " local_pos -= velocity_pivot;\n";
code += " local_pos.z = 0.;\n";
code += " mat3 z_rotation_mat = mat3(\n";
- code += " vec3(cos(orbit_velocities.z),-sin(orbit_velocities.z),0.0),\n";
+ code += " vec3(cos(orbit_velocities.z),sin(orbit_velocities.z),0.0),\n";
code += " vec3(-sin(orbit_velocities.z),cos(orbit_velocities.z), 0.0),\n";
code += " vec3(0.0,0.0,1.0)\n";
code += " );\n";
@@ -958,21 +962,22 @@ void ParticleProcessMaterial::_update_shader() {
code += " {\n";
code += " // copied from previous version\n";
code += " if (physics_params.damping > 0.0) {\n";
+ code += " float v = length(VELOCITY);\n";
if (!particle_flags[PARTICLE_FLAG_DAMPING_AS_FRICTION]) {
- code += " float v = length(VELOCITY);\n";
+ code += " v -= physics_params.damping * DELTA;\n";
+ } else {
+ code += " if (v > 0.001) {\n";
code += " // Realistic friction formula. We assume the mass of a particle to be 0.05kg.\n";
code += " float damp = v * v * physics_params.damping * 0.05 * DELTA;\n";
code += " v -= damp;\n";
- code += " if (v < 0.0) {\n";
- code += " VELOCITY = vec3(0.0);\n";
- code += " } else {\n";
- code += " VELOCITY = normalize(VELOCITY) * v;\n";
- code += " }\n";
- } else {
- code += " if (length(VELOCITY) > 0.01){\n";
- code += " VELOCITY -= normalize(VELOCITY) * length(VELOCITY) * (physics_params.damping) * DELTA;\n";
- code += " }\n";
+ code += " }\n";
}
+
+ code += " if (v < 0.0) {\n";
+ code += " VELOCITY = vec3(0.0);\n";
+ code += " } else {\n";
+ code += " VELOCITY = normalize(VELOCITY) * v;\n";
+ code += " }\n";
code += " }\n";
code += " \n";
code += " }\n";
@@ -1387,7 +1392,7 @@ void ParticleProcessMaterial::set_param_texture(Parameter p_param, const Ref<Tex
} break;
case PARAM_ORBIT_VELOCITY: {
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_texture, tex_rid);
- _adjust_curve_range(p_texture, -500, 500);
+ _adjust_curve_range(p_texture, -2, 2);
notify_property_list_changed();
} break;
case PARAM_LINEAR_ACCEL: {
@@ -2100,8 +2105,8 @@ void ParticleProcessMaterial::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "directional_velocity_max", PROPERTY_HINT_RANGE, "-720,720,0.01,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_DIRECTIONAL_VELOCITY);
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "directional_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveXYZTexture"), "set_param_texture", "get_param_texture", PARAM_DIRECTIONAL_VELOCITY);
ADD_SUBGROUP("Orbit Velocity", "orbit_");
- ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "orbit_velocity_min", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_ORBIT_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "orbit_velocity_max", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_ORBIT_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "orbit_velocity_min", PROPERTY_HINT_RANGE, "-2,2,0.001,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_ORBIT_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "orbit_velocity_max", PROPERTY_HINT_RANGE, "-2,2,0.001,or_less,or_greater"), "set_param_max", "get_param_max", PARAM_ORBIT_VELOCITY);
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "orbit_velocity_curve", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture,CurveXYZTexture"), "set_param_texture", "get_param_texture", PARAM_ORBIT_VELOCITY);
ADD_SUBGROUP("Radial Velocity", "radial_");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "radial_velocity_min", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_less,or_greater"), "set_param_min", "get_param_min", PARAM_RADIAL_VELOCITY);
diff --git a/scene/resources/particle_process_material.h b/scene/resources/particle_process_material.h
index d3d8f89a15..5ed8b61c77 100644
--- a/scene/resources/particle_process_material.h
+++ b/scene/resources/particle_process_material.h
@@ -33,6 +33,7 @@
#include "core/templates/rid.h"
#include "core/templates/self_list.h"
+#include "scene/resources/curve_texture.h"
#include "scene/resources/material.h"
/*
@@ -125,6 +126,7 @@ private:
uint64_t alpha_curve : 1;
uint64_t emission_curve : 1;
uint64_t has_initial_ramp : 1;
+ uint64_t orbit_uses_curve_xyz : 1;
MaterialKey() {
memset(this, 0, sizeof(MaterialKey));
@@ -165,6 +167,8 @@ private:
mk.alpha_curve = alpha_curve.is_valid() ? 1 : 0;
mk.emission_curve = emission_curve.is_valid() ? 1 : 0;
mk.has_initial_ramp = color_initial_ramp.is_valid() ? 1 : 0;
+ CurveXYZTexture *texture = Object::cast_to<CurveXYZTexture>(tex_parameters[PARAM_ORBIT_VELOCITY].ptr());
+ mk.orbit_uses_curve_xyz = texture ? 1 : 0;
for (int i = 0; i < PARAM_MAX; i++) {
if (tex_parameters[i].is_valid()) {
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index b323710743..13791d8c2b 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -1300,7 +1300,11 @@ void PlaneMesh::_create_mesh_array(Array &p_arr) const {
points.push_back(Vector3(-x, z, 0.0) + center_offset);
}
normals.push_back(normal);
- ADD_TANGENT(1.0, 0.0, 0.0, 1.0);
+ if (orientation == FACE_X) {
+ ADD_TANGENT(0.0, 0.0, -1.0, 1.0);
+ } else {
+ ADD_TANGENT(1.0, 0.0, 0.0, 1.0);
+ }
uvs.push_back(Vector2(1.0 - u, 1.0 - v)); /* 1.0 - uv to match orientation with Quad */
point++;
@@ -2722,7 +2726,6 @@ void TextMesh::_generate_glyph_mesh_data(const GlyphMeshKey &p_key, const Glyph
GlyphMeshData &gl_data = cache[p_key];
Dictionary d = TS->font_get_glyph_contours(p_gl.font_rid, p_gl.font_size, p_gl.index);
- Vector2 origin = Vector2(p_gl.x_off, p_gl.y_off) * pixel_size;
PackedVector3Array points = d["points"];
PackedInt32Array contours = d["contours"];
@@ -2742,7 +2745,7 @@ void TextMesh::_generate_glyph_mesh_data(const GlyphMeshKey &p_key, const Glyph
for (int32_t j = start; j <= end; j++) {
if (points[j].z == TextServer::CONTOUR_CURVE_TAG_ON) {
// Point on the curve.
- Vector2 p = Vector2(points[j].x, points[j].y) * pixel_size + origin;
+ Vector2 p = Vector2(points[j].x, points[j].y) * pixel_size;
polygon.push_back(ContourPoint(p, true));
} else if (points[j].z == TextServer::CONTOUR_CURVE_TAG_OFF_CONIC) {
// Conic Bezier arc.
@@ -2776,7 +2779,7 @@ void TextMesh::_generate_glyph_mesh_data(const GlyphMeshKey &p_key, const Glyph
real_t t2 = t * t;
Vector2 point = p1 + omt2 * (p0 - p1) + t2 * (p2 - p1);
- Vector2 p = point * pixel_size + origin;
+ Vector2 p = point * pixel_size;
polygon.push_back(ContourPoint(p, false));
t += step;
}
@@ -2810,7 +2813,7 @@ void TextMesh::_generate_glyph_mesh_data(const GlyphMeshKey &p_key, const Glyph
real_t t = step;
while (t < 1.0) {
Vector2 point = p0.bezier_interpolate(p1, p2, p3, t);
- Vector2 p = point * pixel_size + origin;
+ Vector2 p = point * pixel_size;
polygon.push_back(ContourPoint(p, false));
t += step;
}
@@ -3045,6 +3048,7 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
GlyphMeshKey key = GlyphMeshKey(glyphs[j].font_rid.get_id(), glyphs[j].index);
_generate_glyph_mesh_data(key, glyphs[j]);
GlyphMeshData &gl_data = cache[key];
+ const Vector2 gl_of = Vector2(glyphs[j].x_off, glyphs[j].y_off) * pixel_size;
p_size += glyphs[j].repeat * gl_data.triangles.size() * ((has_depth) ? 2 : 1);
i_size += glyphs[j].repeat * gl_data.triangles.size() * ((has_depth) ? 2 : 1);
@@ -3057,10 +3061,10 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
}
for (int r = 0; r < glyphs[j].repeat; r++) {
- min_p.x = MIN(gl_data.min_p.x + offset.x, min_p.x);
- min_p.y = MIN(gl_data.min_p.y - offset.y, min_p.y);
- max_p.x = MAX(gl_data.max_p.x + offset.x, max_p.x);
- max_p.y = MAX(gl_data.max_p.y - offset.y, max_p.y);
+ min_p.x = MIN(gl_data.min_p.x + offset.x + gl_of.x, min_p.x);
+ min_p.y = MIN(gl_data.min_p.y - offset.y + gl_of.y, min_p.y);
+ max_p.x = MAX(gl_data.max_p.x + offset.x + gl_of.x, max_p.x);
+ max_p.y = MAX(gl_data.max_p.y - offset.y + gl_of.y, max_p.y);
offset.x += glyphs[j].advance * pixel_size;
}
@@ -3126,12 +3130,13 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
int64_t ts = gl_data.triangles.size();
const Vector2 *ts_ptr = gl_data.triangles.ptr();
+ const Vector2 gl_of = Vector2(glyphs[j].x_off, glyphs[j].y_off) * pixel_size;
for (int r = 0; r < glyphs[j].repeat; r++) {
for (int k = 0; k < ts; k += 3) {
// Add front face.
for (int l = 0; l < 3; l++) {
- Vector3 point = Vector3(ts_ptr[k + l].x + offset.x, -ts_ptr[k + l].y + offset.y, depth / 2.0);
+ Vector3 point = Vector3(ts_ptr[k + l].x + offset.x + gl_of.x, -ts_ptr[k + l].y + offset.y - gl_of.y, depth / 2.0);
vertices_ptr[p_idx] = point;
normals_ptr[p_idx] = Vector3(0.0, 0.0, 1.0);
if (has_depth) {
@@ -3149,7 +3154,7 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
if (has_depth) {
// Add back face.
for (int l = 2; l >= 0; l--) {
- Vector3 point = Vector3(ts_ptr[k + l].x + offset.x, -ts_ptr[k + l].y + offset.y, -depth / 2.0);
+ Vector3 point = Vector3(ts_ptr[k + l].x + offset.x + gl_of.x, -ts_ptr[k + l].y + offset.y - gl_of.y, -depth / 2.0);
vertices_ptr[p_idx] = point;
normals_ptr[p_idx] = Vector3(0.0, 0.0, -1.0);
uvs_ptr[p_idx] = Vector2(Math::remap(point.x, min_p.x, max_p.x, real_t(0.0), real_t(1.0)), Math::remap(point.y, -max_p.y, -min_p.y, real_t(0.8), real_t(0.4)));
@@ -3182,10 +3187,10 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
real_t seg_len = (ps_ptr[next].point - ps_ptr[l].point).length();
Vector3 quad_faces[4] = {
- Vector3(ps_ptr[l].point.x + offset.x, -ps_ptr[l].point.y + offset.y, -depth / 2.0),
- Vector3(ps_ptr[next].point.x + offset.x, -ps_ptr[next].point.y + offset.y, -depth / 2.0),
- Vector3(ps_ptr[l].point.x + offset.x, -ps_ptr[l].point.y + offset.y, depth / 2.0),
- Vector3(ps_ptr[next].point.x + offset.x, -ps_ptr[next].point.y + offset.y, depth / 2.0),
+ Vector3(ps_ptr[l].point.x + offset.x + gl_of.x, -ps_ptr[l].point.y + offset.y - gl_of.y, -depth / 2.0),
+ Vector3(ps_ptr[next].point.x + offset.x + gl_of.x, -ps_ptr[next].point.y + offset.y - gl_of.y, -depth / 2.0),
+ Vector3(ps_ptr[l].point.x + offset.x + gl_of.x, -ps_ptr[l].point.y + offset.y - gl_of.y, depth / 2.0),
+ Vector3(ps_ptr[next].point.x + offset.x + gl_of.x, -ps_ptr[next].point.y + offset.y - gl_of.y, depth / 2.0),
};
for (int m = 0; m < 4; m++) {
const Vector2 &d = ((m % 2) == 0) ? d1 : d2;
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index d2a1519d49..d57a0f6b38 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -1240,6 +1240,11 @@ void Theme::get_type_list(List<StringName> *p_list) const {
types.insert(E.key);
}
+ // Variations.
+ for (const KeyValue<StringName, StringName> &E : variation_map) {
+ types.insert(E.key);
+ }
+
for (const StringName &E : types) {
p_list->push_back(E);
}