[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17989] branches/blender2.5/blender/source : 2.5
Ton Roosendaal
ton at blender.org
Sun Dec 21 12:05:44 CET 2008
Revision: 17989
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17989
Author: ton
Date: 2008-12-21 12:05:43 +0100 (Sun, 21 Dec 2008)
Log Message:
-----------
2.5
- View3D: added ALT+B clipping operator. Note this needs a call to
the new function view3d_operator_needs_opengl(C) to ensure you
can use opengl functions. Event handling by default doesn't set
opengl per subwindow, it's also forbidden to draw then!
We might consider to tag operators that need opengl...
- Forgot to include creator.c fix for loading builtin vector font
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h
branches/blender2.5/blender/source/blender/editors/screen/glutil.c
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_select.c
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_view.c
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c
branches/blender2.5/blender/source/creator/creator.c
Modified: branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h 2008-12-21 10:56:14 UTC (rev 17988)
+++ branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h 2008-12-21 11:05:43 UTC (rev 17989)
@@ -44,15 +44,6 @@
void fdrawXORellipse(float xofs, float yofs, float hw, float hh);
void fdrawXORcirc(float xofs, float yofs, float rad);
- /**
- * Draw an XOR'd line in the front buffer between
- * the given points.
- *
- * @attention This function also handles flushing the GL
- * pipeline, which means it is inappropriate for drawing
- * a large number of lines at once.
- */
-void glutil_draw_front_xor_line(int x0, int y0, int x1, int y1);
/**
* Draw a lined (non-looping) arc with the given
Modified: branches/blender2.5/blender/source/blender/editors/screen/glutil.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/glutil.c 2008-12-21 10:56:14 UTC (rev 17988)
+++ branches/blender2.5/blender/source/blender/editors/screen/glutil.c 2008-12-21 11:05:43 UTC (rev 17989)
@@ -199,17 +199,6 @@
set_inverted_drawing(0);
}
-void glutil_draw_front_xor_line(int x0, int y0, int x1, int y1)
-{
- glReadBuffer(GL_FRONT);
- glDrawBuffer(GL_FRONT);
- sdrawXORline(x0, y0, x1, y1);
- glFlush();
- glReadBuffer(GL_BACK);
- glDrawBuffer(GL_BACK);
-
-}
-
void sdrawXORline4(int nr, int x0, int y0, int x1, int y1)
{
static short old[4][2][2];
Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c 2008-12-21 10:56:14 UTC (rev 17988)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c 2008-12-21 11:05:43 UTC (rev 17989)
@@ -117,7 +117,6 @@
void play_anim(int x) {}
void add_blockhandler(void *x, int y, int z) {}
void toggle_blockhandler(void *x, int y, int z) {}
-void view3d_edit_clipping(void *x);
void view3d_border_zoom(void);
void selectlinks(void) {}
void countall(void) {}
@@ -563,7 +562,7 @@
add_blockhandler(sa, VIEW3D_HANDLER_PROPERTIES, UI_PNL_UNSTOW);
break;
case 17: /* Set Clipping Border */
- view3d_edit_clipping(v3d);
+ WM_operator_call(C, "ED_VIEW3D_OT_clipping", WM_OP_REGION_WIN, NULL);
break;
case 18: /* render preview */
toggle_blockhandler(sa, VIEW3D_HANDLER_PREVIEW, 0);
Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h 2008-12-21 10:56:14 UTC (rev 17988)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h 2008-12-21 11:05:43 UTC (rev 17989)
@@ -73,8 +73,6 @@
void ED_VIEW3D_OT_viewrotate(struct wmOperatorType *ot);
void ED_VIEW3D_OT_viewhome(struct wmOperatorType *ot);
void ED_VIEW3D_OT_viewcenter(struct wmOperatorType *ot);
-void ED_VIEW3D_OT_select(struct wmOperatorType *ot);
-void ED_VIEW3D_OT_borderselect(struct wmOperatorType *ot);
/* drawobject.c */
void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag);
@@ -108,7 +106,13 @@
void circ(float x, float y, float rad);
void view3d_update_depths(ARegion *ar, View3D *v3d);
+/* view3d_select.c */
+void ED_VIEW3D_OT_clipping(struct wmOperatorType *ot);
+void ED_VIEW3D_OT_select(struct wmOperatorType *ot);
+void ED_VIEW3D_OT_borderselect(struct wmOperatorType *ot);
+
/* view3d_view.c */
+void view3d_operator_needs_opengl(const struct bContext *C);
float *give_cursor(Scene *scene, View3D *v3d);
void viewline(ARegion *ar, View3D *v3d, short mval[2], float ray_start[3], float ray_end[3]);
void viewray(ARegion *ar, View3D *v3d, short mval[2], float ray_start[3], float ray_normal[3]);
Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c 2008-12-21 10:56:14 UTC (rev 17988)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c 2008-12-21 11:05:43 UTC (rev 17989)
@@ -68,6 +68,8 @@
WM_operatortype_append(ED_VIEW3D_OT_viewcenter);
WM_operatortype_append(ED_VIEW3D_OT_select);
WM_operatortype_append(ED_VIEW3D_OT_borderselect);
+ WM_operatortype_append(ED_VIEW3D_OT_clipping);
+
}
void view3d_keymap(wmWindowManager *wm)
@@ -89,6 +91,7 @@
WM_keymap_add_item(keymap, "ED_VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ED_VIEW3D_OT_borderselect", BKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "ED_VIEW3D_OT_clipping", BKEY, KM_PRESS, KM_ALT, 0);
}
Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_select.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_select.c 2008-12-21 10:56:14 UTC (rev 17988)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_select.c 2008-12-21 11:05:43 UTC (rev 17989)
@@ -1673,14 +1673,12 @@
ot->poll= ED_operator_areaactive;
-
/* rna */
RNA_def_property(ot->srna, "event_type", PROP_INT, PROP_NONE);
RNA_def_property(ot->srna, "xmin", PROP_INT, PROP_NONE);
RNA_def_property(ot->srna, "xmax", PROP_INT, PROP_NONE);
RNA_def_property(ot->srna, "ymin", PROP_INT, PROP_NONE);
RNA_def_property(ot->srna, "ymax", PROP_INT, PROP_NONE);
-
}
@@ -2019,74 +2017,106 @@
smooth_view(v3d, new_ofs, NULL, &new_dist, NULL);
}
+/* ********************* set clipping operator ****************** */
-void view3d_edit_clipping(ARegion *ar, View3D *v3d)
+static int view3d_clipping_exec(bContext *C, wmOperator *op)
{
+ ScrArea *sa= CTX_wm_area(C);
+ View3D *v3d= sa->spacedata.first;
+ rcti rect;
+ double mvmatrix[16];
+ double projmatrix[16];
+ double xs, ys, p[3];
+ GLint viewport[4];
+ short val;
+ rect.xmin= RNA_int_get(op->ptr, "xmin");
+ rect.ymin= RNA_int_get(op->ptr, "ymin");
+ rect.xmax= RNA_int_get(op->ptr, "xmax");
+ rect.ymax= RNA_int_get(op->ptr, "ymax");
+
+ v3d->flag |= V3D_CLIPPING;
+ v3d->clipbb= MEM_callocN(sizeof(BoundBox), "clipbb");
+
+ /* note; otherwise opengl won't work */
+ view3d_operator_needs_opengl(C);
+
+ /* Get the matrices needed for gluUnProject */
+ glGetIntegerv(GL_VIEWPORT, viewport);
+ glGetDoublev(GL_MODELVIEW_MATRIX, mvmatrix);
+ glGetDoublev(GL_PROJECTION_MATRIX, projmatrix);
+
+ /* near zero floating point values can give issues with gluUnProject
+ in side view on some implementations */
+ if(fabs(mvmatrix[0]) < 1e-6) mvmatrix[0]= 0.0;
+ if(fabs(mvmatrix[5]) < 1e-6) mvmatrix[5]= 0.0;
+
+ /* Set up viewport so that gluUnProject will give correct values */
+ viewport[0] = 0;
+ viewport[1] = 0;
+
+ /* four clipping planes and bounding volume */
+ /* first do the bounding volume */
+ for(val=0; val<4; val++) {
+
+ xs= (val==0||val==3)?rect.xmin:rect.xmax;
+ ys= (val==0||val==1)?rect.ymin:rect.ymax;
+
+ gluUnProject(xs, ys, 0.0, mvmatrix, projmatrix, viewport, &p[0], &p[1], &p[2]);
+ VECCOPY(v3d->clipbb->vec[val], p);
+
+ gluUnProject(xs, ys, 1.0, mvmatrix, projmatrix, viewport, &p[0], &p[1], &p[2]);
+ VECCOPY(v3d->clipbb->vec[4+val], p);
+ }
+
+ /* then plane equations */
+ for(val=0; val<4; val++) {
+
+ CalcNormFloat(v3d->clipbb->vec[val], v3d->clipbb->vec[val==3?0:val+1], v3d->clipbb->vec[val+4],
+ v3d->clip[val]);
+
+ v3d->clip[val][3]= - v3d->clip[val][0]*v3d->clipbb->vec[val][0]
+ - v3d->clip[val][1]*v3d->clipbb->vec[val][1]
+ - v3d->clip[val][2]*v3d->clipbb->vec[val][2];
+ }
+ return OPERATOR_FINISHED;
+}
+
+static int view3d_clipping_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ ScrArea *sa= CTX_wm_area(C);
+ View3D *v3d= sa->spacedata.first;
+
if(v3d->flag & V3D_CLIPPING) {
v3d->flag &= ~V3D_CLIPPING;
- ED_region_tag_redraw(ar);
+ ED_area_tag_redraw(sa);
if(v3d->clipbb) MEM_freeN(v3d->clipbb);
v3d->clipbb= NULL;
+ return OPERATOR_FINISHED;
}
else {
- rcti rect;
- double mvmatrix[16];
- double projmatrix[16];
- double xs, ys, p[3];
- GLint viewport[4];
- short val;
-
- /* get border in window coords */
- setlinestyle(2);
- val= 0; // XX get_border(&rect, 3);
- setlinestyle(0);
- if(val==0) return;
-
- v3d->flag |= V3D_CLIPPING;
- v3d->clipbb= MEM_callocN(sizeof(BoundBox), "clipbb");
-
- /* convert border to 3d coordinates */
-
- /* Get the matrices needed for gluUnProject */
- glGetIntegerv(GL_VIEWPORT, viewport);
- glGetDoublev(GL_MODELVIEW_MATRIX, mvmatrix);
- glGetDoublev(GL_PROJECTION_MATRIX, projmatrix);
-
- /* near zero floating point values can give issues with gluUnProject
- in side view on some implementations */
- if(fabs(mvmatrix[0]) < 1e-6) mvmatrix[0]= 0.0;
- if(fabs(mvmatrix[5]) < 1e-6) mvmatrix[5]= 0.0;
-
- /* Set up viewport so that gluUnProject will give correct values */
- viewport[0] = 0;
- viewport[1] = 0;
-
- /* four clipping planes and bounding volume */
- /* first do the bounding volume */
- for(val=0; val<4; val++) {
-
- xs= (val==0||val==3)?rect.xmin:rect.xmax;
- ys= (val==0||val==1)?rect.ymin:rect.ymax;
-
- gluUnProject(xs, ys, 0.0, mvmatrix, projmatrix, viewport, &p[0], &p[1], &p[2]);
- VECCOPY(v3d->clipbb->vec[val], p);
-
- gluUnProject(xs, ys, 1.0, mvmatrix, projmatrix, viewport, &p[0], &p[1], &p[2]);
- VECCOPY(v3d->clipbb->vec[4+val], p);
- }
-
- /* then plane equations */
- for(val=0; val<4; val++) {
-
- CalcNormFloat(v3d->clipbb->vec[val], v3d->clipbb->vec[val==3?0:val+1], v3d->clipbb->vec[val+4],
- v3d->clip[val]);
-
- v3d->clip[val][3]= - v3d->clip[val][0]*v3d->clipbb->vec[val][0]
- - v3d->clip[val][1]*v3d->clipbb->vec[val][1]
- - v3d->clip[val][2]*v3d->clipbb->vec[val][2];
- }
+ return WM_border_select_invoke(C, op, event);
}
}
-
+/* toggles */
+void ED_VIEW3D_OT_clipping(wmOperatorType *ot)
+{
+
+ /* identifiers */
+ ot->name= "Border Select";
+ ot->idname= "ED_VIEW3D_OT_clipping";
+
+ /* api callbacks */
+ ot->invoke= view3d_clipping_invoke;
+ ot->exec= view3d_clipping_exec;
+ ot->modal= WM_border_select_modal;
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list