Validate mesh in WriteMesh before AttributeBegin call (#5884)
If mesh is validated after AttributeBegin call, then the AttributeBegin is never closed with an AttributeEnd, causing problems in pbrt. Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
This commit is contained in:
@@ -800,10 +800,20 @@ void PbrtExporter::WriteLights() {
|
||||
|
||||
void PbrtExporter::WriteMesh(aiMesh* mesh) {
|
||||
mOutput << "# - Mesh: ";
|
||||
const char* mName;
|
||||
if (mesh->mName == aiString(""))
|
||||
mOutput << "<No Name>\n";
|
||||
mName = "<No Name>";
|
||||
else
|
||||
mOutput << mesh->mName.C_Str() << "\n";
|
||||
mName = mesh->mName.C_Str();
|
||||
mOutput << mName << "\n";
|
||||
|
||||
// Check if any types other than tri
|
||||
if ( (mesh->mPrimitiveTypes & aiPrimitiveType_POINT)
|
||||
|| (mesh->mPrimitiveTypes & aiPrimitiveType_LINE)
|
||||
|| (mesh->mPrimitiveTypes & aiPrimitiveType_POLYGON)) {
|
||||
std::cerr << "Error: ignoring point / line / polygon mesh " << mName << ".\n";
|
||||
return;
|
||||
}
|
||||
|
||||
mOutput << "AttributeBegin\n";
|
||||
aiMaterial* material = mScene->mMaterials[mesh->mMaterialIndex];
|
||||
@@ -816,14 +826,6 @@ void PbrtExporter::WriteMesh(aiMesh* mesh) {
|
||||
mOutput << " AreaLightSource \"diffuse\" \"rgb L\" [ " << emission.r <<
|
||||
" " << emission.g << " " << emission.b << " ]\n";
|
||||
|
||||
// Check if any types other than tri
|
||||
if ( (mesh->mPrimitiveTypes & aiPrimitiveType_POINT)
|
||||
|| (mesh->mPrimitiveTypes & aiPrimitiveType_LINE)
|
||||
|| (mesh->mPrimitiveTypes & aiPrimitiveType_POLYGON)) {
|
||||
std::cerr << "Error: ignoring point / line / polygon mesh " << mesh->mName.C_Str() << ".\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// Alpha mask
|
||||
std::string alpha;
|
||||
aiString opacityTexture;
|
||||
|
||||
Reference in New Issue
Block a user