forked from bartvdbraak/blender
Minor sculpt/paint cleanups.
Added some comments, constified a param, and moved a couple things around.
This commit is contained in:
parent
23806a2b7d
commit
dc8b219726
@ -126,7 +126,7 @@ void paint_calc_redraw_planes(float planes[4][4],
|
|||||||
const struct rcti *screen_rect);
|
const struct rcti *screen_rect);
|
||||||
|
|
||||||
void projectf(struct bglMats *mats, const float v[3], float p[2]);
|
void projectf(struct bglMats *mats, const float v[3], float p[2]);
|
||||||
float paint_calc_object_space_radius(struct ViewContext *vc, float center[3], float pixel_radius);
|
float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius);
|
||||||
float paint_get_tex_pixel(struct Brush* br, float u, float v);
|
float paint_get_tex_pixel(struct Brush* br, float u, float v);
|
||||||
int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, const int mval[2], unsigned int *index);
|
int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, const int mval[2], unsigned int *index);
|
||||||
void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
|
void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
|
||||||
|
@ -510,31 +510,33 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
|
|||||||
/* Special actions taken when paint cursor goes over mesh */
|
/* Special actions taken when paint cursor goes over mesh */
|
||||||
/* TODO: sculpt only for now */
|
/* TODO: sculpt only for now */
|
||||||
static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
|
static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
|
||||||
float location[3], float *visual_strength)
|
const float location[3])
|
||||||
{
|
{
|
||||||
float unprojected_radius, projected_radius;
|
float unprojected_radius, projected_radius;
|
||||||
|
|
||||||
/* TODO: check whether this should really only be done when
|
/* update the brush's cached 3D radius */
|
||||||
brush is over mesh? */
|
if(!brush_use_locked_size(vc->scene, brush)) {
|
||||||
if(sd->draw_pressure && brush_use_alpha_pressure(vc->scene, brush))
|
/* get 2D brush radius */
|
||||||
(*visual_strength) *= sd->pressure_value;
|
if(sd->draw_anchored)
|
||||||
|
projected_radius = sd->anchored_size;
|
||||||
|
else {
|
||||||
|
if(brush->flag & BRUSH_ANCHORED)
|
||||||
|
projected_radius = 8;
|
||||||
|
else
|
||||||
|
projected_radius = brush_size(vc->scene, brush);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* convert brush radius from 2D to 3D */
|
||||||
|
unprojected_radius = paint_calc_object_space_radius(vc, location,
|
||||||
|
projected_radius);
|
||||||
|
|
||||||
if(sd->draw_anchored)
|
/* scale 3D brush radius by pressure */
|
||||||
projected_radius = sd->anchored_size;
|
if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush))
|
||||||
else {
|
unprojected_radius *= sd->pressure_value;
|
||||||
if(brush->flag & BRUSH_ANCHORED)
|
|
||||||
projected_radius = 8;
|
|
||||||
else
|
|
||||||
projected_radius = brush_size(vc->scene, brush);
|
|
||||||
}
|
|
||||||
unprojected_radius = paint_calc_object_space_radius(vc, location,
|
|
||||||
projected_radius);
|
|
||||||
|
|
||||||
if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush))
|
/* set cached value in either Brush or UnifiedPaintSettings */
|
||||||
unprojected_radius *= sd->pressure_value;
|
|
||||||
|
|
||||||
if(!brush_use_locked_size(vc->scene, brush))
|
|
||||||
brush_set_unprojected_radius(vc->scene, brush, unprojected_radius);
|
brush_set_unprojected_radius(vc->scene, brush, unprojected_radius);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
||||||
@ -613,8 +615,13 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
|
|||||||
outline_col = brush->sub_col;
|
outline_col = brush->sub_col;
|
||||||
|
|
||||||
/* only do if brush is over the mesh */
|
/* only do if brush is over the mesh */
|
||||||
if(hit)
|
if(hit) {
|
||||||
paint_cursor_on_hit(sd, brush, &vc, location, &visual_strength);
|
/* scale the alpha by pen pressure */
|
||||||
|
if(sd->draw_pressure && brush_use_alpha_pressure(vc.scene, brush))
|
||||||
|
visual_strength *= sd->pressure_value;
|
||||||
|
|
||||||
|
paint_cursor_on_hit(sd, brush, &vc, location);
|
||||||
|
}
|
||||||
|
|
||||||
/* don't show effect of strength past the soft limit */
|
/* don't show effect of strength past the soft limit */
|
||||||
if(visual_strength > 1)
|
if(visual_strength > 1)
|
||||||
|
@ -152,7 +152,7 @@ void projectf(bglMats *mats, const float v[3], float p[2])
|
|||||||
p[1]= uy;
|
p[1]= uy;
|
||||||
}
|
}
|
||||||
|
|
||||||
float paint_calc_object_space_radius(ViewContext *vc, float center[3],
|
float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
|
||||||
float pixel_radius)
|
float pixel_radius)
|
||||||
{
|
{
|
||||||
Object *ob = vc->obact;
|
Object *ob = vc->obact;
|
||||||
|
Loading…
Reference in New Issue
Block a user