ry to fix 2013-specific warnings in mesh.h

pull/3012/head
kimkulling 2020-03-19 15:10:46 +01:00
parent 4d917c97bd
commit 4de4c34fb2
4 changed files with 303 additions and 331 deletions

View File

@ -70,8 +70,8 @@ IncludeCategories:
- Regex: '^<.*' - Regex: '^<.*'
Priority: 3 Priority: 3
# IncludeIsMainRegex: '(Test)?$' # IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: true IndentCaseLabels: false
IndentPPDirectives: AfterHash #IndentPPDirectives: AfterHash
IndentWidth: 4 IndentWidth: 4
# IndentWrappedFunctionNames: false # IndentWrappedFunctionNames: false
# JavaScriptQuotes: Leave # JavaScriptQuotes: Leave

View File

@ -149,13 +149,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define ASSIMP_API_WINONLY #define ASSIMP_API_WINONLY
#endif #endif
#elif defined(SWIG) #elif defined(SWIG)
/* Do nothing, the relevant defines are all in AssimpSwigPort.i */ /* Do nothing, the relevant defines are all in AssimpSwigPort.i */
#else #else
#define ASSIMP_API __attribute__((visibility("default"))) #define ASSIMP_API __attribute__((visibility("default")))
#define ASSIMP_API_WINONLY #define ASSIMP_API_WINONLY
#endif #endif // _WIN32
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable : 4521 4512 4714 4127 4351 4510) #pragma warning(disable : 4521 4512 4714 4127 4351 4510)
@ -226,7 +224,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#error Currently, Borland is unsupported. Feel free to port Assimp. #error Currently, Borland is unsupported. Feel free to port Assimp.
#endif #endif
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/* Define ASSIMP_BUILD_SINGLETHREADED to compile assimp /* Define ASSIMP_BUILD_SINGLETHREADED to compile assimp
* without threading support. The library doesn't utilize * without threading support. The library doesn't utilize
@ -298,7 +295,6 @@ static const ai_real ai_epsilon = (ai_real) 0.00001;
#define AI_BUILD_BIG_ENDIAN #define AI_BUILD_BIG_ENDIAN
#endif #endif
/** /**
* To avoid running out of memory * To avoid running out of memory
* This can be adjusted for specific use cases * This can be adjusted for specific use cases

View File

@ -52,8 +52,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma GCC system_header #pragma GCC system_header
#endif #endif
#include <assimp/types.h> #ifdef _WIN32
#pragma warning(disable : 4351)
#endif // _WIN32
#include <assimp/aabb.h> #include <assimp/aabb.h>
#include <assimp/types.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -129,8 +133,7 @@ extern "C" {
* @note Take a look at the @link data Data Structures page @endlink for * @note Take a look at the @link data Data Structures page @endlink for
* more information on the layout and winding order of a face. * more information on the layout and winding order of a face.
*/ */
struct aiFace struct aiFace {
{
//! Number of indices defining this face. //! Number of indices defining this face.
//! The maximum value for this member is #AI_MAX_FACE_INDICES. //! The maximum value for this member is #AI_MAX_FACE_INDICES.
unsigned int mNumIndices; unsigned int mNumIndices;
@ -142,21 +145,19 @@ struct aiFace
//! Default constructor //! Default constructor
aiFace() AI_NO_EXCEPT aiFace() AI_NO_EXCEPT
: mNumIndices( 0 ) : mNumIndices(0),
, mIndices( nullptr ) { mIndices(nullptr) {
// empty // empty
} }
//! Default destructor. Delete the index array //! Default destructor. Delete the index array
~aiFace() ~aiFace() {
{
delete[] mIndices; delete[] mIndices;
} }
//! Copy constructor. Copy the index array //! Copy constructor. Copy the index array
aiFace( const aiFace& o) aiFace(const aiFace &o) :
: mNumIndices(0) mNumIndices(0), mIndices(nullptr) {
, mIndices( nullptr ) {
*this = o; *this = o;
} }
@ -210,7 +211,6 @@ struct aiFace
#endif // __cplusplus #endif // __cplusplus
}; // struct aiFace }; // struct aiFace
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** @brief A single influence of a bone on a vertex. /** @brief A single influence of a bone on a vertex.
*/ */
@ -226,17 +226,16 @@ struct aiVertexWeight {
//! Default constructor //! Default constructor
aiVertexWeight() AI_NO_EXCEPT aiVertexWeight() AI_NO_EXCEPT
: mVertexId(0) : mVertexId(0),
, mWeight(0.0f) { mWeight(0.0f) {
// empty // empty
} }
//! Initialization from a given index and vertex weight factor //! Initialization from a given index and vertex weight factor
//! \param pID ID //! \param pID ID
//! \param pWeight Vertex weight factor //! \param pWeight Vertex weight factor
aiVertexWeight( unsigned int pID, float pWeight ) aiVertexWeight(unsigned int pID, float pWeight) :
: mVertexId( pID ) mVertexId(pID), mWeight(pWeight) {
, mWeight( pWeight ) {
// empty // empty
} }
@ -251,7 +250,6 @@ struct aiVertexWeight {
#endif // __cplusplus #endif // __cplusplus
}; };
// Forward declare aiNode (pointer use only) // Forward declare aiNode (pointer use only)
struct aiNode; struct aiNode;
@ -301,26 +299,22 @@ struct aiBone {
//! Default constructor //! Default constructor
aiBone() AI_NO_EXCEPT aiBone() AI_NO_EXCEPT
: mName() : mName(),
, mNumWeights( 0 ) mNumWeights(0),
, mWeights( nullptr ) mWeights(nullptr),
, mOffsetMatrix() { mOffsetMatrix() {
// empty // empty
} }
//! Copy constructor //! Copy constructor
aiBone(const aiBone& other) aiBone(const aiBone &other) :
: mName( other.mName ) mName(other.mName), mNumWeights(other.mNumWeights), mWeights(nullptr), mOffsetMatrix(other.mOffsetMatrix) {
, mNumWeights( other.mNumWeights )
, mWeights(nullptr)
, mOffsetMatrix( other.mOffsetMatrix ) {
if (other.mWeights && other.mNumWeights) { if (other.mWeights && other.mNumWeights) {
mWeights = new aiVertexWeight[mNumWeights]; mWeights = new aiVertexWeight[mNumWeights];
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight)); ::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
} }
} }
//! Assignment operator //! Assignment operator
aiBone &operator=(const aiBone &other) { aiBone &operator=(const aiBone &other) {
if (this == &other) { if (this == &other) {
@ -331,8 +325,7 @@ struct aiBone {
mNumWeights = other.mNumWeights; mNumWeights = other.mNumWeights;
mOffsetMatrix = other.mOffsetMatrix; mOffsetMatrix = other.mOffsetMatrix;
if (other.mWeights && other.mNumWeights) if (other.mWeights && other.mNumWeights) {
{
if (mWeights) { if (mWeights) {
delete[] mWeights; delete[] mWeights;
} }
@ -364,7 +357,6 @@ struct aiBone {
#endif // __cplusplus #endif // __cplusplus
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** @brief Enumerates the types of geometric primitives supported by Assimp. /** @brief Enumerates the types of geometric primitives supported by Assimp.
* *
@ -373,8 +365,7 @@ struct aiBone {
* @see aiProcess_Triangulate Automatic triangulation * @see aiProcess_Triangulate Automatic triangulation
* @see AI_CONFIG_PP_SBP_REMOVE Removal of specific primitive types. * @see AI_CONFIG_PP_SBP_REMOVE Removal of specific primitive types.
*/ */
enum aiPrimitiveType enum aiPrimitiveType {
{
/** A point primitive. /** A point primitive.
* *
* This is just a single vertex in the virtual world, * This is just a single vertex in the virtual world,
@ -404,7 +395,6 @@ enum aiPrimitiveType
*/ */
aiPrimitiveType_POLYGON = 0x8, aiPrimitiveType_POLYGON = 0x8,
/** This value is not used. It is just here to force the /** This value is not used. It is just here to force the
* compiler to map this enum to a 32 Bit integer. * compiler to map this enum to a 32 Bit integer.
*/ */
@ -417,8 +407,6 @@ enum aiPrimitiveType
#define AI_PRIMITIVE_TYPE_FOR_N_INDICES(n) \ #define AI_PRIMITIVE_TYPE_FOR_N_INDICES(n) \
((n) > 3 ? aiPrimitiveType_POLYGON : (aiPrimitiveType)(1u << ((n)-1))) ((n) > 3 ? aiPrimitiveType_POLYGON : (aiPrimitiveType)(1u << ((n)-1)))
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** @brief An AnimMesh is an attachment to an #aiMesh stores per-vertex /** @brief An AnimMesh is an attachment to an #aiMesh stores per-vertex
* animations for a particular frame. * animations for a particular frame.
@ -430,8 +418,7 @@ enum aiPrimitiveType
* established by #aiMeshAnim, which references singular mesh attachments * established by #aiMeshAnim, which references singular mesh attachments
* by their ID and binds them to a time offset. * by their ID and binds them to a time offset.
*/ */
struct aiAnimMesh struct aiAnimMesh {
{
/**Anim Mesh name */ /**Anim Mesh name */
C_STRUCT aiString mName; C_STRUCT aiString mName;
@ -476,15 +463,14 @@ struct aiAnimMesh
#ifdef __cplusplus #ifdef __cplusplus
aiAnimMesh() AI_NO_EXCEPT aiAnimMesh() AI_NO_EXCEPT
: mVertices( nullptr ) : mVertices(nullptr),
, mNormals(nullptr) mNormals(nullptr),
, mTangents(nullptr) mTangents(nullptr),
, mBitangents(nullptr) mBitangents(nullptr),
, mColors() mColors(),
, mTextureCoords() mTextureCoords(),
, mNumVertices( 0 ) mNumVertices(0),
, mWeight( 0.0f ) mWeight(0.0f) {
{
// fixme consider moving this to the ctor initializer list as well // fixme consider moving this to the ctor initializer list as well
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) { for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
mTextureCoords[a] = nullptr; mTextureCoords[a] = nullptr;
@ -494,8 +480,7 @@ struct aiAnimMesh
} }
} }
~aiAnimMesh() ~aiAnimMesh() {
{
delete[] mVertices; delete[] mVertices;
delete[] mNormals; delete[] mNormals;
delete[] mTangents; delete[] mTangents;
@ -547,8 +532,7 @@ struct aiAnimMesh
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** @brief Enumerates the methods of mesh morphing supported by Assimp. /** @brief Enumerates the methods of mesh morphing supported by Assimp.
*/ */
enum aiMorphingMethod enum aiMorphingMethod {
{
/** Interpolation between morph targets */ /** Interpolation between morph targets */
aiMorphingMethod_VERTEX_BLEND = 0x1, aiMorphingMethod_VERTEX_BLEND = 0x1,
@ -585,8 +569,7 @@ enum aiMorphingMethod
* aiScene::mFlags * aiScene::mFlags
* @endcode * @endcode
*/ */
struct aiMesh struct aiMesh {
{
/** Bitwise combination of the members of the #aiPrimitiveType enum. /** Bitwise combination of the members of the #aiPrimitiveType enum.
* This specifies which types of primitives are present in the mesh. * This specifies which types of primitives are present in the mesh.
* The "SortByPrimitiveType"-Step can be used to make sure the * The "SortByPrimitiveType"-Step can be used to make sure the
@ -718,7 +701,6 @@ struct aiMesh
**/ **/
C_STRUCT aiString mName; C_STRUCT aiString mName;
/** The number of attachment meshes. Note! Currently only works with Collada loader. */ /** The number of attachment meshes. Note! Currently only works with Collada loader. */
unsigned int mNumAnimMeshes; unsigned int mNumAnimMeshes;
@ -742,24 +724,24 @@ struct aiMesh
//! Default constructor. Initializes all members to 0 //! Default constructor. Initializes all members to 0
aiMesh() AI_NO_EXCEPT aiMesh() AI_NO_EXCEPT
: mPrimitiveTypes( 0 ) : mPrimitiveTypes(0),
, mNumVertices( 0 ) mNumVertices(0),
, mNumFaces( 0 ) mNumFaces(0),
, mVertices( nullptr ) mVertices(nullptr),
, mNormals(nullptr) mNormals(nullptr),
, mTangents(nullptr) mTangents(nullptr),
, mBitangents(nullptr) mBitangents(nullptr),
, mColors() mColors(),
, mTextureCoords() mTextureCoords(),
, mNumUVComponents() mNumUVComponents(),
, mFaces(nullptr) mFaces(nullptr),
, mNumBones( 0 ) mNumBones(0),
, mBones(nullptr) mBones(nullptr),
, mMaterialIndex( 0 ) mMaterialIndex(0),
, mNumAnimMeshes( 0 ) mNumAnimMeshes(0),
, mAnimMeshes(nullptr) mAnimMeshes(nullptr),
, mMethod( 0 ) mMethod(0),
, mAABB() { mAABB() {
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) { for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
mNumUVComponents[a] = 0; mNumUVComponents[a] = 0;
mTextureCoords[a] = nullptr; mTextureCoords[a] = nullptr;
@ -786,8 +768,7 @@ struct aiMesh
// DO NOT REMOVE THIS ADDITIONAL CHECK // DO NOT REMOVE THIS ADDITIONAL CHECK
if (mNumBones && mBones) { if (mNumBones && mBones) {
for (unsigned int a = 0; a < mNumBones; a++) { for (unsigned int a = 0; a < mNumBones; a++) {
if(mBones[a]) if (mBones[a]) {
{
delete mBones[a]; delete mBones[a];
} }
} }
@ -806,24 +787,20 @@ struct aiMesh
//! Check whether the mesh contains positions. Provided no special //! Check whether the mesh contains positions. Provided no special
//! scene flags are set, this will always be true //! scene flags are set, this will always be true
bool HasPositions() const bool HasPositions() const { return mVertices != nullptr && mNumVertices > 0; }
{ return mVertices != nullptr && mNumVertices > 0; }
//! Check whether the mesh contains faces. If no special scene flags //! Check whether the mesh contains faces. If no special scene flags
//! are set this should always return true //! are set this should always return true
bool HasFaces() const bool HasFaces() const { return mFaces != nullptr && mNumFaces > 0; }
{ return mFaces != nullptr && mNumFaces > 0; }
//! Check whether the mesh contains normal vectors //! Check whether the mesh contains normal vectors
bool HasNormals() const bool HasNormals() const { return mNormals != nullptr && mNumVertices > 0; }
{ return mNormals != nullptr && mNumVertices > 0; }
//! Check whether the mesh contains tangent and bitangent vectors //! Check whether the mesh contains tangent and bitangent vectors
//! It is not possible that it contains tangents and no bitangents //! It is not possible that it contains tangents and no bitangents
//! (or the other way round). The existence of one of them //! (or the other way round). The existence of one of them
//! implies that the second is there, too. //! implies that the second is there, too.
bool HasTangentsAndBitangents() const bool HasTangentsAndBitangents() const { return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0; }
{ return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0; }
//! Check whether the mesh contains a vertex color set //! Check whether the mesh contains a vertex color set
//! \param pIndex Index of the vertex color set //! \param pIndex Index of the vertex color set
@ -876,4 +853,3 @@ struct aiMesh
} }
#endif //! extern "C" #endif //! extern "C"
#endif // AI_MESH_H_INC #endif // AI_MESH_H_INC