summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/label_3d.cpp17
-rw-r--r--scene/3d/label_3d.h14
-rw-r--r--scene/3d/path_3d.cpp14
-rw-r--r--scene/3d/path_3d.h2
4 files changed, 19 insertions, 28 deletions
diff --git a/scene/3d/label_3d.cpp b/scene/3d/label_3d.cpp
index d95cf15bfa..6ed4ce8c5b 100644
--- a/scene/3d/label_3d.cpp
+++ b/scene/3d/label_3d.cpp
@@ -155,11 +155,6 @@ void Label3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "text_direction", PROPERTY_HINT_ENUM, "Auto,Left-to-Right,Right-to-Left"), "set_text_direction", "get_text_direction");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "language", PROPERTY_HINT_LOCALE_ID, ""), "set_language", "get_language");
- BIND_ENUM_CONSTANT(AUTOWRAP_OFF);
- BIND_ENUM_CONSTANT(AUTOWRAP_ARBITRARY);
- BIND_ENUM_CONSTANT(AUTOWRAP_WORD);
- BIND_ENUM_CONSTANT(AUTOWRAP_WORD_SMART);
-
BIND_ENUM_CONSTANT(FLAG_SHADED);
BIND_ENUM_CONSTANT(FLAG_DOUBLE_SIDED);
BIND_ENUM_CONSTANT(FLAG_DISABLE_DEPTH_TEST);
@@ -514,16 +509,16 @@ void Label3D::_shape() {
uint16_t autowrap_flags = TextServer::BREAK_MANDATORY;
switch (autowrap_mode) {
- case AUTOWRAP_WORD_SMART:
+ case TextServer::AUTOWRAP_WORD_SMART:
autowrap_flags = TextServer::BREAK_WORD_BOUND_ADAPTIVE | TextServer::BREAK_MANDATORY;
break;
- case AUTOWRAP_WORD:
+ case TextServer::AUTOWRAP_WORD:
autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_MANDATORY;
break;
- case AUTOWRAP_ARBITRARY:
+ case TextServer::AUTOWRAP_ARBITRARY:
autowrap_flags = TextServer::BREAK_GRAPHEME_BOUND | TextServer::BREAK_MANDATORY;
break;
- case AUTOWRAP_OFF:
+ case TextServer::AUTOWRAP_OFF:
break;
}
PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(text_rid, width, 0, autowrap_flags);
@@ -885,7 +880,7 @@ Color Label3D::get_outline_modulate() const {
return outline_modulate;
}
-void Label3D::set_autowrap_mode(Label3D::AutowrapMode p_mode) {
+void Label3D::set_autowrap_mode(TextServer::AutowrapMode p_mode) {
if (autowrap_mode != p_mode) {
autowrap_mode = p_mode;
dirty_lines = true;
@@ -893,7 +888,7 @@ void Label3D::set_autowrap_mode(Label3D::AutowrapMode p_mode) {
}
}
-Label3D::AutowrapMode Label3D::get_autowrap_mode() const {
+TextServer::AutowrapMode Label3D::get_autowrap_mode() const {
return autowrap_mode;
}
diff --git a/scene/3d/label_3d.h b/scene/3d/label_3d.h
index 62f4c3fe96..7766bca068 100644
--- a/scene/3d/label_3d.h
+++ b/scene/3d/label_3d.h
@@ -54,13 +54,6 @@ public:
ALPHA_CUT_OPAQUE_PREPASS
};
- enum AutowrapMode {
- AUTOWRAP_OFF,
- AUTOWRAP_ARBITRARY,
- AUTOWRAP_WORD,
- AUTOWRAP_WORD_SMART
- };
-
private:
real_t pixel_size = 0.01;
bool flags[FLAG_MAX] = {};
@@ -91,7 +84,7 @@ private:
String xl_text;
bool uppercase = false;
- AutowrapMode autowrap_mode = AUTOWRAP_OFF;
+ TextServer::AutowrapMode autowrap_mode = TextServer::AUTOWRAP_OFF;
float width = 500.0;
int font_size = 16;
@@ -200,8 +193,8 @@ public:
void set_outline_modulate(const Color &p_color);
Color get_outline_modulate() const;
- void set_autowrap_mode(AutowrapMode p_mode);
- AutowrapMode get_autowrap_mode() const;
+ void set_autowrap_mode(TextServer::AutowrapMode p_mode);
+ TextServer::AutowrapMode get_autowrap_mode() const;
void set_width(float p_width);
float get_width() const;
@@ -234,7 +227,6 @@ public:
~Label3D();
};
-VARIANT_ENUM_CAST(Label3D::AutowrapMode);
VARIANT_ENUM_CAST(Label3D::DrawFlags);
VARIANT_ENUM_CAST(Label3D::AlphaCutMode);
diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp
index 8c2b1c6889..e13cf6f9c8 100644
--- a/scene/3d/path_3d.cpp
+++ b/scene/3d/path_3d.cpp
@@ -157,10 +157,14 @@ void PathFollow3D::_update_transform(bool p_update_xyz_rot) {
// for a discussion about why not Frenet frame.
t.origin = pos;
-
- if (p_update_xyz_rot && delta_offset != 0) { // Only update rotation if some parameter has changed - i.e. not on addition to scene tree.
- Vector3 t_prev = (pos - c->interpolate_baked(offset - delta_offset, cubic)).normalized();
- Vector3 t_cur = (c->interpolate_baked(offset + delta_offset, cubic) - pos).normalized();
+ if (p_update_xyz_rot && prev_offset != offset) { // Only update rotation if some parameter has changed - i.e. not on addition to scene tree.
+ real_t sample_distance = bi * 0.01;
+ Vector3 t_prev_pos_a = c->interpolate_baked(prev_offset - sample_distance, cubic);
+ Vector3 t_prev_pos_b = c->interpolate_baked(prev_offset + sample_distance, cubic);
+ Vector3 t_cur_pos_a = c->interpolate_baked(offset - sample_distance, cubic);
+ Vector3 t_cur_pos_b = c->interpolate_baked(offset + sample_distance, cubic);
+ Vector3 t_prev = (t_prev_pos_a - t_prev_pos_b).normalized();
+ Vector3 t_cur = (t_cur_pos_a - t_cur_pos_b).normalized();
Vector3 axis = t_prev.cross(t_cur);
real_t dot = t_prev.dot(t_cur);
@@ -303,7 +307,7 @@ void PathFollow3D::_bind_methods() {
}
void PathFollow3D::set_offset(real_t p_offset) {
- delta_offset = p_offset - offset;
+ prev_offset = offset;
offset = p_offset;
if (path) {
diff --git a/scene/3d/path_3d.h b/scene/3d/path_3d.h
index e9ab557693..cb67a044d1 100644
--- a/scene/3d/path_3d.h
+++ b/scene/3d/path_3d.h
@@ -65,7 +65,7 @@ public:
private:
Path3D *path = nullptr;
- real_t delta_offset = 0.0; // Change in offset since last _update_transform.
+ real_t prev_offset = 0.0; // Offset during the last _update_transform.
real_t offset = 0.0;
real_t h_offset = 0.0;
real_t v_offset = 0.0;