forked from bartvdbraak/blender
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
This commit is contained in:
parent
78f8679cfc
commit
6d09fa3577
@ -39,15 +39,6 @@ class PHYSICS_UL_dynapaint_surfaces(UIList):
|
||||
row.label(text="", icon_value=icon)
|
||||
row.prop(surf, "name", text="", emboss=False, icon_value=sticon)
|
||||
row = layout.row(align=True)
|
||||
|
||||
if surf.use_color_preview:
|
||||
row.prop(
|
||||
surf,
|
||||
"show_preview",
|
||||
text="",
|
||||
emboss=False,
|
||||
icon='RESTRICT_VIEW_OFF' if surf.show_preview else 'RESTRICT_VIEW_ON'
|
||||
)
|
||||
row.prop(surf, "is_active", text="")
|
||||
|
||||
elif self.layout_type == 'GRID':
|
||||
@ -373,9 +364,6 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
|
||||
# vertex format outputs.
|
||||
if surface.surface_format == 'VERTEX':
|
||||
if surface_type == 'PAINT':
|
||||
# toggle active preview.
|
||||
layout.prop(surface, "preview_id")
|
||||
|
||||
# paint-map output.
|
||||
row = layout.row()
|
||||
row.prop_search(surface, "output_name_a", ob.data, "vertex_colors", text="Paintmap Layer")
|
||||
|
@ -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 */
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user