doxygen: blender/editors tagged.
[blender.git] / source / blender / editors / space_view3d / drawanimviz.c
index fb271556a9cf8ba27339c15d74f1bc5c54915977..ee78fd92b79a5e61dfff8edf0046af3db4813472 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  * ***** END GPL LICENSE BLOCK *****
  */
 
+/** \file blender/editors/space_view3d/drawanimviz.c
+ *  \ingroup spview3d
+ */
+
+
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
 
+#include "BLO_sys_types.h"
 
 #include "DNA_anim_types.h"
 #include "DNA_armature_types.h"
@@ -64,7 +70,7 @@
 //     - include support for editing the path verts
 
 /* Set up drawing environment for drawing motion paths */
-void draw_motion_paths_init(Scene *scene, View3D *v3d, ARegion *ar) 
+void draw_motion_paths_init(View3D *v3d, ARegion *ar) 
 {
        RegionView3D *rv3d= ar->regiondata;
        
@@ -78,8 +84,7 @@ void draw_motion_paths_init(Scene *scene, View3D *v3d, ARegion *ar)
  *     - assumes that the viewport has already been initialised properly
  *             i.e. draw_motion_paths_init() has been called
  */
-// FIXME: the text is still drawn in the wrong space - it includes the current transforms of the object still...
-void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar, 
+void draw_motion_path_instance(Scene *scene, 
                        Object *ob, bPoseChannel *pchan, bAnimVizSettings *avs, bMotionPath *mpath)
 {
        //RegionView3D *rv3d= ar->regiondata;
@@ -201,15 +206,24 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
                UI_ThemeColor(TH_TEXT_HI);
        }
        
+       // XXX, this isnt up to date but probably should be kept so.
+       invert_m4_m4(ob->imat, ob->obmat);
+       
        /* Draw frame numbers at each framestep value */
        if (avs->path_viewflag & MOTIONPATH_VIEW_FNUMS) {
+               unsigned char col[4];
+               UI_GetThemeColor3ubv(TH_TEXT_HI, col);
+               col[3]= 255;
+
                for (i=0, mpv=mpv_start; i < len; i+=stepsize, mpv+=stepsize) {
                        char str[32];
+                       float co[3];
                        
                        /* only draw framenum if several consecutive highlighted points don't occur on same point */
                        if (i == 0) {
                                sprintf(str, "%d", (i+sfra));
-                               view3d_cached_text_draw_add(mpv->co[0], mpv->co[1], mpv->co[2], str, 0, 0);
+                               mul_v3_m4v3(co, ob->imat, mpv->co);
+                               view3d_cached_text_draw_add(co, str, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col);
                        }
                        else if ((i > stepsize) && (i < len-stepsize)) { 
                                bMotionPathVert *mpvP = (mpv - stepsize);
@@ -217,7 +231,8 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
                                
                                if ((equals_v3v3(mpv->co, mpvP->co)==0) || (equals_v3v3(mpv->co, mpvN->co)==0)) {
                                        sprintf(str, "%d", (sfra+i));
-                                       view3d_cached_text_draw_add(mpv->co[0], mpv->co[1], mpv->co[2], str, 0, 0);
+                                       mul_v3_m4v3(co, ob->imat, mpv->co);
+                                       view3d_cached_text_draw_add(co, str, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col);
                                }
                        }
                }
@@ -225,6 +240,8 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
        
        /* Keyframes - dots and numbers */
        if (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) {
+               unsigned char col[4];
+
                AnimData *adt= BKE_animdata_from_id(&ob->id);
                DLRBT_Tree keys;
                
@@ -250,8 +267,11 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
                }
                
                /* Draw slightly-larger yellow dots at each keyframe */
-               UI_ThemeColor(TH_VERTEX_SELECT);
+               UI_GetThemeColor3ubv(TH_VERTEX_SELECT, col);
+               col[3]= 255;
+
                glPointSize(4.0f); // XXX perhaps a bit too big
+               glColor3ubv(col);
                
                glBegin(GL_POINTS);
                for (i=0, mpv=mpv_start; i < len; i++, mpv++) {
@@ -266,6 +286,7 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
                
                /* Draw frame numbers of keyframes  */
                if (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) {
+                       float co[3];
                        for (i=0, mpv=mpv_start; i < len; i++, mpv++) {
                                float mframe= (float)(sfra + i);
                                
@@ -273,7 +294,8 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
                                        char str[32];
                                        
                                        sprintf(str, "%d", (sfra+i));
-                                       view3d_cached_text_draw_add(mpv->co[0], mpv->co[1], mpv->co[2], str, 0, 0);
+                                       mul_v3_m4v3(co, ob->imat, mpv->co);
+                                       view3d_cached_text_draw_add(co, str, 0, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, col);
                                }
                        }
                }
@@ -283,7 +305,7 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
 }
 
 /* Clean up drawing environment after drawing motion paths */
-void draw_motion_paths_cleanup(Scene *scene, View3D *v3d, ARegion *ar)
+void draw_motion_paths_cleanup(View3D *v3d)
 {
        if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
        glPopMatrix();