Paint/Sculpt:
More minor cleanups: fixed names and factored out a function that was copy-pasted into paint stroke.
This commit is contained in:
@@ -99,6 +99,7 @@ void PAINT_OT_image_from_view(struct wmOperatorType *ot);
|
||||
|
||||
|
||||
/* paint_utils.c */
|
||||
float paint_calc_object_space_radius(struct ViewContext *vc, float center[3], float pixel_radius);
|
||||
float paint_get_tex_pixel(struct Brush* br, float u, float v);
|
||||
int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsigned int *index);
|
||||
void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, int *xy, float *uv);
|
||||
@@ -113,11 +114,11 @@ void PAINT_OT_face_select_all(struct wmOperatorType *ot);
|
||||
int facemask_paint_poll(struct bContext *C);
|
||||
|
||||
/* stroke operator */
|
||||
typedef enum wmBrushStrokeMode {
|
||||
WM_BRUSHSTROKE_NORMAL,
|
||||
WM_BRUSHSTROKE_INVERT,
|
||||
WM_BRUSHSTROKE_SMOOTH,
|
||||
} wmBrushStrokeMode;
|
||||
typedef enum BrushStrokeMode {
|
||||
BRUSH_STROKE_NORMAL,
|
||||
BRUSH_STROKE_INVERT,
|
||||
BRUSH_STROKE_SMOOTH,
|
||||
} BrushStrokeMode;
|
||||
|
||||
/* paint_undo.c */
|
||||
typedef void (*UndoRestoreCb)(struct bContext *C, struct ListBase *lb);
|
||||
|
||||
@@ -317,11 +317,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_RADIALCONTROL_ANGLE);
|
||||
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", WM_BRUSHSTROKE_NORMAL);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_BRUSHSTROKE_INVERT);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_BRUSHSTROKE_SMOOTH);
|
||||
|
||||
//stroke_mode_modal_keymap(keyconf);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH);
|
||||
|
||||
for(i=0; i<=5; i++)
|
||||
RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i);
|
||||
|
||||
@@ -411,22 +411,6 @@ int sculpt_get_brush_geometry(bContext* C, int x, int y, int* pixel_radius, floa
|
||||
return hit;
|
||||
}
|
||||
|
||||
// XXX duplicated from sculpt.c
|
||||
float unproject_brush_radius(Object *ob, ViewContext *vc, float center[3], float offset)
|
||||
{
|
||||
float delta[3], scale, loc[3];
|
||||
|
||||
mul_v3_m4v3(loc, ob->obmat, center);
|
||||
|
||||
initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
|
||||
window_to_3d_delta(vc->ar, delta, offset, 0);
|
||||
|
||||
scale= fabsf(mat4_to_scale(ob->obmat));
|
||||
scale= (scale == 0.0f)? 1.0f: scale;
|
||||
|
||||
return len_v3(delta)/scale;
|
||||
}
|
||||
|
||||
// XXX paint cursor now does a lot of the same work that is needed during a sculpt stroke
|
||||
// problem: all this stuff was not intended to be used at this point, so things feel a
|
||||
// bit hacked. I've put lots of stuff in Brush that probably better goes in Paint
|
||||
@@ -613,13 +597,13 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused)
|
||||
if (visual_strength > 1) visual_strength = 1;
|
||||
|
||||
if (sd->draw_anchored) {
|
||||
unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, sd->anchored_size);
|
||||
unprojected_radius = paint_calc_object_space_radius(&vc, location, sd->anchored_size);
|
||||
}
|
||||
else {
|
||||
if (brush->flag & BRUSH_ANCHORED)
|
||||
unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, 8);
|
||||
unprojected_radius = paint_calc_object_space_radius(&vc, location, 8);
|
||||
else
|
||||
unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, brush_size(brush));
|
||||
unprojected_radius = paint_calc_object_space_radius(&vc, location, brush_size(brush));
|
||||
}
|
||||
|
||||
if (sd->draw_pressure && brush_use_size_pressure(brush))
|
||||
|
||||
@@ -35,6 +35,23 @@
|
||||
|
||||
#include "paint_intern.h"
|
||||
|
||||
float paint_calc_object_space_radius(ViewContext *vc, float center[3],
|
||||
float pixel_radius)
|
||||
{
|
||||
Object *ob = vc->obact;
|
||||
float delta[3], scale, loc[3];
|
||||
|
||||
mul_v3_m4v3(loc, ob->obmat, center);
|
||||
|
||||
initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
|
||||
window_to_3d_delta(vc->ar, delta, pixel_radius, 0);
|
||||
|
||||
scale= fabsf(mat4_to_scale(ob->obmat));
|
||||
scale= (scale == 0.0f)? 1.0f: scale;
|
||||
|
||||
return len_v3(delta)/scale;
|
||||
}
|
||||
|
||||
float paint_get_tex_pixel(Brush* br, float u, float v)
|
||||
{
|
||||
TexResult texres;
|
||||
|
||||
@@ -241,16 +241,6 @@ static void projectf(bglMats *mats, const float v[3], float p[2])
|
||||
p[1]= uy;
|
||||
}
|
||||
|
||||
/*XXX: static void project(bglMats *mats, const float v[3], short p[2])
|
||||
{
|
||||
float f[2];
|
||||
projectf(mats, v, f);
|
||||
|
||||
p[0]= f[0];
|
||||
p[1]= f[1];
|
||||
}
|
||||
*/
|
||||
|
||||
/*** BVH Tree ***/
|
||||
|
||||
/* Get a screen-space rectangle of the modified area */
|
||||
@@ -2752,21 +2742,6 @@ static void SCULPT_OT_radial_control(wmOperatorType *ot)
|
||||
/**** Operator for applying a stroke (various attributes including mouse path)
|
||||
using the current brush. ****/
|
||||
|
||||
static float unproject_brush_radius(Object *ob, ViewContext *vc, float center[3], float offset)
|
||||
{
|
||||
float delta[3], scale, loc[3];
|
||||
|
||||
mul_v3_m4v3(loc, ob->obmat, center);
|
||||
|
||||
initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
|
||||
window_to_3d_delta(vc->ar, delta, offset, 0);
|
||||
|
||||
scale= fabsf(mat4_to_scale(ob->obmat));
|
||||
scale= (scale == 0.0f)? 1.0f: scale;
|
||||
|
||||
return len_v3(delta)/scale;
|
||||
}
|
||||
|
||||
static void sculpt_cache_free(StrokeCache *cache)
|
||||
{
|
||||
if(cache->face_norms)
|
||||
@@ -2840,8 +2815,8 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio
|
||||
}
|
||||
|
||||
mode = RNA_int_get(op->ptr, "mode");
|
||||
cache->invert = mode == WM_BRUSHSTROKE_INVERT;
|
||||
cache->alt_smooth = mode == WM_BRUSHSTROKE_SMOOTH;
|
||||
cache->invert = mode == BRUSH_STROKE_INVERT;
|
||||
cache->alt_smooth = mode == BRUSH_STROKE_SMOOTH;
|
||||
|
||||
/* not very nice, but with current events system implementation
|
||||
we can't handle brush appearance inversion hotkey separately (sergey) */
|
||||
@@ -3019,7 +2994,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, SculptSession
|
||||
|
||||
if(cache->first_time) {
|
||||
if (!brush_use_locked_size(brush)) {
|
||||
cache->initial_radius= unproject_brush_radius(ss->ob, cache->vc, cache->true_location, brush_size(brush));
|
||||
cache->initial_radius= paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(brush));
|
||||
brush_set_unprojected_radius(brush, cache->initial_radius);
|
||||
}
|
||||
else {
|
||||
@@ -3081,7 +3056,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, SculptSession
|
||||
if (!hit)
|
||||
copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse);
|
||||
|
||||
cache->radius= unproject_brush_radius(ss->ob, paint_stroke_view_context(stroke), cache->true_location, cache->pixel_radius);
|
||||
cache->radius= paint_calc_object_space_radius(paint_stroke_view_context(stroke), cache->true_location, cache->pixel_radius);
|
||||
cache->radius_squared = cache->radius*cache->radius;
|
||||
|
||||
copy_v3_v3(sd->anchored_location, cache->true_location);
|
||||
@@ -3488,10 +3463,10 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op)
|
||||
static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
|
||||
{
|
||||
static EnumPropertyItem stroke_mode_items[] = {
|
||||
{ WM_BRUSHSTROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally" },
|
||||
{ WM_BRUSHSTROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke" },
|
||||
{ WM_BRUSHSTROKE_SMOOTH, "SMOOTH", 0, "Smooth", "Switch brush to smooth mode for duration of stroke" },
|
||||
{ 0 }
|
||||
{BRUSH_STROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally"},
|
||||
{BRUSH_STROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke"},
|
||||
{BRUSH_STROKE_SMOOTH, "SMOOTH", 0, "Smooth", "Switch brush to smooth mode for duration of stroke"},
|
||||
{0}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
@@ -3512,7 +3487,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
|
||||
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement,
|
||||
"Stroke", "");
|
||||
|
||||
RNA_def_enum(ot->srna, "mode", stroke_mode_items, WM_BRUSHSTROKE_NORMAL,
|
||||
RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL,
|
||||
"Sculpt Stroke Mode",
|
||||
"Action taken when a sculpt stroke is made");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user