doxygen: blender/editors tagged.
[blender.git] / source / blender / editors / space_view3d / drawanimviz.c
index 3913a6c7a16939944c299462eec372b38623f7f7..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>
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "MEM_guardedalloc.h"
+#include "BLO_sys_types.h"
 
 #include "DNA_anim_types.h"
-#include "DNA_action_types.h"
 #include "DNA_armature_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_ID.h"
-#include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
-#include "DNA_space_types.h"
 #include "DNA_view3d_types.h"
-#include "DNA_userdef_types.h"
+#include "DNA_object_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 #include "BLI_dlrbTree.h"
 
-#include "BKE_anim.h"
 #include "BKE_animsys.h"
 #include "BKE_action.h"
-#include "BKE_armature.h"
-#include "BKE_constraint.h"
-#include "BKE_context.h"
-#include "BKE_depsgraph.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_modifier.h"
-#include "BKE_nla.h"
-#include "BKE_object.h"
-#include "BKE_utildefines.h"
 
 #include "BIF_gl.h"
-#include "BIF_glutil.h"
 
 #include "ED_armature.h"
-#include "ED_anim_api.h"
 #include "ED_keyframes_draw.h"
 
-#include "WM_api.h"
-#include "WM_types.h"
 #include "BLF_api.h"
 
 #include "UI_resources.h"
@@ -90,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;
        
@@ -104,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;
@@ -212,15 +191,39 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
                glVertex3fv(mpv->co);
        glEnd();
        
+       /* Draw big green dot where the current frame is */
+       // NOTE: only do this when drawing keyframes for now... 
+       if (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) {
+               UI_ThemeColor(TH_CFRAME);
+               glPointSize(6.0f);
+               
+               glBegin(GL_POINTS);
+                       mpv = mpv_start + (CFRA - sfra);
+                       glVertex3fv(mpv->co);
+               glEnd();
+               
+               glPointSize(1.0f);
+               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);
+                               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);
@@ -228,14 +231,17 @@ 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);
+                                       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);
                                }
                        }
                }
        }
-
+       
        /* Keyframes - dots and numbers */
-       if (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) {
+       if (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) {
+               unsigned char col[4];
+
                AnimData *adt= BKE_animdata_from_id(&ob->id);
                DLRBT_Tree keys;
                
@@ -243,8 +249,10 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
                BLI_dlrbTree_init(&keys);
                
                if (adt) {
-                       /* for now, it is assumed that keyframes for bones are all grouped in a single group */
-                       if (pchan) {
+                       /* it is assumed that keyframes for bones are all grouped in a single group
+                        * unless an option is set to always use the whole action
+                        */
+                       if ((pchan) && (avs->path_viewflag & MOTIONPATH_VIEW_KFACT)==0) {
                                bActionGroup *agrp= action_groups_find_named(adt->action, pchan->name);
                                
                                if (agrp) {
@@ -259,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++) {
@@ -274,7 +285,8 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
                glPointSize(1.0f);
                
                /* Draw frame numbers of keyframes  */
-               if (avs->path_viewflag & MOTIONPATH_VIEW_FNUMS) {
+               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);
                                
@@ -282,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);
+                                       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);
                                }
                        }
                }
@@ -292,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();