Fixed warnings

This commit is contained in:
Robert Osfield
2014-01-23 19:55:37 +00:00
parent d8482ef1ba
commit 4886a8941d
7 changed files with 71 additions and 64 deletions

View File

@@ -28,15 +28,15 @@ WriterCompareTriangle::operator()(const std::pair<Triangle, int> & t1,
}
void
WriterCompareTriangle::setMaxMin(unsigned int & nbVerticesX,
unsigned int & nbVerticesY,
unsigned int & nbVerticesZ) const
WriterCompareTriangle::setMaxMin(int & nbVerticesX,
int & nbVerticesY,
int & nbVerticesZ) const
{
static const unsigned int min = 1;
static const unsigned int max = 5; // Number of blocks used to divide the scene (arbitrary but seems ok)
nbVerticesX = osg::clampBetween<unsigned int>(nbVerticesX, min, max);
nbVerticesY = osg::clampBetween<unsigned int>(nbVerticesY, min, max);
nbVerticesZ = osg::clampBetween<unsigned int>(nbVerticesZ, min, max);
static const int min = 1;
static const int max = 5; // Number of blocks used to divide the scene (arbitrary but seems ok)
nbVerticesX = osg::clampBetween<int>(nbVerticesX, min, max);
nbVerticesY = osg::clampBetween<int>(nbVerticesY, min, max);
nbVerticesZ = osg::clampBetween<int>(nbVerticesZ, min, max);
}
void WriterCompareTriangle::cutscene(int nbVertices, const osg::BoundingBox & sceneBox)
@@ -45,9 +45,9 @@ void WriterCompareTriangle::cutscene(int nbVertices, const osg::BoundingBox & sc
static const float k = 1.3f; // Arbitrary constant multiplier for density computation ("simulates" non-uniform point distributions)
// Computes "density" of points, and thus the number of blocks to divide the mesh into
unsigned int nbVerticesX = static_cast<unsigned int>( (nbVertices * k) / (length.z() * length.y()) );
unsigned int nbVerticesY = static_cast<unsigned int>( (nbVertices * k) / (length.z() * length.x()) );
unsigned int nbVerticesZ = static_cast<unsigned int>( (nbVertices * k) / (length.x() * length.y()) );
int nbVerticesX = static_cast<int>( (nbVertices * k) / (length.z() * length.y()) );
int nbVerticesY = static_cast<int>( (nbVertices * k) / (length.z() * length.x()) );
int nbVerticesZ = static_cast<int>( (nbVertices * k) / (length.x() * length.y()) );
setMaxMin (nbVerticesX, nbVerticesY, nbVerticesZ); // This function prevent from cutting the scene in too many blocs
@@ -63,9 +63,9 @@ void WriterCompareTriangle::cutscene(int nbVertices, const osg::BoundingBox & sc
boxList.reserve(nbVerticesX * nbVerticesY * nbVerticesZ);
short yinc = 1;
short xinc = 1;
unsigned int y = 0;
unsigned int x = 0;
for (unsigned int z = 0; z < nbVerticesZ; ++z)
int y = 0;
int x = 0;
for (int z = 0; z < nbVerticesZ; ++z)
{
while (x < nbVerticesX && x >= 0)
{

View File

@@ -21,9 +21,9 @@ public:
const std::pair<Triangle, int> & t2) const;
private:
void // This function prevent from cut scene in too many blocs
setMaxMin(unsigned int & nbVerticesX,
unsigned int & nbVerticesY,
unsigned int & nbVerticesZ) const;
setMaxMin(int & nbVerticesX,
int & nbVerticesY,
int & nbVerticesZ) const;
/**
* Cut the scene in different bloc to sort.

View File

@@ -1,19 +1,19 @@
/*
Copyright (C) 1996-2008 by Jan Eric Kyprianidis <www.kyprianidis.com>
All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 2.1 of the License, or
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 2.1 of the License, or
(at your option) any later version.
Thisprogram is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Thisprogram is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; If not, see <http://www.gnu.org/licenses/>.
along with this program; If not, see <http://www.gnu.org/licenses/>.
*/
#include "lib3ds_impl.h"
@@ -231,7 +231,7 @@ named_object_read(Lib3dsFile *file, Lib3dsIo *io) {
uint32_t object_flags;
lib3ds_chunk_read_start(&c, CHK_NAMED_OBJECT, io);
lib3ds_io_read_string(io, name, 64);
lib3ds_io_log(io, LIB3DS_LOG_INFO, " NAME=%s", name);
lib3ds_chunk_read_tell(&c, io);
@@ -444,13 +444,13 @@ mdata_read(Lib3dsFile *file, Lib3dsIo *io) {
}
static int
static int
compare_node_id( const void *a, const void *b ) {
return (int)((*((Lib3dsNode**)a))->node_id) - (int)((*((Lib3dsNode**)b))->node_id);
}
static int
static int
compare_node_id2( const void *a, const void *b ) {
// not a is a pointer in the calling bsearch routine the user_id is an unsigned, while the node_id is an unsigned short?!
return (int)(*((unsigned*)a)) - (int)((*((Lib3dsNode**)b))->node_id);
@@ -494,33 +494,33 @@ kfdata_read(Lib3dsFile *file, Lib3dsIo *io) {
break;
}
case CHK_AMBIENT_NODE_TAG:
case CHK_OBJECT_NODE_TAG:
case CHK_CAMERA_NODE_TAG:
case CHK_TARGET_NODE_TAG:
case CHK_LIGHT_NODE_TAG:
case CHK_SPOTLIGHT_NODE_TAG:
case CHK_AMBIENT_NODE_TAG:
case CHK_OBJECT_NODE_TAG:
case CHK_CAMERA_NODE_TAG:
case CHK_TARGET_NODE_TAG:
case CHK_LIGHT_NODE_TAG:
case CHK_SPOTLIGHT_NODE_TAG:
case CHK_L_TARGET_NODE_TAG: {
Lib3dsNodeType type = 0;
Lib3dsNode *node;
switch (chunk) {
case CHK_AMBIENT_NODE_TAG:
case CHK_AMBIENT_NODE_TAG:
type = LIB3DS_NODE_AMBIENT_COLOR;
break;
case CHK_OBJECT_NODE_TAG:
case CHK_OBJECT_NODE_TAG:
type = LIB3DS_NODE_MESH_INSTANCE;
break;
case CHK_CAMERA_NODE_TAG:
case CHK_CAMERA_NODE_TAG:
type = LIB3DS_NODE_CAMERA;
break;
case CHK_TARGET_NODE_TAG:
case CHK_TARGET_NODE_TAG:
type = LIB3DS_NODE_CAMERA_TARGET;
break;
case CHK_LIGHT_NODE_TAG:
case CHK_LIGHT_NODE_TAG:
type = LIB3DS_NODE_OMNILIGHT;
break;
case CHK_SPOTLIGHT_NODE_TAG:
case CHK_SPOTLIGHT_NODE_TAG:
type = LIB3DS_NODE_SPOTLIGHT;
break;
case CHK_L_TARGET_NODE_TAG:
@@ -565,7 +565,7 @@ kfdata_read(Lib3dsFile *file, Lib3dsIo *io) {
if (p->user_id != 65535) {
parent = *(Lib3dsNode**)bsearch(&p->user_id, nodes, num_nodes, sizeof(Lib3dsNode*), compare_node_id2);
if (parent) {
q->next = p->next;
q->next = p->next;
p->next = parent->childs;
p->parent = parent;
parent->childs = p;
@@ -927,7 +927,7 @@ lib3ds_file_write(Lib3dsFile *file, Lib3dsIo *io) {
void lib3ds_file_reserve_materials(Lib3dsFile *file, int size, int force) {
assert(file);
lib3ds_util_reserve_array((void***)&file->materials, &file->nmaterials, &file->materials_size,
lib3ds_util_reserve_array((void***)&file->materials, &file->nmaterials, &file->materials_size,
size, force, (Lib3dsFreeFunc)lib3ds_material_free);
}
@@ -960,10 +960,10 @@ lib3ds_file_material_by_name(Lib3dsFile *file, const char *name) {
}
void
void
lib3ds_file_reserve_cameras(Lib3dsFile *file, int size, int force) {
assert(file);
lib3ds_util_reserve_array((void***)&file->cameras, &file->ncameras, &file->cameras_size,
lib3ds_util_reserve_array((void***)&file->cameras, &file->ncameras, &file->cameras_size,
size, force, (Lib3dsFreeFunc)lib3ds_camera_free);
}
@@ -996,10 +996,10 @@ lib3ds_file_camera_by_name(Lib3dsFile *file, const char *name) {
}
void
void
lib3ds_file_reserve_lights(Lib3dsFile *file, int size, int force) {
assert(file);
lib3ds_util_reserve_array((void***)&file->lights, &file->nlights, &file->lights_size,
lib3ds_util_reserve_array((void***)&file->lights, &file->nlights, &file->lights_size,
size, force, (Lib3dsFreeFunc)lib3ds_light_free);
}
@@ -1032,10 +1032,10 @@ lib3ds_file_light_by_name(Lib3dsFile *file, const char *name) {
}
void
void
lib3ds_file_reserve_meshes(Lib3dsFile *file, int size, int force) {
assert(file);
lib3ds_util_reserve_array((void***)&file->meshes, &file->nmeshes, &file->meshes_size,
lib3ds_util_reserve_array((void***)&file->meshes, &file->nmeshes, &file->meshes_size,
size, force, (Lib3dsFreeFunc)lib3ds_mesh_free);
}
@@ -1068,7 +1068,7 @@ lib3ds_file_mesh_by_name(Lib3dsFile *file, const char *name) {
}
Lib3dsMesh*
Lib3dsMesh*
lib3ds_file_mesh_for_node(Lib3dsFile *file, Lib3dsNode *node) {
int index;
Lib3dsMeshInstanceNode *n;
@@ -1162,7 +1162,7 @@ lib3ds_file_append_node(Lib3dsFile *file, Lib3dsNode *node, Lib3dsNode *parent)
parent->childs = node;
} else {
file->nodes = node;
}
}
}
node->parent = parent;
node->next = NULL;
@@ -1249,12 +1249,12 @@ lib3ds_file_remove_node(Lib3dsFile *file, Lib3dsNode *node) {
static void
file_minmax_node_id_impl(Lib3dsFile *file, Lib3dsNode *node, uint16_t *min_id, uint16_t *max_id) {
Lib3dsNode *p;
if (min_id && (*min_id > node->node_id))
*min_id = node->node_id;
if (max_id && (*max_id < node->node_id))
*max_id = node->node_id;
p = node->childs;
while (p) {
file_minmax_node_id_impl(file, p, min_id, max_id);
@@ -1263,10 +1263,10 @@ file_minmax_node_id_impl(Lib3dsFile *file, Lib3dsNode *node, uint16_t *min_id, u
}
void
void
lib3ds_file_minmax_node_id(Lib3dsFile *file, uint16_t *min_id, uint16_t *max_id) {
Lib3dsNode *p;
if (min_id)
*min_id = 65535;
if (max_id)
@@ -1281,7 +1281,7 @@ lib3ds_file_minmax_node_id(Lib3dsFile *file, uint16_t *min_id, uint16_t *max_id)
void
lib3ds_file_bounding_box_of_objects(Lib3dsFile *file, int
lib3ds_file_bounding_box_of_objects(Lib3dsFile *file, int
include_meshes, int include_cameras, int include_lights,
float bmin[3], float bmax[3]) {
bmin[0] = bmin[1] = bmin[2] = FLT_MAX;
@@ -1320,10 +1320,13 @@ lib3ds_file_bounding_box_of_objects(Lib3dsFile *file, int
static void
file_bounding_box_of_nodes_impl(Lib3dsNode *node, Lib3dsFile *file,
file_bounding_box_of_nodes_impl(Lib3dsNode *node, Lib3dsFile *file,
int include_meshes, int include_cameras, int include_lights,
float bmin[3], float bmax[3], float matrix[4][4]) {
switch (node->type) {
case LIB3DS_NODE_AMBIENT_COLOR:
break;
case LIB3DS_NODE_MESH_INSTANCE:
if (include_meshes) {
int index;
@@ -1392,7 +1395,7 @@ file_bounding_box_of_nodes_impl(Lib3dsNode *node, Lib3dsFile *file,
void
lib3ds_file_bounding_box_of_nodes(Lib3dsFile *file,
lib3ds_file_bounding_box_of_nodes(Lib3dsFile *file,
int include_meshes, int include_cameras,int include_lights,
float bmin[3], float bmax[3], float matrix[4][4]) {
Lib3dsNode *p;

View File

@@ -123,7 +123,7 @@ ReaderWriterdxf::readNode(const std::string& filename, const osgDB::ReaderWriter
std::string optionsstring=options->getOptionString();
size_t accstart=optionsstring.find("Accuracy(");
if (accstart>=0) {
if (accstart != std::string::npos) {
const char* start=optionsstring.c_str() + accstart + strlen("Accuracy(");
if (sscanf(start,"%lf",&maxError)==1) useAccuracy=true;
}

View File

@@ -35,7 +35,7 @@ namespace lwo2
virtual iff::Chunk *parse_chunk_data(const std::string &tag, const std::string &context, Iter it, Iter end);
iff::Chunk *parse_subchunk(Iter &it, const std::string &context);
Parser& operator = (const Parser&) { return *this; }
Parser& operator = (const Parser&) { return *this; }
};
@@ -894,8 +894,10 @@ namespace lwo2
{
std::string tag;
for (int i=0; i<4; ++i) tag += *(it++);
unsigned int len = ((static_cast<unsigned int>(*(it++)) & 0xFF) << 8) |
(static_cast<unsigned int>(*(it++)) & 0xFF);
unsigned int len = ((static_cast<unsigned int>(*it) & 0xFF) << 8) | (static_cast<unsigned int>(*(it+1)) & 0xFF);
it += 2;
this->os() << "DEBUG INFO: lwo2parser: reading subchunk " << tag << ", length = " << len << ", context = " << context << "\n";
iff::Chunk *chk = parse_chunk_data(tag, context, it, it+len);
if (!chk) this->os() << "DEBUG INFO: lwo2parser: \tprevious subchunk not handled\n";

View File

@@ -3685,8 +3685,8 @@ int unzReadCurrentFile (unzFile file, voidp buf, unsigned len, bool *reached_eo
if (s==NULL) return UNZ_PARAMERROR;
file_in_zip_read_info_s* pfile_in_zip_read_info = s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR;
if ((pfile_in_zip_read_info->read_buffer == NULL)) return UNZ_END_OF_LIST_OF_FILE;
if (pfile_in_zip_read_info == NULL) return UNZ_PARAMERROR;
if (pfile_in_zip_read_info->read_buffer == NULL) return UNZ_END_OF_LIST_OF_FILE;
if (len==0) return 0;
pfile_in_zip_read_info->stream.next_out = (Byte*)buf;

View File

@@ -375,6 +375,7 @@ bool Texture_matchInternalFormatModeStr(const char* str,Texture::InternalFormatM
else if (strcmp(str,"USE_RGTC2_COMPRESSION")==0) mode = Texture::USE_RGTC2_COMPRESSION;
else if (strcmp(str,"USE_S3TC_DXT1c_COMPRESSION")==0) mode = Texture::USE_S3TC_DXT1c_COMPRESSION;
else if (strcmp(str,"USE_S3TC_DXT1a_COMPRESSION")==0) mode = Texture::USE_S3TC_DXT1a_COMPRESSION;
else if (strcmp(str,"USE_ETC2_COMPRESSION")==0) mode = Texture::USE_ETC2_COMPRESSION;
else return false;
return true;
}
@@ -397,6 +398,7 @@ const char* Texture_getInternalFormatModeStr(Texture::InternalFormatMode mode)
case(Texture::USE_RGTC2_COMPRESSION): return "USE_RGTC2_COMPRESSION";
case(Texture::USE_S3TC_DXT1c_COMPRESSION): return "USE_S3TC_DXT1c_COMPRESSION";
case(Texture::USE_S3TC_DXT1a_COMPRESSION): return "USE_S3TC_DXT1a_COMPRESSION";
case(Texture::USE_ETC2_COMPRESSION): return "USE_ETC2_COMPRESSION";
}
return "";
}