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

Function CDrawTailImpl

Source/Objects/movementobject.cpp:3232–3379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3230}
3231
3232void CDrawTailImpl(
3233 MovementObject* mo,
3234 float& time,
3235 float& time_step,
3236 CScriptArrayWrapper<int>& ik_chain_elements,
3237 CScriptArrayWrapper<int>& ik_chain_start_index,
3238 CScriptArrayWrapper<int>& ik_chain_length,
3239 CScriptArrayWrapper<vec3>& tail_points,
3240 CScriptArrayWrapper<vec3>& old_tail_points,
3241 CScriptArrayWrapper<vec3>& temp_old_tail_points,
3242 CScriptArrayWrapper<vec3>& tail_correction,
3243 CScriptArrayWrapper<float>& tail_section_length,
3244 int num_frames) {
3245 MovementObject& this_mo = *mo;
3246 RiggedObject& rigged_object = *this_mo.rigged_object();
3247 Skeleton& skeleton = rigged_object.skeleton();
3248
3249 int chain_start = ik_chain_start_index[kTailIK];
3250 int chain_length = ik_chain_length[kTailIK];
3251
3252 // Tail wag behavior
3253 bool wag_tail = false;
3254 if (wag_tail) {
3255 float wag_freq = 5.0f;
3256 vec3 tail_root = rigged_object_GetTransformedBonePoint(ik_chain_elements[chain_start + chain_length - 1], 0);
3257 int hip_bone = skeleton_GetParent(ik_chain_elements[chain_start + chain_length - 1]);
3258 vec3 axis = rigged_object_GetFrameMatrix(hip_bone).rotation * vec3(0, 0, 1);
3259 quaternion rotation(vec4(axis, sin(time * wag_freq)));
3260 for (int i = 0, len = chain_length; i < len; ++i) {
3261 BoneTransform mat = rigged_object_GetFrameMatrix(ik_chain_elements[chain_start + i]);
3262 mat.origin -= tail_root;
3263 mat = rotation * mat;
3264 mat.origin += tail_root;
3265 rigged_object_SetFrameMatrix(ik_chain_elements[chain_start + i], mat);
3266 }
3267 }
3268
3269 bool ambient_tail = false;
3270 if (ambient_tail) {
3271 vec3 tail_root = rigged_object_GetTransformedBonePoint(ik_chain_elements[chain_start + chain_length - 1], 0);
3272 int hip_bone = skeleton_GetParent(ik_chain_elements[chain_start + chain_length - 1]);
3273 vec3 axis = rigged_object_GetFrameMatrix(hip_bone).rotation * vec3(0, 0, 1);
3274 quaternion rotation(vec4(axis, (sin(time) + sin(time * 1.3f)) * 0.2f));
3275 for (int i = 0, len = chain_length; i < len; ++i) {
3276 BoneTransform mat = rigged_object_GetFrameMatrix(ik_chain_elements[chain_start + i]);
3277 mat.origin -= tail_root;
3278 mat = rotation * mat;
3279 mat.origin += tail_root;
3280 rigged_object_SetFrameMatrix(ik_chain_elements[chain_start + i], mat);
3281 }
3282 }
3283
3284 bool twitch_tail_tip = false;
3285 if (twitch_tail_tip) {
3286 float wag_freq = 5.0f;
3287 vec3 tail_root = rigged_object_GetTransformedBonePoint(ik_chain_elements[chain_start + 0], 0);
3288 int hip_bone = skeleton_GetParent(ik_chain_elements[chain_start + chain_length - 1]);
3289 vec3 axis = rigged_object_GetFrameMatrix(hip_bone).rotation * vec3(0, 0, 1);

Callers 2

CDrawTailFunction · 0.85
CDrawFinalBoneIKFunction · 0.85

Calls 15

ASMultFunction · 0.85
maxFunction · 0.85
rigged_objectMethod · 0.80
skeletonMethod · 0.80
vec3Class · 0.50
vec4Class · 0.50
sinFunction · 0.50
distanceFunction · 0.50
powFunction · 0.50
normalizeFunction · 0.50

Tested by

no test coverage detected