Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/dynamicpaint.c
| Show First 20 Lines • Show All 482 Lines • ▼ Show 20 Lines | |||||
| static void scene_setSubframe(Scene *scene, float subframe) | static void scene_setSubframe(Scene *scene, float subframe) | ||||
| { | { | ||||
| /* dynamic paint subframes must be done on previous frame */ | /* dynamic paint subframes must be done on previous frame */ | ||||
| scene->r.cfra -= 1; | scene->r.cfra -= 1; | ||||
| scene->r.subframe = subframe; | scene->r.subframe = subframe; | ||||
| } | } | ||||
| static int surface_getBrushFlags(DynamicPaintSurface *surface, const SceneLayer *sl) | static int surface_getBrushFlags(DynamicPaintSurface *surface, const ViewLayer *sl) | ||||
| { | { | ||||
| Base *base = NULL; | Base *base = NULL; | ||||
| GroupObject *go = NULL; | GroupObject *go = NULL; | ||||
| Object *brushObj = NULL; | Object *brushObj = NULL; | ||||
| ModifierData *md = NULL; | ModifierData *md = NULL; | ||||
| int flags = 0; | int flags = 0; | ||||
| ▲ Show 20 Lines • Show All 5,134 Lines • ▼ Show 20 Lines | static void dynamic_paint_generate_bake_data_cb(void *userdata, const int index) | ||||
| } | } | ||||
| /* calculate speed vector */ | /* calculate speed vector */ | ||||
| if (do_velocity_data && !new_bdata && !bData->clear) { | if (do_velocity_data && !new_bdata && !bData->clear) { | ||||
| sub_v3_v3v3(bData->velocity[index].v, bData->realCoord[bData->s_pos[index]].v, prev_point); | sub_v3_v3v3(bData->velocity[index].v, bData->realCoord[bData->s_pos[index]].v, prev_point); | ||||
| } | } | ||||
| } | } | ||||
| static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const SceneLayer *sl, Object *ob) | static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const ViewLayer *sl, Object *ob) | ||||
| { | { | ||||
| PaintSurfaceData *sData = surface->data; | PaintSurfaceData *sData = surface->data; | ||||
| PaintBakeData *bData = sData->bData; | PaintBakeData *bData = sData->bData; | ||||
| DerivedMesh *dm = surface->canvas->dm; | DerivedMesh *dm = surface->canvas->dm; | ||||
| int index; | int index; | ||||
| bool new_bdata = false; | bool new_bdata = false; | ||||
| const bool do_velocity_data = ((surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) || | const bool do_velocity_data = ((surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) || | ||||
| (surface_getBrushFlags(surface, sl) & BRUSH_USES_VELOCITY)); | (surface_getBrushFlags(surface, sl) & BRUSH_USES_VELOCITY)); | ||||
| ▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | static int dynamicPaint_doStep(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe) | ||||
| /* | /* | ||||
| * Loop through surface's target paint objects and do painting | * Loop through surface's target paint objects and do painting | ||||
| */ | */ | ||||
| { | { | ||||
| Base *base = NULL; | Base *base = NULL; | ||||
| GroupObject *go = NULL; | GroupObject *go = NULL; | ||||
| Object *brushObj = NULL; | Object *brushObj = NULL; | ||||
| ModifierData *md = NULL; | ModifierData *md = NULL; | ||||
| SceneLayer *sl = eval_ctx->scene_layer; | ViewLayer *sl = eval_ctx->view_layer; | ||||
| /* backup current scene frame */ | /* backup current scene frame */ | ||||
| int scene_frame = scene->r.cfra; | int scene_frame = scene->r.cfra; | ||||
| float scene_subframe = scene->r.subframe; | float scene_subframe = scene->r.subframe; | ||||
| /* either from group or from all objects */ | /* either from group or from all objects */ | ||||
| if (surface->brush_group) | if (surface->brush_group) | ||||
| go = surface->brush_group->gobject.first; | go = surface->brush_group->gobject.first; | ||||
| ▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| float timescale = 1.0f; | float timescale = 1.0f; | ||||
| /* apply previous displace on derivedmesh if incremental surface */ | /* apply previous displace on derivedmesh if incremental surface */ | ||||
| if (surface->flags & MOD_DPAINT_DISP_INCREMENTAL) | if (surface->flags & MOD_DPAINT_DISP_INCREMENTAL) | ||||
| dynamicPaint_applySurfaceDisplace(surface, surface->canvas->dm); | dynamicPaint_applySurfaceDisplace(surface, surface->canvas->dm); | ||||
| /* update bake data */ | /* update bake data */ | ||||
| dynamicPaint_generateBakeData(surface, eval_ctx->scene_layer, cObject); | dynamicPaint_generateBakeData(surface, eval_ctx->view_layer, cObject); | ||||
| /* don't do substeps for first frame */ | /* don't do substeps for first frame */ | ||||
| if (surface->substeps && (frame != surface->start_frame)) { | if (surface->substeps && (frame != surface->start_frame)) { | ||||
| int st; | int st; | ||||
| timescale = 1.0f / (surface->substeps + 1); | timescale = 1.0f / (surface->substeps + 1); | ||||
| for (st = 1; st <= surface->substeps; st++) { | for (st = 1; st <= surface->substeps; st++) { | ||||
| float subframe = ((float) st) / (surface->substeps + 1); | float subframe = ((float) st) / (surface->substeps + 1); | ||||
| if (!dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, subframe)) | if (!dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, subframe)) | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| return dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, 0.0f); | return dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, 0.0f); | ||||
| } | } | ||||