MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / CDrawBodyImpl

Function CDrawBodyImpl

Source/Objects/movementobject.cpp:2985–3024  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2983}
2984
2985static void CDrawBodyImpl(
2986 RiggedObject& rigged_object,
2987 Skeleton& skeleton,
2988 CScriptArrayWrapper<BoneTransform>& inv_skeleton_bind_transforms,
2989 CScriptArrayWrapper<int>& ik_chain_start_index,
2990 CScriptArrayWrapper<int>& ik_chain_elements,
2991 CScriptArrayWrapper<int>& ik_chain_length,
2992 const BoneTransform& hip_transform, const BoneTransform& chest_transform) {
2993 int start = ik_chain_start_index[kTorsoIK];
2994
2995 BoneTransform old_hip_matrix = rigged_object.animation_frame_bone_matrices[ik_chain_elements[start + 2]];
2996
2997 int chest_bone = ik_chain_elements[start + 0];
2998 int abdomen_bone = ik_chain_elements[start + 1];
2999 int hip_bone = ik_chain_elements[start + 2];
3000
3001 vec3 collarbone = chest_transform * skeleton.points[skeleton.bones[chest_bone].points[1]];
3002 vec3 ribs = chest_transform * skeleton.points[skeleton.bones[chest_bone].points[0]];
3003 vec3 stomach = hip_transform * skeleton.points[skeleton.bones[abdomen_bone].points[0]];
3004 vec3 hips = hip_transform * skeleton.points[skeleton.bones[hip_bone].points[0]];
3005
3006 rigged_object.animation_frame_bone_matrices[chest_bone] = chest_transform * inv_skeleton_bind_transforms[chest_bone];
3007 BoneTransform temp = mix(chest_transform, hip_transform, 0.5f);
3008 temp.rotation = mix(hip_transform.rotation, chest_transform.rotation, 0.5f);
3009 rigged_object.animation_frame_bone_matrices[abdomen_bone] = temp * inv_skeleton_bind_transforms[abdomen_bone];
3010
3011 RotateBoneToMatchVec(&rigged_object, ribs, collarbone, chest_bone);
3012 RotateBoneToMatchVec(&rigged_object, stomach, ribs, abdomen_bone);
3013 RotateBoneToMatchVec(&rigged_object, hips, stomach, hip_bone);
3014
3015 BoneTransform hip_rel = rigged_object.animation_frame_bone_matrices[hip_bone] * invert(old_hip_matrix);
3016
3017 start = ik_chain_start_index[kTailIK];
3018 int len = ik_chain_length[kTailIK];
3019
3020 for (int i = 0; i < len; ++i) {
3021 int bone = ik_chain_elements[start + i];
3022 rigged_object.animation_frame_bone_matrices[bone] = hip_rel * rigged_object.animation_frame_bone_matrices[bone];
3023 }
3024}
3025
3026static void CDrawBody(MovementObject* mo, const BoneTransform& hip_transform, const BoneTransform& chest_transform) {
3027 PROFILER_ZONE(g_profiler_ctx, "C++ Draw Body")

Callers 2

CDrawBodyFunction · 0.85
CDrawFinalBoneIKFunction · 0.85

Calls 3

RotateBoneToMatchVecFunction · 0.85
mixFunction · 0.50
invertFunction · 0.50

Tested by

no test coverage detected