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:
authorNicholas Bishop <nicholasbishop@gmail.com>2009-01-17 06:31:56 +0300
committerNicholas Bishop <nicholasbishop@gmail.com>2009-01-17 06:31:56 +0300
commit9b558b21161a7d6c021f5cc0e206a5c6aa7a4ada (patch)
treef54d2067bff87a73299956ae52f2073a0e3d69ed /source/blender
parent44e5b7788bcbe55400bf0d91eed0752ed865b644 (diff)
Added a brush cursor to sculpt mode.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_sculpt.h4
-rw-r--r--source/blender/editors/include/ED_view3d.h8
-rw-r--r--source/blender/editors/sculpt/sculpt.c43
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h2
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c6
5 files changed, 47 insertions, 16 deletions
diff --git a/source/blender/blenkernel/BKE_sculpt.h b/source/blender/blenkernel/BKE_sculpt.h
index e7aec665aab..772dec21643 100644
--- a/source/blender/blenkernel/BKE_sculpt.h
+++ b/source/blender/blenkernel/BKE_sculpt.h
@@ -55,7 +55,9 @@ typedef struct SculptSession {
/* 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;
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 422e7542d53..f298fe14d64 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -59,9 +59,11 @@ float *give_cursor(struct Scene *scene, struct View3D *v3d);
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);
-/* Projection */
-
+/* Depth buffer */
float read_cached_depth(struct ViewContext *vc, int x, int y);
+void request_depth_update(struct ViewContext *vc);
+
+/* Projection */
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 @@ unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y);
/* 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);
diff --git a/source/blender/editors/sculpt/sculpt.c b/source/blender/editors/sculpt/sculpt.c
index ca7d5eeee14..918027e918a 100644
--- a/source/blender/editors/sculpt/sculpt.c
+++ b/source/blender/editors/sculpt/sculpt.c
@@ -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 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even
{
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 @@ static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event
/* 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 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
/**** 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;
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 6632ff72d57..f40344dd95b 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -127,8 +127,6 @@ void VIEW3D_OT_wpaint(struct wmOperatorType *ot);
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]);
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index e17cff0f47a..f97375c767a 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -509,6 +509,12 @@ float read_cached_depth(ViewContext *vc, int x, int y)
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);