Commit eb218095 authored by chili's avatar chili
Browse files

update assimp version

parent 1da10a89
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
...@@ -491,7 +492,7 @@ struct aiUVTransform ...@@ -491,7 +492,7 @@ struct aiUVTransform
} }
#endif #endif
} PACK_STRUCT; };
#include "./Compiler/poppack1.h" #include "./Compiler/poppack1.h"
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
...@@ -312,16 +313,16 @@ inline aiMatrix3x3t<TReal>& aiMatrix3x3t<TReal>::FromToMatrix(const aiVector3t<T ...@@ -312,16 +313,16 @@ inline aiMatrix3x3t<TReal>& aiMatrix3x3t<TReal>::FromToMatrix(const aiVector3t<T
u.x = x.x - from.x; u.y = x.y - from.y; u.z = x.z - from.z; u.x = x.x - from.x; u.y = x.y - from.y; u.z = x.z - from.z;
v.x = x.x - to.x; v.y = x.y - to.y; v.z = x.z - to.z; v.x = x.x - to.x; v.y = x.y - to.y; v.z = x.z - to.z;
const TReal c1 = static_cast<TReal>(2.0) / (u * u); const TReal c1_ = static_cast<TReal>(2.0) / (u * u);
const TReal c2 = static_cast<TReal>(2.0) / (v * v); const TReal c2_ = static_cast<TReal>(2.0) / (v * v);
const TReal c3 = c1 * c2 * (u * v); const TReal c3_ = c1_ * c2_ * (u * v);
for (unsigned int i = 0; i < 3; i++) for (unsigned int i = 0; i < 3; i++)
{ {
for (unsigned int j = 0; j < 3; j++) for (unsigned int j = 0; j < 3; j++)
{ {
mtx[i][j] = - c1 * u[i] * u[j] - c2 * v[i] * v[j] mtx[i][j] = - c1_ * u[i] * u[j] - c2_ * v[i] * v[j]
+ c3 * v[i] * u[j]; + c3_ * v[i] * u[j];
} }
mtx[i][i] += static_cast<TReal>(1.0); mtx[i][i] += static_cast<TReal>(1.0);
} }
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
...@@ -423,12 +424,18 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector ...@@ -423,12 +424,18 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector
{ {
ASSIMP_MATRIX4_4_DECOMPOSE_PART; ASSIMP_MATRIX4_4_DECOMPOSE_PART;
/* /*
| CE -CF D 0 | assuming a right-handed coordinate system
M = | BDE+AF -BDF+AE -BC 0 | and post-multiplication of column vectors,
| -ADE+BF -ADF+BE AC 0 | the rotation matrix for an euler XYZ rotation is M = Rz * Ry * Rx.
| 0 0 0 1 | combining gives:
| CE BDE-AF ADE+BF 0 |
M = | CF BDF+AE ADF-BE 0 |
| -D CB AC 0 |
| 0 0 0 1 |
where
A = cos(angle_x), B = sin(angle_x); A = cos(angle_x), B = sin(angle_x);
C = cos(angle_y), D = sin(angle_y); C = cos(angle_y), D = sin(angle_y);
E = cos(angle_z), F = sin(angle_z); E = cos(angle_z), F = sin(angle_z);
...@@ -437,20 +444,20 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector ...@@ -437,20 +444,20 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector
// Use a small epsilon to solve floating-point inaccuracies // Use a small epsilon to solve floating-point inaccuracies
const TReal epsilon = 10e-3f; const TReal epsilon = 10e-3f;
pRotation.y = std::asin(vCols[2].x);// D. Angle around oY. pRotation.y = std::asin(-vCols[0].z);// D. Angle around oY.
TReal C = std::cos(pRotation.y); TReal C = std::cos(pRotation.y);
if(std::fabs(C) > epsilon) if(std::fabs(C) > epsilon)
{ {
// Finding angle around oX. // Finding angle around oX.
TReal tan_x = vCols[2].z / C;// A TReal tan_x = vCols[2].z / C;// A
TReal tan_y = -vCols[2].y / C;// B TReal tan_y = vCols[1].z / C;// B
pRotation.x = std::atan2(tan_y, tan_x); pRotation.x = std::atan2(tan_y, tan_x);
// Finding angle around oZ. // Finding angle around oZ.
tan_x = vCols[0].x / C;// E tan_x = vCols[0].x / C;// E
tan_y = -vCols[1].x / C;// F tan_y = vCols[0].y / C;// F
pRotation.z = std::atan2(tan_y, tan_x); pRotation.z = std::atan2(tan_y, tan_x);
} }
else else
...@@ -458,8 +465,8 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector ...@@ -458,8 +465,8 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector
pRotation.x = 0;// Set angle around oX to 0. => A == 1, B == 0, C == 0, D == 1. pRotation.x = 0;// Set angle around oX to 0. => A == 1, B == 0, C == 0, D == 1.
// And finding angle around oZ. // And finding angle around oZ.
TReal tan_x = vCols[1].y;// -BDF+AE => E TReal tan_x = vCols[1].y;// BDF+AE => E
TReal tan_y = vCols[0].y;// BDE+AF => F TReal tan_y = -vCols[1].x;// BDE-AF => F
pRotation.z = std::atan2(tan_y, tan_x); pRotation.z = std::atan2(tan_y, tan_x);
} }
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
...@@ -199,8 +200,7 @@ struct aiFace ...@@ -199,8 +200,7 @@ struct aiFace
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** @brief A single influence of a bone on a vertex. /** @brief A single influence of a bone on a vertex.
*/ */
struct aiVertexWeight struct aiVertexWeight {
{
//! Index of the vertex which is influenced by the bone. //! Index of the vertex which is influenced by the bone.
unsigned int mVertexId; unsigned int mVertexId;
...@@ -211,14 +211,28 @@ struct aiVertexWeight ...@@ -211,14 +211,28 @@ struct aiVertexWeight
#ifdef __cplusplus #ifdef __cplusplus
//! Default constructor //! Default constructor
aiVertexWeight() { } aiVertexWeight()
: mVertexId(0)
, mWeight(0.0f) {
// empty
}
//! Initialisation from a given index and vertex weight factor //! Initialisation 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), mWeight( pWeight) : mVertexId( pID )
{ /* nothing to do here */ } , mWeight( pWeight ) {
// empty
}
bool operator == ( const aiVertexWeight &rhs ) const {
return ( mVertexId == rhs.mVertexId && mWeight == rhs.mWeight );
}
bool operator != ( const aiVertexWeight &rhs ) const {
return ( *this == rhs );
}
#endif // __cplusplus #endif // __cplusplus
}; };
...@@ -229,31 +243,41 @@ struct aiVertexWeight ...@@ -229,31 +243,41 @@ struct aiVertexWeight
* *
* A bone has a name by which it can be found in the frame hierarchy and by * A bone has a name by which it can be found in the frame hierarchy and by
* which it can be addressed by animations. In addition it has a number of * which it can be addressed by animations. In addition it has a number of
* influences on vertices. * influences on vertices, and a matrix relating the mesh position to the
* position of the bone at the time of binding.
*/ */
struct aiBone struct aiBone {
{
//! The name of the bone. //! The name of the bone.
C_STRUCT aiString mName; C_STRUCT aiString mName;
//! The number of vertices affected by this bone //! The number of vertices affected by this bone.
//! The maximum value for this member is #AI_MAX_BONE_WEIGHTS. //! The maximum value for this member is #AI_MAX_BONE_WEIGHTS.
unsigned int mNumWeights; unsigned int mNumWeights;
//! The vertices affected by this bone //! The influence weights of this bone, by vertex index.
C_STRUCT aiVertexWeight* mWeights; C_STRUCT aiVertexWeight* mWeights;
//! Matrix that transforms from mesh space to bone space in bind pose /** Matrix that transforms from bone space to mesh space in bind pose.
*
* This matrix describes the position of the mesh
* in the local space of this bone when the skeleton was bound.
* Thus it can be used directly to determine a desired vertex position,
* given the world-space transform of the bone when animated,
* and the position of the vertex in mesh space.
*
* It is sometimes called an inverse-bind matrix,
* or inverse bind pose matrix.
*/
C_STRUCT aiMatrix4x4 mOffsetMatrix; C_STRUCT aiMatrix4x4 mOffsetMatrix;
#ifdef __cplusplus #ifdef __cplusplus
//! Default constructor //! Default constructor
aiBone() aiBone()
: mName() : mName()
, mNumWeights( 0 ) , mNumWeights( 0 )
, mWeights( NULL ) , mWeights( nullptr ) {
{ // empty
} }
//! Copy constructor //! Copy constructor
...@@ -269,6 +293,44 @@ struct aiBone ...@@ -269,6 +293,44 @@ struct aiBone
} }
} }
//! Assignment operator
aiBone &operator=(const aiBone& other)
{
if (this == &other) {
return *this;
}
mName = other.mName;
mNumWeights = other.mNumWeights;
mOffsetMatrix = other.mOffsetMatrix;
if (other.mWeights && other.mNumWeights)
{
if (mWeights) {
delete[] mWeights;
}
mWeights = new aiVertexWeight[mNumWeights];
::memcpy(mWeights,other.mWeights,mNumWeights * sizeof(aiVertexWeight));
}
return *this;
}
bool operator == ( const aiBone &rhs ) const {
if ( mName != rhs.mName || mNumWeights != rhs.mNumWeights ) {
return false;
}
for ( size_t i = 0; i < mNumWeights; ++i ) {
if ( mWeights[ i ] != rhs.mWeights[ i ] ) {
return false;
}
}
return true;
}
//! Destructor - deletes the array of vertex weights //! Destructor - deletes the array of vertex weights
~aiBone() ~aiBone()
{ {
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
...@@ -66,6 +67,7 @@ typedef enum aiMetadataType { ...@@ -66,6 +67,7 @@ typedef enum aiMetadataType {
AI_DOUBLE = 4, AI_DOUBLE = 4,
AI_AISTRING = 5, AI_AISTRING = 5,
AI_AIVECTOR3D = 6, AI_AIVECTOR3D = 6,
AI_META_MAX = 7,
#ifndef SWIG #ifndef SWIG
FORCE_32BIT = INT_MAX FORCE_32BIT = INT_MAX
...@@ -129,42 +131,103 @@ struct aiMetadata { ...@@ -129,42 +131,103 @@ struct aiMetadata {
*/ */
aiMetadata() aiMetadata()
: mNumProperties(0) : mNumProperties(0)
, mKeys(NULL) , mKeys(nullptr)
, mValues(NULL) { , mValues(nullptr) {
// empty // empty
} }
aiMetadata( const aiMetadata &rhs )
: mNumProperties( rhs.mNumProperties )
, mKeys( nullptr )
, mValues( nullptr ) {
mKeys = new aiString[ mNumProperties ];
for ( unsigned int i = 0; i < mNumProperties; ++i ) {
mKeys[ i ] = rhs.mKeys[ i ];
}
mValues = new aiMetadataEntry[ mNumProperties ];
for ( unsigned int i = 0; i < mNumProperties; ++i ) {
mValues[ i ].mType = rhs.mValues[ i ].mType;
switch ( rhs.mValues[ i ].mType ) {
case AI_BOOL:
mValues[ i ].mData = new bool( rhs.mValues[i].mData );
break;
case AI_INT32: {
int32_t v;
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( int32_t ) );
mValues[ i ].mData = new int32_t( v );
}
break;
case AI_UINT64: {
uint64_t v;
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( uint64_t ) );
mValues[ i ].mData = new uint64_t( v );
}
break;
case AI_FLOAT: {
float v;
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( float ) );
mValues[ i ].mData = new float( v );
}
break;
case AI_DOUBLE: {
double v;
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( double ) );
mValues[ i ].mData = new double( v );
}
break;
case AI_AISTRING: {
aiString v;
rhs.Get<aiString>( mKeys[ i ], v );
mValues[ i ].mData = new aiString( v );
}
break;
case AI_AIVECTOR3D: {
aiVector3D v;
rhs.Get<aiVector3D>( mKeys[ i ], v );
mValues[ i ].mData = new aiVector3D( v );
}
break;
#ifndef SWIG
case FORCE_32BIT:
#endif
default:
break;
}
}
}
/** /**
* @brief The destructor. * @brief The destructor.
*/ */
~aiMetadata() { ~aiMetadata() {
delete [] mKeys; delete [] mKeys;
mKeys = NULL; mKeys = nullptr;
if (mValues) { if (mValues) {
// Delete each metadata entry // Delete each metadata entry
for (unsigned i=0; i<mNumProperties; ++i) { for (unsigned i=0; i<mNumProperties; ++i) {
void* data = mValues[i].mData; void* data = mValues[i].mData;
switch (mValues[i].mType) { switch (mValues[i].mType) {
case AI_BOOL: case AI_BOOL:
delete static_cast<bool*>(data); delete static_cast< bool* >( data );
break; break;
case AI_INT32: case AI_INT32:
delete static_cast<int32_t*>(data); delete static_cast< int32_t* >( data );
break; break;
case AI_UINT64: case AI_UINT64:
delete static_cast<uint64_t*>(data); delete static_cast< uint64_t* >( data );
break; break;
case AI_FLOAT: case AI_FLOAT:
delete static_cast<float*>(data); delete static_cast< float* >( data );
break; break;
case AI_DOUBLE: case AI_DOUBLE:
delete static_cast<double*>(data); delete static_cast< double* >( data );
break; break;
case AI_AISTRING: case AI_AISTRING:
delete static_cast<aiString*>(data); delete static_cast< aiString* >( data );
break; break;
case AI_AIVECTOR3D: case AI_AIVECTOR3D:
delete static_cast<aiVector3D*>(data); delete static_cast< aiVector3D* >( data );
break; break;
#ifndef SWIG #ifndef SWIG
case FORCE_32BIT: case FORCE_32BIT:
...@@ -176,7 +239,7 @@ struct aiMetadata { ...@@ -176,7 +239,7 @@ struct aiMetadata {
// Delete the metadata array // Delete the metadata array
delete [] mValues; delete [] mValues;
mValues = NULL; mValues = nullptr;
} }
} }
...@@ -207,8 +270,8 @@ struct aiMetadata { ...@@ -207,8 +270,8 @@ struct aiMetadata {
} }
template<typename T> template<typename T>
inline void Add(const std::string& key, const T& value) inline
{ void Add(const std::string& key, const T& value) {
aiString* new_keys = new aiString[mNumProperties + 1]; aiString* new_keys = new aiString[mNumProperties + 1];
aiMetadataEntry* new_values = new aiMetadataEntry[mNumProperties + 1]; aiMetadataEntry* new_values = new aiMetadataEntry[mNumProperties + 1];
...@@ -255,7 +318,7 @@ struct aiMetadata { ...@@ -255,7 +318,7 @@ struct aiMetadata {
template<typename T> template<typename T>
inline inline
bool Get( unsigned index, T& value ) { bool Get( unsigned index, T& value ) const {
// In range assertion // In range assertion
if ( index >= mNumProperties ) { if ( index >= mNumProperties ) {
return false; return false;
...@@ -276,7 +339,7 @@ struct aiMetadata { ...@@ -276,7 +339,7 @@ struct aiMetadata {
template<typename T> template<typename T>
inline inline
bool Get( const aiString& key, T& value ) { bool Get( const aiString& key, T& value ) const {
// Search for the given key // Search for the given key
for ( unsigned int i = 0; i < mNumProperties; ++i ) { for ( unsigned int i = 0; i < mNumProperties; ++i ) {
if ( mKeys[ i ] == key ) { if ( mKeys[ i ] == key ) {
...@@ -287,7 +350,8 @@ struct aiMetadata { ...@@ -287,7 +350,8 @@ struct aiMetadata {
} }
template<typename T> template<typename T>
inline bool Get( const std::string& key, T& value ) { inline
bool Get( const std::string& key, T& value ) const {
return Get(aiString(key), value); return Get(aiString(key), value);
} }
...@@ -296,7 +360,8 @@ struct aiMetadata { ...@@ -296,7 +360,8 @@ struct aiMetadata {
/// \param [out] pKey - pointer to the key value. /// \param [out] pKey - pointer to the key value.
/// \param [out] pEntry - pointer to the entry: type and value. /// \param [out] pEntry - pointer to the entry: type and value.
/// \return false - if pIndex is out of range, else - true. /// \return false - if pIndex is out of range, else - true.
inline bool Get(size_t index, const aiString*& key, const aiMetadataEntry*& entry) { inline
bool Get(size_t index, const aiString*& key, const aiMetadataEntry*& entry) const {
if ( index >= mNumProperties ) { if ( index >= mNumProperties ) {
return false; return false;
} }
......
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file pbrmaterial.h
* @brief Defines the material system of the library
*/
#ifndef AI_PBRMATERIAL_H_INC
#define AI_PBRMATERIAL_H_INC
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR "$mat.gltf.pbrMetallicRoughness.baseColorFactor", 0, 0
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLIC_FACTOR "$mat.gltf.pbrMetallicRoughness.metallicFactor", 0, 0
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_ROUGHNESS_FACTOR "$mat.gltf.pbrMetallicRoughness.roughnessFactor", 0, 0
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_TEXTURE aiTextureType_DIFFUSE, 1
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 0
#define AI_MATKEY_GLTF_ALPHAMODE "$mat.gltf.alphaMode", 0, 0
#define AI_MATKEY_GLTF_ALPHACUTOFF "$mat.gltf.alphaCutoff", 0, 0
#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS "$mat.gltf.pbrSpecularGlossiness", 0, 0
#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR "$mat.gltf.pbrMetallicRoughness.glossinessFactor", 0, 0
#define _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE "$tex.file.texCoord"
#define _AI_MATKEY_GLTF_MAPPINGNAME_BASE "$tex.mappingname"
#define _AI_MATKEY_GLTF_MAPPINGID_BASE "$tex.mappingid"
#define _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE "$tex.mappingfiltermag"
#define _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE "$tex.mappingfiltermin"
#define _AI_MATKEY_GLTF_SCALE_BASE "$tex.scale"
#define _AI_MATKEY_GLTF_STRENGTH_BASE "$tex.strength"
#define AI_MATKEY_GLTF_TEXTURE_TEXCOORD(type, N) _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGNAME(type, N) _AI_MATKEY_GLTF_MAPPINGNAME_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGID(type, N) _AI_MATKEY_GLTF_MAPPINGID_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGFILTER_MAG(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE, type, N
#define AI_MATKEY_GLTF_MAPPINGFILTER_MIN(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE, type, N
#define AI_MATKEY_GLTF_TEXTURE_SCALE(type, N) _AI_MATKEY_GLTF_SCALE_BASE, type, N
#define AI_MATKEY_GLTF_TEXTURE_STRENGTH(type, N) _AI_MATKEY_GLTF_STRENGTH_BASE, type, N
#endif //!!AI_PBRMATERIAL_H_INC
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
/** @file Android implementation of IOSystem using the standard C file functions.
* Aimed to ease the access to android assets */
#if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
#ifndef AI_ANDROIDJNIIOSYSTEM_H_INC
#define AI_ANDROIDJNIIOSYSTEM_H_INC
#include <assimp/DefaultIOSystem.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <android/native_activity.h>
namespace Assimp {
// ---------------------------------------------------------------------------
/** Android extension to DefaultIOSystem using the standard C file functions */
class ASSIMP_API AndroidJNIIOSystem : public DefaultIOSystem
{
public:
/** Initialize android activity data */
std::string mApkWorkspacePath;
AAssetManager* mApkAssetManager;
/** Constructor. */
AndroidJNIIOSystem(ANativeActivity* activity);
/** Destructor. */
~AndroidJNIIOSystem();
// -------------------------------------------------------------------
/** Tests for the existence of a file at the given path. */
bool Exists( const char* pFile) const;
// -------------------------------------------------------------------
/** Opens a file at the given path, with given mode */
IOStream* Open( const char* strFile, const char* strMode);
// ------------------------------------------------------------------------------------------------
// Inits Android extractor
void AndroidActivityInit(ANativeActivity* activity);
// ------------------------------------------------------------------------------------------------
// Extracts android asset
bool AndroidExtractAsset(std::string name);
};
} //!ns Assimp
#endif //AI_ANDROIDJNIIOSYSTEM_H_INC
#endif //__ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
...@@ -360,6 +361,11 @@ enum aiPostProcessSteps ...@@ -360,6 +361,11 @@ enum aiPostProcessSteps
* and line meshes from the scene. * and line meshes from the scene.
* </li> * </li>
* </ul> * </ul>
*
* This step also removes very small triangles with a surface area smaller
* than 10^-6. If you rely on having these small triangles, or notice holes
* in your model, set the property <tt>#AI_CONFIG_PP_FD_CHECKAREA</tt> to
* false.
* @note Degenerate polygons are not necessarily evil and that's why * @note Degenerate polygons are not necessarily evil and that's why
* they're not removed by default. There are several file formats which * they're not removed by default. There are several file formats which
* don't support lines or points, and some exporters bypass the * don't support lines or points, and some exporters bypass the
...@@ -531,11 +537,24 @@ enum aiPostProcessSteps ...@@ -531,11 +537,24 @@ enum aiPostProcessSteps
/** <hr>This step will perform a global scale of the model. /** <hr>This step will perform a global scale of the model.
* *
* Some importers are providing a mechanism to define a scaling unit for the * Some importers are providing a mechanism to define a scaling unit for the
* model. This post processing step can be used to do so. * model. This post processing step can be used to do so. You need to get the
* global scaling from your importer settings like in FBX. Use the flag
* AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY from the global property table to configure this.
* *
* Use <tt>#AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY</tt> to control this. * Use <tt>#AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY</tt> to setup the global scaing factor.
*/ */
aiProcess_GlobalScale = 0x8000000 aiProcess_GlobalScale = 0x8000000,
// -------------------------------------------------------------------------
/** <hr>A postprocessing step to embed of textures.
*
* This will remove external data dependencies for textures.
* If a texture's file does not exist at the specified path
* (due, for instance, to an absolute path generated on another system),
* it will check if a file with the same name exists at the root folder
* of the imported model. And if so, it uses that.
*/
aiProcess_EmbedTextures = 0x10000000,
// aiProcess_GenEntityMeshes = 0x100000, // aiProcess_GenEntityMeshes = 0x100000,
// aiProcess_OptimizeAnimations = 0x200000 // aiProcess_OptimizeAnimations = 0x200000
......
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2018, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file qnan.h
* @brief Some utilities for our dealings with qnans.
*
* @note Some loaders use qnans to mark invalid values tempoarily, also
* Assimp explicitly enforces undefined normals to be set to qnan.
* qnan utilities are available in standard libraries (C99 for example)
* but last time I checked compiler coverage was so bad that I decided
* to reinvent the wheel.
*/
#ifndef AI_QNAN_H_INCLUDED
#define AI_QNAN_H_INCLUDED
#include <assimp/defs.h>
#include <limits>
#include <stdint.h>
// ---------------------------------------------------------------------------
/** Data structure to represent the bit pattern of a 32 Bit
* IEEE 754 floating-point number. */
union _IEEESingle
{
float Float;
struct
{
uint32_t Frac : 23;
uint32_t Exp : 8;
uint32_t Sign : 1;
} IEEE;
};
// ---------------------------------------------------------------------------
/** Data structure to represent the bit pattern of a 64 Bit
* IEEE 754 floating-point number. */
union _IEEEDouble
{
double Double;
struct
{
uint64_t Frac : 52;
uint64_t Exp : 11;
uint64_t Sign : 1;
} IEEE;
};
// ---------------------------------------------------------------------------
/** Check whether a given float is qNaN.
* @param in Input value */
AI_FORCE_INLINE bool is_qnan(float in)
{
// the straightforward solution does not work:
// return (in != in);
// compiler generates code like this
// load <in> to <register-with-different-width>
// compare <register-with-different-width> against <in>
// FIXME: Use <float> stuff instead? I think fpclassify needs C99
return (reinterpret_cast<_IEEESingle*>(&in)->IEEE.Exp == (1u << 8)-1 &&
reinterpret_cast<_IEEESingle*>(&in)->IEEE.Frac);
}
// ---------------------------------------------------------------------------
/** Check whether a given double is qNaN.
* @param in Input value */
AI_FORCE_INLINE bool is_qnan(double in)
{
// the straightforward solution does not work:
// return (in != in);
// compiler generates code like this
// load <in> to <register-with-different-width>
// compare <register-with-different-width> against <in>
// FIXME: Use <float> stuff instead? I think fpclassify needs C99
return (reinterpret_cast<_IEEEDouble*>(&in)->IEEE.Exp == (1u << 11)-1 &&
reinterpret_cast<_IEEEDouble*>(&in)->IEEE.Frac);
}
// ---------------------------------------------------------------------------
/** @brief check whether a float is either NaN or (+/-) INF.
*
* Denorms return false, they're treated like normal values.
* @param in Input value */
AI_FORCE_INLINE bool is_special_float(float in)
{
return (reinterpret_cast<_IEEESingle*>(&in)->IEEE.Exp == (1u << 8)-1);
}
// ---------------------------------------------------------------------------
/** @brief check whether a double is either NaN or (+/-) INF.
*
* Denorms return false, they're treated like normal values.
* @param in Input value */
AI_FORCE_INLINE bool is_special_float(double in)
{
return (reinterpret_cast<_IEEEDouble*>(&in)->IEEE.Exp == (1u << 11)-1);
}
// ---------------------------------------------------------------------------
/** Check whether a float is NOT qNaN.
* @param in Input value */
template<class TReal>
AI_FORCE_INLINE bool is_not_qnan(TReal in)
{
return !is_qnan(in);
}
// ---------------------------------------------------------------------------
/** @brief Get a fresh qnan. */
AI_FORCE_INLINE ai_real get_qnan()
{
return std::numeric_limits<ai_real>::quiet_NaN();
}
#endif // !! AI_QNAN_H_INCLUDED
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
...@@ -326,6 +327,16 @@ struct aiScene ...@@ -326,6 +327,16 @@ struct aiScene
*/ */
C_STRUCT aiCamera** mCameras; C_STRUCT aiCamera** mCameras;
/**
* @brief The global metadata assigned to the scene itself.
*
* This data contains global metadata which belongs to the scene like
* unit-conversions, versions, vendors or other model-specific data. This
* can be used to store format-specific metadata as well.
*/
C_STRUCT aiMetadata* mMetaData;
#ifdef __cplusplus #ifdef __cplusplus
//! Default constructor - set everything to 0/NULL //! Default constructor - set everything to 0/NULL
...@@ -366,6 +377,27 @@ struct aiScene ...@@ -366,6 +377,27 @@ struct aiScene
return mAnimations != NULL && mNumAnimations > 0; return mAnimations != NULL && mNumAnimations > 0;
} }
//! Returns a short filename from a full path
static const char* GetShortFilename(const char* filename) {
const char* lastSlash = strrchr(filename, '/');
if (lastSlash == nullptr) {
lastSlash = strrchr(filename, '\\');
}
const char* shortFilename = lastSlash != nullptr ? lastSlash + 1 : filename;
return shortFilename;
}
//! Returns an embedded texture
const aiTexture* GetEmbeddedTexture(const char* filename) const {
const char* shortFilename = GetShortFilename(filename);
for (unsigned int i = 0; i < mNumTextures; i++) {
const char* shortTextureFilename = GetShortFilename(mTextures[i]->mFilename.C_Str());
if (strcmp(shortTextureFilename, shortFilename) == 0) {
return mTextures[i];
}
}
return nullptr;
}
#endif // __cplusplus #endif // __cplusplus
/** Internal data, do not touch */ /** Internal data, do not touch */
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
...@@ -179,6 +180,12 @@ struct aiTexture ...@@ -179,6 +180,12 @@ struct aiTexture
*/ */
C_STRUCT aiTexel* pcData; C_STRUCT aiTexel* pcData;
/** Texture original filename
*
* Used to get the texture reference
*/
C_STRUCT aiString mFilename;
#ifdef __cplusplus #ifdef __cplusplus
//! For compressed textures (mHeight == 0): compare the //! For compressed textures (mHeight == 0): compare the
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
...@@ -110,8 +111,7 @@ extern "C" { ...@@ -110,8 +111,7 @@ extern "C" {
/** Maximum dimension for strings, ASSIMP strings are zero terminated. */ /** Maximum dimension for strings, ASSIMP strings are zero terminated. */
#ifdef __cplusplus #ifdef __cplusplus
static static const size_t MAXLEN = 1024;
const size_t MAXLEN = 1024;
#else #else
# define MAXLEN 1024 # define MAXLEN 1024
#endif #endif
...@@ -304,6 +304,20 @@ struct aiString ...@@ -304,6 +304,20 @@ struct aiString
data[len] = 0; data[len] = 0;
} }
/** Assigment operator */
aiString& operator = (const aiString &rOther) {
if (this == &rOther) {
return *this;
}
length = rOther.length;;
memcpy( data, rOther.data, length);
data[length] = '\0';
return *this;
}
/** Assign a const char* to the string */ /** Assign a const char* to the string */
aiString& operator = (const char* sz) { aiString& operator = (const char* sz) {
Set(sz); Set(sz);
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
...@@ -85,7 +86,6 @@ public: ...@@ -85,7 +86,6 @@ public:
const aiVector2t& operator /= (TReal f); const aiVector2t& operator /= (TReal f);
TReal operator[](unsigned int i) const; TReal operator[](unsigned int i) const;
TReal& operator[](unsigned int i);
bool operator== (const aiVector2t& other) const; bool operator== (const aiVector2t& other) const;
bool operator!= (const aiVector2t& other) const; bool operator!= (const aiVector2t& other) const;
...@@ -99,7 +99,7 @@ public: ...@@ -99,7 +99,7 @@ public:
operator aiVector2t<TOther> () const; operator aiVector2t<TOther> () const;
TReal x, y; TReal x, y;
} PACK_STRUCT; };
typedef aiVector2t<ai_real> aiVector2D; typedef aiVector2t<ai_real> aiVector2D;
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
...@@ -60,24 +61,28 @@ aiVector2t<TReal>::operator aiVector2t<TOther> () const { ...@@ -60,24 +61,28 @@ aiVector2t<TReal>::operator aiVector2t<TOther> () const {
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
void aiVector2t<TReal>::Set( TReal pX, TReal pY) { void aiVector2t<TReal>::Set( TReal pX, TReal pY) {
x = pX; y = pY; x = pX; y = pY;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
TReal aiVector2t<TReal>::SquareLength() const { TReal aiVector2t<TReal>::SquareLength() const {
return x*x + y*y; return x*x + y*y;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
TReal aiVector2t<TReal>::Length() const { TReal aiVector2t<TReal>::Length() const {
return std::sqrt( SquareLength()); return std::sqrt( SquareLength());
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
aiVector2t<TReal>& aiVector2t<TReal>::Normalize() { aiVector2t<TReal>& aiVector2t<TReal>::Normalize() {
*this /= Length(); *this /= Length();
return *this; return *this;
...@@ -85,6 +90,7 @@ aiVector2t<TReal>& aiVector2t<TReal>::Normalize() { ...@@ -85,6 +90,7 @@ aiVector2t<TReal>& aiVector2t<TReal>::Normalize() {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
const aiVector2t<TReal>& aiVector2t<TReal>::operator += (const aiVector2t& o) { const aiVector2t<TReal>& aiVector2t<TReal>::operator += (const aiVector2t& o) {
x += o.x; y += o.y; x += o.x; y += o.y;
return *this; return *this;
...@@ -92,6 +98,7 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator += (const aiVector2t& o) { ...@@ -92,6 +98,7 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator += (const aiVector2t& o) {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
const aiVector2t<TReal>& aiVector2t<TReal>::operator -= (const aiVector2t& o) { const aiVector2t<TReal>& aiVector2t<TReal>::operator -= (const aiVector2t& o) {
x -= o.x; y -= o.y; x -= o.x; y -= o.y;
return *this; return *this;
...@@ -99,6 +106,7 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator -= (const aiVector2t& o) { ...@@ -99,6 +106,7 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator -= (const aiVector2t& o) {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
const aiVector2t<TReal>& aiVector2t<TReal>::operator *= (TReal f) { const aiVector2t<TReal>& aiVector2t<TReal>::operator *= (TReal f) {
x *= f; y *= f; x *= f; y *= f;
return *this; return *this;
...@@ -106,6 +114,7 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator *= (TReal f) { ...@@ -106,6 +114,7 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator *= (TReal f) {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
const aiVector2t<TReal>& aiVector2t<TReal>::operator /= (TReal f) { const aiVector2t<TReal>& aiVector2t<TReal>::operator /= (TReal f) {
x /= f; y /= f; x /= f; y /= f;
return *this; return *this;
...@@ -113,30 +122,37 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator /= (TReal f) { ...@@ -113,30 +122,37 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator /= (TReal f) {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
TReal aiVector2t<TReal>::operator[](unsigned int i) const { TReal aiVector2t<TReal>::operator[](unsigned int i) const {
return *(&x + i); switch (i) {
} case 0:
return x;
case 1:
return y;
default:
break;
// ------------------------------------------------------------------------------------------------ }
template <typename TReal> return x;
TReal& aiVector2t<TReal>::operator[](unsigned int i) {
return *(&x + i);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
bool aiVector2t<TReal>::operator== (const aiVector2t& other) const { bool aiVector2t<TReal>::operator== (const aiVector2t& other) const {
return x == other.x && y == other.y; return x == other.x && y == other.y;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
bool aiVector2t<TReal>::operator!= (const aiVector2t& other) const { bool aiVector2t<TReal>::operator!= (const aiVector2t& other) const {
return x != other.x || y != other.y; return x != other.x || y != other.y;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
template<typename TReal> template<typename TReal>
inline
bool aiVector2t<TReal>::Equal(const aiVector2t& other, TReal epsilon) const { bool aiVector2t<TReal>::Equal(const aiVector2t& other, TReal epsilon) const {
return return
std::abs(x - other.x) <= epsilon && std::abs(x - other.x) <= epsilon &&
...@@ -145,6 +161,7 @@ bool aiVector2t<TReal>::Equal(const aiVector2t& other, TReal epsilon) const { ...@@ -145,6 +161,7 @@ bool aiVector2t<TReal>::Equal(const aiVector2t& other, TReal epsilon) const {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
aiVector2t<TReal>& aiVector2t<TReal>::operator= (TReal f) { aiVector2t<TReal>& aiVector2t<TReal>::operator= (TReal f) {
x = y = f; x = y = f;
return *this; return *this;
...@@ -152,6 +169,7 @@ aiVector2t<TReal>& aiVector2t<TReal>::operator= (TReal f) { ...@@ -152,6 +169,7 @@ aiVector2t<TReal>& aiVector2t<TReal>::operator= (TReal f) {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template <typename TReal> template <typename TReal>
inline
const aiVector2t<TReal> aiVector2t<TReal>::SymMul(const aiVector2t& o) { const aiVector2t<TReal> aiVector2t<TReal>::SymMul(const aiVector2t& o) {
return aiVector2t(x*o.x,y*o.y); return aiVector2t(x*o.x,y*o.y);
} }
...@@ -160,65 +178,64 @@ const aiVector2t<TReal> aiVector2t<TReal>::SymMul(const aiVector2t& o) { ...@@ -160,65 +178,64 @@ const aiVector2t<TReal> aiVector2t<TReal>::SymMul(const aiVector2t& o) {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// symmetric addition // symmetric addition
template <typename TReal> template <typename TReal>
inline aiVector2t<TReal> operator + (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2) inline
{ aiVector2t<TReal> operator + (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2) {
return aiVector2t<TReal>( v1.x + v2.x, v1.y + v2.y); return aiVector2t<TReal>( v1.x + v2.x, v1.y + v2.y);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// symmetric subtraction // symmetric subtraction
template <typename TReal> template <typename TReal>
inline aiVector2t<TReal> operator - (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2) inline
{ aiVector2t<TReal> operator - (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2) {
return aiVector2t<TReal>( v1.x - v2.x, v1.y - v2.y); return aiVector2t<TReal>( v1.x - v2.x, v1.y - v2.y);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// scalar product // scalar product
template <typename TReal> template <typename TReal>
inline TReal operator * (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2) inline
{ TReal operator * (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2) {
return v1.x*v2.x + v1.y*v2.y; return v1.x*v2.x + v1.y*v2.y;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// scalar multiplication // scalar multiplication
template <typename TReal> template <typename TReal>
inline aiVector2t<TReal> operator * ( TReal f, const aiVector2t<TReal>& v) inline
{ aiVector2t<TReal> operator * ( TReal f, const aiVector2t<TReal>& v) {
return aiVector2t<TReal>( f*v.x, f*v.y); return aiVector2t<TReal>( f*v.x, f*v.y);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// and the other way around // and the other way around
template <typename TReal> template <typename TReal>
inline aiVector2t<TReal> operator * ( const aiVector2t<TReal>& v, TReal f) inline
{ aiVector2t<TReal> operator * ( const aiVector2t<TReal>& v, TReal f) {
return aiVector2t<TReal>( f*v.x, f*v.y); return aiVector2t<TReal>( f*v.x, f*v.y);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// scalar division // scalar division
template <typename TReal> template <typename TReal>
inline aiVector2t<TReal> operator / ( const aiVector2t<TReal>& v, TReal f) inline
{ aiVector2t<TReal> operator / ( const aiVector2t<TReal>& v, TReal f) {
return v * (1/f); return v * (1/f);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// vector division // vector division
template <typename TReal> template <typename TReal>
inline aiVector2t<TReal> operator / ( const aiVector2t<TReal>& v, const aiVector2t<TReal>& v2) inline
{ aiVector2t<TReal> operator / ( const aiVector2t<TReal>& v, const aiVector2t<TReal>& v2) {
return aiVector2t<TReal>(v.x / v2.x,v.y / v2.y); return aiVector2t<TReal>(v.x / v2.x,v.y / v2.y);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// vector negation // vector negation
template <typename TReal> template <typename TReal>
inline aiVector2t<TReal> operator - ( const aiVector2t<TReal>& v) inline
{ aiVector2t<TReal> operator - ( const aiVector2t<TReal>& v) {
return aiVector2t<TReal>( -v.x, -v.y); return aiVector2t<TReal>( -v.x, -v.y);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment