------------------------------------------------------------------------------------------------ Build linearly subsampled keys from three single envelopes, one for each component (x,y,z)
| 416 | // ------------------------------------------------------------------------------------------------ |
| 417 | // Build linearly subsampled keys from three single envelopes, one for each component (x,y,z) |
| 418 | void AnimResolver::GetKeys(std::vector<aiVectorKey> &out, |
| 419 | LWO::Envelope *_envl_x, |
| 420 | LWO::Envelope *_envl_y, |
| 421 | LWO::Envelope *_envl_z, |
| 422 | unsigned int _flags) { |
| 423 | envl_x = _envl_x; |
| 424 | envl_y = _envl_y; |
| 425 | envl_z = _envl_z; |
| 426 | flags = _flags; |
| 427 | |
| 428 | // generate default channels if none are given |
| 429 | LWO::Envelope def_x, def_y, def_z; |
| 430 | LWO::Key key_dummy; |
| 431 | key_dummy.time = 0.f; |
| 432 | if ((envl_x && envl_x->type == LWO::EnvelopeType_Scaling_X) || |
| 433 | (envl_y && envl_y->type == LWO::EnvelopeType_Scaling_Y) || |
| 434 | (envl_z && envl_z->type == LWO::EnvelopeType_Scaling_Z)) { |
| 435 | key_dummy.value = 1.f; |
| 436 | } else |
| 437 | key_dummy.value = 0.f; |
| 438 | |
| 439 | if (!envl_x) { |
| 440 | envl_x = &def_x; |
| 441 | envl_x->keys.push_back(key_dummy); |
| 442 | } |
| 443 | if (!envl_y) { |
| 444 | envl_y = &def_y; |
| 445 | envl_y->keys.push_back(key_dummy); |
| 446 | } |
| 447 | if (!envl_z) { |
| 448 | envl_z = &def_z; |
| 449 | envl_z->keys.push_back(key_dummy); |
| 450 | } |
| 451 | |
| 452 | // guess how many keys we'll get |
| 453 | size_t reserve; |
| 454 | double sr = 1.; |
| 455 | if (flags & AI_LWO_ANIM_FLAG_SAMPLE_ANIMS) { |
| 456 | if (!sample_rate) |
| 457 | sr = 100.f; |
| 458 | else |
| 459 | sr = sample_rate; |
| 460 | sample_delta = 1.f / sr; |
| 461 | |
| 462 | reserve = (size_t)( |
| 463 | std::max(envl_x->keys.rbegin()->time, |
| 464 | std::max(envl_y->keys.rbegin()->time, envl_z->keys.rbegin()->time)) * |
| 465 | sr); |
| 466 | } else |
| 467 | reserve = std::max(envl_x->keys.size(), std::max(envl_x->keys.size(), envl_z->keys.size())); |
| 468 | out.reserve(reserve + (reserve >> 1)); |
| 469 | |
| 470 | // Iterate through all three arrays at once - it's tricky, but |
| 471 | // rather interesting to implement. |
| 472 | cur_x = envl_x->keys.begin(); |
| 473 | cur_y = envl_y->keys.begin(); |
| 474 | cur_z = envl_z->keys.begin(); |
| 475 |
no test coverage detected