Skip to content

Commit

Permalink
Get rid of warnings on GCC4.4 with -wall
Browse files Browse the repository at this point in the history
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@541 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
  • Loading branch information
aramis_acg committed Feb 6, 2010
1 parent 7dcbff5 commit 1732651
Show file tree
Hide file tree
Showing 33 changed files with 206 additions and 125 deletions.
4 changes: 2 additions & 2 deletions code/ASEParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,8 @@ void Parser::ParseLV2NodeTransformBlock(ASE::BaseNode& mesh)
mesh.mName == temp.substr(0,s))
{
// This should be either a target light or a target camera
if ( mesh.mType == BaseNode::Light && ((ASE::Light&)mesh) .mLightType == ASE::Light::TARGET ||
mesh.mType == BaseNode::Camera && ((ASE::Camera&)mesh).mCameraType == ASE::Camera::TARGET)
if ( (mesh.mType == BaseNode::Light && ((ASE::Light&)mesh) .mLightType == ASE::Light::TARGET) ||
(mesh.mType == BaseNode::Camera && ((ASE::Camera&)mesh).mCameraType == ASE::Camera::TARGET))
{
mode = 2;
}
Expand Down
1 change: 1 addition & 0 deletions code/Assimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ ASSIMP_API aiLogStream aiGetPredefinedLogStream(aiDefaultLogStream pStream,const
LogStream* stream = LogStream::createDefaultStream(pStream,file);
if (!stream) {
sout.callback = NULL;
sout.user = NULL;
}
else {
sout.callback = &CallbackToLogRedirector;
Expand Down
45 changes: 26 additions & 19 deletions code/B3DImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ using namespace std;
// ------------------------------------------------------------------------------------------------
bool B3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const{

int pos=pFile.find_last_of( '.' );
size_t pos=pFile.find_last_of( '.' );
if( pos==string::npos ) return false;

string ext=pFile.substr( pos+1 );
Expand Down Expand Up @@ -219,7 +219,7 @@ template<class T>
T *B3DImporter::to_array( const vector<T> &v ){
if( !v.size() ) return 0;
T *p=new T[v.size()];
for( int i=0;i<v.size();++i ){
for( size_t i=0;i<v.size();++i ){
p[i]=v[i];
}
return p;
Expand All @@ -229,11 +229,11 @@ T *B3DImporter::to_array( const vector<T> &v ){
void B3DImporter::ReadTEXS(){
while( ChunkSize() ){
string name=ReadString();
int flags=ReadInt();
int blend=ReadInt();
aiVector2D pos=ReadVec2();
aiVector2D scale=ReadVec2();
float rot=ReadFloat();
/*int flags=*/ReadInt();
/*int blend=*/ReadInt();
/*aiVector2D pos=*/ReadVec2();
/*aiVector2D scale=*/ReadVec2();
/*float rot=*/ReadFloat();

_textures.push_back( name );
}
Expand All @@ -250,7 +250,7 @@ void B3DImporter::ReadBRUS(){
aiVector3D color=ReadVec3();
float alpha=ReadFloat();
float shiny=ReadFloat();
int blend=ReadInt();
/*int blend=**/ReadInt();
int fx=ReadInt();

MaterialHelper *mat=new MaterialHelper;
Expand Down Expand Up @@ -283,7 +283,7 @@ void B3DImporter::ReadBRUS(){
//Textures
for( int i=0;i<n_texs;++i ){
int texid=ReadInt();
if( texid<-1 || (texid>=0 && texid>=_textures.size()) ){
if( texid<-1 || (texid>=0 && texid>=static_cast<int>(_textures.size())) ){
Fail( "Bad texture id" );
}
if( i==0 && texid>=0 ){
Expand Down Expand Up @@ -337,7 +337,7 @@ void B3DImporter::ReadTRIS( int v0 ){
int matid=ReadInt();
if( matid==-1 ){
matid=0;
}else if( matid<0 || matid>=_materials.size() ){
}else if( matid<0 || matid>=(int)_materials.size() ){
#ifdef DEBUG_B3D
cout<<"material id="<<matid<<endl;
#endif
Expand All @@ -358,7 +358,7 @@ void B3DImporter::ReadTRIS( int v0 ){
int i0=ReadInt()+v0;
int i1=ReadInt()+v0;
int i2=ReadInt()+v0;
if( i0<0 || i0>=_vertices.size() || i1<0 || i1>=_vertices.size() || i2<0 || i2>=_vertices.size() ){
if( i0<0 || i0>=(int)_vertices.size() || i1<0 || i1>=(int)_vertices.size() || i2<0 || i2>=(int)_vertices.size() ){
#ifdef DEBUG_B3D
cout<<"Bad triangle index: i0="<<i0<<", i1="<<i1<<", i2="<<i2<<endl;
#endif
Expand All @@ -377,7 +377,7 @@ void B3DImporter::ReadTRIS( int v0 ){

// ------------------------------------------------------------------------------------------------
void B3DImporter::ReadMESH(){
int matid=ReadInt();
/*int matid=*/ReadInt();

int v0=_vertices.size();

Expand All @@ -397,7 +397,7 @@ void B3DImporter::ReadBONE( int id ){
while( ChunkSize() ){
int vertex=ReadInt();
float weight=ReadFloat();
if( vertex<0 || vertex>=_vertices.size() ){
if( vertex<0 || vertex>=(int)_vertices.size() ){
Fail( "Bad vertex index" );
}

Expand Down Expand Up @@ -454,7 +454,7 @@ void B3DImporter::ReadKEYS( aiNodeAnim *nodeAnim ){

// ------------------------------------------------------------------------------------------------
void B3DImporter::ReadANIM(){
int flags=ReadInt();
/*int flags=*/ReadInt();
int frames=ReadInt();
float fps=ReadFloat();

Expand Down Expand Up @@ -498,7 +498,7 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
if( t=="MESH" ){
int n=_meshes.size();
ReadMESH();
for( int i=n;i<_meshes.size();++i ){
for( int i=n;i<(int)_meshes.size();++i ){
meshes.push_back( i );
}
}else if( t=="BONE" ){
Expand Down Expand Up @@ -544,6 +544,13 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
string t=ReadChunk();
if( t=="BB3D" ){
int version=ReadInt();

if (!DefaultLogger::isNullLogger()) {
char dmp[128];
sprintf(dmp,"B3D file format version: %i",version);
DefaultLogger::get()->info(dmp);
}

while( ChunkSize() ){
string t=ReadChunk();
if( t=="TEXS" ){
Expand All @@ -563,10 +570,10 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
if( !_meshes.size() ) Fail( "No meshes" );

//Fix nodes/meshes/bones
for( int i=0;i<_nodes.size();++i ){
for(size_t i=0;i<_nodes.size();++i ){
aiNode *node=_nodes[i];

for( int j=0;j<node->mNumMeshes;++j ){
for( size_t j=0;j<node->mNumMeshes;++j ){
aiMesh *mesh=_meshes[node->mMeshes[j]];

int n_tris=mesh->mNumFaces;
Expand Down Expand Up @@ -603,7 +610,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
}

vector<aiBone*> bones;
for( int i=0;i<vweights.size();++i ){
for(size_t i=0;i<vweights.size();++i ){
vector<aiVertexWeight> &weights=vweights[i];
if( !weights.size() ) continue;

Expand Down Expand Up @@ -631,7 +638,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
//nodes
scene->mRootNode=_nodes[0];

//materials
//material
if( !_materials.size() ){
_materials.push_back( new MaterialHelper );
}
Expand Down
26 changes: 17 additions & 9 deletions code/BaseImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,24 @@ void BaseImporter::SetupProperties(const Importer* pImp)
if (!pIOHandler) {
return false;
}

const char* magic = (const char*)_magic;
union {
const char* magic;
const uint16_t* magic_u16;
const uint32_t* magic_u32;
};
magic = reinterpret_cast<const char*>(_magic);
boost::scoped_ptr<IOStream> pStream (pIOHandler->Open(pFile));
if (pStream.get() ) {

// skip to offset
pStream->Seek(offset,aiOrigin_SET);

// read 'size' characters from the file
char data[16];
union {
char data[16];
uint16_t data_u16[8];
uint32_t data_u32[4];
};
if(size != pStream->Read(data,1,size)) {
return false;
}
Expand All @@ -217,16 +225,16 @@ void BaseImporter::SetupProperties(const Importer* pImp)
// that's just for convinience, the chance that we cause conflicts
// is quite low and it can save some lines and prevent nasty bugs
if (2 == size) {
int16_t rev = *((int16_t*)magic);
uint16_t rev = *magic_u16;
ByteSwap::Swap(&rev);
if (*((int16_t*)data) == ((int16_t*)magic)[i] || *((int16_t*)data) == rev) {
if (data_u16[0] == *magic_u16 || data_u16[0] == rev) {
return true;
}
}
else if (4 == size) {
int32_t rev = *((int32_t*)magic);
uint32_t rev = *magic_u32;
ByteSwap::Swap(&rev);
if (*((int32_t*)data) == ((int32_t*)magic)[i] || *((int32_t*)data) == rev) {
if (data_u32[0] == *magic_u32 || data_u32[0] == rev) {
return true;
}
}
Expand All @@ -248,10 +256,10 @@ void BaseImporter::SetupProperties(const Importer* pImp)
void ReportResult(ConversionResult res)
{
if(res == sourceExhausted) {
DefaultLogger::get()->error("Source ends with incomplete character sequence, Unicode transformation to UTF-8 fails");
DefaultLogger::get()->error("Source ends with incomplete character sequence, transformation to UTF-8 fails");
}
else if(res == sourceIllegal) {
DefaultLogger::get()->error("Source contains illegal character sequence, Unicode transformation to UTF-8 fails");
DefaultLogger::get()->error("Source contains illegal character sequence, transformation to UTF-8 fails");
}
}

Expand Down
12 changes: 4 additions & 8 deletions code/BaseProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ class ASSIMP_API SharedPostProcessInfo
template <typename T>
bool GetProperty( const char* name, T*& out ) const
{
THeapData<T>* t;
GetProperty(name,(Base*&)t);
THeapData<T>* t = (THeapData<T>*)GetPropertyInternal(name);
if(!t)
{
out = NULL;
Expand All @@ -155,8 +154,7 @@ class ASSIMP_API SharedPostProcessInfo
template <typename T>
bool GetProperty( const char* name, T& out ) const
{
TStaticData<T>* t;
GetProperty(name,(Base*&)t);
TStaticData<T>* t = (TStaticData<T>*)GetPropertyInternal(name);
if(!t)return false;
out = t->data;
return true;
Expand All @@ -169,14 +167,12 @@ class ASSIMP_API SharedPostProcessInfo

private:

//! Internal
void AddProperty( const char* name, Base* data) {
SetGenericPropertyPtr<Base>(pmap,name,data);
}

//! Internal
void GetProperty( const char* name, Base*& data) const {
data = GetGenericProperty<Base*>(pmap,name,NULL);
Base* GetPropertyInternal( const char* name) const {
return GetGenericProperty<Base*>(pmap,name,NULL);
}

private:
Expand Down
2 changes: 1 addition & 1 deletion code/ColladaHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,11 @@ struct Effect
, mTransparent ( 0, 0, 0, 1)
, mShininess (10.0f)
, mRefractIndex (1.f)
, mReflectivity (1.f)
, mTransparency (0.f)
, mDoubleSided (false)
, mWireframe (false)
, mFaceted (false)
, mReflectivity (1.f)
{
}
};
Expand Down
2 changes: 1 addition & 1 deletion code/ColladaLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars

// find the keyframe behind the current point in time
size_t pos = 0;
float postTime;
float postTime = 0.f;
while( 1)
{
if( pos >= e.mTimeAccessor->mCount)
Expand Down
3 changes: 3 additions & 0 deletions code/ColladaParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,9 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si
}

break;
default:
// IT_Invalid and IT_Vertex
ai_assert(false && "shouldn't ever get here");
}
}

Expand Down
2 changes: 1 addition & 1 deletion code/ComputeUVMappingProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ inline bool PlaneIntersect(const aiRay& ray, const aiVector3D& planePos,
{
const float b = planeNormal * (planePos - ray.pos);
float h = ray.dir * planeNormal;
if (h < 10e-5f && h > -10e-5f || (h = b/h) < 0)
if ((h < 10e-5f && h > -10e-5f) || (h = b/h) < 0)
return false;

pos = ray.pos + (ray.dir * h);
Expand Down
25 changes: 18 additions & 7 deletions code/DXFLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,25 @@ bool DXFImporter::ParseEntities()
{
while (GetNextToken()) {
if (!groupCode) {
if (!::strcmp(cursor,"3DFACE") || !::strcmp(cursor,"LINE") || !::strcmp(cursor,"3DLINE"))
if (!Parse3DFace()) return false; else bRepeat = true;

if (!::strcmp(cursor,"POLYLINE") || !::strcmp(cursor,"LWPOLYLINE"))
if (!ParsePolyLine()) return false; else bRepeat = true;

if (!::strcmp(cursor,"ENDSEC"))
if (!::strcmp(cursor,"3DFACE") || !::strcmp(cursor,"LINE") || !::strcmp(cursor,"3DLINE")){
if (!Parse3DFace()) {
return false;
}
else {
bRepeat = true;
}
}
if (!::strcmp(cursor,"POLYLINE") || !::strcmp(cursor,"LWPOLYLINE")){
if (!ParsePolyLine()) {
return false;
}
else {
bRepeat = true;
}
}
if (!::strcmp(cursor,"ENDSEC")) {
return true;
}
}
}
return false;
Expand Down
25 changes: 19 additions & 6 deletions code/DefaultIOSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,32 @@ bool IOSystem::ComparePaths (const char* one, const char* second) const
return !ASSIMP_stricmp(one,second);
}

// this should be sufficient for all platforms :D -- not really :->
#define PATHLIMIT 4096
// maximum path length
// XXX http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
#ifdef PATH_MAX
# define PATHLIMIT PATH_MAX
#else
# define PATHLIMIT 4096
#endif

// ------------------------------------------------------------------------------------------------
// Convert a relative path into an absolute path
inline void MakeAbsolutePath (const char* in, char* _out)
{
ai_assert(in & _out);
char* ret;
#ifdef _WIN32
::_fullpath(_out, in,PATHLIMIT);
ret = ::_fullpath(_out, in,PATHLIMIT);
#else
// use realpath
realpath(in, _out);
#endif
// use realpath
ret = realpath(in, _out);
#endif
if(!ret) {
// preserve the input path, maybe someone else is able to fix
// the path before it is accessed (e.g. our file system filter)
DefaultLogger::get()->warn("Invalid path: "+std::string(in));
strcpy(_out,in);
}
}

// ------------------------------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions code/FixNormalsStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ bool FixInfacingNormalsProcess::ProcessMesh( aiMesh* pcMesh, unsigned int index)
const float fDelta1_z = (vMax1.z - vMin1.z);

// Check whether the boxes are overlapping
if (fDelta0_x > 0.0f != fDelta1_x > 0.0f)return false;
if (fDelta0_y > 0.0f != fDelta1_y > 0.0f)return false;
if (fDelta0_z > 0.0f != fDelta1_z > 0.0f)return false;
if ((fDelta0_x > 0.0f) != (fDelta1_x > 0.0f))return false;
if ((fDelta0_y > 0.0f) != (fDelta1_y > 0.0f))return false;
if ((fDelta0_z > 0.0f) != (fDelta1_z > 0.0f))return false;

// Check whether this is a planar surface
const float fDelta1_yz = fDelta1_y * fDelta1_z;
Expand Down
Loading

0 comments on commit 1732651

Please sign in to comment.