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
path: root/source
diff options
context:
space:
mode:
authorJeroen Bakker <j.bakker@atmind.nl>2019-04-24 16:43:58 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2019-04-25 09:02:18 +0300
commit6d09fa357731e3444a08aa7e705aab8fb4ed895d (patch)
tree37094424c2ad8e003558f113768dc827395e02bc /source
parent78f8679cfc6d6e8f19d84908ab4343ce6638faf3 (diff)
DynamicPaint: Remove Previews
Modifier previews should be implemented by a more generic system. The current system is already a hack and needed a lot of work to get it working again in 2.80 and even so that would be replaced by another system in the near future. For Vertex Colors we have a work around in place by using Workbench Vertex Colors. For Vertex Weights we loose the previewing. Not sure targetting weight is working (even for 279). Reviewed By: brecht Maniphest Tasks: T63857 Differential Revision: https://developer.blender.org/D4734
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_dynamicpaint.h2
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c114
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c3
-rw-r--r--source/blender/makesdna/DNA_dynamicpaint_types.h17
-rw-r--r--source/blender/makesrna/intern/rna_dynamicpaint.c50
5 files changed, 1 insertions, 185 deletions
diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h
index 9f4f2862c95..c4f05d404ce 100644
--- a/source/blender/blenkernel/BKE_dynamicpaint.h
+++ b/source/blender/blenkernel/BKE_dynamicpaint.h
@@ -83,13 +83,11 @@ void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd);
void dynamicPaint_freeSurfaceData(struct DynamicPaintSurface *surface);
void dynamicPaint_cacheUpdateFrames(struct DynamicPaintSurface *surface);
-bool dynamicPaint_surfaceHasColorPreview(struct DynamicPaintSurface *surface);
bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface,
struct Object *ob,
int output);
void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface);
void dynamicPaintSurface_setUniqueName(struct DynamicPaintSurface *surface, const char *basename);
-void dynamicPaint_resetPreview(struct DynamicPaintCanvasSettings *canvas);
struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings *canvas);
/* image sequence baking */
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 7fef07346c3..38ecc95da22 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -302,56 +302,12 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface)
return 0;
}
-/* checks whether surface's format/type has realtime preview */
-bool dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface)
-{
- if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
- return false;
- }
- else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
- return !ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WAVE);
- }
-
- return true;
-}
-
/* get currently active surface (in user interface) */
DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas)
{
return BLI_findlink(&canvas->surfaces, canvas->active_sur);
}
-/* set preview to first previewable surface */
-void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas)
-{
- DynamicPaintSurface *surface = canvas->surfaces.first;
- bool done = false;
-
- for (; surface; surface = surface->next) {
- if (!done && dynamicPaint_surfaceHasColorPreview(surface)) {
- surface->flags |= MOD_DPAINT_PREVIEW;
- done = true;
- }
- else {
- surface->flags &= ~MOD_DPAINT_PREVIEW;
- }
- }
-}
-
-/* set preview to defined surface */
-static void dynamicPaint_setPreview(DynamicPaintSurface *t_surface)
-{
- DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
- for (; surface; surface = surface->next) {
- if (surface == t_surface) {
- surface->flags |= MOD_DPAINT_PREVIEW;
- }
- else {
- surface->flags &= ~MOD_DPAINT_PREVIEW;
- }
- }
-}
-
bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object *ob, int output)
{
const char *name;
@@ -471,14 +427,6 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface)
}
surface_setUniqueOutputName(surface, surface->output_name, 0);
-
- /* update preview */
- if (dynamicPaint_surfaceHasColorPreview(surface)) {
- dynamicPaint_setPreview(surface);
- }
- else {
- dynamicPaint_resetPreview(surface->canvas);
- }
}
static int surface_totalSamples(DynamicPaintSurface *surface)
@@ -1079,7 +1027,7 @@ DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *c
/* Set initial values */
surface->flags = MOD_DPAINT_ANTIALIAS | MOD_DPAINT_MULALPHA | MOD_DPAINT_DRY_LOG |
- MOD_DPAINT_DISSOLVE_LOG | MOD_DPAINT_ACTIVE | MOD_DPAINT_PREVIEW |
+ MOD_DPAINT_DISSOLVE_LOG | MOD_DPAINT_ACTIVE |
MOD_DPAINT_OUT1 | MOD_DPAINT_USE_DRYING;
surface->effect = 0;
surface->effect_ui = 1;
@@ -1280,7 +1228,6 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
t_surface->disp_type = surface->disp_type;
t_surface->image_fileformat = surface->image_fileformat;
t_surface->effect_ui = surface->effect_ui;
- t_surface->preview_id = surface->preview_id;
t_surface->init_color_type = surface->init_color_type;
t_surface->flags = surface->flags;
t_surface->effect = surface->effect;
@@ -1323,7 +1270,6 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
BLI_strncpy(t_surface->output_name, surface->output_name, sizeof(t_surface->output_name));
BLI_strncpy(t_surface->output_name2, surface->output_name2, sizeof(t_surface->output_name2));
}
- dynamicPaint_resetPreview(tpmd->canvas);
}
else if (tpmd->brush) {
DynamicPaintBrushSettings *brush = pmd->brush, *t_brush = tpmd->brush;
@@ -1841,7 +1787,6 @@ typedef struct DynamicPaintModifierApplyData {
float (*fcolor)[4];
MLoopCol *mloopcol;
MLoopCol *mloopcol_wet;
- MLoopCol *mloopcol_preview;
} DynamicPaintModifierApplyData;
static void dynamic_paint_apply_surface_displace_cb(void *__restrict userdata,
@@ -1906,7 +1851,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
const ParallelRangeTLS *__restrict UNUSED(tls))
{
const DynamicPaintModifierApplyData *data = userdata;
- Object *ob = data->ob;
const MLoop *mloop = data->mloop;
const MPoly *mpoly = data->mpoly;
@@ -1917,11 +1861,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
MLoopCol *mloopcol = data->mloopcol;
MLoopCol *mloopcol_wet = data->mloopcol_wet;
- MLoopCol *mloopcol_preview = data->mloopcol_preview;
-
- const Material *material = mloopcol_preview ?
- give_current_material(ob, mpoly[p_index].mat_nr + 1) :
- NULL;
for (int j = 0; j < mpoly[p_index].totloop; j++) {
const int l_index = mpoly[p_index].loopstart + j;
@@ -1940,37 +1879,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
mloopcol_wet[l_index].b = c;
mloopcol_wet[l_index].a = 255;
}
-
- /* viewport preview */
- if (mloopcol_preview) {
- if (surface->preview_id == MOD_DPAINT_SURFACE_PREV_PAINT) {
- float c[3];
-
- /* Apply material color as base vertex color for preview */
- mloopcol_preview[l_index].a = 255;
- if (material) {
- c[0] = material->r;
- c[1] = material->g;
- c[2] = material->b;
- }
- else { /* default gray */
- c[0] = 0.65f;
- c[1] = 0.65f;
- c[2] = 0.65f;
- }
- /* mix surface color */
- interp_v3_v3v3(c, c, fcolor[v_index], fcolor[v_index][3]);
-
- rgb_float_to_uchar((unsigned char *)&mloopcol_preview[l_index].r, c);
- }
- else {
- const char c = unit_float_to_uchar_clamp(pPoint[v_index].wetness);
- mloopcol_preview[l_index].r = c;
- mloopcol_preview[l_index].g = c;
- mloopcol_preview[l_index].b = c;
- mloopcol_preview[l_index].a = 255;
- }
- }
}
}
@@ -2056,22 +1964,11 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
&result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, totloop, surface->output_name2);
}
- /* Save preview results to weight layer to be able to share same drawing methods */
- MLoopCol *mloopcol_preview = NULL;
- if (surface->flags & MOD_DPAINT_PREVIEW) {
- mloopcol_preview = CustomData_get_layer(&result->ldata, CD_PREVIEW_MLOOPCOL);
- if (!mloopcol_preview) {
- mloopcol_preview = CustomData_add_layer(
- &result->ldata, CD_PREVIEW_MLOOPCOL, CD_CALLOC, NULL, totloop);
- }
- }
-
data.ob = ob;
data.mloop = mloop;
data.mpoly = mpoly;
data.mloopcol = mloopcol;
data.mloopcol_wet = mloopcol_wet;
- data.mloopcol_preview = mloopcol_preview;
{
ParallelRangeSettings settings;
@@ -2092,15 +1989,6 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
MDeformVert *dvert = CustomData_get_layer(&result->vdata, CD_MDEFORMVERT);
float *weight = (float *)sData->type_data;
- /* viewport preview */
- if (surface->flags & MOD_DPAINT_PREVIEW) {
- /* Save preview results to weight layer to be
- * able to share same drawing methods.
- * Note this func also sets DM_DIRTY_TESS_CDLAYERS flag! */
- //TODO port this function
- //DM_update_weight_mcol(ob, result, 0, weight, 0, NULL);
- }
-
/* apply weights into a vertex group, if doesn't exists add a new layer */
if (defgrp_index != -1 && !dvert && (surface->output_name[0] != '\0')) {
dvert = CustomData_add_layer(
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 7178a485a6e..63036e158bc 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -83,10 +83,8 @@ static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- /* set preview for this surface only and set active */
canvas->active_sur = 0;
for (surface = surface->prev; surface; surface = surface->prev) {
- surface->flags &= ~MOD_DPAINT_PREVIEW;
canvas->active_sur++;
}
@@ -136,7 +134,6 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
id++;
}
- dynamicPaint_resetPreview(canvas);
DEG_id_tag_update(&obj_ctx->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obj_ctx);
diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h
index 5d482024d07..38b3a4d4c89 100644
--- a/source/blender/makesdna/DNA_dynamicpaint_types.h
+++ b/source/blender/makesdna/DNA_dynamicpaint_types.h
@@ -48,7 +48,6 @@ enum {
MOD_DPAINT_MULALPHA = 1 << 3, /* Multiply color by alpha when saving image */
MOD_DPAINT_DISSOLVE_LOG = 1 << 4, /* Use 1/x for surface dissolve */
MOD_DPAINT_DRY_LOG = 1 << 5, /* Use 1/x for drying paint */
- MOD_DPAINT_PREVIEW = 1 << 6, /* preview this surface on viewport*/
MOD_DPAINT_WAVE_OPEN_BORDERS = 1 << 7, /* passes waves through mesh edges */
MOD_DPAINT_DISP_INCREMENTAL = 1 << 8, /* builds displace on top of earlier values */
@@ -77,12 +76,6 @@ enum {
MOD_DPAINT_EFFECT_DO_SHRINK = 1 << 2, /* do shrink effect */
};
-/* preview_id */
-enum {
- MOD_DPAINT_SURFACE_PREV_PAINT = 0,
- MOD_DPAINT_SURFACE_PREV_WETMAP = 1,
-};
-
/* init_color_type */
enum {
MOD_DPAINT_INITIAL_NONE = 0,
@@ -120,15 +113,11 @@ typedef struct DynamicPaintSurface {
short disp_type, image_fileformat;
/** Ui selection box. */
short effect_ui;
- /** Surface output id to preview. */
- short preview_id;
short init_color_type;
- char _pad0[2];
int flags, effect;
int image_resolution, substeps;
int start_frame, end_frame;
- char _pad[4];
/* initial color */
float init_color[4];
@@ -163,12 +152,6 @@ typedef struct DynamicPaintSurface {
/* canvas flags */
enum {
-/* This should not be needed, having a valid WEIGHT_MCOL layer should be enough.
- * And if not, should be a general flag. But seems unnecessary for now... */
-#if 0
- /** if viewport preview is ready */
- MOD_DPAINT_PREVIEW_READY = 1 << 0,
-#endif
/** surface is already baking, so it wont get updated (loop) */
MOD_DPAINT_BAKING = 1 << 1,
};
diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c
index 215c513c003..92e63b1c778 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -117,20 +117,6 @@ static void rna_DynamicPaintSurface_initialcolortype(Main *bmain, Scene *scene,
rna_DynamicPaint_redoModifier(bmain, scene, ptr);
}
-static void rna_DynamicPaintSurface_changePreview(Main *bmain, Scene *scene, PointerRNA *ptr)
-{
- DynamicPaintSurface *act_surface = (DynamicPaintSurface *)ptr->data;
- DynamicPaintSurface *surface = act_surface->canvas->surfaces.first;
-
- /* since only one color surface can show preview at time
- * disable preview on other surfaces. */
- for (; surface; surface = surface->next) {
- if (surface != act_surface)
- surface->flags &= ~MOD_DPAINT_PREVIEW;
- }
- rna_DynamicPaint_redoModifier(bmain, scene, ptr);
-}
-
static void rna_DynamicPaintSurface_uniqueName(Main *UNUSED(bmain),
Scene *UNUSED(scene),
PointerRNA *ptr)
@@ -239,14 +225,6 @@ static bool rna_DynamicPaint_is_cache_user_get(PointerRNA *ptr)
return (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) ? 1 : 0;
}
-/* is some 3D view preview available */
-static bool rna_DynamicPaint_use_color_preview_get(PointerRNA *ptr)
-{
- DynamicPaintSurface *surface = (DynamicPaintSurface *)ptr->data;
-
- return dynamicPaint_surfaceHasColorPreview(surface);
-}
-
/* does output layer exist*/
static bool rna_DynamicPaint_is_output_exists(DynamicPaintSurface *surface, Object *ob, int index)
{
@@ -354,13 +332,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
- /* Surface output preview. currently only paint has multiple outputs */
- static const EnumPropertyItem prop_dynamicpaint_surface_preview[] = {
- {MOD_DPAINT_SURFACE_PREV_PAINT, "PAINT", 0, "Paint", ""},
- {MOD_DPAINT_SURFACE_PREV_WETMAP, "WETMAP", 0, "Wetmap", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
/* Initial color setting */
static const EnumPropertyItem prop_dynamicpaint_init_color_type[] = {
{MOD_DPAINT_INITIAL_NONE, "NONE", 0, "None", ""},
@@ -421,11 +392,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Is Active", "Toggle whether surface is processed or ignored");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
- prop = RNA_def_property(srna, "show_preview", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_PREVIEW);
- RNA_def_property_ui_text(prop, "Show Preview", "Display surface preview in 3D-views");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurface_changePreview");
-
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "Surface name");
RNA_def_property_update(prop, NC_OBJECT, "rna_DynamicPaintSurface_uniqueName");
@@ -667,13 +633,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_OUT2);
RNA_def_property_ui_text(prop, "Use Output", "Save this output layer");
- prop = RNA_def_property(srna, "preview_id", PROP_ENUM, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_enum_sdna(prop, NULL, "preview_id");
- RNA_def_property_enum_items(prop, prop_dynamicpaint_surface_preview);
- RNA_def_property_ui_text(prop, "Preview", "");
- RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaint_redoModifier");
-
/* to check if output name exists */
func = RNA_def_function(srna, "output_exists", "rna_DynamicPaint_is_output_exists");
RNA_def_function_ui_description(func, "Checks if surface output layer of given name exists");
@@ -767,15 +726,6 @@ static void rna_def_canvas_surface(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, "rna_DynamicPaint_is_cache_user_get", NULL);
RNA_def_property_ui_text(prop, "Use Cache", "");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
-
- /* whether this surface has preview data for 3D view */
- RNA_define_verify_sdna(false);
- prop = RNA_def_property(srna, "use_color_preview", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_DynamicPaint_use_color_preview_get", NULL);
- RNA_def_property_ui_text(
- prop, "Use Color Preview", "Whether this surface has some color preview for 3D view");
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_define_verify_sdna(true);
}
static void rna_def_dynamic_paint_canvas_settings(BlenderRNA *brna)