From be611c1c0592d4aaa9c58f227a9c33301acd544b Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Tue, 19 Apr 2022 13:27:18 +0300 Subject: Implement Label3D node. Add "generate_mipmap" font import option. Add some missing features to the Sprite3D. Move BiDi override code from Control to TextServer. Add functions to access TextServer font cache textures. Add MSDF related flags and shader to the standard material. Change standard material cache to use HashMap instead of Vector. --- editor/plugins/node_3d_editor_gizmos.cpp | 33 ++++++++++++++++++++++++++++++++ editor/plugins/node_3d_editor_gizmos.h | 13 +++++++++++++ editor/plugins/node_3d_editor_plugin.cpp | 1 + editor/plugins/ot_features_plugin.cpp | 24 +++++++++++++++++++++-- 4 files changed, 69 insertions(+), 2 deletions(-) (limited to 'editor/plugins') diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 51e2f6ff00..179f78325c 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -47,6 +47,7 @@ #include "scene/3d/gpu_particles_3d.h" #include "scene/3d/gpu_particles_collision_3d.h" #include "scene/3d/joint_3d.h" +#include "scene/3d/label_3d.h" #include "scene/3d/light_3d.h" #include "scene/3d/lightmap_gi.h" #include "scene/3d/lightmap_probe.h" @@ -2170,6 +2171,38 @@ void Sprite3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { /// +Label3DGizmoPlugin::Label3DGizmoPlugin() { +} + +bool Label3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to(p_spatial) != nullptr; +} + +String Label3DGizmoPlugin::get_gizmo_name() const { + return "Label3D"; +} + +int Label3DGizmoPlugin::get_priority() const { + return -1; +} + +bool Label3DGizmoPlugin::can_be_hidden() const { + return false; +} + +void Label3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { + Label3D *label = Object::cast_to(p_gizmo->get_spatial_node()); + + p_gizmo->clear(); + + Ref tm = label->generate_triangle_mesh(); + if (tm.is_valid()) { + p_gizmo->add_collision_triangles(tm); + } +} + +/// + Position3DGizmoPlugin::Position3DGizmoPlugin() { pos3d_mesh = Ref(memnew(ArrayMesh)); cursor_points = Vector(); diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h index 3b67b898e3..8adb753a51 100644 --- a/editor/plugins/node_3d_editor_gizmos.h +++ b/editor/plugins/node_3d_editor_gizmos.h @@ -321,6 +321,19 @@ public: Sprite3DGizmoPlugin(); }; +class Label3DGizmoPlugin : public EditorNode3DGizmoPlugin { + GDCLASS(Label3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial) override; + String get_gizmo_name() const override; + int get_priority() const override; + bool can_be_hidden() const override; + void redraw(EditorNode3DGizmo *p_gizmo) override; + + Label3DGizmoPlugin(); +}; + class Position3DGizmoPlugin : public EditorNode3DGizmoPlugin { GDCLASS(Position3DGizmoPlugin, EditorNode3DGizmoPlugin); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index f2ca1fcfeb..6eed85e370 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -7278,6 +7278,7 @@ void Node3DEditor::_register_all_gizmos() { add_gizmo_plugin(Ref(memnew(OccluderInstance3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(SoftDynamicBody3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(Sprite3DGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(Label3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(Position3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(RayCast3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(SpringArm3DGizmoPlugin))); diff --git a/editor/plugins/ot_features_plugin.cpp b/editor/plugins/ot_features_plugin.cpp index 936eb747b0..ffa74173be 100644 --- a/editor/plugins/ot_features_plugin.cpp +++ b/editor/plugins/ot_features_plugin.cpp @@ -30,6 +30,8 @@ #include "ot_features_plugin.h" +#include "scene/3d/label_3d.h" + void OpenTypeFeaturesEditor::_value_changed(double val) { if (setting) { return; @@ -116,7 +118,25 @@ void OpenTypeFeaturesAdd::setup(Object *p_object) { bool have_ss = false; bool have_cv = false; bool have_cu = false; - Dictionary features = Object::cast_to(edited_object)->get_theme_font(SNAME("font"))->get_feature_list(); + + Ref font; + + Control *ctrl = Object::cast_to(edited_object); + if (ctrl != nullptr) { + font = ctrl->get_theme_font(SNAME("font")); + } else { + Label3D *l3d = Object::cast_to(edited_object); + if (l3d != nullptr) { + font = l3d->_get_font_or_default(); + } + } + + if (font.is_null()) { + return; + } + + Dictionary features = font->get_feature_list(); + for (const Variant *ftr = features.next(nullptr); ftr != nullptr; ftr = features.next(ftr)) { String ftr_name = TS->tag_to_name(*ftr); if (ftr_name.begins_with("stylistic_set_")) { @@ -185,7 +205,7 @@ OpenTypeFeaturesAdd::OpenTypeFeaturesAdd() { /*************************************************************************/ bool EditorInspectorPluginOpenTypeFeatures::can_handle(Object *p_object) { - return (Object::cast_to(p_object) != nullptr); + return (Object::cast_to(p_object) != nullptr) || (Object::cast_to(p_object) != nullptr); } bool EditorInspectorPluginOpenTypeFeatures::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) { -- cgit v1.2.3