[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18547] branches/blender2.5/blender/source /blender: Added a brush cursor to sculpt mode.

Nicholas Bishop nicholasbishop at gmail.com
Sat Jan 17 04:32:17 CET 2009


Revision: 18547
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18547
Author:   nicholasbishop
Date:     2009-01-17 04:31:56 +0100 (Sat, 17 Jan 2009)

Log Message:
-----------
Added a brush cursor to sculpt mode.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_sculpt.h
    branches/blender2.5/blender/source/blender/editors/include/ED_view3d.h
    branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_view.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_sculpt.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_sculpt.h	2009-01-17 03:12:50 UTC (rev 18546)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_sculpt.h	2009-01-17 03:31:56 UTC (rev 18547)
@@ -55,7 +55,9 @@
 	
 	/* Used to cache the render of the active texture */
 	unsigned int texcache_w, texcache_h, *texcache;
-	
+
+	void *cursor; /* wm handle */
+
 	struct RadialControl *radialcontrol;
 	
 	struct SculptStroke *stroke;

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_view3d.h	2009-01-17 03:12:50 UTC (rev 18546)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_view3d.h	2009-01-17 03:31:56 UTC (rev 18547)
@@ -59,10 +59,12 @@
 void initgrabz(struct View3D *v3d, float x, float y, float z);
 void window_to_3d(struct ARegion *ar, struct View3D *v3d, float *vec, short mx, short my);
 
+/* Depth buffer */
+float read_cached_depth(struct ViewContext *vc, int x, int y);
+void request_depth_update(struct ViewContext *vc);
+
 /* Projection */
 
-float read_cached_depth(struct ViewContext *vc, int x, int y);
-
 void project_short(struct ARegion *ar, struct View3D *v3d, float *vec, short *adr);
 void project_short_noclip(struct ARegion *ar, struct View3D *v3d, float *vec, short *adr);
 
@@ -97,7 +99,9 @@
 /* select */
 #define MAXPICKBUF      10000
 short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, rcti *input);
+
 void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc);
+void view3d_operator_needs_opengl(const struct bContext *C);
 
 /* XXX should move to arithb.c */
 int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2);

Modified: branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c	2009-01-17 03:12:50 UTC (rev 18546)
+++ branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c	2009-01-17 03:31:56 UTC (rev 18547)
@@ -28,8 +28,6 @@
  *
  * Implements the Sculpt Mode tools
  *
- * BDR_sculptmode.h
- *
  */
 
 #include "MEM_guardedalloc.h"
@@ -79,8 +77,8 @@
 #include "ED_screen.h"
 #include "ED_sculpt.h"
 #include "ED_space_api.h"
+#include "ED_view3d.h"
 #include "sculpt_intern.h"
-#include "../space_view3d/view3d_intern.h" /* XXX: oh no, the next generation of bad level call! should move ViewDepths perhaps (also used for view matrices) */
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -1714,10 +1712,6 @@
 {
 	SculptData *sd = &CTX_data_scene(C)->sculptdata;
 
-	// XXX: temporary, much of sculptsession data should be in rna properties
-	sd->session = MEM_callocN(sizeof(SculptSession), "test sculpt session");
-	sd->session->cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
-	
 	view3d_operator_needs_opengl(C);
 	sculpt_brush_stroke_init_properties(C, op, event, sd->session);
 
@@ -1781,9 +1775,7 @@
 
 	/* Finished */
 	if(event->type == LEFTMOUSE && event->val == 0) {
-		View3D *v3d = ((View3D*)CTX_wm_area(C)->spacedata.first);
-		if(v3d->depths)
-			v3d->depths->damaged= 1;
+		request_depth_update(&sd->session->cache->vc);
 
 		sculpt_cache_free(sd->session->cache);
 
@@ -1858,19 +1850,48 @@
 
 /**** Toggle operator for turning sculpt mode on or off ****/
 
+/* XXX: The code for drawing all the paint cursors is really the same, would be better to unify them */
+static void draw_paint_cursor(bContext *C, int x, int y)
+{
+	SculptData *sd= &CTX_data_scene(C)->sculptdata;
+	
+	glTranslatef((float)x, (float)y, 0.0f);
+	
+	glColor4ub(255, 100, 100, 128);
+	glEnable( GL_LINE_SMOOTH );
+	glEnable(GL_BLEND);
+	glutil_draw_lined_arc(0.0, M_PI*2.0, sd->brush->size, 40);
+	glDisable(GL_BLEND);
+	glDisable( GL_LINE_SMOOTH );
+	
+	glTranslatef((float)-x, (float)-y, 0.0f);
+}
+
 static int sculpt_toggle_mode(bContext *C, wmOperator *op)
 {
+	Scene *sce = CTX_data_scene(C);
+
 	if(G.f & G_SCULPTMODE) {
 		/* Leave sculptmode */
 		G.f &= ~G_SCULPTMODE;
+
+		WM_paint_cursor_end(CTX_wm_manager(C), sce->sculptdata.session->cursor);
+
+		sculptsession_free(sce);
 	}
 	else {
 		/* Enter sculptmode */
 
 		G.f |= G_SCULPTMODE;
 
+		sce->sculptdata.session = MEM_callocN(sizeof(SculptSession), "sculpt session");
+
 		/* Needed for testing, if there's no brush then create one */
-		CTX_data_scene(C)->sculptdata.brush = add_brush("test brush");
+		sce->sculptdata.brush = add_brush("test brush");
+
+		/* Activate visible brush */
+		sce->sculptdata.session->cursor =
+			WM_paint_cursor_activate(CTX_wm_manager(C), sculpt_brush_stroke_poll, draw_paint_cursor);
 	}
 
 	return OPERATOR_FINISHED;

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	2009-01-17 03:12:50 UTC (rev 18546)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h	2009-01-17 03:31:56 UTC (rev 18547)
@@ -127,8 +127,6 @@
 void VIEW3D_OT_smoothview(struct wmOperatorType *ot);
 void VIEW3D_OT_setcameratoview(struct wmOperatorType *ot);
 
-void view3d_operator_needs_opengl(const struct bContext *C);
-
 int boundbox_clip(View3D *v3d, float obmat[][4], struct BoundBox *bb);
 
 void view3d_project_short_clip(struct ARegion *ar, View3D *v3d, float *vec, short *adr, float projmat[4][4], float wmat[4][4]);

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_view.c	2009-01-17 03:12:50 UTC (rev 18546)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_view.c	2009-01-17 03:31:56 UTC (rev 18547)
@@ -509,6 +509,12 @@
 		return 1;
 }
 
+void request_depth_update(ViewContext *vc)
+{
+	if(vc->v3d->depths)
+		vc->v3d->depths->damaged= 1;
+}
+
 void view3d_get_object_project_mat(View3D *v3d, Object *ob, float pmat[4][4], float vmat[4][4])
 {
 	Mat4MulMat4(vmat, ob->obmat, v3d->viewmat);





More information about the Bf-blender-cvs mailing list