next warnings.

pull/3012/head
Kim Kulling 2020-02-18 14:41:19 +01:00
parent 22118dff1d
commit 6e13381bdb
12 changed files with 1110 additions and 1282 deletions

View File

@ -45,14 +45,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_3DSFILEHELPER_H_INC
#define AI_3DSFILEHELPER_H_INC
#include <assimp/SpatialSort.h>
#include <assimp/SmoothingGroups.h>
#include <assimp/SpatialSort.h>
#include <assimp/StringUtils.h>
#include <assimp/qnan.h>
#include <assimp/material.h>
#include <assimp/anim.h>
#include <assimp/camera.h>
#include <assimp/light.h>
#include <assimp/anim.h>
#include <assimp/material.h>
#include <assimp/qnan.h>
#include <stdio.h> //sprintf
namespace Assimp {
@ -81,11 +81,9 @@ public:
uint32_t Size;
} PACK_STRUCT;
//! Used for shading field in material3ds structure
//! From AutoDesk 3ds SDK
typedef enum
{
typedef enum {
// translated to gouraud shading with wireframe active
Wire = 0x0,
@ -109,17 +107,15 @@ public:
} shadetype3ds;
// Flags for animated keys
enum
{
enum {
KEY_USE_TENS = 0x1,
KEY_USE_CONT = 0x2,
KEY_USE_BIAS = 0x4,
KEY_USE_EASE_TO = 0x8,
KEY_USE_EASE_FROM = 0x10
} ;
};
enum
{
enum {
// ********************************************************************
// Basic chunks which can be found everywhere in the file
@ -209,7 +205,7 @@ public:
// Specifies the shininess of the material
// followed by percentage chunk
CHUNK_MAT_SHININESS = 0xA040,
CHUNK_MAT_SHININESS_PERCENT = 0xA041 ,
CHUNK_MAT_SHININESS_PERCENT = 0xA041,
// Specifies the shading mode to be used
// followed by a short
@ -322,28 +318,30 @@ public:
// ---------------------------------------------------------------------------
/** Helper structure representing a 3ds mesh face */
struct Face : public FaceWithSmoothingGroup
{
struct Face : public FaceWithSmoothingGroup {
};
#pragma warning(disable : 4315 )
// ---------------------------------------------------------------------------
/** Helper structure representing a texture */
struct Texture {
//! Default constructor
Texture() AI_NO_EXCEPT
: mOffsetU (0.0)
, mOffsetV (0.0)
, mScaleU (1.0)
, mScaleV (1.0)
, mRotation (0.0)
, mMapMode (aiTextureMapMode_Wrap)
, bPrivate()
, iUVSrc (0) {
: mTextureBlend(0.0f),
mMapName(),
mOffsetU(0.0),
mOffsetV(0.0),
mScaleU(1.0),
mScaleV(1.0),
mRotation(0.0),
mMapMode(aiTextureMapMode_Wrap),
bPrivate(),
iUVSrc(0) {
mTextureBlend = get_qnan();
}
Texture(Texture &&other) AI_NO_EXCEPT :
mTextureBlend(std::move(other.mTextureBlend)),
Texture(Texture &&other) AI_NO_EXCEPT : mTextureBlend(std::move(other.mTextureBlend)),
mMapName(std::move(mMapName)),
mOffsetU(std::move(mOffsetU)),
mOffsetV(std::move(mOffsetV)),
@ -353,7 +351,26 @@ struct Texture {
mMapMode(std::move(mMapMode)),
bPrivate(std::move(bPrivate)),
iUVSrc(std::move(iUVSrc)) {
// empty
}
Texture &operator=(Texture &&other) AI_NO_EXCEPT {
if (this == &other) {
return *this;
}
mTextureBlend = std::move(other.mTextureBlend);
mMapName = std::move(other.mMapName);
mOffsetU = std::move(other.mOffsetU);
mOffsetV = std::move(other.mOffsetV);
mScaleU = std::move(other.mScaleU);
mScaleV = std::move(other.mScaleV);
mRotation = std::move(other.mRotation);
mMapMode = std::move(other.mMapMode);
bPrivate = std::move(other.bPrivate);
iUVSrc = std::move(other.iUVSrc);
return *this;
}
//! Specifies the blend factor for the texture
@ -381,55 +398,48 @@ struct Texture {
// ---------------------------------------------------------------------------
/** Helper structure representing a 3ds material */
struct Material
{
struct Material {
//! Default constructor has been deleted
Material() = delete;
//! Constructor with explicit name
explicit Material(const std::string &name)
: mName(name)
, mDiffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) // FIX ... we won't want object to be black
, mSpecularExponent ( ai_real( 0.0 ) )
, mShininessStrength ( ai_real( 1.0 ) )
, mShading(Discreet3DS::Gouraud)
, mTransparency ( ai_real( 1.0 ) )
, mBumpHeight ( ai_real( 1.0 ) )
, mTwoSided (false)
{
explicit Material(const std::string &name) :
mName(name), mDiffuse(ai_real(0.6), ai_real(0.6), ai_real(0.6)) // FIX ... we won't want object to be black
,
mSpecularExponent(ai_real(0.0)),
mShininessStrength(ai_real(1.0)),
mShading(Discreet3DS::Gouraud),
mTransparency(ai_real(1.0)),
mBumpHeight(ai_real(1.0)),
mTwoSided(false) {
}
Material(const Material &other) = default;
Material &operator=(const Material &other) = default;
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
Material(Material &&other) AI_NO_EXCEPT
: mName(std::move(other.mName))
, mDiffuse(std::move(other.mDiffuse))
, mSpecularExponent(std::move(other.mSpecularExponent))
, mShininessStrength(std::move(other.mShininessStrength))
, mSpecular(std::move(other.mSpecular))
, mAmbient(std::move(other.mAmbient))
, mShading(std::move(other.mShading))
, mTransparency(std::move(other.mTransparency))
, sTexDiffuse(std::move(other.sTexDiffuse))
, sTexOpacity(std::move(other.sTexOpacity))
, sTexSpecular(std::move(other.sTexSpecular))
, sTexReflective(std::move(other.sTexReflective))
, sTexBump(std::move(other.sTexBump))
, sTexEmissive(std::move(other.sTexEmissive))
, sTexShininess(std::move(other.sTexShininess))
, mBumpHeight(std::move(other.mBumpHeight))
, mEmissive(std::move(other.mEmissive))
, sTexAmbient(std::move(other.sTexAmbient))
, mTwoSided(std::move(other.mTwoSided))
{
: mName(std::move(other.mName)),
mDiffuse(std::move(other.mDiffuse)),
mSpecularExponent(std::move(other.mSpecularExponent)),
mShininessStrength(std::move(other.mShininessStrength)),
mSpecular(std::move(other.mSpecular)),
mAmbient(std::move(other.mAmbient)),
mShading(std::move(other.mShading)),
mTransparency(std::move(other.mTransparency)),
sTexDiffuse(std::move(other.sTexDiffuse)),
sTexOpacity(std::move(other.sTexOpacity)),
sTexSpecular(std::move(other.sTexSpecular)),
sTexReflective(std::move(other.sTexReflective)),
sTexBump(std::move(other.sTexBump)),
sTexEmissive(std::move(other.sTexEmissive)),
sTexShininess(std::move(other.sTexShininess)),
mBumpHeight(std::move(other.mBumpHeight)),
mEmissive(std::move(other.mEmissive)),
sTexAmbient(std::move(other.sTexAmbient)),
mTwoSided(std::move(other.mTwoSided)) {
}
Material &operator=(Material &&other) AI_NO_EXCEPT {
if (this == &other) {
return *this;
@ -458,10 +468,8 @@ struct Material
return *this;
}
virtual ~Material() {}
//! Name of the material
std::string mName;
//! Diffuse color of the material
@ -505,18 +513,15 @@ struct Material
// ---------------------------------------------------------------------------
/** Helper structure to represent a 3ds file mesh */
struct Mesh : public MeshWithSmoothingGroups<D3DS::Face>
{
struct Mesh : public MeshWithSmoothingGroups<D3DS::Face> {
//! Default constructor has been deleted
Mesh() = delete;
//! Constructor with explicit name
explicit Mesh(const std::string &name)
: mName(name)
{
explicit Mesh(const std::string &name) :
mName(name) {
}
//! Name of the mesh
std::string mName;
@ -533,62 +538,48 @@ struct Mesh : public MeshWithSmoothingGroups<D3DS::Face>
// ---------------------------------------------------------------------------
/** Float key - quite similar to aiVectorKey and aiQuatKey. Both are in the
C-API, so it would be difficult to make them a template. */
struct aiFloatKey
{
struct aiFloatKey {
double mTime; ///< The time of this key
ai_real mValue; ///< The value of this key
#ifdef __cplusplus
// time is not compared
bool operator == (const aiFloatKey& o) const
{return o.mValue == this->mValue;}
bool operator==(const aiFloatKey &o) const { return o.mValue == this->mValue; }
bool operator != (const aiFloatKey& o) const
{return o.mValue != this->mValue;}
bool operator!=(const aiFloatKey &o) const { return o.mValue != this->mValue; }
// Only time is compared. This operator is defined
// for use with std::sort
bool operator < (const aiFloatKey& o) const
{return mTime < o.mTime;}
bool operator<(const aiFloatKey &o) const { return mTime < o.mTime; }
bool operator > (const aiFloatKey& o) const
{return mTime > o.mTime;}
bool operator>(const aiFloatKey &o) const { return mTime > o.mTime; }
#endif
};
// ---------------------------------------------------------------------------
/** Helper structure to represent a 3ds file node */
struct Node
{
struct Node {
Node() = delete;
explicit Node(const std::string &name)
: mParent(NULL)
, mName(name)
, mInstanceNumber(0)
, mHierarchyPos (0)
, mHierarchyIndex (0)
, mInstanceCount (1)
{
aRotationKeys.reserve (20);
aPositionKeys.reserve (20);
aScalingKeys.reserve (20);
explicit Node(const std::string &name) :
mParent(NULL), mName(name), mInstanceNumber(0), mHierarchyPos(0), mHierarchyIndex(0), mInstanceCount(1) {
aRotationKeys.reserve(20);
aPositionKeys.reserve(20);
aScalingKeys.reserve(20);
}
~Node()
{
for (unsigned int i = 0; i < mChildren.size();++i)
~Node() {
for (unsigned int i = 0; i < mChildren.size(); ++i)
delete mChildren[i];
}
//! Pointer to the parent node
Node* mParent;
Node *mParent;
//! Holds all child nodes
std::vector<Node*> mChildren;
std::vector<Node *> mChildren;
//! Name of the node
std::string mName;
@ -614,13 +605,12 @@ struct Node
//! Scaling keys loaded from the file
std::vector<aiVectorKey> aScalingKeys;
// For target lights (spot lights and directional lights):
// The position of the target
std::vector< aiVectorKey > aTargetPositionKeys;
std::vector<aiVectorKey> aTargetPositionKeys;
// For cameras: the camera roll angle
std::vector< aiFloatKey > aCameraRollKeys;
std::vector<aiFloatKey> aCameraRollKeys;
//! Pivot position loaded from the file
aiVector3D vPivot;
@ -630,8 +620,7 @@ struct Node
//! Add a child node, setup the right parent node for it
//! \param pc Node to be 'adopted'
inline Node& push_back(Node* pc)
{
inline Node &push_back(Node *pc) {
mChildren.push_back(pc);
pc->mParent = this;
return *this;
@ -639,8 +628,7 @@ struct Node
};
// ---------------------------------------------------------------------------
/** Helper structure analogue to aiScene */
struct Scene
{
struct Scene {
//! List of all materials loaded
//! NOTE: 3ds references materials globally
std::vector<Material> mMaterials;
@ -649,17 +637,16 @@ struct Scene
std::vector<Mesh> mMeshes;
//! List of all cameras loaded
std::vector<aiCamera*> mCameras;
std::vector<aiCamera *> mCameras;
//! List of all lights loaded
std::vector<aiLight*> mLights;
std::vector<aiLight *> mLights;
//! Pointer to the root node of the scene
// --- moved to main class
// Node* pcRootNode;
};
} // end of namespace D3DS
} // end of namespace Assimp

View File

@ -158,13 +158,13 @@ void Discreet3DSImporter::SetupProperties(const Importer* /*pImp*/)
void Discreet3DSImporter::InternReadFile( const std::string& pFile,
aiScene* pScene, IOSystem* pIOHandler)
{
StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
StreamReaderLE theStream(pIOHandler->Open(pFile,"rb"));
// We should have at least one chunk
if (stream.GetRemainingSize() < 16) {
if (theStream.GetRemainingSize() < 16) {
throw DeadlyImportError("3DS file is either empty or corrupt: " + pFile);
}
this->stream = &stream;
this->stream = &theStream;
// Allocate our temporary 3DS representation
D3DS::Scene _scene;
@ -599,16 +599,19 @@ void Discreet3DSImporter::InverseNodeSearch(D3DS::Node* pcNode,D3DS::Node* pcCur
// ------------------------------------------------------------------------------------------------
// Find a node with a specific name in the import hierarchy
D3DS::Node* FindNode(D3DS::Node* root, const std::string& name)
{
if (root->mName == name)
D3DS::Node* FindNode(D3DS::Node* root, const std::string& name) {
if (root->mName == name) {
return root;
}
for (std::vector<D3DS::Node*>::iterator it = root->mChildren.begin();it != root->mChildren.end(); ++it) {
D3DS::Node* nd;
if (( nd = FindNode(*it,name)))
D3DS::Node *nd = FindNode(*it, name);
if (nullptr != nd) {
return nd;
}
return NULL;
}
return nullptr;
}
// ------------------------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -268,7 +268,7 @@ private:
std::vector<aiLight*>* mLights;
// name counters
unsigned int lights, groups, polys, worlds;
unsigned int mLightsCounter, mGroupsCounter, mPolysCounter, mWorldsCounter;
};
} // end of namespace Assimp

View File

@ -465,7 +465,7 @@ std::list<unsigned int> mesh_idx;
{
auto VertexIndex_GetMinimal = [](const std::list<SComplexFace>& pFaceList, const size_t* pBiggerThan) -> size_t
{
size_t rv;
size_t rv=0;
if(pBiggerThan != nullptr)
{

View File

@ -118,11 +118,11 @@ void HMPImporter::InternReadFile( const std::string& pFile,
aiScene* _pScene, IOSystem* _pIOHandler)
{
pScene = _pScene;
pIOHandler = _pIOHandler;
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
mIOHandler = _pIOHandler;
std::unique_ptr<IOStream> file(mIOHandler->Open(pFile));
// Check whether we can read from the file
if( file.get() == NULL)
if( file.get() == nullptr)
throw DeadlyImportError( "Failed to open HMP file " + pFile + ".");
// Check whether the HMP file is large enough to contain

View File

@ -185,10 +185,12 @@ void AnimResolver::UpdateAnimRangeSetup()
for (unsigned int i = 0; i < num; ++i) {
m = n+old_size*(i+1);
std::copy(n,n+old_size,m);
if ((*it).pre == LWO::PrePostBehaviour_Oscillate && (reverse = !reverse))
const bool res = ((*it).pre == LWO::PrePostBehaviour_Oscillate);
reverse = !reverse;
if (res && reverse ) {
std::reverse(m,m+old_size-1);
}
}
// update time values
n = (*it).keys.end() - (old_size+1);
@ -533,7 +535,7 @@ void AnimResolver::GetKeys(std::vector<aiVectorKey>& out,
// ------------------------------------------------------------------------------------------------
// Extract animation channel
void AnimResolver::ExtractAnimChannel(aiNodeAnim** out, unsigned int flags /*= 0*/)
void AnimResolver::ExtractAnimChannel(aiNodeAnim** out, unsigned int /*= 0*/)
{
*out = NULL;

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@ -58,7 +57,6 @@ struct aiTexture;
namespace Assimp {
using namespace MDL;
// --------------------------------------------------------------------------------------
@ -436,7 +434,7 @@ protected:
unsigned int iGSFileVersion;
/** Output I/O handler. used to load external lmp files */
IOSystem* pIOHandler;
IOSystem* mIOHandler;
/** Output scene to be filled */
aiScene* pScene;

View File

@ -561,7 +561,8 @@ uint32_t Assimp::ComputeMaterialHash(const aiMaterial* mat, bool includeMatName
// Exclude all properties whose first character is '?' from the hash
// See doc for aiMaterialProperty.
if ((prop = mat->mProperties[i]) && (includeMatName || prop->mKey.data[0] != '?')) {
prop = mat->mProperties[ i ];
if ( nullptr != prop && (includeMatName || prop->mKey.data[0] != '?')) {
hash = SuperFastHash(prop->mKey.data,(unsigned int)prop->mKey.length,hash);
hash = SuperFastHash(prop->mData,prop->mDataLength,hash);

View File

@ -575,8 +575,9 @@ void SplitLargeMeshesProcess_Vertex::SplitMesh(
for (unsigned int k = 0; k < pMesh->mNumBones;++k) {
// check whether the bone is existing
BoneWeightList* pcWeightList;
if ((pcWeightList = (BoneWeightList*)pcMesh->mBones[k])) {
aiBone* pcOldBone = pMesh->mBones[k];
pcWeightList = (BoneWeightList *)pcMesh->mBones[k];
if (nullptr != pcWeightList) {
aiBone *pcOldBone = pMesh->mBones[k];
aiBone* pcOut( nullptr );
*ppCurrent++ = pcOut = new aiBone();
pcOut->mName = aiString(pcOldBone->mName);

View File

@ -125,7 +125,8 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
* type (e.g. if mirroring is active there IS a difference between
* offset 2 and 3)
*/
if ((rounded = (int)info.mTranslation.x)) {
rounded = (int)info.mTranslation.x;
if (rounded) {
float out = 0.0f;
szTemp[0] = 0;
if (aiTextureMapMode_Wrap == info.mapU) {
@ -158,7 +159,8 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
* type (e.g. if mirroring is active there IS a difference between
* offset 2 and 3)
*/
if ((rounded = (int)info.mTranslation.y)) {
rounded = (int)info.mTranslation.y;
if (rounded) {
float out = 0.0f;
szTemp[0] = 0;
if (aiTextureMapMode_Wrap == info.mapV) {