New upstream version 5.1.4~ds0
IOhannes m zmölnig (Debian/GNU)
2 years ago
55 | 55 | add_definitions(-DASSIMP_USE_HUNTER) |
56 | 56 | ENDIF() |
57 | 57 | |
58 | PROJECT(Assimp VERSION 5.1.3) | |
58 | PROJECT(Assimp VERSION 5.1.4) | |
59 | 59 | |
60 | 60 | # All supported options ############################################### |
61 | 61 | |
182 | 182 | SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources" ) |
183 | 183 | if(NOT ASSIMP_HUNTER_ENABLED) |
184 | 184 | # Enable C++11 support globally |
185 | set_property( GLOBAL PROPERTY CXX_STANDARD 11 ) | |
185 | set(CMAKE_CXX_STANDARD 11) | |
186 | set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
187 | set(CMAKE_C_STANDARD 99) | |
186 | 188 | endif() |
187 | 189 | |
188 | 190 | IF(NOT ASSIMP_IGNORE_GIT_HASH) |
761 | 763 | |
762 | 764 | IF(MSVC_TOOLSET_VERSION) |
763 | 765 | SET(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}") |
764 | SET(ASSIMP_MSVC_VERSION ${MCVS_PREFIX}) | |
766 | SET(ASSIMP_MSVC_VERSION ${MSVC_PREFIX}) | |
765 | 767 | ELSE() |
766 | 768 | IF(MSVC12) |
767 | 769 | SET(ASSIMP_MSVC_VERSION "vc120") |
377 | 377 | const DXF::Block& bl_src = *(*it).second; |
378 | 378 | |
379 | 379 | for (std::shared_ptr<const DXF::PolyLine> pl_in : bl_src.lines) { |
380 | if (!pl_in) { | |
381 | ASSIMP_LOG_ERROR("DXF: PolyLine instance is nullptr, skipping."); | |
382 | continue; | |
383 | } | |
384 | ||
380 | 385 | std::shared_ptr<DXF::PolyLine> pl_out = std::shared_ptr<DXF::PolyLine>(new DXF::PolyLine(*pl_in)); |
381 | 386 | |
382 | 387 | if (bl_src.base.Length() || insert.scale.x!=1.f || insert.scale.y!=1.f || insert.scale.z!=1.f || insert.angle || insert.pos.Length()) { |
78 | 78 | |
79 | 79 | #define MAGIC_NODE_TAG "_$AssimpFbx$" |
80 | 80 | |
81 | #define CONVERT_FBX_TIME(time) (static_cast<double>(time) * 1000.0 / 46186158000LL) | |
81 | #define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000LL | |
82 | 82 | |
83 | 83 | FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBones) : |
84 | 84 | defaultMaterialIndex(), |
2617 | 2617 | meshMorphAnim->mKeys[j].mNumValuesAndWeights = numValuesAndWeights; |
2618 | 2618 | meshMorphAnim->mKeys[j].mValues = new unsigned int[numValuesAndWeights]; |
2619 | 2619 | meshMorphAnim->mKeys[j].mWeights = new double[numValuesAndWeights]; |
2620 | meshMorphAnim->mKeys[j].mTime = CONVERT_FBX_TIME(animIt.first); | |
2620 | meshMorphAnim->mKeys[j].mTime = CONVERT_FBX_TIME(animIt.first) * anim_fps; | |
2621 | 2621 | for (unsigned int k = 0; k < numValuesAndWeights; k++) { |
2622 | 2622 | meshMorphAnim->mKeys[j].mValues[k] = keyData->values.at(k); |
2623 | 2623 | meshMorphAnim->mKeys[j].mWeights[k] = keyData->weights.at(k); |
2635 | 2635 | return; |
2636 | 2636 | } |
2637 | 2637 | |
2638 | double start_time_fps = has_local_startstop ? CONVERT_FBX_TIME(start_time) : min_time; | |
2639 | double stop_time_fps = has_local_startstop ? CONVERT_FBX_TIME(stop_time) : max_time; | |
2638 | double start_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(start_time) * anim_fps) : min_time; | |
2639 | double stop_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(stop_time) * anim_fps) : max_time; | |
2640 | 2640 | |
2641 | 2641 | // adjust relative timing for animation |
2642 | 2642 | for (unsigned int c = 0; c < anim->mNumChannels; c++) { |
3161 | 3161 | InterpolateKeys(outTranslations, keytimes, keyframeLists[TransformationComp_Translation], defTranslate, maxTime, minTime); |
3162 | 3162 | } else { |
3163 | 3163 | for (size_t i = 0; i < keyCount; ++i) { |
3164 | outTranslations[i].mTime = CONVERT_FBX_TIME(keytimes[i]); | |
3164 | outTranslations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps; | |
3165 | 3165 | outTranslations[i].mValue = defTranslate; |
3166 | 3166 | } |
3167 | 3167 | } |
3170 | 3170 | InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], defRotation, maxTime, minTime, rotOrder); |
3171 | 3171 | } else { |
3172 | 3172 | for (size_t i = 0; i < keyCount; ++i) { |
3173 | outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]); | |
3173 | outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps; | |
3174 | 3174 | outRotations[i].mValue = defQuat; |
3175 | 3175 | } |
3176 | 3176 | } |
3179 | 3179 | InterpolateKeys(outScales, keytimes, keyframeLists[TransformationComp_Scaling], defScale, maxTime, minTime); |
3180 | 3180 | } else { |
3181 | 3181 | for (size_t i = 0; i < keyCount; ++i) { |
3182 | outScales[i].mTime = CONVERT_FBX_TIME(keytimes[i]); | |
3182 | outScales[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps; | |
3183 | 3183 | outScales[i].mValue = defScale; |
3184 | 3184 | } |
3185 | 3185 | } |
3441 | 3441 | } |
3442 | 3442 | |
3443 | 3443 | // magic value to convert fbx times to seconds |
3444 | valOut->mTime = CONVERT_FBX_TIME(time); | |
3444 | valOut->mTime = CONVERT_FBX_TIME(time) * anim_fps; | |
3445 | 3445 | |
3446 | 3446 | min_time = std::min(min_time, valOut->mTime); |
3447 | 3447 | max_time = std::max(max_time, valOut->mTime); |
472 | 472 | |
473 | 473 | // ------------------------------------------------------------------------------------------------ |
474 | 474 | // Generate proepr texture coords |
475 | void HMPImporter::GenerateTextureCoords( | |
476 | const unsigned int width, const unsigned int height) { | |
475 | void HMPImporter::GenerateTextureCoords(const unsigned int width, const unsigned int height) { | |
477 | 476 | ai_assert(nullptr != pScene->mMeshes); |
478 | 477 | ai_assert(nullptr != pScene->mMeshes[0]); |
479 | 478 | ai_assert(nullptr != pScene->mMeshes[0]->mTextureCoords[0]); |
480 | 479 | |
481 | 480 | aiVector3D *uv = pScene->mMeshes[0]->mTextureCoords[0]; |
482 | ||
483 | const float fY = (1.0f / height) + (1.0f / height) / (height - 1); | |
484 | const float fX = (1.0f / width) + (1.0f / width) / (width - 1); | |
481 | if (uv == nullptr) { | |
482 | return; | |
483 | } | |
484 | ||
485 | if (height == 0.0f || width == 0.0) { | |
486 | return; | |
487 | } | |
488 | ||
489 | const float fY = (1.0f / height) + (1.0f / height) / height; | |
490 | const float fX = (1.0f / width) + (1.0f / width) / width; | |
485 | 491 | |
486 | 492 | for (unsigned int y = 0; y < height; ++y) { |
487 | 493 | for (unsigned int x = 0; x < width; ++x, ++uv) { |
392 | 392 | |
393 | 393 | // If a RGB color map is explicitly requested delete the |
394 | 394 | // alpha channel - it could theoretically be != 1. |
395 | if (_mSurfaces[i].mVCMapType == AI_LWO_RGB) | |
395 | if (_mSurfaces[j].mVCMapType == AI_LWO_RGB) | |
396 | 396 | pvVC[w]->a = 1.f; |
397 | 397 | |
398 | 398 | pvVC[w]++; |
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
482 | } // namespace Assimp | |
483 | ||
482 | 484 | #endif // !ASSIMP_BUILD_NO_X3D_IMPORTER |
483 | ||
484 | } // namespace Assimp |
878 | 878 | X3DNodeElementBase *ne(nullptr); |
879 | 879 | |
880 | 880 | MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use); |
881 | XmlParser::getFloatAttribute(node, "radius", radius); | |
881 | XmlParser::getRealAttribute(node, "radius", radius); | |
882 | 882 | XmlParser::getBoolAttribute(node, "solid", solid); |
883 | 883 | |
884 | 884 | // if "USE" defined then find already defined element. |
1409 | 1409 | } |
1410 | 1410 | } |
1411 | 1411 | |
1412 | inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<float> ×) { | |
1412 | inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<ai_real> ×) { | |
1413 | 1413 | return ExportData(asset, animId, buffer, (unsigned int)times.size(), ×[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT); |
1414 | 1414 | } |
1415 | 1415 |
65 | 65 | } |
66 | 66 | |
67 | 67 | namespace glTF2 { |
68 | ||
68 | 69 | class Asset; |
70 | ||
69 | 71 | struct TexProperty; |
70 | 72 | struct TextureInfo; |
71 | 73 | struct NormalTextureInfo; |
83 | 85 | typedef float(vec2)[2]; |
84 | 86 | typedef float(vec3)[3]; |
85 | 87 | typedef float(vec4)[4]; |
88 | ||
86 | 89 | } // namespace glTF2 |
87 | 90 | |
88 | 91 | namespace Assimp { |
1171 | 1171 | ENDIF() |
1172 | 1172 | |
1173 | 1173 | # adds C_FLAGS required to compile zip.c on old GCC 4.x compiler |
1174 | TARGET_COMPILE_FEATURES(assimp PUBLIC c_std_99) | |
1174 | TARGET_COMPILE_FEATURES(assimp PRIVATE c_std_99) | |
1175 | 1175 | |
1176 | 1176 | TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC |
1177 | 1177 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> |
2 | 2 | ---------------------------------------------------------------------- |
3 | 3 | |
4 | 4 | Copyright (c) 2006-2021, assimp team |
5 | ||
6 | 5 | |
7 | 6 | All rights reserved. |
8 | 7 | |
41 | 40 | |
42 | 41 | /** @file PolyTools.h, various utilities for our dealings with arbitrary polygons */ |
43 | 42 | |
43 | #pragma once | |
44 | 44 | #ifndef AI_POLYTOOLS_H_INCLUDED |
45 | 45 | #define AI_POLYTOOLS_H_INCLUDED |
46 | 46 | |
54 | 54 | * The function accepts an unconstrained template parameter for use with |
55 | 55 | * both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/ |
56 | 56 | template <typename T> |
57 | inline double GetArea2D(const T& v1, const T& v2, const T& v3) | |
58 | { | |
57 | inline double GetArea2D(const T& v1, const T& v2, const T& v3) { | |
59 | 58 | return 0.5 * (v1.x * ((double)v3.y - v2.y) + v2.x * ((double)v1.y - v3.y) + v3.x * ((double)v2.y - v1.y)); |
60 | 59 | } |
61 | 60 | |
64 | 63 | * The function accepts an unconstrained template parameter for use with |
65 | 64 | * both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/ |
66 | 65 | template <typename T> |
67 | inline bool OnLeftSideOfLine2D(const T& p0, const T& p1,const T& p2) | |
68 | { | |
66 | inline bool OnLeftSideOfLine2D(const T& p0, const T& p1,const T& p2) { | |
69 | 67 | return GetArea2D(p0,p2,p1) > 0; |
70 | 68 | } |
71 | 69 | |
74 | 72 | * The function accepts an unconstrained template parameter for use with |
75 | 73 | * both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/ |
76 | 74 | template <typename T> |
77 | inline bool PointInTriangle2D(const T& p0, const T& p1,const T& p2, const T& pp) | |
78 | { | |
75 | inline bool PointInTriangle2D(const T& p0, const T& p1,const T& p2, const T& pp) { | |
79 | 76 | // Point in triangle test using baryzentric coordinates |
80 | 77 | const aiVector2D v0 = p1 - p0; |
81 | 78 | const aiVector2D v1 = p2 - p0; |
82 | 79 | const aiVector2D v2 = pp - p0; |
83 | 80 | |
84 | 81 | double dot00 = v0 * v0; |
85 | double dot01 = v0 * v1; | |
86 | double dot02 = v0 * v2; | |
87 | 82 | double dot11 = v1 * v1; |
88 | double dot12 = v1 * v2; | |
89 | ||
90 | const double invDenom = 1 / (dot00 * dot11 - dot01 * dot01); | |
83 | const double dot01 = v0 * v1; | |
84 | const double dot02 = v0 * v2; | |
85 | const double dot12 = v1 * v2; | |
86 | const double denom = dot00 * dot11 - dot01 * dot01; | |
87 | if (denom == 0.0) { | |
88 | return false; | |
89 | } | |
90 | ||
91 | const double invDenom = 1.0 / denom; | |
91 | 92 | dot11 = (dot11 * dot02 - dot01 * dot12) * invDenom; |
92 | 93 | dot00 = (dot00 * dot12 - dot01 * dot02) * invDenom; |
93 | 94 | |
132 | 133 | // in[i+2].x, in[i+2].y)) { |
133 | 134 | convex_turn = AI_MATH_PI_F - theta; |
134 | 135 | convex_sum += convex_turn; |
135 | } | |
136 | else { | |
136 | } else { | |
137 | 137 | convex_sum -= AI_MATH_PI_F - theta; |
138 | 138 | } |
139 | 139 | } |
160 | 160 | if (OnLeftSideOfLine2D(in[npoints-2],in[1],in[0])) { |
161 | 161 | convex_turn = AI_MATH_PI_F - theta; |
162 | 162 | convex_sum += convex_turn; |
163 | } | |
164 | else { | |
163 | } else { | |
165 | 164 | convex_sum -= AI_MATH_PI_F - theta; |
166 | 165 | } |
167 | 166 | |
168 | 167 | return convex_sum >= (2 * AI_MATH_PI_F); |
169 | 168 | } |
170 | ||
171 | 169 | |
172 | 170 | // ------------------------------------------------------------------------------- |
173 | 171 | /** Compute the normal of an arbitrary polygon in R3. |
185 | 183 | * this method is much faster than the 'other' NewellNormal() |
186 | 184 | */ |
187 | 185 | template <int ofs_x, int ofs_y, int ofs_z, typename TReal> |
188 | inline void NewellNormal (aiVector3t<TReal>& out, int num, TReal* x, TReal* y, TReal* z) | |
189 | { | |
186 | inline void NewellNormal (aiVector3t<TReal>& out, int num, TReal* x, TReal* y, TReal* z) { | |
190 | 187 | // Duplicate the first two vertices at the end |
191 | 188 | x[(num+0)*ofs_x] = x[0]; |
192 | 189 | x[(num+1)*ofs_x] = x[ofs_x]; |
223 | 220 | out = aiVector3t<TReal>(sum_yz,sum_zx,sum_xy); |
224 | 221 | } |
225 | 222 | |
226 | } // ! Assimp | |
227 | ||
228 | #endif | |
223 | } // ! namespace Assimp | |
224 | ||
225 | #endif // AI_POLYTOOLS_H_INCLUDED |
1100 | 1100 | |
1101 | 1101 | // make a deep copy of all blend shapes |
1102 | 1102 | CopyPtrArray(dest->mAnimMeshes, dest->mAnimMeshes, dest->mNumAnimMeshes); |
1103 | ||
1104 | // make a deep copy of all texture coordinate names | |
1105 | if (src->mTextureCoordsNames != nullptr) { | |
1106 | dest->mTextureCoordsNames = new aiString *[AI_MAX_NUMBER_OF_TEXTURECOORDS] {}; | |
1107 | for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) { | |
1108 | Copy(&dest->mTextureCoordsNames[i], src->mTextureCoordsNames[i]); | |
1109 | } | |
1110 | } | |
1103 | 1111 | } |
1104 | 1112 | |
1105 | 1113 | // ------------------------------------------------------------------------------------------------ |
1347 | 1355 | } |
1348 | 1356 | } |
1349 | 1357 | |
1358 | // ------------------------------------------------------------------------------------------------ | |
1359 | void SceneCombiner::Copy(aiString **_dest, const aiString *src) { | |
1360 | if (nullptr == _dest || nullptr == src) { | |
1361 | return; | |
1362 | } | |
1363 | ||
1364 | aiString *dest = *_dest = new aiString(); | |
1365 | ||
1366 | // get a flat copy | |
1367 | *dest = *src; | |
1368 | } | |
1369 | ||
1350 | 1370 | #if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0) |
1351 | 1371 | #pragma GCC diagnostic pop |
1352 | 1372 | #endif |
49 | 49 | #include <assimp/ParsingUtils.h> |
50 | 50 | #include "ProcessHelper.h" |
51 | 51 | #include "Material/MaterialSystem.h" |
52 | #include <assimp/Exceptional.h> | |
52 | 53 | #include <stdio.h> |
53 | 54 | |
54 | 55 | using namespace Assimp; |
170 | 171 | } |
171 | 172 | // If the new material count differs from the original, |
172 | 173 | // we need to rebuild the material list and remap mesh material indexes. |
174 | if(iNewNum < 1) | |
175 | throw DeadlyImportError("No materials remaining"); | |
173 | 176 | if (iNewNum != pScene->mNumMaterials) { |
174 | 177 | ai_assert(iNewNum > 0); |
175 | 178 | aiMaterial** ppcMaterials = new aiMaterial*[iNewNum]; |
360 | 360 | static void Copy(aiNodeAnim **dest, const aiNodeAnim *src); |
361 | 361 | static void Copy(aiMeshMorphAnim **dest, const aiMeshMorphAnim *src); |
362 | 362 | static void Copy(aiMetadata **dest, const aiMetadata *src); |
363 | static void Copy(aiString **dest, const aiString *src); | |
363 | 364 | |
364 | 365 | // recursive, of course |
365 | 366 | static void Copy(aiNode **dest, const aiNode *src); |
4 | 4 | ---------------------------------------------------------------------- |
5 | 5 | |
6 | 6 | Copyright (c) 2006-2021, assimp team |
7 | ||
8 | 7 | |
9 | 8 | All rights reserved. |
10 | 9 | |
101 | 100 | /** Creates a dummy material and returns it. */ |
102 | 101 | aiMaterial *CreateMaterial(); |
103 | 102 | |
104 | protected: | |
103 | private: | |
105 | 104 | /** space to assemble the mesh data: points */ |
106 | 105 | std::vector<aiVector3D> mVertices; |
107 | 106 |
3 | 3 | --------------------------------------------------------------------------- |
4 | 4 | |
5 | 5 | Copyright (c) 2006-2021, assimp team |
6 | ||
7 | ||
8 | 6 | |
9 | 7 | All rights reserved. |
10 | 8 |
43 | 43 | */ |
44 | 44 | |
45 | 45 | #pragma once |
46 | #ifndef AI_MATERIAL_INL_INC | |
47 | #define AI_MATERIAL_INL_INC | |
48 | 46 | |
49 | 47 | #ifdef __GNUC__ |
50 | 48 | # pragma GCC system_header |
51 | 49 | #endif |
52 | 50 | |
53 | 51 | // --------------------------------------------------------------------------- |
54 | AI_FORCE_INLINE | |
55 | aiPropertyTypeInfo ai_real_to_property_type_info(float) { | |
52 | AI_FORCE_INLINE aiPropertyTypeInfo ai_real_to_property_type_info(float) { | |
56 | 53 | return aiPTI_Float; |
57 | 54 | } |
58 | 55 | |
59 | AI_FORCE_INLINE | |
60 | aiPropertyTypeInfo ai_real_to_property_type_info(double) { | |
56 | AI_FORCE_INLINE aiPropertyTypeInfo ai_real_to_property_type_info(double) { | |
61 | 57 | return aiPTI_Double; |
62 | 58 | } |
63 | 59 | // --------------------------------------------------------------------------- |
65 | 61 | //! @cond never |
66 | 62 | |
67 | 63 | // --------------------------------------------------------------------------- |
68 | AI_FORCE_INLINE | |
69 | aiReturn aiMaterial::GetTexture( aiTextureType type, | |
64 | AI_FORCE_INLINE aiReturn aiMaterial::GetTexture( aiTextureType type, | |
70 | 65 | unsigned int index, |
71 | 66 | C_STRUCT aiString* path, |
72 | 67 | aiTextureMapping* mapping /*= NULL*/, |
78 | 73 | } |
79 | 74 | |
80 | 75 | // --------------------------------------------------------------------------- |
81 | AI_FORCE_INLINE | |
82 | unsigned int aiMaterial::GetTextureCount(aiTextureType type) const { | |
76 | AI_FORCE_INLINE unsigned int aiMaterial::GetTextureCount(aiTextureType type) const { | |
83 | 77 | return ::aiGetMaterialTextureCount(this,type); |
84 | 78 | } |
85 | 79 | |
86 | 80 | // --------------------------------------------------------------------------- |
87 | 81 | template <typename Type> |
88 | AI_FORCE_INLINE | |
89 | aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
82 | AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
90 | 83 | unsigned int idx, Type* pOut, |
91 | 84 | unsigned int* pMax) const { |
92 | 85 | unsigned int iNum = pMax ? *pMax : 1; |
104 | 97 | return AI_FAILURE; |
105 | 98 | } |
106 | 99 | |
107 | iNum = std::min((size_t)iNum,prop->mDataLength / sizeof(Type)); | |
100 | iNum = static_cast<unsigned int>(std::min(static_cast<size_t>(iNum),prop->mDataLength / sizeof(Type))); | |
108 | 101 | ::memcpy(pOut,prop->mData,iNum * sizeof(Type)); |
109 | 102 | if (pMax) { |
110 | 103 | *pMax = iNum; |
115 | 108 | |
116 | 109 | // --------------------------------------------------------------------------- |
117 | 110 | template <typename Type> |
118 | AI_FORCE_INLINE | |
119 | aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
111 | AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
120 | 112 | unsigned int idx,Type& pOut) const { |
121 | 113 | const aiMaterialProperty* prop; |
122 | 114 | const aiReturn ret = ::aiGetMaterialProperty(this,pKey,type,idx, |
137 | 129 | } |
138 | 130 | |
139 | 131 | // --------------------------------------------------------------------------- |
140 | AI_FORCE_INLINE | |
141 | aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
132 | AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
142 | 133 | unsigned int idx,ai_real* pOut, |
143 | 134 | unsigned int* pMax) const { |
144 | 135 | return ::aiGetMaterialFloatArray(this,pKey,type,idx,pOut,pMax); |
145 | 136 | } |
146 | 137 | // --------------------------------------------------------------------------- |
147 | AI_FORCE_INLINE | |
148 | aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
138 | AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
149 | 139 | unsigned int idx,int* pOut, |
150 | 140 | unsigned int* pMax) const { |
151 | 141 | return ::aiGetMaterialIntegerArray(this,pKey,type,idx,pOut,pMax); |
152 | 142 | } |
153 | 143 | // --------------------------------------------------------------------------- |
154 | AI_FORCE_INLINE | |
155 | aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
144 | AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
156 | 145 | unsigned int idx,ai_real& pOut) const { |
157 | 146 | return aiGetMaterialFloat(this,pKey,type,idx,&pOut); |
158 | 147 | } |
159 | 148 | // --------------------------------------------------------------------------- |
160 | AI_FORCE_INLINE | |
161 | aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
149 | AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
162 | 150 | unsigned int idx,int& pOut) const { |
163 | 151 | return aiGetMaterialInteger(this,pKey,type,idx,&pOut); |
164 | 152 | } |
165 | 153 | // --------------------------------------------------------------------------- |
166 | AI_FORCE_INLINE | |
167 | aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
154 | AI_FORCE_INLINE aiReturn aiMaterial::Get(const char* pKey,unsigned int type, | |
168 | 155 | unsigned int idx,aiColor4D& pOut) const { |
169 | 156 | return aiGetMaterialColor(this,pKey,type,idx,&pOut); |
170 | 157 | } |
189 | 176 | |
190 | 177 | // --------------------------------------------------------------------------- |
191 | 178 | template<class TYPE> |
192 | aiReturn aiMaterial::AddProperty (const TYPE* pInput, | |
193 | const unsigned int pNumValues, | |
194 | const char* pKey, | |
195 | unsigned int type, | |
196 | unsigned int index) | |
197 | { | |
198 | return AddBinaryProperty((const void*)pInput, | |
199 | pNumValues * sizeof(TYPE), | |
179 | aiReturn aiMaterial::AddProperty (const TYPE* pInput, | |
180 | const unsigned int pNumValues, const char* pKey, unsigned int type, | |
181 | unsigned int index) { | |
182 | return AddBinaryProperty((const void*)pInput, pNumValues * sizeof(TYPE), | |
200 | 183 | pKey,type,index,aiPTI_Buffer); |
201 | 184 | } |
202 | 185 | |
212 | 195 | } |
213 | 196 | |
214 | 197 | // --------------------------------------------------------------------------- |
215 | AI_FORCE_INLINE | |
216 | aiReturn aiMaterial::AddProperty(const double* pInput, | |
198 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const double* pInput, | |
217 | 199 | const unsigned int pNumValues, |
218 | 200 | const char* pKey, |
219 | 201 | unsigned int type, |
224 | 206 | } |
225 | 207 | |
226 | 208 | // --------------------------------------------------------------------------- |
227 | AI_FORCE_INLINE | |
228 | aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput, | |
209 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput, | |
229 | 210 | const unsigned int pNumValues, |
230 | 211 | const char* pKey, |
231 | 212 | unsigned int type, |
236 | 217 | } |
237 | 218 | |
238 | 219 | // --------------------------------------------------------------------------- |
239 | AI_FORCE_INLINE | |
240 | aiReturn aiMaterial::AddProperty(const aiColor4D* pInput, | |
220 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor4D* pInput, | |
241 | 221 | const unsigned int pNumValues, |
242 | 222 | const char* pKey, |
243 | 223 | unsigned int type, |
248 | 228 | } |
249 | 229 | |
250 | 230 | // --------------------------------------------------------------------------- |
251 | AI_FORCE_INLINE | |
252 | aiReturn aiMaterial::AddProperty(const aiColor3D* pInput, | |
231 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor3D* pInput, | |
253 | 232 | const unsigned int pNumValues, |
254 | 233 | const char* pKey, |
255 | 234 | unsigned int type, |
260 | 239 | } |
261 | 240 | |
262 | 241 | // --------------------------------------------------------------------------- |
263 | AI_FORCE_INLINE | |
264 | aiReturn aiMaterial::AddProperty(const aiVector3D* pInput, | |
242 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiVector3D* pInput, | |
265 | 243 | const unsigned int pNumValues, |
266 | 244 | const char* pKey, |
267 | 245 | unsigned int type, |
272 | 250 | } |
273 | 251 | |
274 | 252 | // --------------------------------------------------------------------------- |
275 | AI_FORCE_INLINE | |
276 | aiReturn aiMaterial::AddProperty(const int* pInput, | |
253 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const int* pInput, | |
277 | 254 | const unsigned int pNumValues, |
278 | 255 | const char* pKey, |
279 | 256 | unsigned int type, |
292 | 269 | |
293 | 270 | // --------------------------------------------------------------------------- |
294 | 271 | template<> |
295 | AI_FORCE_INLINE | |
296 | aiReturn aiMaterial::AddProperty<float>(const float* pInput, | |
272 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<float>(const float* pInput, | |
297 | 273 | const unsigned int pNumValues, |
298 | 274 | const char* pKey, |
299 | 275 | unsigned int type, |
305 | 281 | |
306 | 282 | // --------------------------------------------------------------------------- |
307 | 283 | template<> |
308 | AI_FORCE_INLINE | |
309 | aiReturn aiMaterial::AddProperty<double>(const double* pInput, | |
284 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<double>(const double* pInput, | |
310 | 285 | const unsigned int pNumValues, |
311 | 286 | const char* pKey, |
312 | 287 | unsigned int type, |
318 | 293 | |
319 | 294 | // --------------------------------------------------------------------------- |
320 | 295 | template<> |
321 | AI_FORCE_INLINE | |
322 | aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput, | |
296 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput, | |
323 | 297 | const unsigned int pNumValues, |
324 | 298 | const char* pKey, |
325 | 299 | unsigned int type, |
331 | 305 | |
332 | 306 | // --------------------------------------------------------------------------- |
333 | 307 | template<> |
334 | AI_FORCE_INLINE | |
335 | aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput, | |
308 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput, | |
336 | 309 | const unsigned int pNumValues, |
337 | 310 | const char* pKey, |
338 | 311 | unsigned int type, |
344 | 317 | |
345 | 318 | // --------------------------------------------------------------------------- |
346 | 319 | template<> |
347 | AI_FORCE_INLINE | |
348 | aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput, | |
320 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput, | |
349 | 321 | const unsigned int pNumValues, |
350 | 322 | const char* pKey, |
351 | 323 | unsigned int type, |
357 | 329 | |
358 | 330 | // --------------------------------------------------------------------------- |
359 | 331 | template<> |
360 | AI_FORCE_INLINE | |
361 | aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput, | |
332 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput, | |
362 | 333 | const unsigned int pNumValues, |
363 | 334 | const char* pKey, |
364 | 335 | unsigned int type, |
370 | 341 | |
371 | 342 | // --------------------------------------------------------------------------- |
372 | 343 | template<> |
373 | AI_FORCE_INLINE | |
374 | aiReturn aiMaterial::AddProperty<int>(const int* pInput, | |
344 | AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<int>(const int* pInput, | |
375 | 345 | const unsigned int pNumValues, |
376 | 346 | const char* pKey, |
377 | 347 | unsigned int type, |
382 | 352 | } |
383 | 353 | |
384 | 354 | //! @endcond |
385 | ||
386 | #endif //! AI_MATERIAL_INL_INC |
91 | 91 | |
92 | 92 | #ifdef __cplusplus |
93 | 93 | //! Comparison operator |
94 | bool operator== (const aiTexel& other) const | |
95 | { | |
94 | bool operator== (const aiTexel& other) const { | |
96 | 95 | return b == other.b && r == other.r && |
97 | 96 | g == other.g && a == other.a; |
98 | 97 | } |
99 | 98 | |
100 | 99 | //! Inverse comparison operator |
101 | bool operator!= (const aiTexel& other) const | |
102 | { | |
100 | bool operator!= (const aiTexel& other) const { | |
103 | 101 | return b != other.b || r != other.r || |
104 | 102 | g != other.g || a != other.a; |
105 | 103 | } |
106 | 104 | |
107 | 105 | //! Conversion to a floating-point 4d color |
108 | operator aiColor4D() const | |
109 | { | |
106 | operator aiColor4D() const { | |
110 | 107 | return aiColor4D(r/255.f,g/255.f,b/255.f,a/255.f); |
111 | 108 | } |
112 | 109 | #endif // __cplusplus |
201 | 198 | } |
202 | 199 | |
203 | 200 | // Construction |
204 | aiTexture() AI_NO_EXCEPT | |
205 | : mWidth(0) | |
206 | , mHeight(0) | |
207 | , pcData(nullptr) | |
208 | , mFilename() { | |
201 | aiTexture() AI_NO_EXCEPT : | |
202 | mWidth(0), | |
203 | mHeight(0), | |
204 | pcData(nullptr), | |
205 | mFilename() { | |
209 | 206 | memset(achFormatHint, 0, sizeof(achFormatHint)); |
210 | 207 | } |
211 | 208 |
3 | 3 | --------------------------------------------------------------------------- |
4 | 4 | |
5 | 5 | Copyright (c) 2006-2021, assimp team |
6 | ||
7 | ||
8 | 6 | |
9 | 7 | All rights reserved. |
10 | 8 |
53 | 53 | // ------------------------------------------------------------------------------------------------ |
54 | 54 | /** Transformation of a vector by a 3x3 matrix */ |
55 | 55 | template <typename TReal> |
56 | AI_FORCE_INLINE | |
57 | aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) { | |
56 | AI_FORCE_INLINE aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) { | |
58 | 57 | aiVector3t<TReal> res; |
59 | 58 | res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z; |
60 | 59 | res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z; |
65 | 64 | // ------------------------------------------------------------------------------------------------ |
66 | 65 | /** Transformation of a vector by a 4x4 matrix */ |
67 | 66 | template <typename TReal> |
68 | AI_FORCE_INLINE | |
69 | aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) { | |
67 | AI_FORCE_INLINE aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) { | |
70 | 68 | aiVector3t<TReal> res; |
71 | 69 | res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z + pMatrix.a4; |
72 | 70 | res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z + pMatrix.b4; |
81 | 79 | } |
82 | 80 | // ------------------------------------------------------------------------------------------------ |
83 | 81 | template <typename TReal> |
84 | AI_FORCE_INLINE | |
85 | void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) { | |
82 | AI_FORCE_INLINE void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) { | |
86 | 83 | x = pX; |
87 | 84 | y = pY; |
88 | 85 | z = pZ; |
89 | 86 | } |
90 | 87 | // ------------------------------------------------------------------------------------------------ |
91 | 88 | template <typename TReal> |
92 | AI_FORCE_INLINE | |
93 | TReal aiVector3t<TReal>::SquareLength() const { | |
89 | AI_FORCE_INLINE TReal aiVector3t<TReal>::SquareLength() const { | |
94 | 90 | return x*x + y*y + z*z; |
95 | 91 | } |
96 | 92 | // ------------------------------------------------------------------------------------------------ |
97 | 93 | template <typename TReal> |
98 | AI_FORCE_INLINE | |
99 | TReal aiVector3t<TReal>::Length() const { | |
94 | AI_FORCE_INLINE TReal aiVector3t<TReal>::Length() const { | |
100 | 95 | return std::sqrt( SquareLength()); |
101 | 96 | } |
102 | 97 | // ------------------------------------------------------------------------------------------------ |
103 | 98 | template <typename TReal> |
104 | AI_FORCE_INLINE | |
105 | aiVector3t<TReal>& aiVector3t<TReal>::Normalize() { | |
99 | aiVector3t<TReal>& aiVector3t<TReal>::Normalize() { | |
100 | const TReal l = Length(); | |
101 | if (l == 0) { | |
102 | return *this; | |
103 | } | |
106 | 104 | *this /= Length(); |
107 | 105 | |
108 | 106 | return *this; |
109 | 107 | } |
110 | 108 | // ------------------------------------------------------------------------------------------------ |
111 | 109 | template <typename TReal> |
112 | AI_FORCE_INLINE | |
113 | aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() { | |
110 | AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() { | |
114 | 111 | TReal len = Length(); |
115 | 112 | if ( len > static_cast< TReal >( 0 ) ) { |
116 | 113 | *this /= len; |
119 | 116 | } |
120 | 117 | // ------------------------------------------------------------------------------------------------ |
121 | 118 | template <typename TReal> |
122 | AI_FORCE_INLINE | |
123 | const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) { | |
119 | AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) { | |
124 | 120 | x += o.x; |
125 | 121 | y += o.y; |
126 | 122 | z += o.z; |
129 | 125 | } |
130 | 126 | // ------------------------------------------------------------------------------------------------ |
131 | 127 | template <typename TReal> |
132 | AI_FORCE_INLINE | |
133 | const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) { | |
128 | AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) { | |
134 | 129 | x -= o.x; |
135 | 130 | y -= o.y; |
136 | 131 | z -= o.z; |
139 | 134 | } |
140 | 135 | // ------------------------------------------------------------------------------------------------ |
141 | 136 | template <typename TReal> |
142 | AI_FORCE_INLINE | |
143 | const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) { | |
137 | AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) { | |
144 | 138 | x *= f; |
145 | 139 | y *= f; |
146 | 140 | z *= f; |
149 | 143 | } |
150 | 144 | // ------------------------------------------------------------------------------------------------ |
151 | 145 | template <typename TReal> |
152 | AI_FORCE_INLINE | |
153 | const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) { | |
146 | AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) { | |
154 | 147 | if ( f == static_cast<TReal>(0.0)) { |
155 | 148 | return *this; |
156 | 149 | } |
163 | 156 | } |
164 | 157 | // ------------------------------------------------------------------------------------------------ |
165 | 158 | template <typename TReal> |
166 | AI_FORCE_INLINE | |
167 | aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){ | |
159 | AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){ | |
168 | 160 | return (*this = mat * (*this)); |
169 | 161 | } |
170 | 162 | // ------------------------------------------------------------------------------------------------ |
171 | 163 | template <typename TReal> |
172 | AI_FORCE_INLINE | |
173 | aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){ | |
164 | AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){ | |
174 | 165 | return (*this = mat * (*this)); |
175 | 166 | } |
176 | 167 | // ------------------------------------------------------------------------------------------------ |
177 | 168 | template <typename TReal> |
178 | AI_FORCE_INLINE | |
179 | TReal aiVector3t<TReal>::operator[](unsigned int i) const { | |
169 | AI_FORCE_INLINE TReal aiVector3t<TReal>::operator[](unsigned int i) const { | |
180 | 170 | switch (i) { |
181 | 171 | case 0: |
182 | 172 | return x; |
191 | 181 | } |
192 | 182 | // ------------------------------------------------------------------------------------------------ |
193 | 183 | template <typename TReal> |
194 | AI_FORCE_INLINE | |
195 | TReal& aiVector3t<TReal>::operator[](unsigned int i) { | |
196 | // return *(&x + i); | |
184 | AI_FORCE_INLINE TReal& aiVector3t<TReal>::operator[](unsigned int i) { | |
197 | 185 | switch (i) { |
198 | 186 | case 0: |
199 | 187 | return x; |
208 | 196 | } |
209 | 197 | // ------------------------------------------------------------------------------------------------ |
210 | 198 | template <typename TReal> |
211 | AI_FORCE_INLINE | |
212 | bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const { | |
199 | AI_FORCE_INLINE bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const { | |
213 | 200 | return x == other.x && y == other.y && z == other.z; |
214 | 201 | } |
215 | 202 | // ------------------------------------------------------------------------------------------------ |
216 | 203 | template <typename TReal> |
217 | AI_FORCE_INLINE | |
218 | bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const { | |
204 | AI_FORCE_INLINE bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const { | |
219 | 205 | return x != other.x || y != other.y || z != other.z; |
220 | 206 | } |
221 | 207 | // --------------------------------------------------------------------------- |
222 | 208 | template<typename TReal> |
223 | AI_FORCE_INLINE | |
224 | bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const { | |
209 | AI_FORCE_INLINE bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const { | |
225 | 210 | return |
226 | 211 | std::abs(x - other.x) <= epsilon && |
227 | 212 | std::abs(y - other.y) <= epsilon && |
229 | 214 | } |
230 | 215 | // ------------------------------------------------------------------------------------------------ |
231 | 216 | template <typename TReal> |
232 | AI_FORCE_INLINE | |
233 | bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const { | |
217 | AI_FORCE_INLINE bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const { | |
234 | 218 | return x != other.x ? x < other.x : y != other.y ? y < other.y : z < other.z; |
235 | 219 | } |
236 | 220 | // ------------------------------------------------------------------------------------------------ |
237 | 221 | template <typename TReal> |
238 | AI_FORCE_INLINE | |
239 | const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) { | |
222 | AI_FORCE_INLINE const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) { | |
240 | 223 | return aiVector3t<TReal>(x*o.x,y*o.y,z*o.z); |
241 | 224 | } |
242 | 225 | // ------------------------------------------------------------------------------------------------ |
243 | 226 | // symmetric addition |
244 | 227 | template <typename TReal> |
245 | AI_FORCE_INLINE | |
246 | aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) { | |
228 | AI_FORCE_INLINE aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) { | |
247 | 229 | return aiVector3t<TReal>( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); |
248 | 230 | } |
249 | 231 | // ------------------------------------------------------------------------------------------------ |
250 | 232 | // symmetric subtraction |
251 | 233 | template <typename TReal> |
252 | AI_FORCE_INLINE | |
253 | aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) { | |
234 | AI_FORCE_INLINE aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) { | |
254 | 235 | return aiVector3t<TReal>( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); |
255 | 236 | } |
256 | 237 | // ------------------------------------------------------------------------------------------------ |
257 | 238 | // scalar product |
258 | 239 | template <typename TReal> |
259 | AI_FORCE_INLINE | |
260 | TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) { | |
240 | AI_FORCE_INLINE TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) { | |
261 | 241 | return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; |
262 | 242 | } |
263 | 243 | // ------------------------------------------------------------------------------------------------ |
264 | 244 | // scalar multiplication |
265 | 245 | template <typename TReal> |
266 | AI_FORCE_INLINE | |
267 | aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) { | |
246 | AI_FORCE_INLINE aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) { | |
268 | 247 | return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z); |
269 | 248 | } |
270 | 249 | // ------------------------------------------------------------------------------------------------ |
271 | 250 | // and the other way around |
272 | 251 | template <typename TReal> |
273 | AI_FORCE_INLINE | |
274 | aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) { | |
252 | AI_FORCE_INLINE aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) { | |
275 | 253 | return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z); |
276 | 254 | } |
277 | 255 | // ------------------------------------------------------------------------------------------------ |
278 | 256 | // scalar division |
279 | 257 | template <typename TReal> |
280 | AI_FORCE_INLINE | |
281 | aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) { | |
258 | AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) { | |
282 | 259 | return v * (1/f); |
283 | 260 | } |
284 | 261 | // ------------------------------------------------------------------------------------------------ |
285 | 262 | // vector division |
286 | 263 | template <typename TReal> |
287 | AI_FORCE_INLINE | |
288 | aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) { | |
264 | AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) { | |
289 | 265 | return aiVector3t<TReal>(v.x / v2.x,v.y / v2.y,v.z / v2.z); |
290 | 266 | } |
291 | 267 | // ------------------------------------------------------------------------------------------------ |
292 | 268 | // cross product |
293 | 269 | template<typename TReal> |
294 | AI_FORCE_INLINE | |
295 | aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) { | |
270 | AI_FORCE_INLINE aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) { | |
296 | 271 | 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); |
297 | 272 | } |
298 | 273 | // ------------------------------------------------------------------------------------------------ |
299 | 274 | // vector negation |
300 | 275 | template<typename TReal> |
301 | AI_FORCE_INLINE | |
302 | aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) { | |
276 | AI_FORCE_INLINE aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) { | |
303 | 277 | return aiVector3t<TReal>( -v.x, -v.y, -v.z); |
304 | 278 | } |
305 | 279 |
Binary diff not shown
Binary diff not shown
41 | 41 | #include "UnitTestPCH.h" |
42 | 42 | |
43 | 43 | #include <assimp/scene.h> |
44 | #include <assimp/SceneCombiner.h> | |
44 | 45 | |
45 | 46 | using namespace Assimp; |
46 | 47 | |
87 | 88 | EXPECT_NE(nullptr, name2); |
88 | 89 | } |
89 | 90 | |
91 | TEST_F(utScene, deepCopyTest) { | |
92 | scene->mRootNode = new aiNode(); | |
93 | ||
94 | scene->mNumMeshes = 1; | |
95 | scene->mMeshes = new aiMesh *[scene->mNumMeshes] (); | |
96 | scene->mMeshes[0] = new aiMesh (); | |
97 | ||
98 | scene->mMeshes[0]->SetTextureCoordsName (0, aiString ("test")); | |
99 | ||
100 | { | |
101 | aiScene* copied = nullptr; | |
102 | SceneCombiner::CopyScene(&copied,scene); | |
103 | delete copied; | |
104 | } | |
105 | } | |
106 | ||
90 | 107 | TEST_F(utScene, getEmbeddedTextureTest) { |
91 | 108 | } |
72 | 72 | pf[0] = pf[1] = pf[2] = pf[3] = 12.0f; |
73 | 73 | |
74 | 74 | EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey2", 0, 0, pf, &pMax)); |
75 | EXPECT_EQ(sizeof(pf) / sizeof(float), pMax); | |
75 | EXPECT_EQ(sizeof(pf) / sizeof(float), static_cast<size_t>(pMax)); | |
76 | 76 | EXPECT_TRUE(!pf[0] && 1.0f == pf[1] && 2.0f == pf[2] && 3.0f == pf[3]); |
77 | 77 | } |
78 | 78 |