------------------------------------------------------------------------------------------------
| 271 | |
| 272 | // ------------------------------------------------------------------------------------------------ |
| 273 | void FindInvalidDataProcess::ProcessAnimationChannel(aiNodeAnim *anim) { |
| 274 | ai_assert(nullptr != anim); |
| 275 | if (anim->mNumPositionKeys == 0 && anim->mNumRotationKeys == 0 && anim->mNumScalingKeys == 0) { |
| 276 | ASSIMP_LOG_ERROR("Invalid node anuimation instance detected."); |
| 277 | |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | // Check whether all values in a tracks are identical - in this case |
| 282 | // we can remove al keys except one. |
| 283 | // POSITIONS |
| 284 | int i = 0; |
| 285 | if (anim->mNumPositionKeys > 1 && AllIdentical(anim->mPositionKeys, anim->mNumPositionKeys, configEpsilon)) { |
| 286 | aiVectorKey v = anim->mPositionKeys[0]; |
| 287 | |
| 288 | // Reallocate ... we need just ONE element, it makes no sense to reuse the array |
| 289 | delete[] anim->mPositionKeys; |
| 290 | anim->mPositionKeys = new aiVectorKey[anim->mNumPositionKeys = 1]; |
| 291 | anim->mPositionKeys[0] = v; |
| 292 | i = 1; |
| 293 | } |
| 294 | |
| 295 | // ROTATIONS |
| 296 | if (anim->mNumRotationKeys > 1 && AllIdentical(anim->mRotationKeys, anim->mNumRotationKeys, configEpsilon)) { |
| 297 | aiQuatKey v = anim->mRotationKeys[0]; |
| 298 | |
| 299 | // Reallocate ... we need just ONE element, it makes no sense to reuse the array |
| 300 | delete[] anim->mRotationKeys; |
| 301 | anim->mRotationKeys = new aiQuatKey[anim->mNumRotationKeys = 1]; |
| 302 | anim->mRotationKeys[0] = v; |
| 303 | i = 1; |
| 304 | } |
| 305 | |
| 306 | // SCALINGS |
| 307 | if (anim->mNumScalingKeys > 1 && AllIdentical(anim->mScalingKeys, anim->mNumScalingKeys, configEpsilon)) { |
| 308 | aiVectorKey v = anim->mScalingKeys[0]; |
| 309 | |
| 310 | // Reallocate ... we need just ONE element, it makes no sense to reuse the array |
| 311 | delete[] anim->mScalingKeys; |
| 312 | anim->mScalingKeys = new aiVectorKey[anim->mNumScalingKeys = 1]; |
| 313 | anim->mScalingKeys[0] = v; |
| 314 | i = 1; |
| 315 | } |
| 316 | if (1 == i) { |
| 317 | ASSIMP_LOG_WARN("Simplified dummy tracks with just one key"); |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | // ------------------------------------------------------------------------------------------------ |
| 322 | // Search a mesh for invalid contents |
nothing calls this directly
no test coverage detected