Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2009-05-18 20:42:34 +0400
committerTon Roosendaal <ton@blender.org>2009-05-18 20:42:34 +0400
commit0cd511eee8039f9c0f59004329cff911693ac761 (patch)
tree9d7c0203b79db54d23412c61de97520452ba7c3a /source/blender
parentd128e1656169db09efb6cc11208cc98f5bbc54bc (diff)
2.5
Text drawing in 3D window fixed, using BLF default font (yes, nice AA'ed fonts too :) Solved it by gathering all strings that needs to be drawn for an object, and then draw in end of object drawing, in pixelspace. Also cleaned up some of the code for projecting 3d coords, much nicer now (mat stored in region-view3d)
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenfont/intern/blf.c2
-rw-r--r--source/blender/editors/include/ED_view3d.h3
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c3
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c12
-rw-r--r--source/blender/editors/space_view3d/drawobject.c260
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h8
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c71
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h4
9 files changed, 218 insertions, 153 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 10bbdb4851b..14bc6a33b72 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -138,7 +138,7 @@ int BLF_load(char *name)
filename= blf_dir_search(name);
if (!filename) {
- printf("Can't found font: %s\n", name);
+ printf("Can't find font: %s\n", name);
return(-1);
}
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index fbe6362db7c..38e52a8f59c 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -92,7 +92,7 @@ void viewray(struct ARegion *ar, struct View3D *v3d, short mval[2], float ray_st
int get_view3d_viewplane(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend, float *pixsize);
int get_view3d_ortho(struct View3D *v3d, struct RegionView3D *rv3d);
-void view3d_get_object_project_mat(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4], float vmat[4][4]);
+void view3d_get_object_project_mat(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]);
void view3d_project_float(struct ARegion *a, float *vec, float *adr, float mat[4][4]);
/* drawobject.c itterators */
@@ -123,7 +123,6 @@ short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigne
void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc);
void view3d_operator_needs_opengl(const struct bContext *C);
void view3d_get_view_aligned_coordinate(struct ViewContext *vc, float *fp, short mval[2]);
-void view3d_get_object_project_mat(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4], float vmat[4][4]);;
void view3d_get_transformation(struct ViewContext *vc, struct Object *ob, struct bglMats *mats);
/* XXX should move to arithb.c */
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 3035ff6d3a6..8818129d200 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -3829,7 +3829,7 @@ useless:
GHash *vertgh;
SlideVert *tempsv;
- float perc = 0, percp = 0,vertdist; // XXX, projectMat[4][4], viewMat[4][4];
+ float perc = 0, percp = 0,vertdist; // XXX, projectMat[4][4];
float shiftlabda= 0.0f,len = 0.0f;
int i = 0,j, numsel, numadded=0, timesthrough = 0, vertsel=0, prop=1, cancel = 0,flip=0;
int wasshift = 0;
@@ -3849,7 +3849,7 @@ useless:
// initNumInput(&num);
-// view3d_get_object_project_mat(curarea, obedit, projectMat, viewMat);
+// view3d_get_object_project_mat(curarea, obedit, projectMat);
mvalo[0] = -1; mvalo[1] = -1;
numsel =0;
@@ -4759,7 +4759,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
EditVert *eve, *nextve;
EditEdge *eed, *seed= NULL;
EditFace *efa, *sefa= NULL;
- float projectMat[4][4], vec[3], dist, mindist, viewMat[4][4];
+ float projectMat[4][4], vec[3], dist, mindist;
short doit= 1, *mval= event->mval; // XXX ,propmode,prop;
@@ -4771,7 +4771,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* select flush... vertices are important */
EM_selectmode_set(em);
- view3d_get_object_project_mat(rv3d, obedit, projectMat, viewMat);
+ view3d_get_object_project_mat(rv3d, obedit, projectMat);
/* find best face, exclude triangles and break on face select or faces with 2 edges select */
mindist= 1000000.0f;
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 22fb8e61789..77cd06581fd 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -276,7 +276,6 @@ typedef struct ProjPaintState {
float cloneOffset[2];
float projectMat[4][4]; /* Projection matrix, use for getting screen coords */
- float viewMat[4][4];
float viewDir[3]; /* View vector, use for do_backfacecull and for ray casting with an ortho viewport */
float viewPos[3]; /* View location in object relative 3D space, so can compare to verts */
float clipsta, clipend;
@@ -2971,7 +2970,7 @@ static void project_paint_begin(ProjPaintState *ps)
ps->viewDir[1] = 0.0f;
ps->viewDir[2] = 1.0f;
- view3d_get_object_project_mat(ps->rv3d, ps->ob, ps->projectMat, ps->viewMat);
+ view3d_get_object_project_mat(ps->rv3d, ps->ob, ps->projectMat);
/* viewDir - object relative */
Mat4Invert(ps->ob->imat, ps->ob->obmat);
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index dfdd70b11e7..68a9bf3f555 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -1805,8 +1805,7 @@ static void draw_pose_channels(Scene *scene, View3D *v3d, RegionView3D *rv3d, Ba
/* Draw names of bone */
if (arm->flag & ARM_DRAWNAMES) {
VecMidf(vec, pchan->pose_head, pchan->pose_tail);
- BLF_draw_default(vec[0], vec[1], vec[2], " ");
- BLF_draw_default(vec[0] + BLF_width_default(" "), vec[1], vec[2], pchan->name);
+ view3d_object_text_draw_add(vec[0], vec[1], vec[2], pchan->name, 10);
}
/* Draw additional axes on the bone tail */
@@ -1991,8 +1990,7 @@ static void draw_ebones(View3D *v3d, RegionView3D *rv3d, Object *ob, int dt)
if (arm->flag & ARM_DRAWNAMES) {
VecMidf(vec, eBone->head, eBone->tail);
glRasterPos3fv(vec);
- BLF_draw_default(vec[0], vec[1], vec[2], " ");
- BLF_draw_default(vec[0] + BLF_width_default(" "), vec[1], vec[2], eBone->name);
+ view3d_object_text_draw_add(vec[0], vec[1], vec[2], eBone->name, 10);
}
/* Draw additional axes */
if (arm->flag & ARM_DRAWAXES) {
@@ -2154,12 +2152,12 @@ static void draw_pose_paths(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
/* only draw framenum if several consecutive highlighted points don't occur on same point */
if (a == 0) {
sprintf(str, " %d\n", (a+sfra));
- BLF_draw_default(fp[0], fp[1], fp[2], str);
+ view3d_object_text_draw_add(fp[0], fp[1], fp[2], str, 0);
}
else if ((a > stepsize) && (a < len-stepsize)) {
if ((VecEqual(fp, fp-(stepsize*3))==0) || (VecEqual(fp, fp+(stepsize*3))==0)) {
sprintf(str, " %d\n", (a+sfra));
- BLF_draw_default(fp[0], fp[1], fp[2], str);
+ view3d_object_text_draw_add(fp[0], fp[1], fp[2], str, 0);
}
}
}
@@ -2202,7 +2200,7 @@ static void draw_pose_paths(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
char str[32];
sprintf(str, " %d\n", (a+sfra));
- BLF_draw_default(fp[0], fp[1], fp[2], str);
+ view3d_object_text_draw_add(fp[0], fp[1], fp[2], str, 0);
}
}
}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 3725fc24b6c..f2528f0241f 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -96,8 +96,9 @@
#include "GPU_material.h"
#include "GPU_extensions.h"
-#include "ED_particle.h"
#include "ED_mesh.h"
+#include "ED_particle.h"
+#include "ED_screen.h"
#include "ED_types.h"
#include "ED_util.h"
@@ -133,6 +134,74 @@ static void drawcircle_size(float size);
static void draw_empty_sphere(float size);
static void draw_empty_cone(float size);
+
+/* ************* only use while object drawing ************** */
+static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr)
+{
+ RegionView3D *rv3d= ar->regiondata;
+ float fx, fy, vec4[4];
+
+ adr[0]= IS_CLIPPED;
+
+ /* clipplanes in eye space */
+ if(rv3d->rflag & RV3D_CLIPPING) {
+ VECCOPY(vec4, vec);
+ Mat4MulVecfl(rv3d->viewmatob, vec4);
+ if(view3d_test_clipping(rv3d, vec4))
+ return;
+ }
+
+ VECCOPY(vec4, vec);
+ vec4[3]= 1.0;
+
+ Mat4MulVec4fl(rv3d->persmatob, vec4);
+
+ /* clipplanes in window space */
+ if( vec4[3]>BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */
+ fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]);
+
+ if( fx>0 && fx<ar->winx) {
+
+ fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]);
+
+ if(fy>0.0 && fy< (float)ar->winy) {
+ adr[0]= (short)floor(fx);
+ adr[1]= (short)floor(fy);
+ }
+ }
+ }
+}
+
+/* only use while object drawing */
+static void view3d_project_short_noclip(ARegion *ar, float *vec, short *adr)
+{
+ RegionView3D *rv3d= ar->regiondata;
+ float fx, fy, vec4[4];
+
+ adr[0]= IS_CLIPPED;
+
+ VECCOPY(vec4, vec);
+ vec4[3]= 1.0;
+
+ Mat4MulVec4fl(rv3d->persmatob, vec4);
+
+ if( vec4[3]>BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */
+ fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]);
+
+ if( fx>-32700 && fx<32700) {
+
+ fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]);
+
+ if(fy>-32700.0 && fy<32700.0) {
+ adr[0]= (short)floor(fx);
+ adr[1]= (short)floor(fy);
+ }
+ }
+ }
+}
+
+/* ************************ */
+
/* check for glsl drawing */
int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt)
@@ -364,11 +433,11 @@ void drawaxes(float size, int flag, char drawtype)
// patch for 3d cards crashing on glSelect for text drawing (IBM)
if((flag & DRAW_PICKING) == 0) {
if (axis==0)
- BLF_draw_default(v2[0], v2[1], v2[2], "x");
+ view3d_object_text_draw_add(v2[0], v2[1], v2[2], "x", 0);
else if (axis==1)
- BLF_draw_default(v2[0], v2[1], v2[2], "y");
+ view3d_object_text_draw_add(v2[0], v2[1], v2[2], "y", 0);
else
- BLF_draw_default(v2[0], v2[1], v2[2], "z");
+ view3d_object_text_draw_add(v2[0], v2[1], v2[2], "z", 0);
}
}
break;
@@ -426,6 +495,75 @@ static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, float *vec, int se
if(v3d->zbuf) glDepthFunc(GL_LEQUAL);
}
+/* *********** text drawing for object ************* */
+static ListBase strings= {NULL, NULL};
+
+typedef struct ViewObjectString {
+ struct ViewObjectString *next, *prev;
+ float vec[3], col[4];
+ char str[128];
+ short mval[2];
+ short xoffs;
+} ViewObjectString;
+
+
+void view3d_object_text_draw_add(float x, float y, float z, char *str, short xoffs)
+{
+ ViewObjectString *vos= MEM_callocN(sizeof(ViewObjectString), "ViewObjectString");
+
+ BLI_addtail(&strings, vos);
+ BLI_strncpy(vos->str, str, 128);
+ vos->vec[0]= x;
+ vos->vec[1]= y;
+ vos->vec[2]= z;
+ glGetFloatv(GL_CURRENT_COLOR, vos->col);
+ vos->xoffs= xoffs;
+}
+
+static void view3d_object_text_draw(View3D *v3d, ARegion *ar)
+{
+ ViewObjectString *vos;
+ int tot= 0;
+
+ /* project first and test */
+ for(vos= strings.first; vos; vos= vos->next) {
+ view3d_project_short_clip(ar, vos->vec, vos->mval);
+ if(vos->mval[0]!=IS_CLIPPED)
+ tot++;
+ }
+
+ if(tot) {
+ RegionView3D *rv3d= ar->regiondata;
+ int a;
+
+ if(rv3d->rflag & RV3D_CLIPPING)
+ for(a=0; a<6; a++)
+ glDisable(GL_CLIP_PLANE0+a);
+
+ wmPushMatrix();
+ ED_region_pixelspace(ar);
+
+ if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
+
+ for(vos= strings.first; vos; vos= vos->next) {
+ if(vos->mval[0]!=IS_CLIPPED) {
+ glColor3fv(vos->col);
+ BLF_draw_default((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], 0.0, vos->str);
+ }
+ }
+
+ if(v3d->zbuf) glEnable(GL_DEPTH_TEST);
+
+ wmPopMatrix();
+
+ if(rv3d->rflag & RV3D_CLIPPING)
+ for(a=0; a<6; a++)
+ glEnable(GL_CLIP_PLANE0+a);
+ }
+
+ if(strings.first)
+ BLI_freelistN(&strings);
+}
void drawsolidcube(float size)
{
@@ -1093,15 +1231,12 @@ void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPo
BPoint *bp = lt->editlatt->def;
DispList *dl = find_displist(&obedit->disp, DL_VERTS);
float *co = dl?dl->verts:NULL;
- float pmat[4][4], vmat[4][4];
int i, N = lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
short s[2] = {IS_CLIPPED, 0};
- view3d_get_object_project_mat(vc->rv3d, vc->obedit, pmat, vmat);
-
for (i=0; i<N; i++, bp++, co+=3) {
if (bp->hide==0) {
- view3d_project_short_clip(vc->ar, dl?co:bp->vec, s, pmat, vmat);
+ view3d_project_short_clip(vc->ar, dl?co:bp->vec, s);
if (s[0] != IS_CLIPPED)
func(userData, bp, s[0], s[1]);
}
@@ -1195,16 +1330,16 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
static void mesh_foreachScreenVert__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
{
- struct { void (*func)(void *userData, EditVert *eve, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; float pmat[4][4], vmat[4][4]; } *data = userData;
+ struct { void (*func)(void *userData, EditVert *eve, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; } *data = userData;
EditVert *eve = EM_get_vert_for_index(index);
if (eve->h==0) {
short s[2]= {IS_CLIPPED, 0};
if (data->clipVerts) {
- view3d_project_short_clip(data->vc.ar, co, s, data->pmat, data->vmat);
+ view3d_project_short_clip(data->vc.ar, co, s);
} else {
- view3d_project_short_noclip(data->vc.ar, co, s, data->pmat);
+ view3d_project_short_noclip(data->vc.ar, co, s);
}
if (s[0]!=IS_CLIPPED)
@@ -1214,7 +1349,7 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, float *co
void mesh_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, EditVert *eve, int x, int y, int index), void *userData, int clipVerts)
{
- struct { void (*func)(void *userData, EditVert *eve, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; float pmat[4][4], vmat[4][4]; } data;
+ struct { void (*func)(void *userData, EditVert *eve, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; } data;
DerivedMesh *dm = editmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
data.vc= *vc;
@@ -1222,8 +1357,6 @@ void mesh_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, EditVe
data.userData = userData;
data.clipVerts = clipVerts;
- view3d_get_object_project_mat(vc->rv3d, vc->obedit, data.pmat, data.vmat);
-
EM_init_index_arrays(vc->em, 1, 0, 0);
dm->foreachMappedVert(dm, mesh_foreachScreenVert__mapFunc, &data);
EM_free_index_arrays();
@@ -1233,17 +1366,17 @@ void mesh_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, EditVe
static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, float *v0co, float *v1co)
{
- struct { void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; float pmat[4][4], vmat[4][4]; } *data = userData;
+ struct { void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; } *data = userData;
EditEdge *eed = EM_get_edge_for_index(index);
short s[2][2];
if (eed->h==0) {
if (data->clipVerts==1) {
- view3d_project_short_clip(data->vc.ar, v0co, s[0], data->pmat, data->vmat);
- view3d_project_short_clip(data->vc.ar, v1co, s[1], data->pmat, data->vmat);
+ view3d_project_short_clip(data->vc.ar, v0co, s[0]);
+ view3d_project_short_clip(data->vc.ar, v1co, s[1]);
} else {
- view3d_project_short_noclip(data->vc.ar, v0co, s[0], data->pmat);
- view3d_project_short_noclip(data->vc.ar, v1co, s[1], data->pmat);
+ view3d_project_short_noclip(data->vc.ar, v0co, s[0]);
+ view3d_project_short_noclip(data->vc.ar, v1co, s[1]);
if (data->clipVerts==2) {
if (!(s[0][0]>=0 && s[0][1]>= 0 && s[0][0]<data->vc.ar->winx && s[0][1]<data->vc.ar->winy))
@@ -1258,7 +1391,7 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, float *v0
void mesh_foreachScreenEdge(ViewContext *vc, void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index), void *userData, int clipVerts)
{
- struct { void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; float pmat[4][4], vmat[4][4]; } data;
+ struct { void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; } data;
DerivedMesh *dm = editmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
data.vc= *vc;
@@ -1266,8 +1399,6 @@ void mesh_foreachScreenEdge(ViewContext *vc, void (*func)(void *userData, EditEd
data.userData = userData;
data.clipVerts = clipVerts;
- view3d_get_object_project_mat(vc->rv3d, vc->obedit, data.pmat, data.vmat);
-
EM_init_index_arrays(vc->em, 0, 1, 0);
dm->foreachMappedEdge(dm, mesh_foreachScreenEdge__mapFunc, &data);
EM_free_index_arrays();
@@ -1277,12 +1408,12 @@ void mesh_foreachScreenEdge(ViewContext *vc, void (*func)(void *userData, EditEd
static void mesh_foreachScreenFace__mapFunc(void *userData, int index, float *cent, float *no)
{
- struct { void (*func)(void *userData, EditFace *efa, int x, int y, int index); void *userData; ViewContext vc; float pmat[4][4], vmat[4][4]; } *data = userData;
+ struct { void (*func)(void *userData, EditFace *efa, int x, int y, int index); void *userData; ViewContext vc; } *data = userData;
EditFace *efa = EM_get_face_for_index(index);
short s[2];
if (efa && efa->h==0 && efa->fgonf!=EM_FGON) {
- view3d_project_short_clip(data->vc.ar, cent, s, data->pmat, data->vmat);
+ view3d_project_short_clip(data->vc.ar, cent, s);
data->func(data->userData, efa, s[0], s[1], index);
}
@@ -1290,15 +1421,13 @@ static void mesh_foreachScreenFace__mapFunc(void *userData, int index, float *ce
void mesh_foreachScreenFace(ViewContext *vc, void (*func)(void *userData, EditFace *efa, int x, int y, int index), void *userData)
{
- struct { void (*func)(void *userData, EditFace *efa, int x, int y, int index); void *userData; ViewContext vc; float pmat[4][4], vmat[4][4]; } data;
+ struct { void (*func)(void *userData, EditFace *efa, int x, int y, int index); void *userData; ViewContext vc; } data;
DerivedMesh *dm = editmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
data.vc= *vc;
data.func = func;
data.userData = userData;
- view3d_get_object_project_mat(vc->rv3d, vc->obedit, data.pmat, data.vmat);
-
EM_init_index_arrays(vc->em, 0, 0, 1);
dm->foreachMappedFaceCenter(dm, mesh_foreachScreenFace__mapFunc, &data);
EM_free_index_arrays();
@@ -1309,13 +1438,10 @@ void mesh_foreachScreenFace(ViewContext *vc, void (*func)(void *userData, EditFa
void nurbs_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), void *userData)
{
Curve *cu= vc->obedit->data;
- float pmat[4][4], vmat[4][4];
short s[2] = {IS_CLIPPED, 0};
Nurb *nu;
int i;
- view3d_get_object_project_mat(vc->rv3d, vc->obedit, pmat, vmat);
-
for (nu= cu->editnurb->first; nu; nu=nu->next) {
if((nu->type & 7)==CU_BEZIER) {
for (i=0; i<nu->pntsu; i++) {
@@ -1323,17 +1449,17 @@ void nurbs_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, Nurb
if(bezt->hide==0) {
if (G.f & G_HIDDENHANDLES) {
- view3d_project_short_clip(vc->ar, bezt->vec[1], s, pmat, vmat);
+ view3d_project_short_clip(vc->ar, bezt->vec[1], s);
if (s[0] != IS_CLIPPED)
func(userData, nu, NULL, bezt, 1, s[0], s[1]);
} else {
- view3d_project_short_clip(vc->ar, bezt->vec[0], s, pmat, vmat);
+ view3d_project_short_clip(vc->ar, bezt->vec[0], s);
if (s[0] != IS_CLIPPED)
func(userData, nu, NULL, bezt, 0, s[0], s[1]);
- view3d_project_short_clip(vc->ar, bezt->vec[1], s, pmat, vmat);
+ view3d_project_short_clip(vc->ar, bezt->vec[1], s);
if (s[0] != IS_CLIPPED)
func(userData, nu, NULL, bezt, 1, s[0], s[1]);
- view3d_project_short_clip(vc->ar, bezt->vec[2], s, pmat, vmat);
+ view3d_project_short_clip(vc->ar, bezt->vec[2], s);
if (s[0] != IS_CLIPPED)
func(userData, nu, NULL, bezt, 2, s[0], s[1]);
}
@@ -1345,7 +1471,7 @@ void nurbs_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, Nurb
BPoint *bp = &nu->bp[i];
if(bp->hide==0) {
- view3d_project_short_clip(vc->ar, bp->vec, s, pmat, vmat);
+ view3d_project_short_clip(vc->ar, bp->vec, s);
if (s[0] != IS_CLIPPED)
func(userData, nu, bp, NULL, -1, s[0], s[1]);
}
@@ -1826,7 +1952,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
}
sprintf(val, conv_float, VecLenf(v1, v2));
- BLF_draw_default(x, y, z, val);
+ view3d_object_text_draw_add(x, y, z, val, 0);
}
}
}
@@ -1861,7 +1987,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
area = AreaT3Dfl(v1, v2, v3);
sprintf(val, conv_float, area);
- BLF_draw_default(efa->cent[0], efa->cent[1], efa->cent[2], val);
+ view3d_object_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0);
}
}
}
@@ -1903,13 +2029,13 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
/* Vec 1 */
sprintf(val,"%.3f", VecAngle3(v4, v1, v2));
VecLerpf(fvec, efa->cent, efa->v1->co, 0.8);
- BLF_draw_default(efa->cent[0], efa->cent[1], efa->cent[2], val);
+ view3d_object_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0);
}
if( (e1->f & e2->f & SELECT) || (G.moving && (efa->v2->f & SELECT)) ) {
/* Vec 2 */
sprintf(val,"%.3f", VecAngle3(v1, v2, v3));
VecLerpf(fvec, efa->cent, efa->v2->co, 0.8);
- BLF_draw_default(fvec[0], fvec[1], fvec[2], val);
+ view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0);
}
if( (e2->f & e3->f & SELECT) || (G.moving && (efa->v3->f & SELECT)) ) {
/* Vec 3 */
@@ -1918,14 +2044,14 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
else
sprintf(val,"%.3f", VecAngle3(v2, v3, v1));
VecLerpf(fvec, efa->cent, efa->v3->co, 0.8);
- BLF_draw_default(fvec[0], fvec[1], fvec[2], val);
+ view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0);
}
/* Vec 4 */
if(efa->v4) {
if( (e3->f & e4->f & SELECT) || (G.moving && (efa->v4->f & SELECT)) ) {
sprintf(val,"%.3f", VecAngle3(v3, v4, v1));
VecLerpf(fvec, efa->cent, efa->v4->co, 0.8);
- BLF_draw_default(fvec[0], fvec[1], fvec[2], val);
+ view3d_object_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0);
}
}
}
@@ -3253,7 +3379,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if(part->draw&PART_DRAW_NUM && !(G.f & G_RENDER_SHADOW)){
/* in path drawing state.co is the end point */
sprintf(val," %i",a);
- BLF_draw_default(state.co[0], state.co[1], state.co[2], val);
+ view3d_object_text_draw_add(state.co[0], state.co[1], state.co[2], val, 0);
}
}
}
@@ -3569,7 +3695,7 @@ static void draw_particle_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Ob
if(key->flag & PEK_HIDE) continue;
sprintf(val," %.1f",*key->time);
- BLF_draw_default(key->world_co[0], key->world_co[1], key->world_co[2], val);
+ view3d_object_text_draw_add(key->world_co[0], key->world_co[1], key->world_co[2], val, 0);
}
}
}
@@ -3592,7 +3718,7 @@ static void draw_particle_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Ob
if((pset->flag & PE_SHOW_TIME) && !(G.f & G_RENDER_SHADOW)){
sprintf(val," %.1f",*key->time);
- BLF_draw_default(key->world_co[0], key->world_co[1], key->world_co[2], val);
+ view3d_object_text_draw_add(key->world_co[0], key->world_co[1], key->world_co[2], val, 0);
}
}
}
@@ -4605,24 +4731,24 @@ void drawRBpivot(bRigidBodyJointConstraint *data)
glLineWidth (4.0f);
setlinestyle(2);
for (axis=0; axis<3; axis++) {
- float dir[3] = {0,0,0};
- float v[3]= {data->pivX, data->pivY, data->pivZ};
+ float dir[3] = {0,0,0};
+ float v[3]= {data->pivX, data->pivY, data->pivZ};
- dir[axis] = 1.f;
- glBegin(GL_LINES);
- Mat4MulVecfl(mat,dir);
- v[0] += dir[0];
- v[1] += dir[1];
- v[2] += dir[2];
- glVertex3fv(v1);
- glVertex3fv(v);
- glEnd();
- if (axis==0)
- BLF_draw_default(v[0], v[1], v[2], "px");
- else if (axis==1)
- BLF_draw_default(v[0], v[1], v[2], "py");
- else
- BLF_draw_default(v[0], v[1], v[2], "pz");
+ dir[axis] = 1.f;
+ glBegin(GL_LINES);
+ Mat4MulVecfl(mat,dir);
+ v[0] += dir[0];
+ v[1] += dir[1];
+ v[2] += dir[2];
+ glVertex3fv(v1);
+ glVertex3fv(v);
+ glEnd();
+ if (axis==0)
+ view3d_object_text_draw_add(v[0], v[1], v[2], "px", 0);
+ else if (axis==1)
+ view3d_object_text_draw_add(v[0], v[1], v[2], "py", 0);
+ else
+ view3d_object_text_draw_add(v[0], v[1], v[2], "pz", 0);
}
glLineWidth (1.0f);
setlinestyle(0);
@@ -4743,7 +4869,11 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
/* patch? children objects with a timeoffs change the parents. How to solve! */
/* if( ((int)ob->ctime) != F_(scene->r.cfra)) where_is_object(scene, ob); */
+ /* multiply view with object matrix */
wmMultMatrix(ob->obmat);
+ /* local viewmat and persmat, to calculate projections */
+ wmGetMatrix(rv3d->viewmatob);
+ wmGetSingleMatrix(rv3d->persmatob);
/* which wire color */
if((flag & DRAW_CONSTCOLOR) == 0) {
@@ -5041,10 +5171,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
/* patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing */
/* but, we also dont draw names for sets or duplicators */
if(flag == 0) {
- if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
- BLF_draw_default(0.0, 0.0, 0.0, " ");
- BLF_draw_default(0.0 + BLF_width_default(" "), 0.0, 0.0, ob->id.name+2);
- if(v3d->zbuf) glEnable(GL_DEPTH_TEST);
+ view3d_object_text_draw_add(0.0f, 0.0f, 0.0f, ob->id.name+2, 10);
}
}
/*if(dtx & OB_DRAWIMAGE) drawDispListwire(&ob->disp);*/
@@ -5065,6 +5192,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
setlinestyle(0);
}
}
+
+ /* return warning, this is cached text draw */
+ view3d_object_text_draw(v3d, ar);
wmLoadMatrix(rv3d->viewmat);
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 58ed8e9ba11..9f162c5327b 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -43,6 +43,8 @@ struct wmWindowManager;
struct EditMesh;
struct ViewContext;
+#define BL_NEAR_CLIP 0.001
+
/* drawing flags: */
#define DRAW_PICKING 1
#define DRAW_CONSTCOLOR 2
@@ -86,6 +88,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt);
void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, int dt, int outline);
void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob);
void drawaxes(float size, int flag, char drawtype);
+void view3d_object_text_draw_add(float x, float y, float z, char *str, short xoffs);
/* drawarmature.c */
int draw_armature(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag);
@@ -119,11 +122,6 @@ void VIEW3D_OT_localview(struct wmOperatorType *ot);
int boundbox_clip(RegionView3D *rv3d, float obmat[][4], struct BoundBox *bb);
-void view3d_project_short_clip(struct ARegion *ar, float *vec, short *adr, float projmat[4][4], float wmat[4][4]);
-void view3d_project_short_noclip(struct ARegion *ar, float *vec, short *adr, float mat[4][4]);
-
-void view3d_project_float(struct ARegion *a, float *vec, float *adr, float mat[4][4]);
-
void centerview(struct ARegion *ar, View3D *v3d);
void smooth_view(struct bContext *C, Object *, Object *, float *ofs, float *quat, float *dist, float *lens);
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 2aade74dcca..06e5f69bbdf 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -80,9 +80,6 @@
#include "view3d_intern.h" // own include
-#define BL_NEAR_CLIP 0.001
-
-
/* use this call when executing an operator,
event system doesn't set for each event the
@@ -536,76 +533,16 @@ void request_depth_update(RegionView3D *rv3d)
rv3d->depths->damaged= 1;
}
-void view3d_get_object_project_mat(RegionView3D *rv3d, Object *ob, float pmat[4][4], float vmat[4][4])
+void view3d_get_object_project_mat(RegionView3D *rv3d, Object *ob, float pmat[4][4])
{
+ float vmat[4][4];
+
Mat4MulMat4(vmat, ob->obmat, rv3d->viewmat);
Mat4MulMat4(pmat, vmat, rv3d->winmat);
- Mat4CpyMat4(vmat, ob->obmat);
-}
-
-/* projectmat brings it to window coords, wmat to rotated world space */
-void view3d_project_short_clip(ARegion *ar, float *vec, short *adr, float projmat[4][4], float wmat[4][4])
-{
- RegionView3D *rv3d= ar->regiondata;
- float fx, fy, vec4[4];
-
- adr[0]= IS_CLIPPED;
-
- /* clipplanes in eye space */
- if(rv3d->rflag & RV3D_CLIPPING) {
- VECCOPY(vec4, vec);
- Mat4MulVecfl(wmat, vec4);
- if(view3d_test_clipping(rv3d, vec4))
- return;
- }
-
- VECCOPY(vec4, vec);
- vec4[3]= 1.0;
-
- Mat4MulVec4fl(projmat, vec4);
-
- /* clipplanes in window space */
- if( vec4[3]>BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */
- fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]);
-
- if( fx>0 && fx<ar->winx) {
-
- fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]);
-
- if(fy>0.0 && fy< (float)ar->winy) {
- adr[0]= (short)floor(fx);
- adr[1]= (short)floor(fy);
- }
- }
- }
}
-void view3d_project_short_noclip(ARegion *ar, float *vec, short *adr, float mat[4][4])
-{
- float fx, fy, vec4[4];
-
- adr[0]= IS_CLIPPED;
-
- VECCOPY(vec4, vec);
- vec4[3]= 1.0;
-
- Mat4MulVec4fl(mat, vec4);
-
- if( vec4[3]>BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */
- fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]);
-
- if( fx>-32700 && fx<32700) {
-
- fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]);
-
- if(fy>-32700.0 && fy<32700.0) {
- adr[0]= (short)floor(fx);
- adr[1]= (short)floor(fy);
- }
- }
- }
-}
+/* use above call to get projecting mat */
void view3d_project_float(ARegion *ar, float *vec, float *adr, float mat[4][4])
{
float vec4[4];
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 5d9aac45102..e546038902f 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -79,6 +79,10 @@ typedef struct RegionView3D {
float persmat[4][4];
float persinv[4][4];
+ /* local viewmat/persmat, multiplied with object matrix, while drawing */
+ float viewmatob[4][4];
+ float persmatob[4][4];
+
float viewquat[4], dist, zfac; /* zfac is initgrabz() result */
float camdx, camdy; /* camera view offsets, 1.0 = viewplane moves entire width/height */
float pixsize;