Blender V5.3
dynamicpaint.cc File Reference
#include "MEM_guardedalloc.h"
#include <algorithm>
#include <cmath>
#include <cstdio>
#include "BLI_assert.hh"
#include "BLI_fileops.hh"
#include "BLI_kdtree.hh"
#include "BLI_listbase.hh"
#include "BLI_math_color_c.hh"
#include "BLI_math_geom_c.hh"
#include "BLI_math_matrix_c.hh"
#include "BLI_math_vector_c.hh"
#include "BLI_mutex.hh"
#include "BLI_path_utils.hh"
#include "BLI_string.hh"
#include "BLI_string_utf8.hh"
#include "BLI_string_utils.hh"
#include "BLI_task_c.hh"
#include "BLI_threads.hh"
#include "BLI_utildefines.hh"
#include "BLT_translation.hh"
#include "DNA_dynamicpaint_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "BKE_armature.hh"
#include "BKE_bvhutils.hh"
#include "BKE_collision.h"
#include "BKE_colorband.hh"
#include "BKE_constraint.h"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_dynamicpaint.h"
#include "BKE_effect.h"
#include "BKE_image.hh"
#include "BKE_image_format.hh"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_material.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_mapping.hh"
#include "BKE_mesh_runtime.hh"
#include "BKE_modifier.hh"
#include "BKE_object.hh"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_scene.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
#include "RE_texture.h"
#include "atomic_ops.h"
#include "CLG_log.h"

Go to the source code of this file.

Classes

struct  blender::DynamicPaintRuntime
struct  blender::Bounds2D
struct  blender::Bounds3D
struct  blender::DynamicPaintVolumeGrid
struct  blender::Vec3f
struct  blender::BakeAdjPoint
struct  blender::PaintBakeNormal
struct  blender::PaintBakeData
struct  blender::PaintUVPoint
struct  blender::ImgSeqFormatData
struct  blender::PaintAdjData
struct  blender::DynamicPaintSetInitColorData
struct  blender::DynamicPaintModifierApplyData
struct  blender::DynamicPaintCreateUVSurfaceData
struct  blender::DynamicPaintFindIslandBorderData
struct  blender::DynamicPaintOutputSurfaceImageData
struct  blender::DynamicPaintBrushVelocityData
struct  blender::DynamicPaintPaintData
struct  blender::DynamicPaintEffectData
struct  blender::DynamicPaintDissolveDryData
struct  blender::DynamicPaintGenerateBakeData

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define SUBFRAME_RECURSION   OBJECT_MODIFIER_UPDATE_SUBFRAME_RECURSION_DEFAULT
#define BRUSH_USES_VELOCITY   (1 << 0)
#define HIT_VOLUME   1
#define HIT_PROXIMITY   2
#define NOT_FOUND   -1
#define ON_MESH_EDGE   -2
#define OUT_OF_TEXTURE   -3
#define EFF_MOVEMENT_PER_FRAME   0.05f
#define WAVE_TIME_FAC   (1.0f / 24.0f)
#define CANVAS_REL_SIZE   5.0f
#define MIN_WETNESS   0.001f
#define MAX_WETNESS   5.0f
#define ADJ_ON_MESH_EDGE   (1 << 0)
#define ADJ_BORDER_PIXEL   (1 << 1)

Functions

BLI_INLINE void blender::value_dissolve (float *r_value, const float time, const float scale, const bool is_log)
void blender::dynamicPaint_Modifier_free_runtime (struct DynamicPaintRuntime *runtime)
static DynamicPaintRuntime * blender::dynamicPaint_Modifier_runtime_ensure (DynamicPaintModifierData *pmd)
static Mesh * blender::dynamicPaint_canvas_mesh_get (DynamicPaintCanvasSettings *canvas)
static bool blender::setError (DynamicPaintCanvasSettings *canvas, const char *string)
static int blender::dynamicPaint_surfaceNumOfPoints (DynamicPaintSurface *surface)
struct DynamicPaintSurface * blender::get_activeSurface (struct DynamicPaintCanvasSettings *canvas)
bool blender::dynamicPaint_outputLayerExists (struct DynamicPaintSurface *surface, struct Object *ob, int output)
static bool blender::surface_duplicateOutputExists (DynamicPaintSurface *t_surface, const StringRefNull name)
static void blender::surface_setUniqueOutputName (DynamicPaintSurface *surface, char *basename, int output)
static bool blender::surface_duplicateNameExists (DynamicPaintSurface *t_surface, const StringRefNull name)
void blender::dynamicPaintSurface_setUniqueName (struct DynamicPaintSurface *surface, const char *basename)
void blender::dynamicPaintSurface_updateType (struct DynamicPaintSurface *surface)
static int blender::surface_totalSamples (DynamicPaintSurface *surface)
static void blender::blendColors (const float t_color[3], const float t_alpha, const float s_color[3], const float s_alpha, float result[4])
static float blender::mixColors (float a_color[3], float a_weight, const float b_color[3], float b_weight, float ratio)
static void blender::scene_setSubframe (Scene *scene, float subframe)
static int blender::surface_getBrushFlags (DynamicPaintSurface *surface, Depsgraph *depsgraph)
static bool blender::boundsIntersect (Bounds3D *b1, Bounds3D *b2)
static bool blender::boundsIntersectDist (Bounds3D *b1, Bounds3D *b2, const float dist)
static bool blender::boundIntersectPoint (Bounds3D *b, const float point[3], const float radius)
static void blender::boundInsert (Bounds3D *b, const float point[3])
static float blender::getSurfaceDimension (PaintSurfaceData *sData)
static void blender::freeGrid (PaintSurfaceData *data)
static void blender::grid_bound_insert_cb_ex (void *__restrict userdata, const int i, const TaskParallelTLS *__restrict tls)
static void blender::grid_bound_insert_reduce (const void *__restrict, void *__restrict chunk_join, void *__restrict chunk)
static void blender::grid_cell_points_cb_ex (void *__restrict userdata, const int i, const TaskParallelTLS *__restrict tls)
static void blender::grid_cell_points_reduce (const void *__restrict userdata, void *__restrict chunk_join, void *__restrict chunk)
static void blender::grid_cell_bounds_cb (void *__restrict userdata, const int x, const TaskParallelTLS *__restrict)
static void blender::surfaceGenerateGrid (DynamicPaintSurface *surface)
void blender::dynamicPaint_freeBrush (struct DynamicPaintModifierData *pmd)
static void blender::dynamicPaint_freeAdjData (PaintSurfaceData *data)
static void blender::free_bakeData (PaintSurfaceData *data)
static void blender::surface_freeUnusedData (DynamicPaintSurface *surface)
void blender::dynamicPaint_freeSurfaceData (struct DynamicPaintSurface *surface)
void blender::dynamicPaint_freeSurface (const DynamicPaintModifierData *pmd, DynamicPaintSurface *surface)
void blender::dynamicPaint_freeCanvas (struct DynamicPaintModifierData *pmd)
void blender::dynamicPaint_Modifier_free (struct DynamicPaintModifierData *pmd)
struct DynamicPaintSurface * blender::dynamicPaint_createNewSurface (struct DynamicPaintCanvasSettings *canvas, struct Scene *scene)
bool blender::dynamicPaint_createType (struct DynamicPaintModifierData *pmd, int type, struct Scene *scene)
void blender::dynamicPaint_Modifier_copy (const DynamicPaintModifierData *pmd, DynamicPaintModifierData *tpmd, int flag)
static void blender::dynamicPaint_allocateSurfaceType (DynamicPaintSurface *surface)
static bool blender::surface_usesAdjDistance (DynamicPaintSurface *surface)
static bool blender::surface_usesAdjData (DynamicPaintSurface *surface)
static void blender::dynamicPaint_initAdjacencyData (DynamicPaintSurface *surface, const bool force_init)
static void blender::dynamic_paint_set_init_color_tex_to_vcol_cb (void *__restrict userdata, const int i, const TaskParallelTLS *__restrict)
static void blender::dynamic_paint_set_init_color_tex_to_imseq_cb (void *__restrict userdata, const int i, const TaskParallelTLS *__restrict)
static void blender::dynamic_paint_set_init_color_vcol_to_imseq_cb (void *__restrict userdata, const int i, const TaskParallelTLS *__restrict)
static void blender::dynamicPaint_setInitialColor (const Scene *, DynamicPaintSurface *surface)
void blender::dynamicPaint_clearSurface (const Scene *scene, DynamicPaintSurface *surface)
bool blender::dynamicPaint_resetSurface (const Scene *scene, DynamicPaintSurface *surface)
static bool blender::dynamicPaint_checkSurfaceData (const Scene *scene, DynamicPaintSurface *surface)
static void blender::dynamic_paint_apply_surface_displace_cb (void *__restrict userdata, const int i, const TaskParallelTLS *__restrict)
static void blender::dynamicPaint_applySurfaceDisplace (DynamicPaintSurface *surface, Mesh *result)
static void blender::dynamic_paint_apply_surface_vpaint_blend_cb (void *__restrict userdata, const int i, const TaskParallelTLS *__restrict)
static void blender::dynamic_paint_apply_surface_vpaint_cb (void *__restrict userdata, const int p_index, const TaskParallelTLS *__restrict)
static void blender::dynamic_paint_apply_surface_wave_cb (void *__restrict userdata, const int i, const TaskParallelTLS *__restrict)
static Mesh * blender::dynamicPaint_Modifier_apply (DynamicPaintModifierData *pmd, Object *ob, Mesh *mesh)
void blender::dynamicPaint_cacheUpdateFrames (struct DynamicPaintSurface *surface)
static void blender::canvas_copyMesh (DynamicPaintCanvasSettings *canvas, Mesh *mesh)
static void blender::dynamicPaint_frameUpdate (DynamicPaintModifierData *pmd, Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *mesh)
struct Mesh * blender::dynamicPaint_Modifier_do (struct DynamicPaintModifierData *pmd, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct Mesh *mesh)
static void blender::dynamicPaint_mixPaintColors (const DynamicPaintSurface *surface, const int index, const int paintFlags, const float paintColor[3], const float paintAlpha, const float paintWetness, const float timescale)
static void blender::dynamicPaint_mixWaveHeight (PaintWavePoint *wPoint, const DynamicPaintBrushSettings *brush, float isect_height)
static void blender::dynamicPaint_updatePointData (const DynamicPaintSurface *surface, const int index, const DynamicPaintBrushSettings *brush, float paint[3], float influence, float depth, float vel_factor, const float timescale)
static bool blender::meshBrush_boundsIntersect (Bounds3D *b1, Bounds3D *b2, DynamicPaintBrushSettings *brush, float brush_radius)
static void blender::dynamic_paint_brush_velocity_compute_cb (void *__restrict userdata, const int i, const TaskParallelTLS *__restrict)
static void blender::dynamicPaint_brushMeshCalculateVelocity (Depsgraph *depsgraph, Scene *scene, Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale)
static void blender::dynamicPaint_brushObjectCalculateVelocity (Depsgraph *depsgraph, Scene *scene, Object *ob, Vec3f *brushVel, float timescale)
static void blender::dynamic_paint_paint_mesh_cell_point_cb_ex (void *__restrict userdata, const int id, const TaskParallelTLS *__restrict)
static bool blender::dynamicPaint_paintMesh (Depsgraph *depsgraph, DynamicPaintSurface *surface, DynamicPaintBrushSettings *brush, Object *brushOb, Scene *scene, float timescale)
static void blender::dynamic_paint_paint_particle_cell_point_cb_ex (void *__restrict userdata, const int id, const TaskParallelTLS *__restrict)
static bool blender::dynamicPaint_paintParticles (DynamicPaintSurface *surface, ParticleSystem *psys, DynamicPaintBrushSettings *brush, float timescale)
static void blender::dynamic_paint_paint_single_point_cb_ex (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static bool blender::dynamicPaint_paintSinglePoint (Depsgraph *depsgraph, DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush, Object *brushOb, Scene *scene, float timescale)
static void blender::dynamic_paint_prepare_adjacency_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static void blender::dynamicPaint_prepareAdjacencyData (DynamicPaintSurface *surface, const bool force_init)
static void blender::surface_determineForceTargetPoints (const PaintSurfaceData *sData, const int index, const float force[3], float closest_d[2], int closest_id[2])
static void blender::dynamicPaint_doSmudge (DynamicPaintSurface *surface, DynamicPaintBrushSettings *brush, float timescale)
static void blender::dynamic_paint_prepare_effect_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static int blender::dynamicPaint_prepareEffectStep (Depsgraph *depsgraph, DynamicPaintSurface *surface, Scene *scene, Object *ob, float **force, float timescale)
static void blender::dynamic_paint_effect_spread_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static void blender::dynamic_paint_effect_shrink_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static void blender::dynamic_paint_effect_drip_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static void blender::dynamicPaint_doEffectStep (DynamicPaintSurface *surface, float *force, PaintPoint *prevPoint, float timescale, float steps)
static void blender::dynamic_paint_border_cb (void *__restrict userdata, const int b_index, const TaskParallelTLS *__restrict)
static void blender::dynamicPaint_doBorderStep (DynamicPaintSurface *surface)
static void blender::dynamic_paint_wave_step_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static void blender::dynamicPaint_doWaveStep (DynamicPaintSurface *surface, float timescale)
static bool blender::dynamic_paint_surface_needs_dry_dissolve (DynamicPaintSurface *surface)
static void blender::dynamic_paint_surface_pre_step_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static bool blender::dynamicPaint_surfaceHasMoved (DynamicPaintSurface *surface, Object *ob)
static void blender::dynamic_paint_generate_bake_data_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static bool blender::dynamicPaint_generateBakeData (DynamicPaintSurface *surface, Depsgraph *depsgraph, Object *ob)
static int blender::dynamicPaint_doStep (Depsgraph *depsgraph, Scene *scene, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
int blender::dynamicPaint_calculateFrame (struct DynamicPaintSurface *surface, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *cObject, int frame)

Variables

static CLG_LogRef blender::LOG = {"object.dynamicpaint"}
static const float blender::gaussianFactors [5]
static const float blender::gaussianTotal = 3.309425f
static int blender::neighX [8] = {1, 1, 0, -1, -1, -1, 0, 1}
static int blender::neighY [8] = {0, 1, 1, 1, 0, -1, -1, -1}
static int blender::neighStraightX [8] = {1, 0, -1, 0, 1, -1, -1, 1}
static int blender::neighStraightY [8] = {0, 1, 0, -1, 1, 1, -1, -1}

Image Sequence / UV Image Surface Calls

#define JITTER_SAMPLES
static void blender::dynamic_paint_create_uv_surface_direct_cb (void *__restrict userdata, const int ty, const TaskParallelTLS *__restrict)
static void blender::dynamic_paint_create_uv_surface_neighbor_cb (void *__restrict userdata, const int ty, const TaskParallelTLS *__restrict)
static float blender::dist_squared_to_corner_tris_uv_edges (const Span< int3 > corner_tris, const Span< float2 > uv_map, int tri_index, const float point[2])
static void blender::dynamic_paint_find_island_border (const DynamicPaintCreateUVSurfaceData *data, DynamicPaintFindIslandBorderData *bdata, int tri_index, const float pixel[2], int in_edge, int depth)
static int blender::dynamic_paint_find_neighbor_pixel (const DynamicPaintCreateUVSurfaceData *data, const MeshElemMap *vert_to_tri_map, const int w, const int h, const int px, const int py, const int n_index)
static bool blender::dynamicPaint_pointHasNeighbor (PaintAdjData *ed, int index, int neighbor)
static bool blender::dynamicPaint_symmetrizeAdjData (PaintAdjData *ed, int active_points)
int blender::dynamicPaint_createUVSurface (struct Scene *scene, struct DynamicPaintSurface *surface, float *progress, bool *do_update)
static void blender::dynamic_paint_output_surface_image_paint_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static void blender::dynamic_paint_output_surface_image_displace_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static void blender::dynamic_paint_output_surface_image_wave_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static void blender::dynamic_paint_output_surface_image_wetmap_cb (void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
void blender::dynamicPaint_outputSurfaceImage (struct DynamicPaintSurface *surface, const char *filepath, short output_layer)

Macro Definition Documentation

◆ ADJ_BORDER_PIXEL

◆ ADJ_ON_MESH_EDGE

#define ADJ_ON_MESH_EDGE   (1 << 0)

◆ BRUSH_USES_VELOCITY

#define BRUSH_USES_VELOCITY   (1 << 0)

◆ CANVAS_REL_SIZE

#define CANVAS_REL_SIZE   5.0f

◆ EFF_MOVEMENT_PER_FRAME

#define EFF_MOVEMENT_PER_FRAME   0.05f

◆ HIT_PROXIMITY

#define HIT_PROXIMITY   2

Definition at line 112 of file dynamicpaint.cc.

Referenced by blender::dynamic_paint_paint_mesh_cell_point_cb_ex().

◆ HIT_VOLUME

#define HIT_VOLUME   1

Definition at line 111 of file dynamicpaint.cc.

Referenced by blender::dynamic_paint_paint_mesh_cell_point_cb_ex().

◆ JITTER_SAMPLES

#define JITTER_SAMPLES
Value:
{ \
0.0f, \
0.0f, \
-0.2f, \
-0.4f, \
0.2f, \
0.4f, \
0.4f, \
-0.2f, \
-0.4f, \
0.3f, \
}

Definition at line 2208 of file dynamicpaint.cc.

Referenced by blender::dynamic_paint_create_uv_surface_direct_cb(), and blender::dynamic_paint_create_uv_surface_neighbor_cb().

◆ MAX_WETNESS

#define MAX_WETNESS   5.0f

Definition at line 124 of file dynamicpaint.cc.

Referenced by blender::dynamic_paint_effect_drip_cb().

◆ MIN_WETNESS

◆ NOT_FOUND

#define NOT_FOUND   -1

◆ ON_MESH_EDGE

#define ON_MESH_EDGE   -2

◆ OUT_OF_TEXTURE

◆ SUBFRAME_RECURSION

◆ WAVE_TIME_FAC

#define WAVE_TIME_FAC   (1.0f / 24.0f)

Definition at line 120 of file dynamicpaint.cc.

Referenced by blender::dynamicPaint_doWaveStep().