2222#include " engine/world.h"
2323#include " renderer/editor/fbx_importer.h"
2424#include " renderer/editor/model_importer.h"
25+ #include " renderer/editor/model_meta.h"
2526#include " renderer/editor/world_viewer.h"
2627#include " renderer/model.h"
2728#include " renderer/render_module.h"
@@ -132,7 +133,15 @@ struct GLTFImporter : ModelImporter {
132133return nullptr ;
133134}
134135
135- bool parse (const Path& src, ReadFlags flags, const ImportConfig* cfg) override {
136+ bool parseSimple (const Path& src) override {
137+ return parse (src, nullptr );
138+ }
139+
140+ bool parse (const Path& src, const ModelMeta& meta) override {
141+ return parse (src, &meta);
142+ }
143+
144+ bool parse (const Path& src, const ModelMeta* meta) {
136145PROFILE_FUNCTION ();
137146FileSystem& fs = m_app.getEngine ().getFileSystem ();
138147
@@ -303,7 +312,7 @@ struct GLTFImporter : ModelImporter {
303312anim.length = m_src_data->animations [i].samplers [0 ].input ->max [0 ];
304313}
305314
306- if (cfg) postprocess (*cfg , src);
315+ postprocess (*meta , src);
307316
308317return true ;
309318}
@@ -344,7 +353,7 @@ struct GLTFImporter : ModelImporter {
344353return res;
345354}
346355
347- void postprocess (const ImportConfig& cfg , const Path& path) {
356+ void postprocess (const ModelMeta& meta , const Path& path) {
348357u32 bone_remap[1024 ];
349358for (i32 i = 0 ; i < m_bones.size (); ++i) {
350359bone_remap[m_bones[i].id - 1 ] = i;
@@ -372,7 +381,7 @@ struct GLTFImporter : ModelImporter {
372381
373382const Matrix mesh_mtx = getMeshTransform (m_src_data, src_mesh);
374383
375- mesh.vertex_data .resize (mesh.vertex_size * src_mesh.primitives [0 ].attributes [0 ].data ->count );
384+ mesh.vertex_buffer .resize (mesh.vertex_size * src_mesh.primitives [0 ].attributes [0 ].data ->count );
376385for (u32 j = 0 ; j < src_mesh.primitives [0 ].attributes_count ; ++j) {
377386u32 attr_offset = 0 ;
378387for (AttributeDesc& desc : mesh.attributes ) {
@@ -383,7 +392,7 @@ struct GLTFImporter : ModelImporter {
383392const cgltf_attribute& attr = src_mesh.primitives [0 ].attributes [j];
384393u32 attr_size = getAttributeSize (attr);
385394const u8 * src_data = (const u8 *)attr.data ->buffer_view ->buffer ->data + attr.data ->buffer_view ->offset + attr.data ->offset ;
386- u8 * vb = mesh.vertex_data .getMutableData ();
395+ u8 * vb = mesh.vertex_buffer .getMutableData ();
387396
388397if (attr.type == cgltf_attribute_type_joints) {
389398if (attr.data ->component_type == cgltf_component_type_r_8u && attr.data ->type == cgltf_type_vec4) {
@@ -439,7 +448,7 @@ struct GLTFImporter : ModelImporter {
439448}
440449}
441450
442- postprocessCommon (cfg );
451+ postprocessCommon (meta );
443452}
444453
445454static bool hasAttribute (const cgltf_mesh& mesh, cgltf_attribute_type type) {
@@ -599,12 +608,12 @@ struct GLTFPlugin : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
599608
600609bool compile (const Path& src) override {
601610GLTFImporter writer (m_app);
602- ModelImporter::ImportConfig cfg ;
603- cfg .skeleton = src;
604- if (!writer.parse (src, ModelImporter::ReadFlags::NONE, &cfg )) return false ;
611+ ModelMeta meta (m_app. getAllocator ()) ;
612+ meta .skeleton = src;
613+ if (!writer.parse (src, &meta )) return false ;
605614
606- bool result = writer.write (src, cfg, ModelImporter::WriteFlags::NONE );
607- result = result && writer.writeMaterials (src, cfg , false );
615+ bool result = writer.write (src, meta );
616+ result = result && writer.writeMaterials (src, meta , false );
608617return result;
609618}
610619
0 commit comments