# use a more or less heuristic approach to fix the face winding order automatically. Overall things look much better now and normals are 100% right for most models.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@987 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
5ac47b9873
commit
f3bd6ac49b
|
@ -734,8 +734,25 @@ void ProcessExtrudedAreaSolid(const IFC::IfcExtrudedAreaSolid& solid, TempMesh&
|
||||||
aiMatrix4x4 trafo;
|
aiMatrix4x4 trafo;
|
||||||
ConvertAxisPlacement(trafo, solid.Position,conv);
|
ConvertAxisPlacement(trafo, solid.Position,conv);
|
||||||
|
|
||||||
|
aiVector3D vavg;
|
||||||
BOOST_FOREACH(aiVector3D& v, result.verts) {
|
BOOST_FOREACH(aiVector3D& v, result.verts) {
|
||||||
v *= trafo;
|
v *= trafo;
|
||||||
|
vavg += v;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fixup face orientation.
|
||||||
|
vavg /= static_cast<float>( result.verts.size() );
|
||||||
|
|
||||||
|
size_t c = 0;
|
||||||
|
BOOST_FOREACH(unsigned int cnt, result.vertcnt) {
|
||||||
|
if (cnt>2){
|
||||||
|
const aiVector3D& thisvert = result.verts[c];
|
||||||
|
const aiVector3D normal((thisvert-result.verts[c+1])^(thisvert-result.verts[c+2]));
|
||||||
|
if (normal*(thisvert-vavg) < 0) {
|
||||||
|
std::reverse(result.verts.begin()+c,result.verts.begin()+cnt+c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c += cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFCImporter::LogDebug("generate mesh procedurally by extrusion (IfcExtrudedAreaSolid)");
|
IFCImporter::LogDebug("generate mesh procedurally by extrusion (IfcExtrudedAreaSolid)");
|
||||||
|
@ -1188,6 +1205,7 @@ void ProcessSpatialStructures(ConversionData& conv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for(;range.first != range.second; ++range.first) {
|
for(;range.first != range.second; ++range.first) {
|
||||||
const IFC::IfcSpatialStructureElement* const prod = (*range.first).second->ToPtr<IFC::IfcSpatialStructureElement>();
|
const IFC::IfcSpatialStructureElement* const prod = (*range.first).second->ToPtr<IFC::IfcSpatialStructureElement>();
|
||||||
if(!prod) {
|
if(!prod) {
|
||||||
|
@ -1215,6 +1233,8 @@ void ProcessSpatialStructures(ConversionData& conv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IFCImporter::ThrowException("Failed to determine primary site element");
|
IFCImporter::ThrowException("Failed to determine primary site element");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue