Commit: f7e131a6acd800a311e50b680e5be6d9824a1df7
Author: Antony Riakiotakis
Date: Wed Feb 11 15:07:04 2015 +0100
Branches: master
https://developer.blender.org/rBf7e131a6acd800a311e50b680e5be6d9824a1df7
Cavity masking - add curve control to cavity mask and move relevant
structs to paint struct (might be useful for vertex paint too in the
future)
Cavity masking now has a curve control. The control will set the amount
of masking for positive cavity ("pointness") or negative cavity
("cavity") with x axis being the amount of cavity and 0.0 = full cavity,
1.0 = full pointness, 0.5 = no cavity and the y axis being the amount of
alpha.
===================================================================
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/intern/paint.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/writefile.c
M source/blender/editors/sculpt_paint/paint_image_proj.c
M source/blender/editors/sculpt_paint/paint_stroke.c
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 7af8be1..c0baeaf 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1722,10 +1722,8 @@ class VIEW3D_PT_tools_projectpaint(View3DPaintPanel,
Panel):
sub.prop(ipaint, "normal_angle", text="")
layout.prop(ipaint, "use_cavity")
- sub = layout.column()
- sub.active = (ipaint.use_cavity)
- sub.prop(ipaint, "cavity_mul", slider=True)
- sub.prop(ipaint, "invert_cavity")
+ if ipaint.use_cavity:
+ layout.template_curve_mapping(ipaint, "cavity_curve", brush=True)
layout.prop(ipaint, "seam_bleed")
layout.prop(ipaint, "dither")
diff --git a/source/blender/blenkernel/BKE_paint.h
b/source/blender/blenkernel/BKE_paint.h
index 9ad99f7..3e4e6ab 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -113,6 +113,8 @@ void BKE_paint_init(struct UnifiedPaintSettings *ups,
struct Paint *p, const cha
void BKE_paint_free(struct Paint *p);
void BKE_paint_copy(struct Paint *src, struct Paint *tar);
+void BKE_paint_cavity_curve_preset(struct Paint *p, int preset);
+
struct Paint *BKE_paint_get_active(struct Scene *sce);
struct Paint *BKE_paint_get_active_from_context(const struct bContext *C);
PaintMode BKE_paintmode_get_active_from_context(const struct bContext *C);
diff --git a/source/blender/blenkernel/intern/paint.c
b/source/blender/blenkernel/intern/paint.c
index 5859124..431eec0 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -48,6 +48,7 @@
#include "BLI_listbase.h"
#include "BKE_brush.h"
+#include "BKE_colortools.h"
#include "BKE_main.h"
#include "BKE_context.h"
#include "BKE_crazyspace.h"
@@ -395,6 +396,21 @@ bool BKE_paint_select_elem_test(Object *ob)
BKE_paint_select_face_test(ob));
}
+void BKE_paint_cavity_curve_preset(Paint *p, int preset)
+{
+ CurveMap *cm = NULL;
+
+ if (!p->cavity_curve)
+ p->cavity_curve = curvemapping_add(1, 0, 0, 1, 1);
+
+ cm = p->cavity_curve->cm;
+ cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
+
+ p->cavity_curve->preset = preset;
+ curvemap_reset(cm, &p->cavity_curve->clipr, p->cavity_curve->preset,
CURVEMAP_SLOPE_POSITIVE);
+ curvemapping_changed(p->cavity_curve, false);
+}
+
void BKE_paint_init(UnifiedPaintSettings *ups, Paint *p, const char col[3])
{
Brush *brush;
@@ -410,12 +426,15 @@ void BKE_paint_init(UnifiedPaintSettings *ups, Paint *p,
const char col[3])
ups->last_stroke_valid = false;
zero_v3(ups->average_stroke_accum);
ups->average_stroke_counter = 0;
+ if (!p->cavity_curve)
+ BKE_paint_cavity_curve_preset(p, CURVE_PRESET_LINE);
}
void BKE_paint_free(Paint *paint)
{
id_us_min((ID *)paint->brush);
id_us_min((ID *)paint->palette);
+ curvemapping_free(paint->cavity_curve);
}
/* called when copying scene settings, so even if 'src' and 'tar' are the same
@@ -427,6 +446,7 @@ void BKE_paint_copy(Paint *src, Paint *tar)
tar->brush = src->brush;
id_us_plus((ID *)tar->brush);
id_us_plus((ID *)tar->palette);
+ tar->cavity_curve = curvemapping_copy(src->cavity_curve);
}
void BKE_paint_stroke_get_average(Scene *scene, Object *ob, float stroke[3])
diff --git a/source/blender/blenloader/intern/readfile.c
b/source/blender/blenloader/intern/readfile.c
index 7bfe6f0..5e48136 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5428,12 +5428,26 @@ static void link_recurs_seq(FileData *fd, ListBase *lb)
}
}
-static void direct_link_paint(FileData *fd, Paint **paint)
+static void direct_link_paint(FileData *fd, Paint *p)
+{
+ if (p->num_input_samples < 1)
+ p->num_input_samples = 1;
+
+ p->cavity_curve = newdataadr(fd, p->cavity_curve);
+ if (p->cavity_curve)
+ direct_link_curvemapping(fd, p->cavity_curve);
+ else
+ BKE_paint_cavity_curve_preset(p, CURVE_PRESET_SHARP);
+}
+
+static void direct_link_paint_helper(FileData *fd, Paint **paint)
{
/* TODO. is this needed */
(*paint) = newdataadr(fd, (*paint));
- if (*paint && (*paint)->num_input_samples < 1)
- (*paint)->num_input_samples = 1;
+
+ if (*paint) {
+ direct_link_paint(fd, *paint);
+ }
}
static void direct_link_sequence_modifiers(FileData *fd, ListBase *lb)
@@ -5499,11 +5513,13 @@ static void direct_link_scene(FileData *fd, Scene *sce)
sce->toolsettings= newdataadr(fd, sce->toolsettings);
if (sce->toolsettings) {
- direct_link_paint(fd, (Paint**)&sce->toolsettings->sculpt);
- direct_link_paint(fd, (Paint**)&sce->toolsettings->vpaint);
- direct_link_paint(fd, (Paint**)&sce->toolsettings->wpaint);
- direct_link_paint(fd, (Paint**)&sce->toolsettings->uvsculpt);
+ direct_link_paint_helper(fd,
(Paint**)&sce->toolsettings->sculpt);
+ direct_link_paint_helper(fd,
(Paint**)&sce->toolsettings->vpaint);
+ direct_link_paint_helper(fd,
(Paint**)&sce->toolsettings->wpaint);
+ direct_link_paint_helper(fd,
(Paint**)&sce->toolsettings->uvsculpt);
+ direct_link_paint(fd, &sce->toolsettings->imapaint.paint);
+
sce->toolsettings->imapaint.paintcursor = NULL;
sce->toolsettings->particle.paintcursor = NULL;
sce->toolsettings->particle.scene = NULL;
diff --git a/source/blender/blenloader/intern/writefile.c
b/source/blender/blenloader/intern/writefile.c
index e671e10..6031400 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2316,6 +2316,12 @@ static void write_view_settings(WriteData *wd,
ColorManagedViewSettings *view_se
}
}
+static void write_paint(WriteData *wd, Paint *p)
+{
+ if (p->cavity_curve)
+ write_curvemapping(wd, p->cavity_curve);
+}
+
static void write_scenes(WriteData *wd, ListBase *scebase)
{
Scene *sce;
@@ -2351,18 +2357,22 @@ static void write_scenes(WriteData *wd, ListBase
*scebase)
writestruct(wd, DATA, "ToolSettings", 1, tos);
if (tos->vpaint) {
writestruct(wd, DATA, "VPaint", 1, tos->vpaint);
+ write_paint (wd, &tos->vpaint->paint);
}
if (tos->wpaint) {
writestruct(wd, DATA, "VPaint", 1, tos->wpaint);
+ write_paint (wd, &tos->wpaint->paint);
}
if (tos->sculpt) {
writestruct(wd, DATA, "Sculpt", 1, tos->sculpt);
+ write_paint (wd, &tos->sculpt->paint);
}
if (tos->uvsculpt) {
writestruct(wd, DATA, "UvSculpt", 1, tos->uvsculpt);
+ write_paint (wd, &tos->uvsculpt->paint);
}
- // write_paint(wd, &tos->imapaint.paint);
+ write_paint(wd, &tos->imapaint.paint);
ed= sce->ed;
if (ed) {
@@ -3069,7 +3079,7 @@ static void write_brushes(WriteData *wd, ListBase *idbase)
if (brush->curve)
write_curvemapping(wd, brush->curve);
- if (brush->curve)
+ if (brush->gradient)
writestruct(wd, DATA, "ColorBand", 1,
brush->gradient);
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c
b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 6d4a04e..8e9661f 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -62,6 +62,7 @@
#include "BKE_camera.h"
#include "BKE_context.h"
+#include "BKE_colortools.h"
#include "BKE_depsgraph.h"
#include "BKE_DerivedMesh.h"
#include "BKE_idprop.h"
@@ -257,7 +258,6 @@ typedef struct ProjPaintState {
float screenMax[2];
float screen_width; /* Calculated from screenMin & screenMax */
float screen_height;
- float cavity_multiplier;
int winx, winy; /* from the carea or from the projection
render */
/* options for projection painting */
@@ -305,6 +305,7 @@ typedef struct ProjPaintState {
/* redraw */
bool need_redraw;
+ struct CurveMapping *cavity_curve;
BlurKernel *blurkernel;
SpinLock *tile_lock;
@@ -1318,8 +1319,8 @@ static float project_paint_uvpixel_mask(
}
ca_mask = w[0] * ca1 + w[1] * ca2 + w[2] * ca3;
+ ca_mask = curvemapping_evaluateF(ps->cavity_curve, 0, ca_mask);
CLAMP(ca_mask, 0.0, 1.0);
- ca_mask = 1.0f - ca_mask;
mask *= ca_mask;
}
@@ -3253,7 +3254,8 @@ static void proj_paint_state_cavity_init(ProjPaintState
*ps)
float no[3];
mul_v3_fl(edges[a], 1.0f / counter[a]);
normal_short_to_float_v3(no, mv->no);
- cavities[a] = ps->cavity_multiplier * 10.0f *
dot_v3v3(no, edges[a]);
+ /* augment the diffe*/
+ cavities[a] = saacos(10.0f * dot_v3v3(no,
edges[a])) * M_1_PI;
}
else
cavities[a] = 0.0;
@@ -4931,11 +4933,8 @@ static void project_state_init(bContext *C, Object *ob,
ProjPaintState *ps, int
ps->do_backfacecull = (settings->imapaint.flag &
IMAGEPAINT_PROJECT_BACKFACE) ? false : true;
ps->do_occlude = (settings->imapaint.flag &
IMAGEPAINT_PROJECT_XRAY) ? false : true;
ps->do_mask_normal = (settings->imapaint.flag &
IMAGEPAINT_PROJECT_FLAT) ? false : true;
- ps->do_mask_cavity = (settings->imapaint.flag &
IMAGEPAINT_PROJECT_CAVITY) ? true : false;
- ps->cavity_multiplier = settings->imapaint.cavity_mul;
- if (settings->imapaint.flag & IMAGEPAINT_PROJECT_CAVITY_INV) {
- ps->cavity_multiplier *= -1;
- }
+ ps->do_mask_cavity = (settings->imapaint.paint.flags &
PAINT_USE_CAVITY_MASK) ? true : false;
+ ps->cavity_curve = settings->imapaint.paint.cavity_curve;
}
else {
ps->do_backfacecull = ps->do_occlude = ps->do_mask_normal =
ps->do_mask_cavity = 0;
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c
b/source/blender/editors/sculpt_paint/paint_stroke.c
index d9d0d8f..bfd429d 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -651,7 +651,8 @@ PaintStroke *paint_stroke_new(bContext *C,
PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke");
ToolSettings *toolsettings = CTX_data_tool_settings(C);
UnifiedPaintSettings *ups = &toolsettings->unified_paint_settings;
- Brush *br = stroke->brush =
BKE_paint_brush(BKE_paint_get_active_from_context(C));
+ Paint *p = BKE_paint_get_active_from_context(C);
+ Brush *br = stroke->brush = BKE_paint_brush(p);
float zoomx, zoomy;
view3d_set_viewcontext(C, &stroke->vc);
@@ -683,10 +684,11 @@ PaintStroke
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs