Merge pull request #2621 from RevoluPowered/fix-segfault-fbx-import
Fix segfault #2614pull/2630/head
commit
84c0d6b95a
|
@ -610,8 +610,7 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
|
||||||
const std::string& ReferenceInformationType)
|
const std::string& ReferenceInformationType)
|
||||||
{
|
{
|
||||||
const size_t face_count = m_faces.size();
|
const size_t face_count = m_faces.size();
|
||||||
|
if( 0 == face_count )
|
||||||
if(face_count == 0)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -626,16 +625,14 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
|
||||||
if (materials_out.empty()) {
|
if (materials_out.empty()) {
|
||||||
FBXImporter::LogError(Formatter::format("expected material index, ignoring"));
|
FBXImporter::LogError(Formatter::format("expected material index, ignoring"));
|
||||||
return;
|
return;
|
||||||
}
|
} else if (materials_out.size() > 1) {
|
||||||
else if (materials_out.size() > 1) {
|
|
||||||
FBXImporter::LogWarn(Formatter::format("expected only a single material index, ignoring all except the first one"));
|
FBXImporter::LogWarn(Formatter::format("expected only a single material index, ignoring all except the first one"));
|
||||||
materials_out.clear();
|
materials_out.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
materials_out.resize(m_vertices.size());
|
materials_out.resize(m_vertices.size());
|
||||||
std::fill(materials_out.begin(), materials_out.end(), materials_out.at(0));
|
std::fill(materials_out.begin(), materials_out.end(), materials_out.at(0));
|
||||||
}
|
} else if (MappingInformationType == "ByPolygon" && ReferenceInformationType == "IndexToDirect") {
|
||||||
else if (MappingInformationType == "ByPolygon" && ReferenceInformationType == "IndexToDirect") {
|
|
||||||
materials_out.resize(face_count);
|
materials_out.resize(face_count);
|
||||||
|
|
||||||
if(materials_out.size() != face_count) {
|
if(materials_out.size() != face_count) {
|
||||||
|
@ -644,18 +641,16 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
FBXImporter::LogError(Formatter::format("ignoring material assignments, access type not implemented: ")
|
FBXImporter::LogError(Formatter::format("ignoring material assignments, access type not implemented: ")
|
||||||
<< MappingInformationType << "," << ReferenceInformationType);
|
<< MappingInformationType << "," << ReferenceInformationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
ShapeGeometry::ShapeGeometry(uint64_t id, const Element& element, const std::string& name, const Document& doc)
|
ShapeGeometry::ShapeGeometry(uint64_t id, const Element& element, const std::string& name, const Document& doc)
|
||||||
: Geometry(id, element, name, doc)
|
: Geometry(id, element, name, doc) {
|
||||||
{
|
const Scope *sc = element.Compound();
|
||||||
const Scope* sc = element.Compound();
|
if (nullptr == sc) {
|
||||||
if (!sc) {
|
|
||||||
DOMError("failed to read Geometry object (class: Shape), no data scope found");
|
DOMError("failed to read Geometry object (class: Shape), no data scope found");
|
||||||
}
|
}
|
||||||
const Element& Indexes = GetRequiredElement(*sc, "Indexes", &element);
|
const Element& Indexes = GetRequiredElement(*sc, "Indexes", &element);
|
||||||
|
|
Loading…
Reference in New Issue