From f2fc6b3a8d7e882c500a12153f14d204ba770308 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sat, 4 Nov 2017 14:32:21 -0700 Subject: [PATCH] Fixed POV-Ray warnings. --- common/lc_mesh.cpp | 23 ++++++++++++++++++++--- common/project.cpp | 25 +++---------------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/common/lc_mesh.cpp b/common/lc_mesh.cpp index 953436f1..85a31543 100644 --- a/common/lc_mesh.cpp +++ b/common/lc_mesh.cpp @@ -252,7 +252,20 @@ void lcMesh::ExportPOVRay(lcFile& File, const char* MeshName, const char** Color { char Line[1024]; - sprintf(Line, "#declare lc_%s = union {\n", MeshName); + int NumSections = 0; + + for (int SectionIdx = 0; SectionIdx < mLods[LC_MESH_LOD_HIGH].NumSections; SectionIdx++) + { + lcMeshSection* Section = &mLods[LC_MESH_LOD_HIGH].Sections[SectionIdx]; + + if (Section->PrimitiveType == LC_MESH_TRIANGLES || Section->PrimitiveType == LC_MESH_TEXTURED_TRIANGLES) + NumSections++; + } + + if (NumSections > 1) + sprintf(Line, "#declare lc_%s = union {\n", MeshName); + else + sprintf(Line, "#declare lc_%s = mesh {\n", MeshName); File.WriteLine(Line); lcVertex* Verts = (lcVertex*)mVertexData; @@ -266,7 +279,8 @@ void lcMesh::ExportPOVRay(lcFile& File, const char* MeshName, const char** Color IndexType* Indices = (IndexType*)mIndexData + Section->IndexOffset / sizeof(IndexType); - File.WriteLine(" mesh {\n"); + if (NumSections > 1) + File.WriteLine(" mesh {\n"); for (int Idx = 0; Idx < Section->NumIndices; Idx += 3) { @@ -288,8 +302,11 @@ void lcMesh::ExportPOVRay(lcFile& File, const char* MeshName, const char** Color File.WriteLine(Line); } - File.WriteLine(" }\n"); + if (NumSections > 1) + File.WriteLine(" }\n"); } + + File.WriteLine("}\n\n"); } void lcMesh::ExportPOVRay(lcFile& File, const char* MeshName, const char** ColorTable) diff --git a/common/project.cpp b/common/project.cpp index 1d8b82fa..5d2d31c7 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -1948,6 +1948,8 @@ bool Project::ExportPOVRay(const QString& FileName) return false; } + POVFile.WriteLine("#version 3.7;\n\nglobal_settings {\n assumed_gamma 1.0\n}\n\n"); + char Line[1024]; lcPiecesLibrary* Library = lcGetPiecesLibrary(); @@ -2135,8 +2137,6 @@ bool Project::ExportPOVRay(const QString& FileName) Mesh->ExportPOVRay(POVFile, Name, &ColorTablePointer[0]); - POVFile.WriteLine("}\n\n"); - sprintf(Line, "#declare lc_%s_clear = lc_%s\n\n", Name, Name); POVFile.WriteLine(Line); } @@ -2150,7 +2150,7 @@ bool Project::ExportPOVRay(const QString& FileName) sprintf(Line, "camera {\n perspective\n right x * image_width / image_height\n sky<%1g,%1g,%1g>\n location <%1g, %1g, %1g>\n look_at <%1g, %1g, %1g>\n angle %.0f * image_width / image_height\n}\n\n", Up[1], Up[0], Up[2], Position[1] / 25.0f, Position[0] / 25.0f, Position[2] / 25.0f, Target[1] / 25.0f, Target[0] / 25.0f, Target[2] / 25.0f, Camera->m_fovy); POVFile.WriteLine(Line); - sprintf(Line, "background { color rgb <%1g, %1g, %1g> }\n\nlight_source { <0, 0, 20> rgb<1, 1, 1, 1> }\n\n", + sprintf(Line, "background { color rgb <%1g, %1g, %1g> }\n\nlight_source { <0, 0, 20> rgb<1, 1, 1> }\n\n", Properties.mBackgroundSolidColor[0], Properties.mBackgroundSolidColor[1], Properties.mBackgroundSolidColor[2]); POVFile.WriteLine(Line); @@ -2182,26 +2182,7 @@ bool Project::ExportPOVRay(const QString& FileName) } POVFile.Close(); -/* - if (Dialog.mRender) - { - QStringList Arguments; - Arguments.append(QString::fromLatin1("+I%1").arg(Dialog.mFileName)); - - if (!Dialog.mLGEOPath.isEmpty()) - { - Arguments.append(QString::fromLatin1("+L%1lg/").arg(Dialog.mLGEOPath)); - Arguments.append(QString::fromLatin1("+L%1ar/").arg(Dialog.mLGEOPath)); - } - - Arguments.append(QString::fromLatin1("/EXIT")); - -#ifndef QT_NO_PROCESS - QProcess::execute(Dialog.mPOVRayPath, Arguments); -#endif - } - */ return true; }