MCPcopy Create free account
hub / github.com/defold/defold / CommitPoseMatrixToCache

Function CommitPoseMatrixToCache

engine/rig/src/rig.cpp:721–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

DoAnimateFunction · 0.85

Calls 4

PoseToMatrixFunction · 0.85
GetBoneCountFunction · 0.70
MaxFunction · 0.50
BeginMethod · 0.45

Tested by

no test coverage detected