# HG changeset patch # User John Tsiombikas # Date 1362118879 -7200 # Node ID a720e8d7023dc913e652ef8708d8243de9c47b7c # Parent d48408ab376fc3bc006fdf2e9c37a78d939a70d0 fixed a bug in the manual slerping in anm_get_node_rotation diff -r d48408ab376f -r a720e8d7023d src/anim.c --- a/src/anim.c Wed Feb 27 21:38:33 2013 +0200 +++ b/src/anim.c Fri Mar 01 08:21:19 2013 +0200 @@ -200,6 +200,13 @@ quat_t anm_get_node_rotation(struct anm_node *node, anm_time_t tm) { + /*quat_t q; + q.x = anm_get_value(node->tracks + ANM_TRACK_ROT_X, tm); + q.y = anm_get_value(node->tracks + ANM_TRACK_ROT_Y, tm); + q.z = anm_get_value(node->tracks + ANM_TRACK_ROT_Z, tm); + q.w = anm_get_value(node->tracks + ANM_TRACK_ROT_W, tm); + return q;*/ + int idx0, idx1, last_idx; anm_time_t tstart, tend; float t, dt; @@ -223,12 +230,29 @@ tstart = track_x->keys[0].time; tend = track_x->keys[last_idx].time; + + if(tstart == tend) { + q.x = track_x->keys[0].val; + q.y = track_y->keys[0].val; + q.z = track_z->keys[0].val; + q.w = track_w->keys[0].val; + return q; + } + tm = anm_remap_time(track_x, tm, tstart, tend); idx0 = anm_get_key_interval(track_x, tm); assert(idx0 >= 0 && idx0 < track_x->count); idx1 = idx0 + 1; + if(idx0 == last_idx) { + q.x = track_x->keys[idx0].val; + q.y = track_y->keys[idx0].val; + q.z = track_z->keys[idx0].val; + q.w = track_w->keys[idx0].val; + return q; + } + dt = (float)(track_x->keys[idx1].time - track_x->keys[idx0].time); t = (float)(tm - track_x->keys[idx0].time) / dt; diff -r d48408ab376f -r a720e8d7023d src/track.c --- a/src/track.c Wed Feb 27 21:38:33 2013 +0200 +++ b/src/track.c Fri Mar 01 08:21:19 2013 +0200 @@ -284,9 +284,13 @@ static anm_time_t remap_repeat(anm_time_t tm, anm_time_t start, anm_time_t end) { - anm_time_t interv = end - start; - anm_time_t x = (tm - start) % interv; + anm_time_t x, interv = end - start; + if(interv == 0) { + return start; + } + + x = (tm - start) % interv; if(x < 0) { x += interv; }