Codebase list assimp / upstream/5.1.4_ds0
New upstream version 5.1.4~ds0 IOhannes m zmölnig (Debian/GNU) 2 years ago
26 changed file(s) with 170 addition(s) and 183 deletion(s). Raw diff Collapse all Expand all
5555 add_definitions(-DASSIMP_USE_HUNTER)
5656 ENDIF()
5757
58 PROJECT(Assimp VERSION 5.1.3)
58 PROJECT(Assimp VERSION 5.1.4)
5959
6060 # All supported options ###############################################
6161
182182 SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources" )
183183 if(NOT ASSIMP_HUNTER_ENABLED)
184184 # 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)
186188 endif()
187189
188190 IF(NOT ASSIMP_IGNORE_GIT_HASH)
761763
762764 IF(MSVC_TOOLSET_VERSION)
763765 SET(MSVC_PREFIX "vc${MSVC_TOOLSET_VERSION}")
764 SET(ASSIMP_MSVC_VERSION ${MCVS_PREFIX})
766 SET(ASSIMP_MSVC_VERSION ${MSVC_PREFIX})
765767 ELSE()
766768 IF(MSVC12)
767769 SET(ASSIMP_MSVC_VERSION "vc120")
377377 const DXF::Block& bl_src = *(*it).second;
378378
379379 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
380385 std::shared_ptr<DXF::PolyLine> pl_out = std::shared_ptr<DXF::PolyLine>(new DXF::PolyLine(*pl_in));
381386
382387 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()) {
7878
7979 #define MAGIC_NODE_TAG "_$AssimpFbx$"
8080
81 #define CONVERT_FBX_TIME(time) (static_cast<double>(time) * 1000.0 / 46186158000LL)
81 #define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000LL
8282
8383 FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBones) :
8484 defaultMaterialIndex(),
26172617 meshMorphAnim->mKeys[j].mNumValuesAndWeights = numValuesAndWeights;
26182618 meshMorphAnim->mKeys[j].mValues = new unsigned int[numValuesAndWeights];
26192619 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;
26212621 for (unsigned int k = 0; k < numValuesAndWeights; k++) {
26222622 meshMorphAnim->mKeys[j].mValues[k] = keyData->values.at(k);
26232623 meshMorphAnim->mKeys[j].mWeights[k] = keyData->weights.at(k);
26352635 return;
26362636 }
26372637
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;
26402640
26412641 // adjust relative timing for animation
26422642 for (unsigned int c = 0; c < anim->mNumChannels; c++) {
31613161 InterpolateKeys(outTranslations, keytimes, keyframeLists[TransformationComp_Translation], defTranslate, maxTime, minTime);
31623162 } else {
31633163 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;
31653165 outTranslations[i].mValue = defTranslate;
31663166 }
31673167 }
31703170 InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], defRotation, maxTime, minTime, rotOrder);
31713171 } else {
31723172 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;
31743174 outRotations[i].mValue = defQuat;
31753175 }
31763176 }
31793179 InterpolateKeys(outScales, keytimes, keyframeLists[TransformationComp_Scaling], defScale, maxTime, minTime);
31803180 } else {
31813181 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;
31833183 outScales[i].mValue = defScale;
31843184 }
31853185 }
34413441 }
34423442
34433443 // magic value to convert fbx times to seconds
3444 valOut->mTime = CONVERT_FBX_TIME(time);
3444 valOut->mTime = CONVERT_FBX_TIME(time) * anim_fps;
34453445
34463446 min_time = std::min(min_time, valOut->mTime);
34473447 max_time = std::max(max_time, valOut->mTime);
472472
473473 // ------------------------------------------------------------------------------------------------
474474 // 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) {
477476 ai_assert(nullptr != pScene->mMeshes);
478477 ai_assert(nullptr != pScene->mMeshes[0]);
479478 ai_assert(nullptr != pScene->mMeshes[0]->mTextureCoords[0]);
480479
481480 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;
485491
486492 for (unsigned int y = 0; y < height; ++y) {
487493 for (unsigned int x = 0; x < width; ++x, ++uv) {
392392
393393 // If a RGB color map is explicitly requested delete the
394394 // alpha channel - it could theoretically be != 1.
395 if (_mSurfaces[i].mVCMapType == AI_LWO_RGB)
395 if (_mSurfaces[j].mVCMapType == AI_LWO_RGB)
396396 pvVC[w]->a = 1.f;
397397
398398 pvVC[w]++;
479479 }
480480 }
481481
482 } // namespace Assimp
483
482484 #endif // !ASSIMP_BUILD_NO_X3D_IMPORTER
483
484 } // namespace Assimp
878878 X3DNodeElementBase *ne(nullptr);
879879
880880 MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
881 XmlParser::getFloatAttribute(node, "radius", radius);
881 XmlParser::getRealAttribute(node, "radius", radius);
882882 XmlParser::getBoolAttribute(node, "solid", solid);
883883
884884 // if "USE" defined then find already defined element.
14091409 }
14101410 }
14111411
1412 inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<float> &times) {
1412 inline Ref<Accessor> GetSamplerInputRef(Asset &asset, std::string &animId, Ref<Buffer> &buffer, std::vector<ai_real> &times) {
14131413 return ExportData(asset, animId, buffer, (unsigned int)times.size(), &times[0], AttribType::SCALAR, AttribType::SCALAR, ComponentType_FLOAT);
14141414 }
14151415
6565 }
6666
6767 namespace glTF2 {
68
6869 class Asset;
70
6971 struct TexProperty;
7072 struct TextureInfo;
7173 struct NormalTextureInfo;
8385 typedef float(vec2)[2];
8486 typedef float(vec3)[3];
8587 typedef float(vec4)[4];
88
8689 } // namespace glTF2
8790
8891 namespace Assimp {
11711171 ENDIF()
11721172
11731173 # 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)
11751175
11761176 TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
11771177 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
22 ----------------------------------------------------------------------
33
44 Copyright (c) 2006-2021, assimp team
5
65
76 All rights reserved.
87
4140
4241 /** @file PolyTools.h, various utilities for our dealings with arbitrary polygons */
4342
43 #pragma once
4444 #ifndef AI_POLYTOOLS_H_INCLUDED
4545 #define AI_POLYTOOLS_H_INCLUDED
4646
5454 * The function accepts an unconstrained template parameter for use with
5555 * both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
5656 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) {
5958 return 0.5 * (v1.x * ((double)v3.y - v2.y) + v2.x * ((double)v1.y - v3.y) + v3.x * ((double)v2.y - v1.y));
6059 }
6160
6463 * The function accepts an unconstrained template parameter for use with
6564 * both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
6665 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) {
6967 return GetArea2D(p0,p2,p1) > 0;
7068 }
7169
7472 * The function accepts an unconstrained template parameter for use with
7573 * both aiVector3D and aiVector2D, but generally ignores the third coordinate.*/
7674 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) {
7976 // Point in triangle test using baryzentric coordinates
8077 const aiVector2D v0 = p1 - p0;
8178 const aiVector2D v1 = p2 - p0;
8279 const aiVector2D v2 = pp - p0;
8380
8481 double dot00 = v0 * v0;
85 double dot01 = v0 * v1;
86 double dot02 = v0 * v2;
8782 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;
9192 dot11 = (dot11 * dot02 - dot01 * dot12) * invDenom;
9293 dot00 = (dot00 * dot12 - dot01 * dot02) * invDenom;
9394
132133 // in[i+2].x, in[i+2].y)) {
133134 convex_turn = AI_MATH_PI_F - theta;
134135 convex_sum += convex_turn;
135 }
136 else {
136 } else {
137137 convex_sum -= AI_MATH_PI_F - theta;
138138 }
139139 }
160160 if (OnLeftSideOfLine2D(in[npoints-2],in[1],in[0])) {
161161 convex_turn = AI_MATH_PI_F - theta;
162162 convex_sum += convex_turn;
163 }
164 else {
163 } else {
165164 convex_sum -= AI_MATH_PI_F - theta;
166165 }
167166
168167 return convex_sum >= (2 * AI_MATH_PI_F);
169168 }
170
171169
172170 // -------------------------------------------------------------------------------
173171 /** Compute the normal of an arbitrary polygon in R3.
185183 * this method is much faster than the 'other' NewellNormal()
186184 */
187185 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) {
190187 // Duplicate the first two vertices at the end
191188 x[(num+0)*ofs_x] = x[0];
192189 x[(num+1)*ofs_x] = x[ofs_x];
223220 out = aiVector3t<TReal>(sum_yz,sum_zx,sum_xy);
224221 }
225222
226 } // ! Assimp
227
228 #endif
223 } // ! namespace Assimp
224
225 #endif // AI_POLYTOOLS_H_INCLUDED
11001100
11011101 // make a deep copy of all blend shapes
11021102 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 }
11031111 }
11041112
11051113 // ------------------------------------------------------------------------------------------------
13471355 }
13481356 }
13491357
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
13501370 #if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0)
13511371 #pragma GCC diagnostic pop
13521372 #endif
4949 #include <assimp/ParsingUtils.h>
5050 #include "ProcessHelper.h"
5151 #include "Material/MaterialSystem.h"
52 #include <assimp/Exceptional.h>
5253 #include <stdio.h>
5354
5455 using namespace Assimp;
170171 }
171172 // If the new material count differs from the original,
172173 // we need to rebuild the material list and remap mesh material indexes.
174 if(iNewNum < 1)
175 throw DeadlyImportError("No materials remaining");
173176 if (iNewNum != pScene->mNumMaterials) {
174177 ai_assert(iNewNum > 0);
175178 aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];
360360 static void Copy(aiNodeAnim **dest, const aiNodeAnim *src);
361361 static void Copy(aiMeshMorphAnim **dest, const aiMeshMorphAnim *src);
362362 static void Copy(aiMetadata **dest, const aiMetadata *src);
363 static void Copy(aiString **dest, const aiString *src);
363364
364365 // recursive, of course
365366 static void Copy(aiNode **dest, const aiNode *src);
44 ----------------------------------------------------------------------
55
66 Copyright (c) 2006-2021, assimp team
7
87
98 All rights reserved.
109
101100 /** Creates a dummy material and returns it. */
102101 aiMaterial *CreateMaterial();
103102
104 protected:
103 private:
105104 /** space to assemble the mesh data: points */
106105 std::vector<aiVector3D> mVertices;
107106
33 ---------------------------------------------------------------------------
44
55 Copyright (c) 2006-2021, assimp team
6
7
86
97 All rights reserved.
108
254254 }
255255 #endif
256256
257
258257 #endif // !! AI_LIGHT_H_INC
4343 */
4444
4545 #pragma once
46 #ifndef AI_MATERIAL_INL_INC
47 #define AI_MATERIAL_INL_INC
4846
4947 #ifdef __GNUC__
5048 # pragma GCC system_header
5149 #endif
5250
5351 // ---------------------------------------------------------------------------
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) {
5653 return aiPTI_Float;
5754 }
5855
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) {
6157 return aiPTI_Double;
6258 }
6359 // ---------------------------------------------------------------------------
6561 //! @cond never
6662
6763 // ---------------------------------------------------------------------------
68 AI_FORCE_INLINE
69 aiReturn aiMaterial::GetTexture( aiTextureType type,
64 AI_FORCE_INLINE aiReturn aiMaterial::GetTexture( aiTextureType type,
7065 unsigned int index,
7166 C_STRUCT aiString* path,
7267 aiTextureMapping* mapping /*= NULL*/,
7873 }
7974
8075 // ---------------------------------------------------------------------------
81 AI_FORCE_INLINE
82 unsigned int aiMaterial::GetTextureCount(aiTextureType type) const {
76 AI_FORCE_INLINE unsigned int aiMaterial::GetTextureCount(aiTextureType type) const {
8377 return ::aiGetMaterialTextureCount(this,type);
8478 }
8579
8680 // ---------------------------------------------------------------------------
8781 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,
9083 unsigned int idx, Type* pOut,
9184 unsigned int* pMax) const {
9285 unsigned int iNum = pMax ? *pMax : 1;
10497 return AI_FAILURE;
10598 }
10699
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)));
108101 ::memcpy(pOut,prop->mData,iNum * sizeof(Type));
109102 if (pMax) {
110103 *pMax = iNum;
115108
116109 // ---------------------------------------------------------------------------
117110 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,
120112 unsigned int idx,Type& pOut) const {
121113 const aiMaterialProperty* prop;
122114 const aiReturn ret = ::aiGetMaterialProperty(this,pKey,type,idx,
137129 }
138130
139131 // ---------------------------------------------------------------------------
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,
142133 unsigned int idx,ai_real* pOut,
143134 unsigned int* pMax) const {
144135 return ::aiGetMaterialFloatArray(this,pKey,type,idx,pOut,pMax);
145136 }
146137 // ---------------------------------------------------------------------------
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,
149139 unsigned int idx,int* pOut,
150140 unsigned int* pMax) const {
151141 return ::aiGetMaterialIntegerArray(this,pKey,type,idx,pOut,pMax);
152142 }
153143 // ---------------------------------------------------------------------------
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,
156145 unsigned int idx,ai_real& pOut) const {
157146 return aiGetMaterialFloat(this,pKey,type,idx,&pOut);
158147 }
159148 // ---------------------------------------------------------------------------
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,
162150 unsigned int idx,int& pOut) const {
163151 return aiGetMaterialInteger(this,pKey,type,idx,&pOut);
164152 }
165153 // ---------------------------------------------------------------------------
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,
168155 unsigned int idx,aiColor4D& pOut) const {
169156 return aiGetMaterialColor(this,pKey,type,idx,&pOut);
170157 }
189176
190177 // ---------------------------------------------------------------------------
191178 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),
200183 pKey,type,index,aiPTI_Buffer);
201184 }
202185
212195 }
213196
214197 // ---------------------------------------------------------------------------
215 AI_FORCE_INLINE
216 aiReturn aiMaterial::AddProperty(const double* pInput,
198 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const double* pInput,
217199 const unsigned int pNumValues,
218200 const char* pKey,
219201 unsigned int type,
224206 }
225207
226208 // ---------------------------------------------------------------------------
227 AI_FORCE_INLINE
228 aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
209 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
229210 const unsigned int pNumValues,
230211 const char* pKey,
231212 unsigned int type,
236217 }
237218
238219 // ---------------------------------------------------------------------------
239 AI_FORCE_INLINE
240 aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
220 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
241221 const unsigned int pNumValues,
242222 const char* pKey,
243223 unsigned int type,
248228 }
249229
250230 // ---------------------------------------------------------------------------
251 AI_FORCE_INLINE
252 aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
231 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
253232 const unsigned int pNumValues,
254233 const char* pKey,
255234 unsigned int type,
260239 }
261240
262241 // ---------------------------------------------------------------------------
263 AI_FORCE_INLINE
264 aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
242 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
265243 const unsigned int pNumValues,
266244 const char* pKey,
267245 unsigned int type,
272250 }
273251
274252 // ---------------------------------------------------------------------------
275 AI_FORCE_INLINE
276 aiReturn aiMaterial::AddProperty(const int* pInput,
253 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty(const int* pInput,
277254 const unsigned int pNumValues,
278255 const char* pKey,
279256 unsigned int type,
292269
293270 // ---------------------------------------------------------------------------
294271 template<>
295 AI_FORCE_INLINE
296 aiReturn aiMaterial::AddProperty<float>(const float* pInput,
272 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<float>(const float* pInput,
297273 const unsigned int pNumValues,
298274 const char* pKey,
299275 unsigned int type,
305281
306282 // ---------------------------------------------------------------------------
307283 template<>
308 AI_FORCE_INLINE
309 aiReturn aiMaterial::AddProperty<double>(const double* pInput,
284 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<double>(const double* pInput,
310285 const unsigned int pNumValues,
311286 const char* pKey,
312287 unsigned int type,
318293
319294 // ---------------------------------------------------------------------------
320295 template<>
321 AI_FORCE_INLINE
322 aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
296 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,
323297 const unsigned int pNumValues,
324298 const char* pKey,
325299 unsigned int type,
331305
332306 // ---------------------------------------------------------------------------
333307 template<>
334 AI_FORCE_INLINE
335 aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
308 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor4D>(const aiColor4D* pInput,
336309 const unsigned int pNumValues,
337310 const char* pKey,
338311 unsigned int type,
344317
345318 // ---------------------------------------------------------------------------
346319 template<>
347 AI_FORCE_INLINE
348 aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
320 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiColor3D>(const aiColor3D* pInput,
349321 const unsigned int pNumValues,
350322 const char* pKey,
351323 unsigned int type,
357329
358330 // ---------------------------------------------------------------------------
359331 template<>
360 AI_FORCE_INLINE
361 aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
332 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<aiVector3D>(const aiVector3D* pInput,
362333 const unsigned int pNumValues,
363334 const char* pKey,
364335 unsigned int type,
370341
371342 // ---------------------------------------------------------------------------
372343 template<>
373 AI_FORCE_INLINE
374 aiReturn aiMaterial::AddProperty<int>(const int* pInput,
344 AI_FORCE_INLINE aiReturn aiMaterial::AddProperty<int>(const int* pInput,
375345 const unsigned int pNumValues,
376346 const char* pKey,
377347 unsigned int type,
382352 }
383353
384354 //! @endcond
385
386 #endif //! AI_MATERIAL_INL_INC
9191
9292 #ifdef __cplusplus
9393 //! Comparison operator
94 bool operator== (const aiTexel& other) const
95 {
94 bool operator== (const aiTexel& other) const {
9695 return b == other.b && r == other.r &&
9796 g == other.g && a == other.a;
9897 }
9998
10099 //! Inverse comparison operator
101 bool operator!= (const aiTexel& other) const
102 {
100 bool operator!= (const aiTexel& other) const {
103101 return b != other.b || r != other.r ||
104102 g != other.g || a != other.a;
105103 }
106104
107105 //! Conversion to a floating-point 4d color
108 operator aiColor4D() const
109 {
106 operator aiColor4D() const {
110107 return aiColor4D(r/255.f,g/255.f,b/255.f,a/255.f);
111108 }
112109 #endif // __cplusplus
201198 }
202199
203200 // 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() {
209206 memset(achFormatHint, 0, sizeof(achFormatHint));
210207 }
211208
33 ---------------------------------------------------------------------------
44
55 Copyright (c) 2006-2021, assimp team
6
7
86
97 All rights reserved.
108
5353 // ------------------------------------------------------------------------------------------------
5454 /** Transformation of a vector by a 3x3 matrix */
5555 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) {
5857 aiVector3t<TReal> res;
5958 res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z;
6059 res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z;
6564 // ------------------------------------------------------------------------------------------------
6665 /** Transformation of a vector by a 4x4 matrix */
6766 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) {
7068 aiVector3t<TReal> res;
7169 res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z + pMatrix.a4;
7270 res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z + pMatrix.b4;
8179 }
8280 // ------------------------------------------------------------------------------------------------
8381 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) {
8683 x = pX;
8784 y = pY;
8885 z = pZ;
8986 }
9087 // ------------------------------------------------------------------------------------------------
9188 template <typename TReal>
92 AI_FORCE_INLINE
93 TReal aiVector3t<TReal>::SquareLength() const {
89 AI_FORCE_INLINE TReal aiVector3t<TReal>::SquareLength() const {
9490 return x*x + y*y + z*z;
9591 }
9692 // ------------------------------------------------------------------------------------------------
9793 template <typename TReal>
98 AI_FORCE_INLINE
99 TReal aiVector3t<TReal>::Length() const {
94 AI_FORCE_INLINE TReal aiVector3t<TReal>::Length() const {
10095 return std::sqrt( SquareLength());
10196 }
10297 // ------------------------------------------------------------------------------------------------
10398 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 }
106104 *this /= Length();
107105
108106 return *this;
109107 }
110108 // ------------------------------------------------------------------------------------------------
111109 template <typename TReal>
112 AI_FORCE_INLINE
113 aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
110 AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
114111 TReal len = Length();
115112 if ( len > static_cast< TReal >( 0 ) ) {
116113 *this /= len;
119116 }
120117 // ------------------------------------------------------------------------------------------------
121118 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) {
124120 x += o.x;
125121 y += o.y;
126122 z += o.z;
129125 }
130126 // ------------------------------------------------------------------------------------------------
131127 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) {
134129 x -= o.x;
135130 y -= o.y;
136131 z -= o.z;
139134 }
140135 // ------------------------------------------------------------------------------------------------
141136 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) {
144138 x *= f;
145139 y *= f;
146140 z *= f;
149143 }
150144 // ------------------------------------------------------------------------------------------------
151145 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) {
154147 if ( f == static_cast<TReal>(0.0)) {
155148 return *this;
156149 }
163156 }
164157 // ------------------------------------------------------------------------------------------------
165158 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){
168160 return (*this = mat * (*this));
169161 }
170162 // ------------------------------------------------------------------------------------------------
171163 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){
174165 return (*this = mat * (*this));
175166 }
176167 // ------------------------------------------------------------------------------------------------
177168 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 {
180170 switch (i) {
181171 case 0:
182172 return x;
191181 }
192182 // ------------------------------------------------------------------------------------------------
193183 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) {
197185 switch (i) {
198186 case 0:
199187 return x;
208196 }
209197 // ------------------------------------------------------------------------------------------------
210198 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 {
213200 return x == other.x && y == other.y && z == other.z;
214201 }
215202 // ------------------------------------------------------------------------------------------------
216203 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 {
219205 return x != other.x || y != other.y || z != other.z;
220206 }
221207 // ---------------------------------------------------------------------------
222208 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 {
225210 return
226211 std::abs(x - other.x) <= epsilon &&
227212 std::abs(y - other.y) <= epsilon &&
229214 }
230215 // ------------------------------------------------------------------------------------------------
231216 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 {
234218 return x != other.x ? x < other.x : y != other.y ? y < other.y : z < other.z;
235219 }
236220 // ------------------------------------------------------------------------------------------------
237221 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) {
240223 return aiVector3t<TReal>(x*o.x,y*o.y,z*o.z);
241224 }
242225 // ------------------------------------------------------------------------------------------------
243226 // symmetric addition
244227 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) {
247229 return aiVector3t<TReal>( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
248230 }
249231 // ------------------------------------------------------------------------------------------------
250232 // symmetric subtraction
251233 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) {
254235 return aiVector3t<TReal>( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
255236 }
256237 // ------------------------------------------------------------------------------------------------
257238 // scalar product
258239 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) {
261241 return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
262242 }
263243 // ------------------------------------------------------------------------------------------------
264244 // scalar multiplication
265245 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) {
268247 return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
269248 }
270249 // ------------------------------------------------------------------------------------------------
271250 // and the other way around
272251 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) {
275253 return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
276254 }
277255 // ------------------------------------------------------------------------------------------------
278256 // scalar division
279257 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) {
282259 return v * (1/f);
283260 }
284261 // ------------------------------------------------------------------------------------------------
285262 // vector division
286263 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) {
289265 return aiVector3t<TReal>(v.x / v2.x,v.y / v2.y,v.z / v2.z);
290266 }
291267 // ------------------------------------------------------------------------------------------------
292268 // cross product
293269 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) {
296271 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);
297272 }
298273 // ------------------------------------------------------------------------------------------------
299274 // vector negation
300275 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) {
303277 return aiVector3t<TReal>( -v.x, -v.y, -v.z);
304278 }
305279
test/models/3DS/IMAGE1.bmp less more
Binary diff not shown
Binary diff not shown
Binary diff not shown
4141 #include "UnitTestPCH.h"
4242
4343 #include <assimp/scene.h>
44 #include <assimp/SceneCombiner.h>
4445
4546 using namespace Assimp;
4647
8788 EXPECT_NE(nullptr, name2);
8889 }
8990
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
90107 TEST_F(utScene, getEmbeddedTextureTest) {
91108 }
7272 pf[0] = pf[1] = pf[2] = pf[3] = 12.0f;
7373
7474 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));
7676 EXPECT_TRUE(!pf[0] && 1.0f == pf[1] && 2.0f == pf[2] && 3.0f == pf[3]);
7777 }
7878