fix more warnings.

pull/3012/head
Kim Kulling 2020-02-16 15:37:20 +01:00
parent 4a3ecbea14
commit c2bfbdacf4
15 changed files with 133 additions and 110 deletions

View File

@ -342,6 +342,20 @@ struct Texture {
mTextureBlend = get_qnan();
}
Texture(Texture &&other) AI_NO_EXCEPT :
mTextureBlend(std::move(other.mTextureBlend)),
mMapName(std::move(mMapName)),
mOffsetU(std::move(mOffsetU)),
mOffsetV(std::move(mOffsetV)),
mScaleU(std::move(mScaleU)),
mScaleV(std::move(mScaleV)),
mRotation(std::move(mRotation)),
mMapMode(std::move(mMapMode)),
bPrivate(std::move(bPrivate)),
iUVSrc(std::move(iUVSrc)) {
}
//! Specifies the blend factor for the texture
ai_real mTextureBlend;

View File

@ -371,7 +371,7 @@ protected:
void* value = node->mMetaData->mValues[i].mData;
Write<aiString>(&chunk, key);
Write<uint16_t>(&chunk, type);
Write<uint16_t>(&chunk, (uint16_t) type);
switch (type) {
case AI_BOOL:
@ -553,13 +553,14 @@ protected:
const aiFace& f = mesh->mFaces[i];
static_assert(AI_MAX_FACE_INDICES <= 0xffff, "AI_MAX_FACE_INDICES <= 0xffff");
Write<uint16_t>(&chunk,f.mNumIndices);
Write<uint32_t>(&chunk,f.mNumIndices);
for (unsigned int a = 0; a < f.mNumIndices;++a) {
if (mesh->mNumVertices < (1u<<16)) {
Write<uint16_t>(&chunk,f.mIndices[a]);
Write<uint32_t>(&chunk,f.mIndices[a]);
} else {
Write<unsigned int>(&chunk, f.mIndices[a]);
}
else Write<unsigned int>(&chunk,f.mIndices[a]);
}
}
}

View File

@ -155,36 +155,37 @@ AI_WONT_RETURN void B3DImporter::Fail( string str ){
// ------------------------------------------------------------------------------------------------
int B3DImporter::ReadByte(){
if( _pos<_buf.size() ) {
return _buf[_pos++];
if (_pos > _buf.size()) {
Fail("EOF");
}
Fail( "EOF" );
return 0;
return _buf[_pos++];
}
// ------------------------------------------------------------------------------------------------
int B3DImporter::ReadInt(){
if( _pos+4<=_buf.size() ){
if (_pos + 4 > _buf.size()) {
Fail("EOF");
}
int n;
memcpy(&n, &_buf[_pos], 4);
_pos+=4;
return n;
}
Fail( "EOF" );
return 0;
}
// ------------------------------------------------------------------------------------------------
float B3DImporter::ReadFloat(){
if( _pos+4<=_buf.size() ){
float B3DImporter::ReadFloat() {
if (_pos + 4 > _buf.size()) {
Fail("EOF");
}
float n;
memcpy(&n, &_buf[_pos], 4);
_pos+=4;
return n;
}
Fail( "EOF" );
return 0.0f;
}
// ------------------------------------------------------------------------------------------------
@ -214,6 +215,9 @@ aiQuaternion B3DImporter::ReadQuat(){
// ------------------------------------------------------------------------------------------------
string B3DImporter::ReadString(){
if (_pos > _buf.size()) {
Fail("EOF");
}
string str;
while( _pos<_buf.size() ){
char c=(char)ReadByte();
@ -222,7 +226,6 @@ string B3DImporter::ReadString(){
}
str+=c;
}
Fail( "EOF" );
return string();
}
@ -247,7 +250,7 @@ void B3DImporter::ExitChunk(){
}
// ------------------------------------------------------------------------------------------------
unsigned B3DImporter::ChunkSize(){
size_t B3DImporter::ChunkSize(){
return _stack.back()-_pos;
}
// ------------------------------------------------------------------------------------------------
@ -355,8 +358,8 @@ void B3DImporter::ReadVRTS(){
Fail( "Bad texcoord data" );
}
int sz=12+(_vflags&1?12:0)+(_vflags&2?16:0)+(_tcsets*_tcsize*4);
int n_verts=ChunkSize()/sz;
int sz = 12+(_vflags&1?12:0)+(_vflags&2?16:0)+(_tcsets*_tcsize*4);
size_t n_verts = ChunkSize()/sz;
int v0=static_cast<int>(_vertices.size());
_vertices.resize( v0+n_verts );
@ -377,14 +380,14 @@ void B3DImporter::ReadVRTS(){
ReadQuat(); //skip v 4bytes...
}
for( int i=0;i<_tcsets;++i ){
for( int j=0;j<_tcsets;++j ){
float t[4]={0,0,0,0};
for( int j=0;j<_tcsize;++j ){
t[j]=ReadFloat();
for( int k=0;k<_tcsize;++k ){
t[k]=ReadFloat();
}
t[1]=1-t[1];
if( !i ) {
v.texcoords=aiVector3D( t[0],t[1],t[2] );
t[1] = 1 - t[1];
if( !j ) {
v.texcoords = aiVector3D( t[0],t[1],t[2] );
}
}
}
@ -408,7 +411,7 @@ void B3DImporter::ReadTRIS(int v0) {
mesh->mNumFaces = 0;
mesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
int n_tris = ChunkSize() / 12;
size_t n_tris = ChunkSize() / 12;
aiFace *face = mesh->mFaces = new aiFace[n_tris];
for (int i = 0; i < n_tris; ++i) {
@ -463,7 +466,7 @@ void B3DImporter::ReadBONE(int id) {
Vertex &v = _vertices[vertex];
for (int i = 0; i < 4; ++i) {
if (!v.weights[i]) {
v.bones[i] = id;
v.bones[i] = static_cast<unsigned char>(id);
v.weights[i] = weight;
break;
}
@ -547,24 +550,24 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
vector<aiNode*> children;
while( ChunkSize() ){
string t=ReadChunk();
if( t=="MESH" ){
const string chunk = ReadChunk();
if (chunk == "MESH") {
unsigned int n= static_cast<unsigned int>(_meshes.size());
ReadMESH();
for( unsigned int i=n;i<static_cast<unsigned int>(_meshes.size());++i ){
meshes.push_back( i );
}
}else if( t=="BONE" ){
} else if (chunk == "BONE") {
ReadBONE( nodeid );
}else if( t=="ANIM" ){
} else if (chunk == "ANIM") {
ReadANIM();
}else if( t=="KEYS" ){
} else if (chunk == "KEYS") {
if( !nodeAnim ){
nodeAnim.reset(new aiNodeAnim);
nodeAnim->mNodeName=node->mName;
}
ReadKEYS( nodeAnim.get() );
}else if( t=="NODE" ){
} else if (chunk == "NODE") {
aiNode *child=ReadNODE( node );
children.push_back( child );
}
@ -613,12 +616,12 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
}
while( ChunkSize() ){
string t=ReadChunk();
if( t=="TEXS" ){
const string chunk = ReadChunk();
if (chunk == "TEXS") {
ReadTEXS();
}else if( t=="BRUS" ){
} else if (chunk == "BRUS") {
ReadBRUS();
}else if( t=="NODE" ){
} else if (chunk == "NODE") {
ReadNODE( 0 );
}
ExitChunk();
@ -656,48 +659,51 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
vector< vector<aiVertexWeight> > vweights( _nodes.size() );
for( int i=0;i<n_verts;i+=3 ){
for( int j=0;j<3;++j ){
Vertex &v=_vertices[face->mIndices[j]];
for (int vertIdx = 0; vertIdx < n_verts; vertIdx += 3) {
for (int faceIndex = 0; faceIndex < 3; ++faceIndex) {
Vertex &v = _vertices[face->mIndices[faceIndex]];
*mv++=v.vertex;
if( mn ) *mn++=v.normal;
if( mc ) *mc++=v.texcoords;
face->mIndices[j]=i+j;
face->mIndices[faceIndex] = vertIdx + faceIndex;
for( int k=0;k<4;++k ){
if( !v.weights[k] ) break;
if( !v.weights[k] )
break;
int bone=v.bones[k];
float weight=v.weights[k];
int bone = v.bones[k];
float weight = v.weights[k];
vweights[bone].push_back( aiVertexWeight(i+j,weight) );
vweights[bone].push_back(aiVertexWeight(vertIdx + faceIndex, weight));
}
}
++face;
}
vector<aiBone*> bones;
for(size_t i=0;i<vweights.size();++i ){
vector<aiVertexWeight> &weights=vweights[i];
if( !weights.size() ) continue;
for (size_t weightIndx = 0; weightIndx < vweights.size(); ++weightIndx) {
vector<aiVertexWeight> &weights = vweights[weightIndx];
if (!weights.size()) {
continue;
}
aiBone *bone=new aiBone;
aiBone *bone = new aiBone;
bones.push_back( bone );
aiNode *bnode=_nodes[i];
aiNode *bnode = _nodes[weightIndx];
bone->mName=bnode->mName;
bone->mNumWeights= static_cast<unsigned int>(weights.size());
bone->mWeights=to_array( weights );
bone->mName = bnode->mName;
bone->mNumWeights = static_cast<unsigned int>(weights.size());
bone->mWeights = to_array( weights );
aiMatrix4x4 mat=bnode->mTransformation;
aiMatrix4x4 mat = bnode->mTransformation;
while( bnode->mParent ){
bnode=bnode->mParent;
mat=bnode->mTransformation * mat;
}
bone->mOffsetMatrix=mat.Inverse();
bone->mOffsetMatrix = mat.Inverse();
}
mesh->mNumBones= static_cast<unsigned int>(bones.size());
mesh->mBones=to_array( bones );

View File

@ -82,7 +82,7 @@ private:
std::string ReadString();
std::string ReadChunk();
void ExitChunk();
unsigned ChunkSize();
size_t ChunkSize();
template<class T>
T *to_array( const std::vector<T> &v );
@ -112,10 +112,10 @@ private:
void ReadBB3D( aiScene *scene );
unsigned _pos;
size_t _pos;
// unsigned _size;
std::vector<unsigned char> _buf;
std::vector<unsigned> _stack;
std::vector<size_t> _stack;
std::vector<std::string> _textures;
std::vector<std::unique_ptr<aiMaterial> > _materials;

View File

@ -146,7 +146,7 @@ aiScene* BaseImporter::ReadFile(Importer* pImp, const std::string& pFile, IOSyst
}
// ------------------------------------------------------------------------------------------------
void BaseImporter::SetupProperties(const Importer* pImp)
void BaseImporter::SetupProperties(const Importer* )
{
// the default implementation does nothing
}

View File

@ -53,6 +53,8 @@ using namespace Assimp;
# define CHAR_BIT 8
#endif
#pragma warning(disable : 4127)
// ------------------------------------------------------------------------------------------------
// Constructs a spatially sorted representation from the given position array.
SpatialSort::SpatialSort( const aiVector3D* pPositions, unsigned int pNumPositions,

View File

@ -332,8 +332,7 @@ unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial* pMat,
aiMaterialProperty* prop = pMat->mProperties[i];
if ( prop /* just a sanity check ... */
&& 0 == strcmp( prop->mKey.data, _AI_MATKEY_TEXTURE_BASE )
&& prop->mSemantic == type) {
&& 0 == strcmp(prop->mKey.data, _AI_MATKEY_TEXTURE_BASE) && static_cast < aiTextureType>(prop->mSemantic) == type) {
max = std::max(max,prop->mIndex+1);
}

View File

@ -62,7 +62,7 @@ bool ArmaturePopulate::IsActive(unsigned int pFlags) const {
return (pFlags & aiProcess_PopulateArmatureData) != 0;
}
void ArmaturePopulate::SetupProperties(const Importer *pImp) {
void ArmaturePopulate::SetupProperties(const Importer *) {
// do nothing
}
@ -162,7 +162,7 @@ void ArmaturePopulate::BuildNodeList(const aiNode *current_node,
// A bone stack allows us to have multiple armatures, with the same bone names
// A bone stack allows us also to retrieve bones true transform even with
// duplicate names :)
void ArmaturePopulate::BuildBoneStack(aiNode *current_node,
void ArmaturePopulate::BuildBoneStack(aiNode *,
const aiNode *root_node,
const aiScene *scene,
const std::vector<aiBone *> &bones,

View File

@ -238,7 +238,7 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
// FIX: check whether we can reuse the SpatialSort of a previous step
SpatialSort* vertexFinder = NULL;
SpatialSort _vertexFinder;
float posEpsilon;
float posEpsilon = 10e-6f;
if (shared)
{
std::vector<std::pair<SpatialSort,float> >* avf;

View File

@ -99,8 +99,8 @@ void UpdateMeshReferences(aiNode* node, const std::vector<unsigned int>& meshMap
}
// just let the members that are unused, that's much cheaper
// than a full array realloc'n'copy party ...
if(!(node->mNumMeshes = out)) {
node->mNumMeshes = out;
if ( 0 == out ) {
delete[] node->mMeshes;
node->mMeshes = NULL;
}
@ -122,9 +122,8 @@ void FindInvalidDataProcess::Execute( aiScene* pScene) {
// Process meshes
for( unsigned int a = 0; a < pScene->mNumMeshes; a++) {
int result;
if ((result = ProcessMesh( pScene->mMeshes[a]))) {
int result = ProcessMesh(pScene->mMeshes[a]);
if (0 == result ) {
out = true;
if (2 == result) {
@ -141,8 +140,8 @@ void FindInvalidDataProcess::Execute( aiScene* pScene) {
}
// Process animations
for (unsigned int a = 0; a < pScene->mNumAnimations;++a) {
ProcessAnimation( pScene->mAnimations[a]);
for (unsigned int animIdx = 0; animIdx < pScene->mNumAnimations; ++animIdx) {
ProcessAnimation(pScene->mAnimations[animIdx]);
}

View File

@ -132,11 +132,9 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh)
// need to build a clean list of bones, too
for (unsigned int i = 0;i < pcMesh->mNumBones;++i)
{
for (unsigned int a = 0; a < pcMesh->mBones[i]->mNumWeights;a++)
{
const aiVertexWeight& w = pcMesh->mBones[i]->mWeights[a];
if(pcFace->mIndices[q] == w.mVertexId)
{
for (unsigned int boneIdx = 0; boneIdx < pcMesh->mBones[i]->mNumWeights; ++boneIdx) {
const aiVertexWeight &w = pcMesh->mBones[i]->mWeights[boneIdx];
if(pcFace->mIndices[q] == w.mVertexId) {
aiVertexWeight wNew;
wNew.mVertexId = iIndex;
wNew.mWeight = w.mWeight;
@ -157,17 +155,17 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh)
pvBitangents[iIndex] = pcMesh->mBitangents[pcFace->mIndices[q]];
}
unsigned int p = 0;
while (pcMesh->HasTextureCoords(p))
unsigned int pp = 0;
while (pcMesh->HasTextureCoords(pp))
{
apvTextureCoords[p][iIndex] = pcMesh->mTextureCoords[p][pcFace->mIndices[q]];
++p;
apvTextureCoords[pp][iIndex] = pcMesh->mTextureCoords[pp][pcFace->mIndices[q]];
++pp;
}
p = 0;
while (pcMesh->HasVertexColors(p))
pp = 0;
while (pcMesh->HasVertexColors(pp))
{
apvColorSets[p][iIndex] = pcMesh->mColors[p][pcFace->mIndices[q]];
++p;
apvColorSets[pp][iIndex] = pcMesh->mColors[pp][pcFace->mIndices[q]];
++pp;
}
pcFace->mIndices[q] = iIndex;
}

View File

@ -179,7 +179,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode *nd, std::list<aiNode *> &n
// copy all mesh references in one array
if (out_meshes) {
unsigned int *meshes = new unsigned int[out_meshes + join_master->mNumMeshes], *tmp = meshes;
unsigned int *meshIdxs = new unsigned int[out_meshes + join_master->mNumMeshes], *tmp = meshIdxs;
for (unsigned int n = 0; n < join_master->mNumMeshes; ++n) {
*tmp++ = join_master->mMeshes[n];
}
@ -217,7 +217,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode *nd, std::list<aiNode *> &n
delete join_node; // bye, node
}
delete[] join_master->mMeshes;
join_master->mMeshes = meshes;
join_master->mMeshes = meshIdxs;
join_master->mNumMeshes += out_meshes;
}
}

View File

@ -330,19 +330,23 @@ void SortByPTypeProcess::Execute( aiScene* pScene) {
ai_assert(outFaces == out->mFaces + out->mNumFaces);
// now generate output bones
for (unsigned int q = 0; q < mesh->mNumBones;++q)
if (!tempBones[q].empty())++out->mNumBones;
for (unsigned int q = 0; q < mesh->mNumBones; ++q) {
if (!tempBones[q].empty()) {
++out->mNumBones;
}
}
if (out->mNumBones)
{
if (out->mNumBones) {
out->mBones = new aiBone*[out->mNumBones];
for (unsigned int q = 0, real = 0; q < mesh->mNumBones;++q)
for (unsigned int q = 0, boneIdx = 0; q < mesh->mNumBones;++q)
{
TempBoneInfo& in = tempBones[q];
if (in.empty())continue;
if (in.empty()) {
continue;
}
aiBone* srcBone = mesh->mBones[q];
aiBone* bone = out->mBones[real] = new aiBone();
aiBone *bone = out->mBones[boneIdx] = new aiBone();
bone->mName = srcBone->mName;
bone->mOffsetMatrix = srcBone->mOffsetMatrix;
@ -352,7 +356,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene) {
::memcpy(bone->mWeights,&in[0],bone->mNumWeights*sizeof(aiVertexWeight));
++real;
++boneIdx;
}
}
}
@ -364,7 +368,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene) {
delete mesh;
// avoid invalid pointer
pScene->mMeshes[i] = NULL;
pScene->mMeshes[i] = nullptr;
}
if (outMeshes.empty())

View File

@ -419,7 +419,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
num = 0;
break;
curOut -= (max-num); /* undo all previous work */
/*curOut -= (max-num); // undo all previous work
for (tmp = 0; tmp < max-2; ++tmp) {
aiFace& nface = *curOut++;
@ -433,7 +433,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
}
num = 0;
break;
break;*/
}
aiFace& nface = *curOut++;

View File

@ -612,7 +612,7 @@ void ValidateDSProcess::SearchForInvalidTextures(const aiMaterial* pMaterial,
bool bNoSpecified = true;
for (unsigned int i = 0; i < pMaterial->mNumProperties;++i) {
aiMaterialProperty* prop = pMaterial->mProperties[i];
if (prop->mSemantic != type) {
if (static_cast<aiTextureType>(prop->mSemantic) != type) {
continue;
}