| 719 | } |
| 720 | |
| 721 | static void CommitPoseMatrixToCache(HRigContext context, HRigInstance instance) |
| 722 | { |
| 723 | uint32_t bone_count = GetBoneCount(instance); |
| 724 | if (bone_count == 0 || instance->m_PoseMatrixCacheIndex == INVALID_POSE_MATRIX_CACHE_ENTRY) |
| 725 | { |
| 726 | return; |
| 727 | } |
| 728 | |
| 729 | PoseMatrixCache* cache = &context->m_PoseMatrixCache; |
| 730 | uint32_t cache_entry_offset = cache->m_CacheEntryOffsets[instance->m_PoseMatrixCacheIndex]; |
| 731 | |
| 732 | Matrix4* pose_matrix_write_ptr = cache->m_PoseMatrices.Begin() + cache_entry_offset; |
| 733 | PoseToMatrix(instance->m_Pose, pose_matrix_write_ptr); |
| 734 | |
| 735 | // Premultiply pose matrices with the bind pose inverse so they |
| 736 | // can be directly be used to transform each vertex. |
| 737 | const dmArray<RigBone>& bind_pose = *instance->m_BindPose; |
| 738 | for (uint32_t bi = 0; bi < bone_count; ++bi) |
| 739 | { |
| 740 | Matrix4& pose_matrix = pose_matrix_write_ptr[bi]; |
| 741 | pose_matrix = pose_matrix * bind_pose[bi].m_ModelToLocal; |
| 742 | } |
| 743 | |
| 744 | cache->m_MaxBoneCount = dmMath::Max(cache->m_MaxBoneCount, (uint32_t) instance->m_MaxBoneCount); |
| 745 | } |
| 746 | |
| 747 | bool IsAnimating(HRigInstance instance) |
| 748 | { |
no test coverage detected