Fix compiler warnings

pull/3580/head
Matt Pharr 2021-01-12 08:03:16 -08:00
parent 1042845414
commit 1fd8646b7a
2 changed files with 25 additions and 24 deletions

View File

@ -94,7 +94,7 @@ void ExportScenePbrt (
const char* pFile, const char* pFile,
IOSystem* pIOSystem, IOSystem* pIOSystem,
const aiScene* pScene, const aiScene* pScene,
const ExportProperties* pProperties const ExportProperties* /*pProperties*/
){ ){
std::string path = DefaultIOSystem::absolutePath(std::string(pFile)); std::string path = DefaultIOSystem::absolutePath(std::string(pFile));
std::string file = DefaultIOSystem::completeBaseName(std::string(pFile)); std::string file = DefaultIOSystem::completeBaseName(std::string(pFile));
@ -118,7 +118,7 @@ PbrtExporter::PbrtExporter (
if (mScene->mNumTextures > 0) if (mScene->mNumTextures > 0)
if (!mIOSystem->CreateDirectory("textures")) if (!mIOSystem->CreateDirectory("textures"))
throw DeadlyExportError("Could not create textures/ directory."); throw DeadlyExportError("Could not create textures/ directory.");
for (int i = 0; i < mScene->mNumTextures; ++i) { for (unsigned int i = 0; i < mScene->mNumTextures; ++i) {
aiTexture* tex = mScene->mTextures[i]; aiTexture* tex = mScene->mTextures[i];
std::string fn = CleanTextureFilename(tex->mFilename, false); std::string fn = CleanTextureFilename(tex->mFilename, false);
std::cerr << "Writing embedded texture: " << tex->mFilename.C_Str() << " -> " std::cerr << "Writing embedded texture: " << tex->mFilename.C_Str() << " -> "
@ -173,7 +173,7 @@ void PbrtExporter::WriteMetaData() {
mOutput << "# Scene metadata:\n"; mOutput << "# Scene metadata:\n";
aiMetadata* pMetaData = mScene->mMetaData; aiMetadata* pMetaData = mScene->mMetaData;
for (int i = 0; i < pMetaData->mNumProperties; i++) { for (unsigned int i = 0; i < pMetaData->mNumProperties; i++) {
mOutput << "# - "; mOutput << "# - ";
mOutput << pMetaData->mKeys[i].C_Str() << " :"; mOutput << pMetaData->mKeys[i].C_Str() << " :";
switch(pMetaData->mValues[i].mType) { switch(pMetaData->mValues[i].mType) {
@ -246,7 +246,7 @@ void PbrtExporter::WriteCameras() {
std::cerr << "Multiple cameras found in scene file; defaulting to first one specified.\n"; std::cerr << "Multiple cameras found in scene file; defaulting to first one specified.\n";
} }
for (int i = 0; i < mScene->mNumCameras; i++) { for (unsigned int i = 0; i < mScene->mNumCameras; i++) {
WriteCamera(i); WriteCamera(i);
} }
} }
@ -290,7 +290,7 @@ void PbrtExporter::WriteCamera(int i) {
// Get camera aspect ratio // Get camera aspect ratio
float aspect = camera->mAspect; float aspect = camera->mAspect;
if (aspect == 0) { if (aspect == 0) {
aspect = 4.0/3.0; aspect = 4.f/3.f;
mOutput << "# - Aspect ratio : 1.33333 (no aspect found, defaulting to 4/3)\n"; mOutput << "# - Aspect ratio : 1.33333 (no aspect found, defaulting to 4/3)\n";
} else { } else {
mOutput << "# - Aspect ratio : " << aspect << "\n"; mOutput << "# - Aspect ratio : " << aspect << "\n";
@ -357,9 +357,9 @@ void PbrtExporter::WriteWorldDefinition() {
std::map<int, int> meshUses; std::map<int, int> meshUses;
std::function<void(aiNode*)> visitNode; std::function<void(aiNode*)> visitNode;
visitNode = [&](aiNode* node) { visitNode = [&](aiNode* node) {
for (int i = 0; i < node->mNumMeshes; ++i) for (unsigned int i = 0; i < node->mNumMeshes; ++i)
++meshUses[node->mMeshes[i]]; ++meshUses[node->mMeshes[i]];
for (int i = 0; i < node->mNumChildren; ++i) for (unsigned int i = 0; i < node->mNumChildren; ++i)
visitNode(node->mChildren[i]); visitNode(node->mChildren[i]);
}; };
visitNode(mScene->mRootNode); visitNode(mScene->mRootNode);
@ -403,7 +403,7 @@ void PbrtExporter::WriteTextures() {
aiTextureMapMode mapMode[3]; aiTextureMapMode mapMode[3];
// For every material in the scene, // For every material in the scene,
for (int m = 0 ; m < mScene->mNumMaterials; m++) { for (unsigned int m = 0 ; m < mScene->mNumMaterials; m++) {
auto material = mScene->mMaterials[m]; auto material = mScene->mMaterials[m];
// Parse through all texture types, // Parse through all texture types,
for (int tt = 1; tt <= aiTextureType_UNKNOWN; tt++) { for (int tt = 1; tt <= aiTextureType_UNKNOWN; tt++) {
@ -571,7 +571,7 @@ void PbrtExporter::WriteMaterials() {
mOutput << "####################\n"; mOutput << "####################\n";
mOutput << "# Materials (" << mScene->mNumMaterials << ") total\n\n"; mOutput << "# Materials (" << mScene->mNumMaterials << ") total\n\n";
for (int i = 0; i < mScene->mNumMaterials; i++) { for (unsigned int i = 0; i < mScene->mNumMaterials; i++) {
WriteMaterial(i); WriteMaterial(i);
} }
mOutput << "\n\n"; mOutput << "\n\n";
@ -674,7 +674,7 @@ std::string PbrtExporter::CleanTextureFilename(const aiString &f, bool rewriteEx
std::string extension = fn; std::string extension = fn;
extension.erase(0, offset + 1); extension.erase(0, offset + 1);
std::transform(extension.begin(), extension.end(), extension.begin(), std::transform(extension.begin(), extension.end(), extension.begin(),
[](unsigned char c){ return std::tolower(c); }); [](unsigned char c) { return (char)std::tolower(c); });
if (extension != "tga" && extension != "exr" && extension != "png" && if (extension != "tga" && extension != "exr" && extension != "png" &&
extension != "pfm" && extension != "hdr") { extension != "pfm" && extension != "hdr") {
@ -683,8 +683,8 @@ std::string PbrtExporter::CleanTextureFilename(const aiString &f, bool rewriteEx
fn += "png"; fn += "png";
// Does it already exist? Warn if not. // Does it already exist? Warn if not.
std::ifstream f(fn); std::ifstream filestream(fn);
if (!f.good()) if (!filestream.good())
std::cerr << orig << ": must convert this texture to PNG.\n"; std::cerr << orig << ": must convert this texture to PNG.\n";
} }
} }
@ -716,7 +716,7 @@ void PbrtExporter::WriteLights() {
mOutput << "AttributeEnd\n\n"; mOutput << "AttributeEnd\n\n";
} }
} else { } else {
for (int i = 0; i < mScene->mNumLights; ++i) { for (unsigned int i = 0; i < mScene->mNumLights; ++i) {
const aiLight *light = mScene->mLights[i]; const aiLight *light = mScene->mLights[i];
mOutput << "# Light " << light->mName.C_Str() << "\n"; mOutput << "# Light " << light->mName.C_Str() << "\n";
@ -832,7 +832,7 @@ void PbrtExporter::WriteMesh(aiMesh* mesh) {
" \"integer indices\" ["; " \"integer indices\" [";
// Start with faces (which hold indices) // Start with faces (which hold indices)
for (int i = 0; i < mesh->mNumFaces; i++) { for (unsigned int i = 0; i < mesh->mNumFaces; i++) {
auto face = mesh->mFaces[i]; auto face = mesh->mFaces[i];
if (face.mNumIndices != 3) throw DeadlyExportError("oh no not a tri!"); if (face.mNumIndices != 3) throw DeadlyExportError("oh no not a tri!");
@ -845,7 +845,7 @@ void PbrtExporter::WriteMesh(aiMesh* mesh) {
// Then go to vertices // Then go to vertices
mOutput << " \"point3 P\" ["; mOutput << " \"point3 P\" [";
for(int i = 0; i < mesh->mNumVertices; i++) { for (unsigned int i = 0; i < mesh->mNumVertices; i++) {
auto vector = mesh->mVertices[i]; auto vector = mesh->mVertices[i];
mOutput << vector.x << " " << vector.y << " " << vector.z << " "; mOutput << vector.x << " " << vector.y << " " << vector.z << " ";
if ((i % 4) == 3) mOutput << "\n "; if ((i % 4) == 3) mOutput << "\n ";
@ -855,7 +855,7 @@ void PbrtExporter::WriteMesh(aiMesh* mesh) {
// Normals (if present) // Normals (if present)
if (mesh->mNormals) { if (mesh->mNormals) {
mOutput << " \"normal N\" ["; mOutput << " \"normal N\" [";
for (int i = 0; i < mesh->mNumVertices; i++) { for (unsigned int i = 0; i < mesh->mNumVertices; i++) {
auto normal = mesh->mNormals[i]; auto normal = mesh->mNormals[i];
mOutput << normal.x << " " << normal.y << " " << normal.z << " "; mOutput << normal.x << " " << normal.y << " " << normal.z << " ";
if ((i % 4) == 3) mOutput << "\n "; if ((i % 4) == 3) mOutput << "\n ";
@ -866,7 +866,7 @@ void PbrtExporter::WriteMesh(aiMesh* mesh) {
// Tangents (if present) // Tangents (if present)
if (mesh->mTangents) { if (mesh->mTangents) {
mOutput << " \"vector3 S\" ["; mOutput << " \"vector3 S\" [";
for (int i = 0; i < mesh->mNumVertices; i++) { for (unsigned int i = 0; i < mesh->mNumVertices; i++) {
auto tangent = mesh->mTangents[i]; auto tangent = mesh->mTangents[i];
mOutput << tangent.x << " " << tangent.y << " " << tangent.z << " "; mOutput << tangent.x << " " << tangent.y << " " << tangent.z << " ";
if ((i % 4) == 3) mOutput << "\n "; if ((i % 4) == 3) mOutput << "\n ";
@ -881,7 +881,7 @@ void PbrtExporter::WriteMesh(aiMesh* mesh) {
// assert(mesh->mTextureCoords[i] != nullptr); // assert(mesh->mTextureCoords[i] != nullptr);
aiVector3D* uv = mesh->mTextureCoords[i]; aiVector3D* uv = mesh->mTextureCoords[i];
mOutput << " \"point2 uv\" ["; mOutput << " \"point2 uv\" [";
for (int j = 0; j < mesh->mNumVertices; ++j) { for (unsigned int j = 0; j < mesh->mNumVertices; ++j) {
mOutput << uv[j].x << " " << uv[j].y << " "; mOutput << uv[j].x << " " << uv[j].y << " ";
if ((j % 6) == 5) mOutput << "\n "; if ((j % 6) == 5) mOutput << "\n ";
} }
@ -919,7 +919,7 @@ void PbrtExporter::WriteGeometricObjects(aiNode* node, aiMatrix4x4 worldFromObje
mOutput << " Transform [ " << TransformAsString(worldFromObject) << "]\n"; mOutput << " Transform [ " << TransformAsString(worldFromObject) << "]\n";
for (int i = 0; i < node->mNumMeshes; i++) { for (unsigned int i = 0; i < node->mNumMeshes; i++) {
aiMesh* mesh = mScene->mMeshes[node->mMeshes[i]]; aiMesh* mesh = mScene->mMeshes[node->mMeshes[i]];
if (meshUses[node->mMeshes[i]] == 1) { if (meshUses[node->mMeshes[i]] == 1) {
// If it's only used once in the scene, emit it directly as // If it's only used once in the scene, emit it directly as
@ -940,7 +940,7 @@ void PbrtExporter::WriteGeometricObjects(aiNode* node, aiMatrix4x4 worldFromObje
} }
// Recurse through children // Recurse through children
for (int i = 0; i < node->mNumChildren; i++) { for (unsigned int i = 0; i < node->mNumChildren; i++) {
WriteGeometricObjects(node->mChildren[i], worldFromObject, meshUses); WriteGeometricObjects(node->mChildren[i], worldFromObject, meshUses);
} }
} }

View File

@ -4120,7 +4120,7 @@ static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z)
if (s >= 16) return -1; // invalid code! if (s >= 16) return -1; // invalid code!
// code size is s, so: // code size is s, so:
b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s];
if (b >= sizeof (z->size)) return -1; // some data was corrupt somewhere! if ((unsigned int)b >= sizeof (z->size)) return -1; // some data was corrupt somewhere!
if (z->size[b] != s) return -1; // was originally an assert, but report failure instead. if (z->size[b] != s) return -1; // was originally an assert, but report failure instead.
a->code_buffer >>= s; a->code_buffer >>= s;
a->num_bits -= s; a->num_bits -= s;
@ -6775,8 +6775,8 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
stbi_uc *two_back = 0; stbi_uc *two_back = 0;
stbi__gif g; stbi__gif g;
int stride; int stride;
int out_size = 0; int out_size;
int delays_size = 0; int delays_size;
memset(&g, 0, sizeof(g)); memset(&g, 0, sizeof(g));
if (delays) { if (delays) {
*delays = 0; *delays = 0;
@ -6815,7 +6815,8 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
if (delays) { if (delays) {
*delays = (int*) stbi__malloc( layers * sizeof(int) ); *delays = (int*) stbi__malloc( layers * sizeof(int) );
delays_size = layers * sizeof(int); delays_size = layers * sizeof(int);
} } else
delays_size = 0;
} }
memcpy( out + ((layers - 1) * stride), u, stride ); memcpy( out + ((layers - 1) * stride), u, stride );
if (layers >= 2) { if (layers >= 2) {