Dynamicpaint: fix (unreported) missing progress bar in early baking stage.
Nothing was shown in UI during pre-bake step, while it can take several minutes to complete with heavy geometry.
This commit is contained in:
parent
c1b7acda4c
commit
951db20862
|
@ -82,7 +82,7 @@ void dynamicPaint_resetPreview(struct DynamicPaintCanvasSettings *canvas);
|
|||
struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings *canvas);
|
||||
|
||||
/* image sequence baking */
|
||||
int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface);
|
||||
int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface, float *progress, short *do_update);
|
||||
int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, struct Scene *scene, struct Object *cObject, int frame);
|
||||
void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char *filename, short output_layer);
|
||||
|
||||
|
|
|
@ -2496,7 +2496,7 @@ static int dynamic_paint_find_neighbour_pixel(
|
|||
}
|
||||
}
|
||||
|
||||
int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
|
||||
int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface, float *progress, short *do_update)
|
||||
{
|
||||
/* Antialias jitter point relative coords */
|
||||
const int aa_samples = (surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1;
|
||||
|
@ -2517,6 +2517,9 @@ int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
|
|||
Bounds2D *faceBB = NULL;
|
||||
int *final_index;
|
||||
|
||||
*progress = 0.0f;
|
||||
*do_update = true;
|
||||
|
||||
if (!dm)
|
||||
return setError(canvas, N_("Canvas mesh not updated"));
|
||||
if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ)
|
||||
|
@ -2575,6 +2578,9 @@ int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
|
|||
error = true;
|
||||
}
|
||||
|
||||
*progress = 0.01f;
|
||||
*do_update = true;
|
||||
|
||||
if (!error) {
|
||||
for (int i = 0; i < tottri; i++) {
|
||||
copy_v2_v2(faceBB[i].min, mloopuv[mlooptri[i].tri[0]].uv);
|
||||
|
@ -2585,6 +2591,9 @@ int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
|
|||
}
|
||||
}
|
||||
|
||||
*progress = 0.02f;
|
||||
*do_update = true;
|
||||
|
||||
/* Loop through every pixel and check if pixel is uv-mapped on a canvas face. */
|
||||
DynamicPaintCreateUVSurfaceData data = {
|
||||
.surface = surface, .tempPoints = tempPoints, .tempWeights = tempWeights,
|
||||
|
@ -2593,6 +2602,9 @@ int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
|
|||
};
|
||||
BLI_task_parallel_range(0, h, &data, dynamic_paint_create_uv_surface_direct_cb, h > 64 || tottri > 1000);
|
||||
|
||||
*progress = 0.04f;
|
||||
*do_update = true;
|
||||
|
||||
/*
|
||||
* Now loop through every pixel that was left without index
|
||||
* and find if they have neighboring pixels that have an index.
|
||||
|
@ -2602,6 +2614,9 @@ int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
|
|||
data.active_points = &active_points;
|
||||
BLI_task_parallel_range(0, h, &data, dynamic_paint_create_uv_surface_neighbor_cb, h > 64);
|
||||
|
||||
*progress = 0.06f;
|
||||
*do_update = true;
|
||||
|
||||
/* Generate surface adjacency data. */
|
||||
{
|
||||
int cursor = 0;
|
||||
|
@ -2660,6 +2675,9 @@ int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
|
|||
}
|
||||
}
|
||||
|
||||
*progress = 0.08f;
|
||||
*do_update = true;
|
||||
|
||||
/* Create final surface data without inactive points */
|
||||
ImgSeqFormatData *f_data = MEM_callocN(sizeof(*f_data), "ImgSeqFormatData");
|
||||
if (f_data) {
|
||||
|
@ -2740,6 +2758,9 @@ int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
|
|||
dynamicPaint_setInitialColor(scene, surface);
|
||||
}
|
||||
|
||||
*progress = 0.09f;
|
||||
*do_update = true;
|
||||
|
||||
return (error == 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -350,6 +350,9 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
|
|||
return;
|
||||
}
|
||||
|
||||
/* Show progress bar. */
|
||||
*(job->do_update) = true;
|
||||
|
||||
/* Set frame to start point (also inits modifier data) */
|
||||
frame = surface->start_frame;
|
||||
orig_frame = scene->r.cfra;
|
||||
|
@ -357,14 +360,15 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
|
|||
ED_update_for_newframe(job->bmain, scene, 1);
|
||||
|
||||
/* Init surface */
|
||||
if (!dynamicPaint_createUVSurface(scene, surface)) {
|
||||
if (!dynamicPaint_createUVSurface(scene, surface, job->progress, job->do_update)) {
|
||||
job->success = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Loop through selected frames */
|
||||
for (frame = surface->start_frame; frame <= surface->end_frame; frame++) {
|
||||
float progress = (frame - surface->start_frame) / (float)frames;
|
||||
/* The first 10% are for createUVSurface... */
|
||||
const float progress = 0.1f + 0.9f * (frame - surface->start_frame) / (float)frames;
|
||||
surface->current_frame = frame;
|
||||
|
||||
/* If user requested stop, quit baking */
|
||||
|
|
Loading…
Reference in New Issue