From c8c8a92ab693a589f2897c25f28738d8397646bd Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 9 May 2007 11:16:32 +0000 Subject: In very rare cases, an offset-bone could not exist, whilst the action channel does. Then it crashes... This commit adds a NULL test, but now trying to solve how this case can happen. --- source/blender/blenkernel/intern/action.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 3427d794870..8ecdedc329e 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -987,20 +987,22 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float /* bring it into armature space */ VecSubf(min, max, min); bone= get_named_bone(ob->data, strip->offs_bone); /* weak */ - Mat4Mul3Vecfl(bone->arm_mat, min); - - /* dominant motion, cyclic_offset was cleared in rest_pose */ - if (strip->flag & (ACTSTRIP_CYCLIC_USEX | ACTSTRIP_CYCLIC_USEY | ACTSTRIP_CYCLIC_USEZ)) { - if (strip->flag & ACTSTRIP_CYCLIC_USEX) pose->cyclic_offset[0]= time*min[0]; - if (strip->flag & ACTSTRIP_CYCLIC_USEY) pose->cyclic_offset[1]= time*min[1]; - if (strip->flag & ACTSTRIP_CYCLIC_USEZ) pose->cyclic_offset[2]= time*min[2]; - } else { - if( fabs(min[0]) >= fabs(min[1]) && fabs(min[0]) >= fabs(min[2])) - pose->cyclic_offset[0]= time*min[0]; - else if( fabs(min[1]) >= fabs(min[0]) && fabs(min[1]) >= fabs(min[2])) - pose->cyclic_offset[1]= time*min[1]; - else - pose->cyclic_offset[2]= time*min[2]; + if(bone) { + Mat4Mul3Vecfl(bone->arm_mat, min); + + /* dominant motion, cyclic_offset was cleared in rest_pose */ + if (strip->flag & (ACTSTRIP_CYCLIC_USEX | ACTSTRIP_CYCLIC_USEY | ACTSTRIP_CYCLIC_USEZ)) { + if (strip->flag & ACTSTRIP_CYCLIC_USEX) pose->cyclic_offset[0]= time*min[0]; + if (strip->flag & ACTSTRIP_CYCLIC_USEY) pose->cyclic_offset[1]= time*min[1]; + if (strip->flag & ACTSTRIP_CYCLIC_USEZ) pose->cyclic_offset[2]= time*min[2]; + } else { + if( fabs(min[0]) >= fabs(min[1]) && fabs(min[0]) >= fabs(min[2])) + pose->cyclic_offset[0]= time*min[0]; + else if( fabs(min[1]) >= fabs(min[0]) && fabs(min[1]) >= fabs(min[2])) + pose->cyclic_offset[1]= time*min[1]; + else + pose->cyclic_offset[2]= time*min[2]; + } } } } -- cgit v1.2.3