on your marks, get set, bake
[carveJwlIkooP6JGAAIwe30JlM.git] / skeleton.h
index 2fcfb5023f171540b517c989a918914061a8c754..79e80171b2acc49935c11ac5ad973122b3bf54e1 100644 (file)
@@ -61,7 +61,7 @@ VG_STATIC u32 skeleton_bone_id( struct skeleton *skele, const char *name )
    }
 
    vg_error( "skeleton_bone_id( *, \"%s\" );\n", name );
-   vg_fatal_exit_loop( "Bone does not exist\n" );
+   vg_fatal_error( "Bone does not exist\n" );
 
    return 0;
 }
@@ -73,6 +73,22 @@ VG_STATIC void keyframe_copy_pose( mdl_keyframe *kfa, mdl_keyframe *kfb,
       kfb[i] = kfa[i];
 }
 
+
+/* apply a rotation from the perspective of root */
+VG_STATIC void keyframe_rotate_around( mdl_keyframe *kf, 
+                                       v3f origin, v3f offset, v4f q )
+{
+   v3f v0, co;
+   v3_add( kf->co, offset, co );
+   v3_sub( co, origin, v0 );
+   q_mulv( q, v0, v0 );
+   v3_add( v0, origin, co );
+   v3_sub( co, offset, kf->co );
+
+   q_mul( q, kf->q, kf->q );
+   q_normalize( kf->q );
+}
+
 /*
  * Lerp between two sets of keyframes and store in dest. Rotations use Nlerp.
  */
@@ -387,7 +403,7 @@ VG_STATIC struct skeleton_anim *skeleton_get_anim( struct skeleton *skele,
    }
 
    vg_error( "skeleton_get_anim( *, \"%s\" )\n", name );
-   vg_fatal_exit_loop( "Invalid animation name\n" );
+   vg_fatal_error( "Invalid animation name\n" );
 
    return NULL;
 }
@@ -425,7 +441,7 @@ VG_STATIC void skeleton_alloc_from( struct skeleton *skele,
 
 VG_STATIC void skeleton_fatal_err(void)
 {
-   vg_fatal_exit_loop( "Skeleton setup failed" );
+   vg_fatal_error( "Skeleton setup failed" );
 }
 
 /* Setup an animated skeleton from model. mdl's metadata should stick around */