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:
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt.c')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c109
1 files changed, 36 insertions, 73 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 7156b49c026..be985342ea8 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -281,7 +281,7 @@ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
float bb_min[3], bb_max[3], pmat[4][4];
int i, j, k;
- view3d_get_object_project_mat(rv3d, ob, pmat);
+ ED_view3d_ob_project_mat_get(rv3d, ob, pmat);
if(!pbvh)
return 0;
@@ -301,7 +301,7 @@ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d,
vec[0] = i ? bb_min[0] : bb_max[0];
vec[1] = j ? bb_min[1] : bb_max[1];
vec[2] = k ? bb_min[2] : bb_max[2];
- view3d_project_float(ar, vec, proj, pmat);
+ ED_view3d_project_float(ar, vec, proj, pmat);
rect->xmin = MIN2(rect->xmin, proj[0]);
rect->xmax = MAX2(rect->xmax, proj[0]);
rect->ymin = MIN2(rect->ymin, proj[1]);
@@ -357,7 +357,7 @@ void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar,
rect.ymax -= 2;
#endif
- view3d_calculate_clipping(&bb, planes, &mats, &rect);
+ ED_view3d_calc_clipping(&bb, planes, &mats, &rect);
mul_m4_fl(planes, -1.0f);
/* clear redraw flag from nodes */
@@ -912,7 +912,7 @@ static void calc_sculpt_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **n
{
switch (brush->sculpt_plane) {
case SCULPT_DISP_DIR_VIEW:
- viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
+ ED_view3d_global_to_vector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
break;
case SCULPT_DISP_DIR_X:
@@ -1823,7 +1823,7 @@ static void calc_sculpt_plane(Sculpt *sd, Object *ob, PBVHNode **nodes, int totn
{
switch (brush->sculpt_plane) {
case SCULPT_DISP_DIR_VIEW:
- viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
+ ED_view3d_global_to_vector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
break;
case SCULPT_DISP_DIR_X:
@@ -2816,65 +2816,6 @@ static const char *sculpt_tool_name(Sculpt *sd)
}
}
-/**** Radial control ****/
-static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
- Paint *p = paint_get_active(CTX_data_scene(C));
- Brush *brush = paint_brush(p);
- float col[4], tex_col[4];
-
- WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor);
- p->paint_cursor = NULL;
- brush_radial_control_invoke(op, brush, 1);
-
- if((brush->flag & BRUSH_DIR_IN) && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH))
- copy_v3_v3(col, brush->sub_col);
- else
- copy_v3_v3(col, brush->add_col);
- col[3]= 0.5f;
-
- copy_v3_v3(tex_col, U.sculpt_paint_overlay_col);
- tex_col[3]= (brush->texture_overlay_alpha / 100.0f);
-
- RNA_float_set_array(op->ptr, "color", col);
- RNA_float_set_array(op->ptr, "texture_color", tex_col);
-
- return WM_radial_control_invoke(C, op, event);
-}
-
-static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
-{
- int ret = WM_radial_control_modal(C, op, event);
- if(ret != OPERATOR_RUNNING_MODAL)
- paint_cursor_start(C, sculpt_poll);
- return ret;
-}
-
-static int sculpt_radial_control_exec(bContext *C, wmOperator *op)
-{
- Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint);
- int ret = brush_radial_control_exec(op, brush, 1);
-
- WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush);
-
- return ret;
-}
-
-static void SCULPT_OT_radial_control(wmOperatorType *ot)
-{
- WM_OT_radial_control_partial(ot);
-
- ot->name= "Sculpt Radial Control";
- ot->idname= "SCULPT_OT_radial_control";
-
- ot->invoke= sculpt_radial_control_invoke;
- ot->modal= sculpt_radial_control_modal;
- ot->exec= sculpt_radial_control_exec;
- ot->poll= sculpt_poll;
-
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
-}
-
/**** Operator for applying a stroke (various attributes including mouse path)
using the current brush. ****/
@@ -2985,7 +2926,7 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio
cache->mats = MEM_callocN(sizeof(bglMats), "sculpt bglMats");
view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, cache->mats);
- viewvector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal);
+ ED_view3d_global_to_vector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal);
/* Initialize layer brush displacements and persistent coords */
if(brush->sculpt_tool == SCULPT_TOOL_LAYER) {
/* not supported yet for multires */
@@ -3053,8 +2994,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
cache->orig_grab_location[1],
cache->orig_grab_location[2]);
- window_to_3d_delta(cache->vc->ar, grab_location,
- cache->mouse[0], cache->mouse[1]);
+ ED_view3d_win_to_delta(cache->vc->ar, cache->mouse, grab_location);
/* compute delta to move verts by */
if(!cache->first_time) {
@@ -3306,7 +3246,7 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou
sculpt_stroke_modifiers_check(C, ob);
- viewline(vc->ar, vc->v3d, mval, ray_start, ray_end);
+ ED_view3d_win_to_segment_clip(vc->ar, vc->v3d, mval, ray_start, ray_end);
invert_m4_m4(obimat, ob->obmat);
mul_m4_v3(obimat, ray_start);
@@ -3346,18 +3286,23 @@ static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss)
sculpt_update_tex(sd, ss);
}
-static int sculpt_brush_stroke_init(bContext *C, ReportList *UNUSED(reports))
+static int sculpt_brush_stroke_init(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
SculptSession *ss = CTX_data_active_object(C)->sculpt;
Brush *brush = paint_brush(&sd->paint);
+ int mode= RNA_enum_get(op->ptr, "mode");
+ int is_smooth= 0;
view3d_operator_needs_opengl(C);
sculpt_brush_init_tex(sd, ss);
- sculpt_update_mesh_elements(scene, sd, ob, brush->sculpt_tool == SCULPT_TOOL_SMOOTH);
+ is_smooth|= mode == BRUSH_STROKE_SMOOTH;
+ is_smooth|= brush->sculpt_tool == SCULPT_TOOL_SMOOTH;
+
+ sculpt_update_mesh_elements(scene, sd, ob, is_smooth);
return 1;
}
@@ -3573,7 +3518,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even
struct PaintStroke *stroke;
int ignore_background_click;
- if(!sculpt_brush_stroke_init(C, op->reports))
+ if(!sculpt_brush_stroke_init(C, op))
return OPERATOR_CANCELLED;
stroke = paint_stroke_new(C, sculpt_stroke_get_location,
@@ -3602,7 +3547,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even
static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op)
{
- if(!sculpt_brush_stroke_init(C, op->reports))
+ if(!sculpt_brush_stroke_init(C, op))
return OPERATOR_CANCELLED;
op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start,
@@ -3614,6 +3559,24 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_active_object(C);
+ SculptSession *ss = ob->sculpt;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+
+ paint_stroke_cancel(C, op);
+
+ if(ss->cache) {
+ sculpt_cache_free(ss->cache);
+ ss->cache = NULL;
+ }
+
+ sculpt_brush_exit_tex(sd);
+
+ return OPERATOR_CANCELLED;
+}
+
static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
{
static EnumPropertyItem stroke_mode_items[] = {
@@ -3632,6 +3595,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
ot->modal= paint_stroke_modal;
ot->exec= sculpt_brush_stroke_exec;
ot->poll= sculpt_poll;
+ ot->cancel= sculpt_brush_stroke_cancel;
/* flags (sculpt does own undo? (ton) */
ot->flag= OPTYPE_BLOCKING;
@@ -3758,7 +3722,6 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot)
void ED_operatortypes_sculpt(void)
{
- WM_operatortype_append(SCULPT_OT_radial_control);
WM_operatortype_append(SCULPT_OT_brush_stroke);
WM_operatortype_append(SCULPT_OT_sculptmode_toggle);
WM_operatortype_append(SCULPT_OT_set_persistent_base);