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
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2008-12-21 14:05:43 +0300
committerTon Roosendaal <ton@blender.org>2008-12-21 14:05:43 +0300
commit841f376a1c2b5dfef22e02696d5ad2ba053ecfbe (patch)
tree9983016e996284a49351f4608721e09f8d367734 /source
parentf44d8c2780c08fb96461daf831789c59242fcaa2 (diff)
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
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/BIF_glutil.h9
-rw-r--r--source/blender/editors/screen/glutil.c11
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h8
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c152
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c23
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c4
-rw-r--r--source/creator/creator.c4
9 files changed, 128 insertions, 89 deletions
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index 6364b8bf1af..0d34c122392 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -44,15 +44,6 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1);
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
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index d500c9f37c1..bead9a6399f 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -199,17 +199,6 @@ void sdrawXORline(int x0, int y0, int x1, int y1)
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];
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 9838976a10c..674291e7e5d 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -117,7 +117,6 @@ void editmesh_align_view_to_selected(void *x, int y) {}
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 @@ static void do_view3d_viewmenu(bContext *C, void *arg, int event)
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);
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index ec7138a190b..f6b3bd0ced0 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -73,8 +73,6 @@ void ED_VIEW3D_OT_viewmove(struct wmOperatorType *ot);
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 circf(float x, float y, float rad);
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]);
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index bd818f6c747..92564d8b20b 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -68,6 +68,8 @@ void view3d_operatortypes(void)
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 @@ void view3d_keymap(wmWindowManager *wm)
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);
}
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 9d0616d4f54..351dfad4cc5 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -1673,14 +1673,12 @@ void ED_VIEW3D_OT_borderselect(wmOperatorType *ot)
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 @@ void view3d_border_zoom(Scene *scene, ARegion *ar, View3D *v3d)
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;
- if(v3d->flag & V3D_CLIPPING) {
- v3d->flag &= ~V3D_CLIPPING;
- ED_region_tag_redraw(ar);
- if(v3d->clipbb) MEM_freeN(v3d->clipbb);
- v3d->clipbb= NULL;
- }
- 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");
+ 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++) {
- /* convert border to 3d coordinates */
+ xs= (val==0||val==3)?rect.xmin:rect.xmax;
+ ys= (val==0||val==1)?rect.ymin:rect.ymax;
- /* 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;
+ gluUnProject(xs, ys, 0.0, mvmatrix, projmatrix, viewport, &p[0], &p[1], &p[2]);
+ VECCOPY(v3d->clipbb->vec[val], p);
- /* Set up viewport so that gluUnProject will give correct values */
- viewport[0] = 0;
- viewport[1] = 0;
+ 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++) {
- /* 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);
- }
+ CalcNormFloat(v3d->clipbb->vec[val], v3d->clipbb->vec[val==3?0:val+1], v3d->clipbb->vec[val+4],
+ v3d->clip[val]);
- /* 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];
- }
+ 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_area_tag_redraw(sa);
+ if(v3d->clipbb) MEM_freeN(v3d->clipbb);
+ v3d->clipbb= NULL;
+ return OPERATOR_FINISHED;
+ }
+ else {
+ 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;
+
+ ot->poll= ED_operator_areaactive;
+
+ /* rna */
+ 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);
+}
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 5f1957b84b6..7c2f5a7d5ab 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -51,6 +51,7 @@
#include "BKE_anim.h"
#include "BKE_action.h"
+#include "BKE_context.h"
#include "BKE_object.h"
#include "BKE_global.h"
#include "BKE_main.h"
@@ -76,6 +77,28 @@
#define BL_NEAR_CLIP 0.001
+/* use this call when executing an operator,
+ event system doesn't set for each event the
+ opengl drawing context */
+void view3d_operator_needs_opengl(const bContext *C)
+{
+ ARegion *ar= CTX_wm_region(C);
+
+ /* for debugging purpose, context should always be OK */
+ if(ar->regiontype!=RGN_TYPE_WINDOW)
+ printf("view3d_operator_needs_opengl error, wrong region\n");
+ else {
+ ScrArea *sa= CTX_wm_area(C);
+ View3D *v3d= sa->spacedata.first;
+
+ wmSubWindowSet(CTX_wm_window(C), ar->swinid);
+ glMatrixMode(GL_PROJECTION);
+ wmLoadMatrix(v3d->winmat);
+ glMatrixMode(GL_MODELVIEW);
+ wmLoadMatrix(v3d->viewmat);
+ }
+}
+
float *give_cursor(Scene *scene, View3D *v3d)
{
if(v3d && v3d->localview) return v3d->cursor;
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 11f6f8fa93a..3158ea0759c 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -264,8 +264,8 @@ static void border_select_apply(bContext *C, wmOperator *op, int event_type)
RNA_int_set(op->ptr, "ymin", rect->ymin);
RNA_int_set(op->ptr, "xmax", rect->xmax);
RNA_int_set(op->ptr, "ymax", rect->ymax);
-
- RNA_int_set(op->ptr, "event_type", event_type);
+ if( RNA_property_is_set(op->ptr, "event_type"))
+ RNA_int_set(op->ptr, "event_type", event_type);
op->type->exec(C, op);
}
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 5c10b0c346c..0d0f4f7bb01 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -72,7 +72,7 @@
//XXX #include "playanim_ext.h"
#include "wm_event_types.h"
-//XXX #include "nla.h"
+#include "ED_datafiles.h"
//XXX #include "datatoc.h"
#include "WM_api.h"
@@ -403,7 +403,7 @@ int main(int argc, char **argv)
if(G.background) signal(SIGINT, blender_esc); /* ctrl c out bg render */
/* background render uses this font too */
- //XXX BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size);
+ BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size);
init_def_material();