summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/import/editor_import_collada.cpp11
-rw-r--r--editor/plugins/ot_features_plugin.cpp39
-rw-r--r--editor/plugins/ot_features_plugin.h8
-rw-r--r--modules/fbx/data/fbx_mesh_data.cpp11
-rw-r--r--modules/gltf/gltf_document.cpp7
5 files changed, 45 insertions, 31 deletions
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 3b5a82b2c3..69fa64c24c 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -994,13 +994,12 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ImporterMesh> &p
Array a = p_morph_meshes[mi]->get_surface_arrays(surface);
//add valid weight and bone arrays if they exist, TODO check if they are unique to shape (generally not)
- if (has_weights) {
- a[Mesh::ARRAY_WEIGHTS] = d[Mesh::ARRAY_WEIGHTS];
- a[Mesh::ARRAY_BONES] = d[Mesh::ARRAY_BONES];
+ // Enforce blend shape mask array format
+ for (int mj = 0; mj < Mesh::ARRAY_MAX; mj++) {
+ if (!(Mesh::ARRAY_FORMAT_BLEND_SHAPE_MASK & (1 << mj))) {
+ a[mj] = Variant();
+ }
}
-
- a[Mesh::ARRAY_INDEX] = Variant();
- //a.resize(Mesh::ARRAY_MAX); //no need for index
mr.push_back(a);
}
diff --git a/editor/plugins/ot_features_plugin.cpp b/editor/plugins/ot_features_plugin.cpp
index 9cd428a2d4..27b35d803c 100644
--- a/editor/plugins/ot_features_plugin.cpp
+++ b/editor/plugins/ot_features_plugin.cpp
@@ -96,10 +96,19 @@ OpenTypeFeaturesEditor::OpenTypeFeaturesEditor() {
/*************************************************************************/
void OpenTypeFeaturesAdd::_add_feature(int p_option) {
- get_edited_object()->set("opentype_features/" + TS->tag_to_name(p_option), 1);
+ edited_object->set("opentype_features/" + TS->tag_to_name(p_option), 1);
}
-void OpenTypeFeaturesAdd::update_property() {
+void OpenTypeFeaturesAdd::_features_menu() {
+ Size2 size = get_size();
+ menu->set_position(get_screen_position() + Size2(0, size.height * get_global_transform().get_scale().y));
+ menu->reset_size();
+ menu->popup();
+}
+
+void OpenTypeFeaturesAdd::setup(Object *p_object) {
+ edited_object = p_object;
+
menu->clear();
menu_ss->clear();
menu_cv->clear();
@@ -107,7 +116,7 @@ void OpenTypeFeaturesAdd::update_property() {
bool have_ss = false;
bool have_cv = false;
bool have_cu = false;
- Dictionary features = Object::cast_to<Control>(get_edited_object())->get_theme_font(SNAME("font"))->get_feature_list();
+ Dictionary features = Object::cast_to<Control>(edited_object)->get_theme_font(SNAME("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_")) {
@@ -134,20 +143,11 @@ void OpenTypeFeaturesAdd::update_property() {
}
}
-void OpenTypeFeaturesAdd::_features_menu() {
- Size2 size = get_size();
- menu->set_position(get_screen_position() + Size2(0, size.height * get_global_transform().get_scale().y));
- menu->reset_size();
- menu->popup();
-}
-
void OpenTypeFeaturesAdd::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
- set_label("");
- button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- button->set_size(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))->get_size());
+ set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
} break;
}
}
@@ -156,6 +156,8 @@ void OpenTypeFeaturesAdd::_bind_methods() {
}
OpenTypeFeaturesAdd::OpenTypeFeaturesAdd() {
+ set_text(TTR("Add Feature..."));
+
menu = memnew(PopupMenu);
add_child(menu);
@@ -171,13 +173,7 @@ OpenTypeFeaturesAdd::OpenTypeFeaturesAdd() {
menu_cu->set_name("CUMenu");
menu->add_child(menu_cu);
- button = memnew(Button);
- button->set_flat(true);
- button->set_text(RTR("Add feature..."));
- button->set_tooltip(RTR("Add feature..."));
- add_child(button);
-
- button->connect("pressed", callable_mp(this, &OpenTypeFeaturesAdd::_features_menu));
+ connect("pressed", callable_mp(this, &OpenTypeFeaturesAdd::_features_menu));
menu->connect("id_pressed", callable_mp(this, &OpenTypeFeaturesAdd::_add_feature));
menu_cv->connect("id_pressed", callable_mp(this, &OpenTypeFeaturesAdd::_add_feature));
menu_ss->connect("id_pressed", callable_mp(this, &OpenTypeFeaturesAdd::_add_feature));
@@ -193,7 +189,8 @@ bool EditorInspectorPluginOpenTypeFeatures::can_handle(Object *p_object) {
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) {
if (p_path == "opentype_features/_new") {
OpenTypeFeaturesAdd *editor = memnew(OpenTypeFeaturesAdd);
- add_property_editor(p_path, editor);
+ editor->setup(p_object);
+ add_custom_control(editor);
return true;
} else if (p_path.begins_with("opentype_features")) {
OpenTypeFeaturesEditor *editor = memnew(OpenTypeFeaturesEditor);
diff --git a/editor/plugins/ot_features_plugin.h b/editor/plugins/ot_features_plugin.h
index 8c38d888de..fcbc8692ca 100644
--- a/editor/plugins/ot_features_plugin.h
+++ b/editor/plugins/ot_features_plugin.h
@@ -56,10 +56,10 @@ public:
/*************************************************************************/
-class OpenTypeFeaturesAdd : public EditorProperty {
- GDCLASS(OpenTypeFeaturesAdd, EditorProperty);
+class OpenTypeFeaturesAdd : public Button {
+ GDCLASS(OpenTypeFeaturesAdd, Button);
- Button *button = nullptr;
+ Object *edited_object = nullptr;
PopupMenu *menu = nullptr;
PopupMenu *menu_ss = nullptr;
PopupMenu *menu_cv = nullptr;
@@ -73,7 +73,7 @@ protected:
static void _bind_methods();
public:
- virtual void update_property() override;
+ void setup(Object *p_object);
OpenTypeFeaturesAdd();
};
diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp
index 643a74f83e..1d59851778 100644
--- a/modules/fbx/data/fbx_mesh_data.cpp
+++ b/modules/fbx/data/fbx_mesh_data.cpp
@@ -371,6 +371,17 @@ ImporterMeshInstance3D *FBXMeshData::create_fbx_mesh(const ImportState &state, c
Array mesh_array = surface->surface_tool->commit_to_arrays();
Array blend_shapes = surface->morphs;
+ // Enforce blend shape mask array format
+ for (int i = 0; i < blend_shapes.size(); i++) {
+ Array bsdata = blend_shapes[i];
+
+ for (int j = 0; j < Mesh::ARRAY_MAX; j++) {
+ if (!(Mesh::ARRAY_FORMAT_BLEND_SHAPE_MASK & (1 << j))) {
+ bsdata[j] = Variant();
+ }
+ }
+ }
+
if (surface->material.is_valid()) {
mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, mesh_array, blend_shapes, Dictionary(), surface->material, surface->material->get_name());
} else {
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index c70081a620..a8211569eb 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -2907,6 +2907,13 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
}
array_copy = blend_surface_tool->commit_to_arrays();
+ // Enforce blend shape mask array format
+ for (int l = 0; l < Mesh::ARRAY_MAX; l++) {
+ if (!(Mesh::ARRAY_FORMAT_BLEND_SHAPE_MASK & (1 << l))) {
+ array_copy[l] = Variant();
+ }
+ }
+
morphs.push_back(array_copy);
}
}