worldspace text locations & made some improvements to string formatting for particle...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 3 Mar 2010 11:23:59 +0000 (11:23 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 3 Mar 2010 11:23:59 +0000 (11:23 +0000)
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_intern.h

index 697fe478602e5cd3e237f1538715e8430b5420a5..b594fba90b94fa4062cf4b490ca7b7afb171f262 100644 (file)
@@ -544,7 +544,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
        
        /* project first and test */
        for(vos= strings->first; vos; vos= vos->next) {
-               if(mat)
+               if(mat && !(vos->flag & V3D_CACHE_TEXT_WORLDSPACE))
                        mul_m4_v3(mat, vos->vec);
                view3d_project_short_clip(ar, vos->vec, vos->mval, 0);
                if(vos->mval[0]!=IS_CLIPPED)
@@ -3693,22 +3693,19 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                                        setlinestyle(0);
                                }
 
-                               if((part->draw&PART_DRAW_NUM || part->draw&PART_DRAW_HEALTH) && !(G.f & G_RENDER_SHADOW)){
+                               if((part->draw & PART_DRAW_NUM || part->draw & PART_DRAW_HEALTH) && !(G.f & G_RENDER_SHADOW)){
+                                       char *val_pos= val;
                                        val[0]= '\0';
-                                       
+
                                        if(part->draw&PART_DRAW_NUM)
-                                               sprintf(val, " %i", a);
+                                               val_pos += sprintf(val, "%i", a);
 
-                                       if(part->draw&PART_DRAW_NUM && part->draw&PART_DRAW_HEALTH)
-                                               strcat(val, ":");
+                                       if((part->draw & PART_DRAW_HEALTH) && a < totpart && part->phystype==PART_PHYS_BOIDS)
+                                               sprintf(val_pos, (val_pos==val) ? "%.2f" : ":%.2f", pa_health);
 
-                                       if(part->draw&PART_DRAW_HEALTH && a < totpart && part->phystype==PART_PHYS_BOIDS) {
-                                               char tval[8];
-                                               sprintf(tval, " %.2f", pa_health);
-                                               strcat(val, tval);
-                                       }
                                        /* in path drawing state.co is the end point */
-                                       view3d_cached_text_draw_add(state.co[0],  state.co[1],  state.co[2], val, 0, 0);
+                                       /* use worldspace beause object matrix is alredy applied */
+                                       view3d_cached_text_draw_add(state.co[0],  state.co[1],  state.co[2], val, 10, V3D_CACHE_TEXT_WORLDSPACE);
                                }
                        }
                }
index 9757a13fc536abfe751a426545829eedff7cd79e..d56d70d1fbc95e10c48d4a3f2ac01fa0a0c9b90e 100644 (file)
@@ -110,6 +110,7 @@ void view3d_cached_text_draw_begin(void);
 void view3d_cached_text_draw_add(float x, float y, float z, char *str, short xoffs, short flag);
 void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, float mat[][4]);
 #define V3D_CACHE_TEXT_ZBUF 1
+#define V3D_CACHE_TEXT_WORLDSPACE 2
 
 /* drawarmature.c */
 int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag);