Merge pull request #4253 from assimp/kimkulling_fix_double_prec_build_issue4248
Use correct XmlParser-methods and add some missing castspull/4244/head^2
commit
0491eb3591
|
@ -879,7 +879,7 @@ void X3DImporter::readSphere(XmlNode &node) {
|
|||
X3DNodeElementBase *ne(nullptr);
|
||||
|
||||
MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
|
||||
XmlParser::getFloatAttribute(node, "radius", radius);
|
||||
XmlParser::getRealAttribute(node, "radius", radius);
|
||||
XmlParser::getBoolAttribute(node, "solid", solid);
|
||||
|
||||
// if "USE" defined then find already defined element.
|
||||
|
|
|
@ -1410,7 +1410,7 @@ void glTF2Exporter::ExportMetadata() {
|
|||
}
|
||||
}
|
||||
|
||||
inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<float> ×) {
|
||||
inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<ai_real> ×) {
|
||||
return ExportData(asset, animId, buffer, (unsigned int)times.size(), ×[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,9 @@ class Ref;
|
|||
}
|
||||
|
||||
namespace glTF2 {
|
||||
|
||||
class Asset;
|
||||
|
||||
struct TexProperty;
|
||||
struct TextureInfo;
|
||||
struct NormalTextureInfo;
|
||||
|
@ -84,6 +86,7 @@ struct MaterialIOR;
|
|||
typedef float(vec2)[2];
|
||||
typedef float(vec3)[3];
|
||||
typedef float(vec4)[4];
|
||||
|
||||
} // namespace glTF2
|
||||
|
||||
namespace Assimp {
|
||||
|
|
|
@ -6,7 +6,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2021, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
@ -102,7 +101,7 @@ protected:
|
|||
/** Creates a dummy material and returns it. */
|
||||
aiMaterial *CreateMaterial();
|
||||
|
||||
protected:
|
||||
private:
|
||||
/** space to assemble the mesh data: points */
|
||||
std::vector<aiVector3D> mVertices;
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2021, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
|
|
@ -255,5 +255,4 @@ struct aiLight {
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // !! AI_LIGHT_H_INC
|
||||
|
|
|
@ -44,21 +44,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef AI_MATERIAL_INL_INC
|
||||
#define AI_MATERIAL_INL_INC
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiPropertyTypeInfo ai_real_to_property_type_info(float) {
|
||||
AI_FORCE_INLINE aiPropertyTypeInfo ai_real_to_property_type_info(float) {
|
||||
return aiPTI_Float;
|
||||
}
|
||||
|
||||
AI_FORCE_INLINE
|
||||
aiPropertyTypeInfo ai_real_to_property_type_info(double) {
|
||||
AI_FORCE_INLINE aiPropertyTypeInfo ai_real_to_property_type_info(double) {
|
||||
return aiPTI_Double;
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -66,8 +62,7 @@ aiPropertyTypeInfo ai_real_to_property_type_info(double) {
|
|||
//! @cond never
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::GetTexture( aiTextureType type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::GetTexture( aiTextureType type,
|
||||
unsigned int index,
|
||||
C_STRUCT aiString* path,
|
||||
aiTextureMapping* mapping /*= NULL*/,
|
||||
|
@ -79,15 +74,13 @@ aiReturn aiMaterial::GetTexture( aiTextureType type,
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
unsigned int aiMaterial::GetTextureCount(aiTextureType type) const {
|
||||
AI_FORCE_INLINE unsigned int aiMaterial::GetTextureCount(aiTextureType type) const {
|
||||
return ::aiGetMaterialTextureCount(this,type);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template <typename Type>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx, Type* pOut,
|
||||
unsigned int* pMax) const {
|
||||
unsigned int iNum = pMax ? *pMax : 1;
|
||||
|
@ -105,7 +98,7 @@ aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
|||
return AI_FAILURE;
|
||||
}
|
||||
|
||||
iNum = std::min((size_t)iNum,prop->mDataLength / sizeof(Type));
|
||||
iNum = static_cast<unsigned int>(std::min(static_cast<size_t>(iNum),prop->mDataLength / sizeof(Type)));
|
||||
::memcpy(pOut,prop->mData,iNum * sizeof(Type));
|
||||
if (pMax) {
|
||||
*pMax = iNum;
|
||||
|
@ -116,8 +109,7 @@ aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
template <typename Type>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,Type& pOut) const {
|
||||
const aiMaterialProperty* prop;
|
||||
const aiReturn ret = ::aiGetMaterialProperty(this,pKey,type,idx,
|
||||
|
@ -138,34 +130,29 @@ aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,ai_real* pOut,
|
||||
unsigned int* pMax) const {
|
||||
return ::aiGetMaterialFloatArray(this,pKey,type,idx,pOut,pMax);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,int* pOut,
|
||||
unsigned int* pMax) const {
|
||||
return ::aiGetMaterialIntegerArray(this,pKey,type,idx,pOut,pMax);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,ai_real& pOut) const {
|
||||
return aiGetMaterialFloat(this,pKey,type,idx,&pOut);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,int& pOut) const {
|
||||
return aiGetMaterialInteger(this,pKey,type,idx,&pOut);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
||||
unsigned int idx,aiColor4D& pOut) const {
|
||||
return aiGetMaterialColor(this,pKey,type,idx,&pOut);
|
||||
}
|
||||
|
@ -191,13 +178,9 @@ AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
|||
// ---------------------------------------------------------------------------
|
||||
template<class TYPE>
|
||||
aiReturn aiMaterial::AddProperty (const TYPE* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
unsigned int index)
|
||||
{
|
||||
return AddBinaryProperty((const void*)pInput,
|
||||
pNumValues * sizeof(TYPE),
|
||||
const unsigned int pNumValues, const char* pKey, unsigned int type,
|
||||
unsigned int index) {
|
||||
return AddBinaryProperty((const void*)pInput, pNumValues * sizeof(TYPE),
|
||||
pKey,type,index,aiPTI_Buffer);
|
||||
}
|
||||
|
||||
|
@ -213,8 +196,7 @@ AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const float* pInput,
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const double* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const double* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -225,8 +207,7 @@ aiReturn aiMaterial::AddProperty(const double* pInput,
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -237,8 +218,7 @@ aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -249,8 +229,7 @@ aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -261,8 +240,7 @@ aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -273,8 +251,7 @@ aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty(const int* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const int* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -293,8 +270,7 @@ aiReturn aiMaterial::AddProperty(const int* pInput,
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<float>(const float* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<float>(const float* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -306,8 +282,7 @@ aiReturn aiMaterial::AddProperty<float>(const float* pInput,
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<double>(const double* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<double>(const double* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -319,8 +294,7 @@ aiReturn aiMaterial::AddProperty<double>(const double* pInput,
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -332,8 +306,7 @@ aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -345,8 +318,7 @@ aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -358,8 +330,7 @@ aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -371,8 +342,7 @@ aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<>
|
||||
AI_FORCE_INLINE
|
||||
aiReturn aiMaterial::AddProperty<int>(const int* pInput,
|
||||
AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<int>(const int* pInput,
|
||||
const unsigned int pNumValues,
|
||||
const char* pKey,
|
||||
unsigned int type,
|
||||
|
@ -383,5 +353,3 @@ aiReturn aiMaterial::AddProperty<int>(const int* pInput,
|
|||
}
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif //! AI_MATERIAL_INL_INC
|
||||
|
|
|
@ -92,22 +92,19 @@ struct aiTexel {
|
|||
|
||||
#ifdef __cplusplus
|
||||
//! Comparison operator
|
||||
bool operator== (const aiTexel& other) const
|
||||
{
|
||||
bool operator== (const aiTexel& other) const {
|
||||
return b == other.b && r == other.r &&
|
||||
g == other.g && a == other.a;
|
||||
}
|
||||
|
||||
//! Inverse comparison operator
|
||||
bool operator!= (const aiTexel& other) const
|
||||
{
|
||||
bool operator!= (const aiTexel& other) const {
|
||||
return b != other.b || r != other.r ||
|
||||
g != other.g || a != other.a;
|
||||
}
|
||||
|
||||
//! Conversion to a floating-point 4d color
|
||||
operator aiColor4D() const
|
||||
{
|
||||
operator aiColor4D() const {
|
||||
return aiColor4D(r/255.f,g/255.f,b/255.f,a/255.f);
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
@ -202,11 +199,11 @@ struct aiTexture {
|
|||
}
|
||||
|
||||
// Construction
|
||||
aiTexture() AI_NO_EXCEPT
|
||||
: mWidth(0)
|
||||
, mHeight(0)
|
||||
, pcData(nullptr)
|
||||
, mFilename() {
|
||||
aiTexture() AI_NO_EXCEPT :
|
||||
mWidth(0),
|
||||
mHeight(0),
|
||||
pcData(nullptr),
|
||||
mFilename() {
|
||||
memset(achFormatHint, 0, sizeof(achFormatHint));
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
|||
|
||||
Copyright (c) 2006-2021, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
|
|
|
@ -54,8 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
/** Transformation of a vector by a 3x3 matrix */
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
|
||||
aiVector3t<TReal> res;
|
||||
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z;
|
||||
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z;
|
||||
|
@ -66,8 +65,7 @@ aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
/** Transformation of a vector by a 4x4 matrix */
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
|
||||
aiVector3t<TReal> res;
|
||||
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z + pMatrix.a4;
|
||||
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z + pMatrix.b4;
|
||||
|
@ -82,36 +80,35 @@ aiVector3t<TReal>::operator aiVector3t<TOther> () const {
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) {
|
||||
AI_FORCE_INLINE void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) {
|
||||
x = pX;
|
||||
y = pY;
|
||||
z = pZ;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal aiVector3t<TReal>::SquareLength() const {
|
||||
AI_FORCE_INLINE TReal aiVector3t<TReal>::SquareLength() const {
|
||||
return x*x + y*y + z*z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal aiVector3t<TReal>::Length() const {
|
||||
AI_FORCE_INLINE TReal aiVector3t<TReal>::Length() const {
|
||||
return std::sqrt( SquareLength());
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::Normalize() {
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::Normalize() {
|
||||
const TReal l = Length();
|
||||
if (l == 0) {
|
||||
return *this;
|
||||
}
|
||||
*this /= Length();
|
||||
|
||||
return *this;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
|
||||
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
|
||||
TReal len = Length();
|
||||
if ( len > static_cast< TReal >( 0 ) ) {
|
||||
*this /= len;
|
||||
|
@ -120,8 +117,7 @@ aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) {
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) {
|
||||
x += o.x;
|
||||
y += o.y;
|
||||
z += o.z;
|
||||
|
@ -130,8 +126,7 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) {
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) {
|
||||
x -= o.x;
|
||||
y -= o.y;
|
||||
z -= o.z;
|
||||
|
@ -140,8 +135,7 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
|
||||
x *= f;
|
||||
y *= f;
|
||||
z *= f;
|
||||
|
@ -150,8 +144,7 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
|
||||
if ( f == static_cast<TReal>(0.0)) {
|
||||
return *this;
|
||||
}
|
||||
|
@ -164,20 +157,17 @@ const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){
|
||||
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){
|
||||
return (*this = mat * (*this));
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){
|
||||
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){
|
||||
return (*this = mat * (*this));
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal aiVector3t<TReal>::operator[](unsigned int i) const {
|
||||
AI_FORCE_INLINE TReal aiVector3t<TReal>::operator[](unsigned int i) const {
|
||||
switch (i) {
|
||||
case 0:
|
||||
return x;
|
||||
|
@ -192,9 +182,7 @@ TReal aiVector3t<TReal>::operator[](unsigned int i) const {
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal& aiVector3t<TReal>::operator[](unsigned int i) {
|
||||
// return *(&x + i);
|
||||
AI_FORCE_INLINE TReal& aiVector3t<TReal>::operator[](unsigned int i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
return x;
|
||||
|
@ -209,20 +197,17 @@ TReal& aiVector3t<TReal>::operator[](unsigned int i) {
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const {
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const {
|
||||
return x == other.x && y == other.y && z == other.z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const {
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const {
|
||||
return x != other.x || y != other.y || z != other.z;
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
template<typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const {
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const {
|
||||
return
|
||||
std::abs(x - other.x) <= epsilon &&
|
||||
std::abs(y - other.y) <= epsilon &&
|
||||
|
@ -230,77 +215,66 @@ bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) con
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
|
||||
return x != other.x ? x < other.x : y != other.y ? y < other.y : z < other.z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
|
||||
AI_FORCE_INLINE const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
|
||||
return aiVector3t<TReal>(x*o.x,y*o.y,z*o.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// symmetric addition
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// symmetric subtraction
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar product
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar multiplication
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) {
|
||||
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// and the other way around
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) {
|
||||
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar division
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) {
|
||||
return v * (1/f);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// vector division
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>(v.x / v2.x,v.y / v2.y,v.z / v2.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// cross product
|
||||
template<typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>( v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// vector negation
|
||||
template<typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
|
||||
return aiVector3t<TReal>( -v.x, -v.y, -v.z);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ TEST_F(MaterialSystemTest, testFloatArrayProperty) {
|
|||
pf[0] = pf[1] = pf[2] = pf[3] = 12.0f;
|
||||
|
||||
EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey2", 0, 0, pf, &pMax));
|
||||
EXPECT_EQ(sizeof(pf) / sizeof(float), pMax);
|
||||
EXPECT_EQ(sizeof(pf) / sizeof(float), static_cast<size_t>(pMax));
|
||||
EXPECT_TRUE(!pf[0] && 1.0f == pf[1] && 2.0f == pf[2] && 3.0f == pf[3]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue