Merge branch 'master' into ms3d-fixes

This commit is contained in:
Kim Kulling
2021-04-11 19:12:06 +02:00
committed by GitHub
11 changed files with 159 additions and 46 deletions
+4 -1
View File
@@ -157,7 +157,10 @@ void HMPImporter::InternReadFile(const std::string &pFile,
szBuffer[2] = ((char *)&iMagic)[2];
szBuffer[3] = ((char *)&iMagic)[3];
szBuffer[4] = '\0';
delete[] mBuffer;
mBuffer = nullptr;
// We're definitely unable to load this file
throw DeadlyImportError("Unknown HMP subformat ", pFile,
". Magic word (", szBuffer, ") is not known");
+6
View File
@@ -813,6 +813,11 @@ struct Mesh : public Object {
AccessorList position, normal, tangent;
};
std::vector<Target> targets;
// extension: FB_ngon_encoding
bool ngonEncoded;
Primitive(): ngonEncoded(false) {}
};
std::vector<Primitive> primitives;
@@ -1108,6 +1113,7 @@ public:
bool KHR_materials_clearcoat;
bool KHR_materials_transmission;
bool KHR_draco_mesh_compression;
bool FB_ngon_encoding;
} extensionsUsed;
//! Keeps info about the required extensions
+18
View File
@@ -507,6 +507,20 @@ namespace glTF2 {
Mesh::Primitive& p = m.primitives[i];
Value prim;
prim.SetObject();
// Extensions
if (p.ngonEncoded)
{
Value exts;
exts.SetObject();
Value FB_ngon_encoding;
FB_ngon_encoding.SetObject();
exts.AddMember(StringRef("FB_ngon_encoding"), FB_ngon_encoding, w.mAl);
prim.AddMember("extensions", exts, w.mAl);
}
{
prim.AddMember("mode", Value(int(p.mode)).Move(), w.mAl);
@@ -874,6 +888,10 @@ namespace glTF2 {
if (this->mAsset.extensionsUsed.KHR_materials_transmission) {
exts.PushBack(StringRef("KHR_materials_transmission"), mAl);
}
if (this->mAsset.extensionsUsed.FB_ngon_encoding) {
exts.PushBack(StringRef("FB_ngon_encoding"), mAl);
}
}
if (!exts.Empty())
+4
View File
@@ -97,6 +97,9 @@ glTF2Exporter::glTF2Exporter(const char* filename, IOSystem* pIOSystem, const ai
mAsset.reset( new Asset( pIOSystem ) );
// Always on as our triangulation process is aware of this type of encoding
mAsset->extensionsUsed.FB_ngon_encoding = true;
if (isBinary) {
mAsset->SetAsBinary();
}
@@ -955,6 +958,7 @@ void glTF2Exporter::ExportMeshes()
m->name = name;
p.material = mAsset->materials.Get(aim->mMaterialIndex);
p.ngonEncoded = (aim->mPrimitiveTypes & aiPrimitiveType_NGONEncodingFlag) != 0;
/******************* Vertices ********************/
Ref<Accessor> v = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mVertices, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT, BufferViewTarget_ARRAY_BUFFER);