Issue-1169: fix clang build.
This commit is contained in:
@@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef AI_COLOR4D_H_INC
|
||||
#define AI_COLOR4D_H_INC
|
||||
|
||||
#include "./Compiler/pushpack1.h"
|
||||
#include "defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -89,7 +88,7 @@ public:
|
||||
|
||||
// Red, green, blue and alpha color values
|
||||
TReal r, g, b, a;
|
||||
} PACK_STRUCT; // !struct aiColor4D
|
||||
}; // !struct aiColor4D
|
||||
|
||||
typedef aiColor4t<ai_real> aiColor4D;
|
||||
|
||||
@@ -97,10 +96,8 @@ typedef aiColor4t<ai_real> aiColor4D;
|
||||
|
||||
struct aiColor4D {
|
||||
ai_real r, g, b, a;
|
||||
} PACK_STRUCT;
|
||||
};
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#include "./Compiler/poppack1.h"
|
||||
|
||||
#endif // AI_COLOR4D_H_INC
|
||||
|
||||
@@ -76,12 +76,34 @@ AI_FORCE_INLINE const aiColor4t<TReal>& aiColor4t<TReal>::operator /= (TReal f)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE TReal aiColor4t<TReal>::operator[](unsigned int i) const {
|
||||
return *(&r + i);
|
||||
//return *(&r + i);
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
return r;
|
||||
case 1:
|
||||
return g;
|
||||
case 2:
|
||||
return b;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE TReal& aiColor4t<TReal>::operator[](unsigned int i) {
|
||||
return *(&r + i);
|
||||
// return *(&r + i);
|
||||
switch ( i ) {
|
||||
case 0:
|
||||
return r;
|
||||
case 1:
|
||||
return g;
|
||||
case 2:
|
||||
return b;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
|
||||
@@ -46,7 +46,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef AI_MATRIX3X3_H_INC
|
||||
#define AI_MATRIX3X3_H_INC
|
||||
|
||||
#include "./Compiler/pushpack1.h"
|
||||
#include "defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -153,7 +152,7 @@ public:
|
||||
/** @brief A function for creating a rotation matrix that rotates a
|
||||
* vector called "from" into another vector called "to".
|
||||
* Input : from[3], to[3] which both must be *normalized* non-zero vectors
|
||||
* Output: mtx[3][3] -- a 3x3 matrix in colum-major form
|
||||
* Output: mtx[3][3] -- a 3x3 matrix in column-major form
|
||||
* Authors: Tomas Möller, John Hughes
|
||||
* "Efficiently Building a Matrix to Rotate One Vector to Another"
|
||||
* Journal of Graphics Tools, 4(4):1-4, 1999
|
||||
@@ -165,7 +164,7 @@ public:
|
||||
TReal a1, a2, a3;
|
||||
TReal b1, b2, b3;
|
||||
TReal c1, c2, c3;
|
||||
} PACK_STRUCT;
|
||||
};
|
||||
|
||||
typedef aiMatrix3x3t<ai_real> aiMatrix3x3;
|
||||
|
||||
@@ -175,10 +174,8 @@ struct aiMatrix3x3 {
|
||||
ai_real a1, a2, a3;
|
||||
ai_real b1, b2, b3;
|
||||
ai_real c1, c2, c3;
|
||||
} PACK_STRUCT;
|
||||
};
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#include "./Compiler/poppack1.h"
|
||||
|
||||
#endif // AI_MATRIX3X3_H_INC
|
||||
|
||||
@@ -101,16 +101,34 @@ inline aiMatrix3x3t<TReal> aiMatrix3x3t<TReal>::operator* (const aiMatrix3x3t<TR
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline TReal* aiMatrix3x3t<TReal>::operator[] (unsigned int p_iIndex)
|
||||
{
|
||||
return &this->a1 + p_iIndex * 3;
|
||||
inline TReal* aiMatrix3x3t<TReal>::operator[] (unsigned int p_iIndex) {
|
||||
switch ( p_iIndex ) {
|
||||
case 0:
|
||||
return &a1;
|
||||
case 1:
|
||||
return &b1;
|
||||
case 2:
|
||||
return &c1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return &a1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline const TReal* aiMatrix3x3t<TReal>::operator[] (unsigned int p_iIndex) const
|
||||
{
|
||||
return &this->a1 + p_iIndex * 3;
|
||||
inline const TReal* aiMatrix3x3t<TReal>::operator[] (unsigned int p_iIndex) const {
|
||||
switch ( p_iIndex ) {
|
||||
case 0:
|
||||
return &a1;
|
||||
case 1:
|
||||
return &b1;
|
||||
case 2:
|
||||
return &c1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return &a1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -46,7 +46,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define AI_MATRIX4X4_H_INC
|
||||
|
||||
#include "vector3.h"
|
||||
#include "./Compiler/pushpack1.h"
|
||||
#include "defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -257,7 +256,7 @@ public:
|
||||
TReal b1, b2, b3, b4;
|
||||
TReal c1, c2, c3, c4;
|
||||
TReal d1, d2, d3, d4;
|
||||
} PACK_STRUCT;
|
||||
};
|
||||
|
||||
typedef aiMatrix4x4t<ai_real> aiMatrix4x4;
|
||||
|
||||
@@ -268,11 +267,9 @@ struct aiMatrix4x4 {
|
||||
ai_real b1, b2, b3, b4;
|
||||
ai_real c1, c2, c3, c4;
|
||||
ai_real d1, d2, d3, d4;
|
||||
} PACK_STRUCT;
|
||||
};
|
||||
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#include "./Compiler/poppack1.h"
|
||||
|
||||
#endif // AI_MATRIX4X4_H_INC
|
||||
|
||||
@@ -243,9 +243,19 @@ inline TReal* aiMatrix4x4t<TReal>::operator[](unsigned int p_iIndex) {
|
||||
if (p_iIndex > 3) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// XXX this is UB. Has been for years. The fact that it works now does not make it better.
|
||||
return &this->a1 + p_iIndex * 4;
|
||||
switch ( p_iIndex ) {
|
||||
case 0:
|
||||
return &a1;
|
||||
case 1:
|
||||
return &b1;
|
||||
case 2:
|
||||
return &c1;
|
||||
case 3:
|
||||
return &d1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return &a1;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@@ -255,8 +265,19 @@ inline const TReal* aiMatrix4x4t<TReal>::operator[](unsigned int p_iIndex) const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// XXX same
|
||||
return &this->a1 + p_iIndex * 4;
|
||||
switch ( p_iIndex ) {
|
||||
case 0:
|
||||
return &a1;
|
||||
case 1:
|
||||
return &b1;
|
||||
case 2:
|
||||
return &c1;
|
||||
case 3:
|
||||
return &d1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return &a1;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user