Applied Dynamic Paint 1.18f patch as a codebase for GSoC.

This commit is contained in:
Miika Hamalainen 2011-05-24 07:08:58 +00:00
parent 25e276d357
commit 3b41ab432b
36 changed files with 4621 additions and 10 deletions

@ -43,6 +43,7 @@ _modules = (
"properties_particle",
"properties_physics_cloth",
"properties_physics_common",
"properties_physics_dynamicpaint",
"properties_physics_field",
"properties_physics_fluid",
"properties_physics_smoke",

@ -229,6 +229,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel):
row.prop(md, "mid_level")
row.prop(md, "strength")
def DYNAMIC_PAINT(self, layout, ob, md):
layout.label(text="See Dynamic Paint panel.")
def EDGE_SPLIT(self, layout, ob, md):
split = layout.split()

@ -64,6 +64,7 @@ class PHYSICS_PT_add(PhysicButtonsPanel, bpy.types.Panel):
if(ob.type == 'MESH'):
physics_add(self, col, context.collision, "Collision", 'COLLISION', 'MOD_PHYSICS', False)
physics_add(self, col, context.cloth, "Cloth", 'CLOTH', 'MOD_CLOTH', True)
physics_add(self, col, context.dynamic_paint, "Dynamic Paint", 'DYNAMIC_PAINT', 'MOD_FLUIDSIM', True)
col = split.column()

@ -0,0 +1,264 @@
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
import bpy
class PhysicButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
@classmethod
def poll(cls, context):
ob = context.object
rd = context.scene.render
return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.dynamic_paint)
class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint"
def draw(self, context):
layout = self.layout
md = context.dynamic_paint
ob = context.object
if md:
layout.prop(md, "dynamicpaint_type", expand=True)
if md.dynamicpaint_type == 'CANVAS':
canvas = md.canvas_settings
layout.operator("dpaint.bake", text="Bake Dynamic Paint", icon='MOD_FLUIDSIM')
if len(canvas.ui_info) != 0:
layout.label(text=canvas.ui_info)
col = layout.column()
col.label(text="Quality:")
col.prop(canvas, "resolution")
col.prop(canvas, "use_anti_aliasing")
col = layout.column()
col.label(text="Frames:")
split = col.split()
col = split.column(align=True)
col.prop(canvas, "start_frame", text="Start")
col.prop(canvas, "end_frame", text="End")
col = split.column()
col.prop(canvas, "substeps")
elif md.dynamicpaint_type == 'PAINT':
paint = md.paint_settings
layout.prop(paint, "do_paint")
split = layout.split()
col = split.column()
col.active = paint.do_paint
col.prop(paint, "absolute_alpha")
col.prop(paint, "paint_erase")
col.prop(paint, "paint_wetness", text="Wetness")
col = split.column()
col.active = paint.do_paint
sub = col.column()
sub.active = (paint.paint_source != "PSYS");
sub.prop(paint, "use_material")
if paint.use_material and paint.paint_source != "PSYS":
col.prop(paint, "material", text="")
else:
col.prop(paint, "paint_color", text="")
col.prop(paint, "paint_alpha", text="Alpha")
layout.label()
layout.prop(paint, "do_displace")
class PHYSICS_PT_dp_output(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint: Output"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
return md and (md.dynamicpaint_type == 'CANVAS')
def draw(self, context):
layout = self.layout
canvas = context.dynamic_paint.canvas_settings
col = layout.column()
col.prop(canvas, "output_paint")
sub = col.column()
sub.active = canvas.output_paint
sub.prop(canvas, "paint_output_path", text="")
sub.prop(canvas, "premultiply", text="Premultiply alpha")
layout.separator()
col = layout.column()
col.prop(canvas, "output_wet")
sub = col.column()
sub.active = canvas.output_wet
sub.prop(canvas, "wet_output_path", text="")
layout.separator()
col = layout.column()
col.prop(canvas, "output_disp")
sub = col.column()
sub.active = canvas.output_disp
sub.prop(canvas, "displace_output_path", text="")
sub.prop(canvas, "displacement", text="Strength")
split = sub.split()
sub = split.column()
sub.prop(canvas, "disp_type", text="Type")
sub = split.column()
sub.prop(canvas, "disp_format", text="Format")
class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint: Advanced"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
return md and (md.dynamicpaint_type == 'CANVAS')
def draw(self, context):
layout = self.layout
canvas = context.dynamic_paint.canvas_settings
ob = context.object
col = layout.column()
split = col.split(percentage=0.7)
split.prop(canvas, "dry_speed", text="Dry Time")
split.prop(canvas, "use_dry_log", text="Slow")
col = layout.column()
col.prop(canvas, "use_dissolve_paint")
sub = col.column()
sub.active = canvas.use_dissolve_paint
sub.prop(canvas, "dissolve_speed", text="Time")
col = layout.column()
col.prop(canvas, "use_flatten_disp", text="Flatten Displace")
sub = col.column()
sub.active = canvas.use_flatten_disp
sub.prop(canvas, "flatten_speed", text="Time")
layout.separator()
layout.prop_search(canvas, "uv_layer", ob.data, "uv_textures")
class PHYSICS_PT_dp_effects(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint: Effects"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
return md and (md.dynamicpaint_type == 'CANVAS')
def draw(self, context):
layout = self.layout
canvas = context.dynamic_paint.canvas_settings
layout.prop(canvas, "effect_ui", expand=True)
if canvas.effect_ui == "SPREAD":
layout.prop(canvas, "use_spread")
col = layout.column()
col.active = canvas.use_spread
col.prop(canvas, "spread_speed")
elif canvas.effect_ui == "DRIP":
layout.prop(canvas, "use_drip")
col = layout.column()
col.active = canvas.use_drip
col.prop(canvas, "drip_speed")
elif canvas.effect_ui == "SHRINK":
layout.prop(canvas, "use_shrink")
col = layout.column()
col.active = canvas.use_shrink
col.prop(canvas, "shrink_speed")
class PHYSICS_PT_dp_advanced_paint(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint: Advanced"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
return md and (md.dynamicpaint_type == 'PAINT')
def draw(self, context):
layout = self.layout
paint = context.dynamic_paint.paint_settings
ob = context.object
split = layout.split()
col = split.column()
col.prop(paint, "paint_source")
if paint.paint_source == "PSYS":
col.prop_search(paint, "psys", ob, "particle_systems", text="")
if paint.psys:
col.label(text="Particle effect:")
sub = col.column()
sub.active = not paint.use_part_radius
sub.prop(paint, "solid_radius", text="Solid Radius")
col.prop(paint, "use_part_radius", text="Use Particle's Radius")
col.prop(paint, "smooth_radius", text="Smooth radius")
elif paint.paint_source == "DISTANCE" or paint.paint_source == "VOLDIST":
col.prop(paint, "paint_distance", text="Paint Distance")
split = layout.row().split()
sub = split.column()
sub.prop(paint, "prox_facealigned", text="Face Aligned")
sub = split.column()
sub.prop(paint, "prox_falloff", text="Falloff")
if paint.prox_falloff == "RAMP":
col = layout.row().column()
col.label(text="Falloff Ramp:")
col.prop(paint, "prox_ramp_alpha", text="Only Use Alpha")
col.template_color_ramp(paint, "paint_ramp", expand=True)
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.register_module(__name__)
if __name__ == "__main__":
register()

@ -108,6 +108,11 @@ BVHTree* bvhtree_from_mesh_edges(struct BVHTreeFromMesh *data, struct DerivedMes
*/
void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data);
/*
* Math functions used by callbacks
*/
float ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, const float *v0, const float *v1, const float *v2);
float nearest_point_in_tri_surface(const float *v0,const float *v1,const float *v2,const float *p, int *v, int *e, float *nearest );
/*
* BVHCache

@ -0,0 +1,88 @@
/**
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* Contributor(s): Miika Hämäläinen
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef BKE_DYNAMIC_PAINT_H_
#define BKE_DYNAMIC_PAINT_H_
typedef struct FaceAdv {
float no[3];
float no_q[3];
} FaceAdv;
typedef struct BB2d {
float min[2], max[2];
} BB2d;
typedef struct Vec3f {
float v[3];
} Vec3f;
/* Actual surface point */
typedef struct PaintSurfacePoint {
/*
* Paint layer data
*/
float color[3];
float alpha;
float depth; /* displacement */
/*
* Effect / moving layer data
* ! Only generated if effects enabled !
*/
int neighbours[8]; /* Indexes of 8 neighbouring pixels if exist */
float neighbour_dist[8]; /* Distances to all 8 neighbouring pixels */
float gravity_dir; /* UV space direction of gravity */
float gravity_rate; /* Gravity strength. (Depends on surface angle.) */
/* Wet paint is handled at effect layer only
* and mixed to surface when drying */
float e_color[3];
float e_alpha;
float wetness;
short state; /* 0 = empty or dry
* 1 = wet paint
* 2 = new paint */
/*
* Pixel / mesh data
*/
int index; /* face index on domain derived mesh */
int v1, v2, v3; /* vertex indexes */
int neighbour_pixel; /* If this pixel isn't uv mapped to any face,
but it's neighbouring pixel is */
short quad;
struct Vec3f *barycentricWeights; /* b-weights for all pixel samples */
float realCoord[3]; /* current pixel center world-space coordinates */
float invNorm[3]; /*current pixel world-space inverted normal. depends on smooth/flat shading */
} PaintSurfacePoint;
typedef struct PaintSurface {
struct PaintSurfacePoint *point;
int w, h, active_points;
short pixelSamples;
} PaintSurface;
void dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm);
void dynamicPaint_Modifier_free (struct DynamicPaintModifierData *pmd);
void dynamicPaint_Modifier_createType(struct DynamicPaintModifierData *pmd);
void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct DynamicPaintModifierData *tsmd);
#endif /* BKE_DYNAMIC_PAINT_H_ */

@ -90,6 +90,7 @@ set(SRC
intern/deform.c
intern/depsgraph.c
intern/displist.c
intern/dynamicpaint.c
intern/effect.c
intern/fcurve.c
intern/fluidsim.c

@ -50,7 +50,7 @@
/* Math stuff for ray casting on mesh faces and for nearest surface */
static float ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_dist), const float *v0, const float *v1, const float *v2)
float ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_dist), const float *v0, const float *v1, const float *v2)
{
float dist;
@ -83,7 +83,7 @@ static float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, con
* Function adapted from David Eberly's distance tools (LGPL)
* http://www.geometrictools.com/LibFoundation/Distance/Distance.html
*/
static float nearest_point_in_tri_surface(const float *v0,const float *v1,const float *v2,const float *p, int *v, int *e, float *nearest )
float nearest_point_in_tri_surface(const float *v0,const float *v1,const float *v2,const float *p, int *v, int *e, float *nearest )
{
float diff[3];
float e0[3];

File diff suppressed because it is too large Load Diff

@ -49,6 +49,7 @@
#include "DNA_particle_types.h"
#include "DNA_smoke_types.h"
#include "DNA_scene_types.h"
#include "DNA_dynamicpaint_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
@ -3455,6 +3456,14 @@ void object_remove_particle_system(Scene *scene, Object *ob)
smd->flow->psys = NULL;
}
if((md = modifiers_findByType(ob, eModifierType_DynamicPaint)))
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if((pmd->type == MOD_DYNAMICPAINT_TYPE_PAINT) && pmd->paint && pmd->paint->psys)
if(pmd->paint->psys == psys)
pmd->paint->psys = NULL;
}
/* clear modifier */
psmd= psys_get_modifier(ob, psys);
BLI_remlink(&ob->modifiers, psmd);

@ -60,6 +60,7 @@ float area_poly_v3(int nr, float verts[][3], const float normal[3]);
float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2]);
float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2]);
void closest_to_line_segment_v2(float *closest, float p[2], float l1[2], float l2[2]);
float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]);
float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]);

@ -211,6 +211,21 @@ float dist_to_line_segment_v2(const float v1[2], const float v2[2], const float
return sqrtf(rc[0]*rc[0]+ rc[1]*rc[1]);
}
/* point closest to v1 on line v2-v3 in 2D */
void closest_to_line_segment_v2(float *closest, float p[2], float l1[2], float l2[2])
{
float lambda, cp[2];
lambda= closest_to_line_v2(cp,p, l1, l2);
if(lambda <= 0.0f)
copy_v2_v2(closest, l1);
else if(lambda >= 1.0f)
copy_v2_v2(closest, l2);
else
copy_v2_v2(closest, cp);
}
/* point closest to v1 on line v2-v3 in 3D */
void closest_to_line_segment_v3(float closest[3], const float v1[3], const float v2[3], const float v3[3])
{

@ -58,6 +58,7 @@
#include "DNA_cloth_types.h"
#include "DNA_controller_types.h"
#include "DNA_constraint_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_effect_types.h"
#include "DNA_fileglobal_types.h"
#include "DNA_genfile.h"
@ -4030,6 +4031,33 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
}
}
else if (md->type==eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
pmd->baking = 0; /* just in case (should be 0 already) */
if(pmd->type==MOD_DYNAMICPAINT_TYPE_CANVAS)
{
pmd->paint = NULL;
pmd->canvas = newdataadr(fd, pmd->canvas);
pmd->canvas->pmd = pmd;
pmd->canvas->surface = NULL;
pmd->canvas->dm = NULL;
pmd->canvas->ui_info[0] = '\0';
}
else if(pmd->type==MOD_DYNAMICPAINT_TYPE_PAINT)
{
pmd->canvas = NULL;
pmd->paint = newdataadr(fd, pmd->paint);
pmd->paint->pmd = pmd;
pmd->paint->mat = newdataadr(fd, pmd->paint->mat);
pmd->paint->psys = newdataadr(fd, pmd->paint->psys);
pmd->paint->paint_ramp = newdataadr(fd, pmd->paint->paint_ramp);
pmd->paint->dm = NULL;
}
}
else if (md->type==eModifierType_Collision) {
CollisionModifierData *collmd = (CollisionModifierData*) md;

@ -99,6 +99,7 @@ Any case: direct data is ALWAYS after the lib block
#include "DNA_cloth_types.h"
#include "DNA_constraint_types.h"
#include "DNA_controller_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_genfile.h"
#include "DNA_group_types.h"
#include "DNA_gpencil_types.h"
@ -1251,6 +1252,20 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
writestruct(wd, DATA, "FluidsimSettings", 1, fluidmd->fss);
}
else if(md->type==eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
if(pmd->type & MOD_DYNAMICPAINT_TYPE_CANVAS)
{
writestruct(wd, DATA, "DynamicPaintCanvasSettings", 1, pmd->canvas);
}
else if(pmd->type & MOD_DYNAMICPAINT_TYPE_PAINT)
{
writestruct(wd, DATA, "DynamicPaintPainterSettings", 1, pmd->paint);
writestruct(wd, DATA, "Material", 1, pmd->paint->mat);
writestruct(wd, DATA, "ColorBand", 1, pmd->paint->paint_ramp);
}
}
else if (md->type==eModifierType_Collision) {
/*

@ -741,7 +741,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
uiBlockBeginAlign(block);
/* Softbody not allowed in this situation, enforce! */
if ( ((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect))
&& (md->type!=eModifierType_Surface) )
&& !ELEM(md->type, eModifierType_Surface, eModifierType_DynamicPaint) )
{
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
@ -798,7 +798,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
box= uiLayoutBox(column);
row= uiLayoutRow(box, 0);
if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) {
if (!ELEM3(md->type, eModifierType_Collision, eModifierType_Surface, eModifierType_DynamicPaint)) {
/* only here obdata, the rest of modifiers is ob level */
uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);

@ -95,6 +95,9 @@ void BOID_OT_state_move_down(struct wmOperatorType *ot);
/* physics_fluid.c */
void FLUID_OT_bake(struct wmOperatorType *ot);
/* dynamicpaint.c */
void DPAINT_OT_bake(struct wmOperatorType *ot);
/* physics_pointcache.c */
void PTCACHE_OT_bake_all(struct wmOperatorType *ot);
void PTCACHE_OT_free_bake_all(struct wmOperatorType *ot);

@ -166,6 +166,13 @@ static void operatortypes_pointcache(void)
WM_operatortype_append(PTCACHE_OT_remove);
}
/********************************* dynamic paint ***********************************/
static void operatortypes_dynamicpaint(void)
{
WM_operatortype_append(DPAINT_OT_bake);
}
//static void keymap_pointcache(wmWindowManager *wm)
//{
// wmKeyMap *keymap= WM_keymap_find(wm, "Pointcache", 0, 0);
@ -184,6 +191,7 @@ void ED_operatortypes_physics(void)
operatortypes_boids();
operatortypes_fluid();
operatortypes_pointcache();
operatortypes_dynamicpaint();
}
void ED_keymap_physics(wmKeyConfig *keyconf)

@ -647,7 +647,7 @@ const char *buttons_context_dir[] = {
"world", "object", "mesh", "armature", "lattice", "curve",
"meta_ball", "lamp", "camera", "material", "material_slot",
"texture", "texture_slot", "bone", "edit_bone", "pose_bone", "particle_system", "particle_system_editable",
"cloth", "soft_body", "fluid", "smoke", "collision", "brush", NULL};
"cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", NULL};
int buttons_context(const bContext *C, const char *member, bContextDataResult *result)
{
@ -859,6 +859,16 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
set_pointer_type(path, result, &RNA_Brush);
return 1;
}
else if(CTX_data_equals(member, "dynamic_paint")) {
PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
if(ptr && ptr->data) {
Object *ob= ptr->data;
ModifierData *md= modifiers_findByType(ob, eModifierType_DynamicPaint);
CTX_data_pointer_set(result, &ob->id, &RNA_DynamicPaintModifier, md);
return 1;
}
}
else {
return 0; /* not found */
}

@ -4420,6 +4420,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
UI_icon_draw(x, y, ICON_MOD_SOLIDIFY); break;
case eModifierType_Screw:
UI_icon_draw(x, y, ICON_MOD_SCREW); break;
case eModifierType_DynamicPaint:
UI_icon_draw(x, y, ICON_MOD_FLUIDSIM); break;
default:
UI_icon_draw(x, y, ICON_DOT); break;
}

@ -0,0 +1,132 @@
/**
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* Contributor(s): Miika Hämäläinen
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef DNA_DYNAMICPAINT_TYPES_H
#define DNA_DYNAMICPAINT_TYPES_H
struct CurveMapping;
/* flags */
#define MOD_DPAINT_ANTIALIAS (1<<0) /* do antialiasing */
#define MOD_DPAINT_DISSOLVE (1<<1) /* do dissolve */
#define MOD_DPAINT_FLATTEN (1<<2) /* do displace flatten */
#define MOD_DPAINT_MULALPHA (1<<3) /* Multiply color by alpha when saving */
#define MOD_DPAINT_DRY_LOG (1<<4) /* Use 1/x for drying paint */
/* output */
#define MOD_DPAINT_OUT_PAINT (1<<0) /* output paint texture */
#define MOD_DPAINT_OUT_WET (1<<1) /* output wetmap */
#define MOD_DPAINT_OUT_DISP (1<<2) /* output displace texture */
/* disp_type */
#define MOD_DPAINT_DISPFOR_PNG 0 /* displacement output format */
#define MOD_DPAINT_DISPFOR_OPENEXR 1 /* displacement output format */
/* disp_format */
#define MOD_DPAINT_DISP_DISPLACE 0 /* displacement output displace map */
#define MOD_DPAINT_DISP_DEPTH 1 /* displacement output depth data */
/* effect */
#define MOD_DPAINT_EFFECT_DO_SPREAD (1<<0) /* do spread effect */
#define MOD_DPAINT_EFFECT_DO_DRIP (1<<1) /* do spread effect */
#define MOD_DPAINT_EFFECT_DO_SHRINK (1<<2) /* do spread effect */
/* Canvas settings */
typedef struct DynamicPaintCanvasSettings {
struct DynamicPaintModifierData *pmd; /* for fast RNA access */
struct DerivedMesh *dm;
struct PaintSurface *surface;
int flags;
int output;
short disp_type, disp_format;
int effect;
short effect_ui; // just ui selection box
short pad; // replace if need for another short
int resolution;
int start_frame, end_frame;
int substeps;
int dry_speed;
int diss_speed;
float disp_depth;
int dflat_speed; // displace flattening speed
char paint_output_path[240], wet_output_path[240], displace_output_path[240];
float spread_speed, drip_speed, shrink_speed;
char uvlayer_name[32];
char ui_info[128]; // UI info text
char error[64]; // Bake error description
} DynamicPaintCanvasSettings;
/* flags */
#define MOD_DPAINT_PART_RAD (1<<0) /* use particle radius */
#define MOD_DPAINT_DO_PAINT (1<<1) /* use particle radius */
#define MOD_DPAINT_DO_WETNESS (1<<2) /* use particle radius */
#define MOD_DPAINT_DO_DISPLACE (1<<3) /* use particle radius */
#define MOD_DPAINT_USE_MATERIAL (1<<4) /* use object material */
#define MOD_DPAINT_ABS_ALPHA (1<<5) /* doesn't increase alpha unless
paint alpha is higher than existing */
#define MOD_DPAINT_ERASE (1<<6) /* removes paint */
#define MOD_DPAINT_RAMP_ALPHA (1<<7) /* only read falloff ramp alpha */
#define MOD_DPAINT_EDGE_DISP (1<<8) /* add displacement to intersection edges */
#define MOD_DPAINT_PROX_FACEALIGNED (1<<9) /* do proximity check only in normal dir */
/* collision type */
#define MOD_DPAINT_COL_VOLUME 1 /* paint with mesh volume */
#define MOD_DPAINT_COL_DIST 2 /* paint using distance to mesh surface */
#define MOD_DPAINT_COL_VOLDIST 3 /* use both volume and distance */
#define MOD_DPAINT_COL_PSYS 4 /* use particle system */
/* proximity_falloff */
#define MOD_DPAINT_PRFALL_SHARP 0 /* no-falloff */
#define MOD_DPAINT_PRFALL_SMOOTH 1 /* smooth, linear falloff */
#define MOD_DPAINT_PRFALL_RAMP 2 /* use color ramp */
/* Painter settings */
typedef struct DynamicPaintPainterSettings {
struct DynamicPaintModifierData *pmd; /* for fast RNA access */
struct DerivedMesh *dm;
struct ParticleSystem *psys;
struct Material *mat;
int flags;
int collision;
float r, g, b, alpha;
float wetness;
float particle_radius, particle_smooth;
float paint_distance;
float displace_distance, prox_displace_strength;
// Falloff curves
struct ColorBand *paint_ramp; /* Proximity paint falloff */
short proximity_falloff;
short pad; // replace if need for new value
int pad2; // replace if need for new value
//int pad;
} DynamicPaintPainterSettings;
#endif

@ -71,6 +71,7 @@ typedef enum ModifierType {
eModifierType_Solidify,
eModifierType_Screw,
eModifierType_Warp,
eModifierType_DynamicPaint,
NUM_MODIFIER_TYPES
} ModifierType;
@ -749,6 +750,9 @@ typedef struct ScrewModifierData {
typedef struct WarpModifierData {
ModifierData modifier;
/* keep in sync with MappingInfoModifierData */
struct Tex *texture;
struct Object *map_object;
@ -783,5 +787,20 @@ typedef enum {
eWarp_Falloff_Sphere = 7, /* PROP_SPHERE */
/* PROP_RANDOM not used */
} WarpModifierFalloff;
/* Dynamic paint modifier flags */
#define MOD_DYNAMICPAINT_TYPE_CANVAS (1 << 0)
#define MOD_DYNAMICPAINT_TYPE_PAINT (1 << 1)
typedef struct DynamicPaintModifierData {
ModifierData modifier;
struct DynamicPaintCanvasSettings *canvas;
struct DynamicPaintPainterSettings *paint;
float time;
int type; /* canvas / painter */
short baking; /* Set nonzero if baking,
* -> updates derived mesh on modifier call*/
short pad;
int pad2;
} DynamicPaintModifierData;
#endif

@ -132,6 +132,7 @@ const char *includefiles[] = {
"DNA_anim_types.h",
"DNA_boid_types.h",
"DNA_smoke_types.h",
"DNA_dynamicpaint_types.h",
// empty string to indicate end of includefiles
""
@ -1183,4 +1184,5 @@ int main(int argc, char ** argv)
#include "DNA_anim_types.h"
#include "DNA_boid_types.h"
#include "DNA_smoke_types.h"
#include "DNA_dynamicpaint_types.h"
/* end of list */

@ -194,6 +194,9 @@ extern StructRNA RNA_Driver;
extern StructRNA RNA_DriverTarget;
extern StructRNA RNA_DriverVariable;
extern StructRNA RNA_DupliObject;
extern StructRNA RNA_DynamicPaintCanvasSettings;
extern StructRNA RNA_DynamicPaintModifier;
extern StructRNA RNA_DynamicPaintPainterSettings;
extern StructRNA RNA_EdgeSplitModifier;
extern StructRNA RNA_EditBone;
extern StructRNA RNA_EffectSequence;

@ -2400,6 +2400,7 @@ static RNAProcessItem PROCESS_ITEMS[]= {
{"rna_context.c", NULL, RNA_def_context},
{"rna_controller.c", "rna_controller_api.c", RNA_def_controller},
{"rna_curve.c", NULL, RNA_def_curve},
{"rna_dynamicpaint.c", NULL, RNA_def_dynamic_paint},
{"rna_fcurve.c", "rna_fcurve_api.c", RNA_def_fcurve},
{"rna_fluidsim.c", NULL, RNA_def_fluidsim},
{"rna_gpencil.c", NULL, RNA_def_gpencil},

@ -0,0 +1,437 @@
/**
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* Contributor(s): Miika Hämäläinen
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <stdlib.h>
#include <limits.h>
#include "RNA_define.h"
#include "rna_internal.h"
#include "BKE_modifier.h"
#include "BKE_dynamicpaint.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_dynamicpaint_types.h"
#include "WM_types.h"
#ifdef RNA_RUNTIME
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_particle.h"
static char *rna_DynamicPaintCanvasSettings_path(PointerRNA *ptr)
{
DynamicPaintCanvasSettings *settings = (DynamicPaintCanvasSettings*)ptr->data;
ModifierData *md= (ModifierData *)settings->pmd;
return BLI_sprintfN("modifiers[\"%s\"].canvas_settings", md->name);
}
static char *rna_DynamicPaintPainterSettings_path(PointerRNA *ptr)
{
DynamicPaintPainterSettings *settings = (DynamicPaintPainterSettings*)ptr->data;
ModifierData *md= (ModifierData *)settings->pmd;
return BLI_sprintfN("modifiers[\"%s\"].paint_settings", md->name);
}
static void rna_DynamicPaint_uvlayer_set(PointerRNA *ptr, const char *value)
{
DynamicPaintCanvasSettings *canvas= (DynamicPaintCanvasSettings*)ptr->data;
rna_object_uvlayer_name_set(ptr, value, canvas->uvlayer_name, sizeof(canvas->uvlayer_name));
}
#else
static void rna_def_dynamic_paint_canvas_settings(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
/*
* Effect type
* Only used by ui to view per effect settings
*/
static EnumPropertyItem prop_dynamicpaint_effecttype[] = {
{1, "SPREAD", 0, "Spread", ""},
{2, "DRIP", 0, "Drip", ""},
{3, "SHRINK", 0, "Shrink", ""},
{0, NULL, 0, NULL, NULL}};
/*
* Displacemap file format
*/
static EnumPropertyItem prop_dynamicpaint_disp_format[] = {
{MOD_DPAINT_DISPFOR_PNG, "PNG", 0, "PNG", ""},
#ifdef WITH_OPENEXR
{MOD_DPAINT_DISPFOR_OPENEXR, "OPENEXR", 0, "OpenEXR", ""},
#endif
{0, NULL, 0, NULL, NULL}};
/*
* Displacemap type
*/
static EnumPropertyItem prop_dynamicpaint_disp_type[] = {
{MOD_DPAINT_DISP_DISPLACE, "DISPLACE", 0, "Displacement", ""},
{MOD_DPAINT_DISP_DEPTH, "DEPTH", 0, "Depth", ""},
{0, NULL, 0, NULL, NULL}};
srna = RNA_def_struct(brna, "DynamicPaintCanvasSettings", NULL);
RNA_def_struct_ui_text(srna, "Canvas Settings", "Dynamic Paint canvas settings");
RNA_def_struct_sdna(srna, "DynamicPaintCanvasSettings");
RNA_def_struct_path_func(srna, "rna_DynamicPaintCanvasSettings_path");
/*
* Paint, wet and disp
*/
prop= RNA_def_property(srna, "use_dissolve_paint", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DISSOLVE);
RNA_def_property_ui_text(prop, "Dissolve Paint", "Enable paint to disappear over time.");
prop= RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "diss_speed");
RNA_def_property_range(prop, 1.0, 10000.0);
RNA_def_property_ui_range(prop, 1.0, 10000.0, 5, 0);
RNA_def_property_ui_text(prop, "Dissolve Speed", "Dissolve Speed");
prop= RNA_def_property(srna, "use_flatten_disp", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_FLATTEN);
RNA_def_property_ui_text(prop, "Time Flatten", "Makes displacement map to flatten over time.");
prop= RNA_def_property(srna, "flatten_speed", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "dflat_speed");
RNA_def_property_range(prop, 1.0, 10000.0);
RNA_def_property_ui_range(prop, 1.0, 10000.0, 5, 0);
RNA_def_property_ui_text(prop, "Flatten Speed", "Flatten Speed");
prop= RNA_def_property(srna, "dry_speed", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "dry_speed");
RNA_def_property_range(prop, 1.0, 10000.0);
RNA_def_property_ui_range(prop, 1.0, 10000.0, 5, 0);
RNA_def_property_ui_text(prop, "Dry Speed", "Dry Speed");
/*
* Simulation settings
*/
prop= RNA_def_property(srna, "resolution", PROP_INT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "resolution");
RNA_def_property_range(prop, 16.0, 4096.0);
RNA_def_property_ui_range(prop, 16.0, 4096.0, 1, 0);
RNA_def_property_ui_text(prop, "Resolution", "Texture resolution");
prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "uvlayer_name");
RNA_def_property_ui_text(prop, "UV Layer", "UV layer name");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DynamicPaint_uvlayer_set");
prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "start_frame");
RNA_def_property_range(prop, 1.0, 9999.0);
RNA_def_property_ui_range(prop, 1.0, 9999, 1, 0);
RNA_def_property_ui_text(prop, "Start Frame", "Simulation start frame");
prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "end_frame");
RNA_def_property_range(prop, 1.0, 9999.0);
RNA_def_property_ui_range(prop, 1.0, 9999.0, 1, 0);
RNA_def_property_ui_text(prop, "End Frame", "Simulation end frame");
prop= RNA_def_property(srna, "substeps", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "substeps");
RNA_def_property_range(prop, 0.0, 10.0);
RNA_def_property_ui_range(prop, 0.0, 10, 1, 0);
RNA_def_property_ui_text(prop, "Sub-Steps", "Do extra frames between scene frames to ensure smooth motion.");
prop= RNA_def_property(srna, "use_anti_aliasing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ANTIALIAS);
RNA_def_property_ui_text(prop, "Anti-aliasing", "Uses 5x multisampling to smoothen paint edges.");
prop= RNA_def_property(srna, "ui_info", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "ui_info");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Bake Info", "Info on bake status");
/*
* Effect Settings
*/
prop= RNA_def_property(srna, "effect_ui", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_sdna(prop, NULL, "effect_ui");
RNA_def_property_enum_items(prop, prop_dynamicpaint_effecttype);
RNA_def_property_ui_text(prop, "Effect Type", "");
prop= RNA_def_property(srna, "use_dry_log", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DRY_LOG);
RNA_def_property_ui_text(prop, "Slow", "Use 1/x instead of linear drying.");
prop= RNA_def_property(srna, "use_spread", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "effect", MOD_DPAINT_EFFECT_DO_SPREAD);
RNA_def_property_ui_text(prop, "Use Spread", "Processes spread effect. Spreads wet paint around surface.");
prop= RNA_def_property(srna, "spread_speed", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "spread_speed");
RNA_def_property_range(prop, 0.1, 5.0);
RNA_def_property_ui_range(prop, 0.1, 5.0, 1, 2);
RNA_def_property_ui_text(prop, "Spread Speed", "How fast spread effect moves on the canvas surface.");
prop= RNA_def_property(srna, "use_drip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "effect", MOD_DPAINT_EFFECT_DO_DRIP);
RNA_def_property_ui_text(prop, "Use Drip", "Processes drip effect. Drips wet paint to gravity direction.");
prop= RNA_def_property(srna, "drip_speed", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "drip_speed");
RNA_def_property_range(prop, 0.1, 5.0);
RNA_def_property_ui_range(prop, 0.1, 5.0, 1, 2);
RNA_def_property_ui_text(prop, "Drip Speed", "How fast drip effect moves on the canvas surface.");
prop= RNA_def_property(srna, "use_shrink", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "effect", MOD_DPAINT_EFFECT_DO_SHRINK);
RNA_def_property_ui_text(prop, "Use Shrink", "Processes shrink effect. Shrinks paint areas.");
prop= RNA_def_property(srna, "shrink_speed", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shrink_speed");
RNA_def_property_range(prop, 0.1, 5.0);
RNA_def_property_ui_range(prop, 0.1, 5.0, 1, 2);
RNA_def_property_ui_text(prop, "Shrink Speed", "How fast shrink effect moves on the canvas surface.");
/*
* Output settings
*/
prop= RNA_def_property(srna, "premultiply", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_MULALPHA);
RNA_def_property_ui_text(prop, "Premultiply alpha", "Multiplies color by alpha. (Recommended for Blender input.)");
prop= RNA_def_property(srna, "paint_output_path", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_sdna(prop, NULL, "paint_output_path");
RNA_def_property_ui_text(prop, "Output Path", "Directory/name to save color textures");
prop= RNA_def_property(srna, "wet_output_path", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_sdna(prop, NULL, "wet_output_path");
RNA_def_property_ui_text(prop, "Output Path", "Directory/name to save wetmap textures");
prop= RNA_def_property(srna, "displace_output_path", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_sdna(prop, NULL, "displace_output_path");
RNA_def_property_ui_text(prop, "Output Path", "Directory/name to save displace textures");
prop= RNA_def_property(srna, "output_paint", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "output", MOD_DPAINT_OUT_PAINT);
RNA_def_property_ui_text(prop, "Ouput Paintmaps", "Generates paint textures.");
prop= RNA_def_property(srna, "output_wet", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "output", MOD_DPAINT_OUT_WET);
RNA_def_property_ui_text(prop, "Ouput Wetmaps", "Generates wetmaps.");
prop= RNA_def_property(srna, "output_disp", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "output", MOD_DPAINT_OUT_DISP);
RNA_def_property_ui_text(prop, "Output Displacement", "Generates displacement textures.");
prop= RNA_def_property(srna, "displacement", PROP_FLOAT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_float_sdna(prop, NULL, "disp_depth");
RNA_def_property_range(prop, 0.01, 5.0);
RNA_def_property_ui_range(prop, 0.01, 5.0, 1, 2);
RNA_def_property_ui_text(prop, "Displace Strength", "Maximum level of intersection to store in the texture. Use same value as the displace method strength.");
prop= RNA_def_property(srna, "disp_format", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_sdna(prop, NULL, "disp_format");
RNA_def_property_enum_items(prop, prop_dynamicpaint_disp_format);
RNA_def_property_ui_text(prop, "File Format", "");
prop= RNA_def_property(srna, "disp_type", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_sdna(prop, NULL, "disp_type");
RNA_def_property_enum_items(prop, prop_dynamicpaint_disp_type);
RNA_def_property_ui_text(prop, "Data Type", "");
}
static void rna_def_dynamic_paint_painter_settings(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
/* paint collision type */
static EnumPropertyItem prop_dynamicpaint_collisiontype[] = {
{MOD_DPAINT_COL_PSYS, "PSYS", 0, "Particle System", ""},
{MOD_DPAINT_COL_DIST, "DISTANCE", 0, "Proximity", ""},
{MOD_DPAINT_COL_VOLDIST, "VOLDIST", 0, "Mesh Volume + Proximity", ""},
{MOD_DPAINT_COL_VOLUME, "VOLUME", 0, "Mesh Volume", ""},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem prop_dynamicpaint_prox_falloff[] = {
{MOD_DPAINT_PRFALL_SMOOTH, "SMOOTH", 0, "Smooth", ""},
{MOD_DPAINT_PRFALL_SHARP, "SHARP", 0, "Sharp", ""},
{MOD_DPAINT_PRFALL_RAMP, "RAMP", 0, "Color Ramp", ""},
{0, NULL, 0, NULL, NULL}};
srna = RNA_def_struct(brna, "DynamicPaintPainterSettings", NULL);
RNA_def_struct_ui_text(srna, "Paint Settings", "Paint settings");
RNA_def_struct_sdna(srna, "DynamicPaintPainterSettings");
RNA_def_struct_path_func(srna, "rna_DynamicPaintPainterSettings_path");
/*
* Paint
*/
prop= RNA_def_property(srna, "paint_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "r");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Paint Color", "Color of the paint.");
RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL);
prop= RNA_def_property(srna, "paint_alpha", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "alpha");
RNA_def_property_range(prop, 0.0, 10.0);
RNA_def_property_ui_range(prop, 0.0, 10.0, 1, 2);
RNA_def_property_ui_text(prop, "Paint Alpha", "Paint alpha.");
prop= RNA_def_property(srna, "use_material", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_USE_MATERIAL);
RNA_def_property_ui_text(prop, "Use object material", "Use object material to define color and alpha.");
prop= RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "mat");
RNA_def_property_ui_text(prop, "Material", "Material to use. If not defined, material linked to the mesh is used.");
RNA_def_property_flag(prop, PROP_EDITABLE);
prop= RNA_def_property(srna, "absolute_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ABS_ALPHA);
RNA_def_property_ui_text(prop, "Absolute Alpha", "Only increase alpha value if paint alpha is higher than existing.");
prop= RNA_def_property(srna, "paint_wetness", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "wetness");
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_range(prop, 0.0, 1.0, 5, 3);
RNA_def_property_ui_text(prop, "Paint Wetness", "Paint Wetness. Visible in wet map. Some effects only affect wet paint.");
prop= RNA_def_property(srna, "paint_erase", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ERASE);
RNA_def_property_ui_text(prop, "Erase Paint", "Erase / remove paint instead of adding it.");
/*
* Paint Area / Collision
*/
prop= RNA_def_property(srna, "paint_source", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_sdna(prop, NULL, "collision");
RNA_def_property_enum_items(prop, prop_dynamicpaint_collisiontype);
RNA_def_property_ui_text(prop, "Paint Source", "");
prop= RNA_def_property(srna, "paint_distance", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "paint_distance");
RNA_def_property_range(prop, 0.0, 500.0);
RNA_def_property_ui_range(prop, 0.0, 500.0, 10, 3);
RNA_def_property_ui_text(prop, "Proximity Distance", "Maximum distance to mesh surface to affect paint.");
prop= RNA_def_property(srna, "prox_ramp_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_RAMP_ALPHA);
RNA_def_property_ui_text(prop, "Only Use Alpha", "Only reads color ramp alpha.");
prop= RNA_def_property(srna, "edge_displace", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_EDGE_DISP);
RNA_def_property_ui_text(prop, "Edge Displace", "Add displacement to intersection edges too.");
prop= RNA_def_property(srna, "displace_distance", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "displace_distance");
RNA_def_property_range(prop, 0.0, 10.0);
RNA_def_property_ui_range(prop, 0.0, 10.0, 5, 3);
RNA_def_property_ui_text(prop, "Displace Distance", "Maximum distance to mesh surface to displace.");
prop= RNA_def_property(srna, "prox_displace_strength", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "prox_displace_strength");
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_range(prop, 0.0, 1.0, 5, 3);
RNA_def_property_ui_text(prop, "Strength", "How much of maximum intersection will be used in edges.");
prop= RNA_def_property(srna, "prox_falloff", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_sdna(prop, NULL, "proximity_falloff");
RNA_def_property_enum_items(prop, prop_dynamicpaint_prox_falloff);
RNA_def_property_ui_text(prop, "Paint Falloff", "");
prop= RNA_def_property(srna, "prox_facealigned", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_PROX_FACEALIGNED);
RNA_def_property_ui_text(prop, "Face Aligned", "Check proximity in face normal direction only.");
/*
* Particle
*/
prop= RNA_def_property(srna, "psys", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "psys");
RNA_def_property_struct_type(prop, "ParticleSystem");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Particle Systems", "The particle system to paint with.");
prop= RNA_def_property(srna, "use_part_radius", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_PART_RAD);
RNA_def_property_ui_text(prop, "Use Particle Radius", "Uses radius from particle settings.");
prop= RNA_def_property(srna, "solid_radius", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "particle_radius");
RNA_def_property_range(prop, 0.01, 10.0);
RNA_def_property_ui_range(prop, 0.01, 2.0, 5, 3);
RNA_def_property_ui_text(prop, "Solid Radius", "Radius that will be painted solid.");
prop= RNA_def_property(srna, "smooth_radius", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "particle_smooth");
RNA_def_property_range(prop, 0.0, 10.0);
RNA_def_property_ui_range(prop, 0.0, 1.0, 5, 0);
RNA_def_property_ui_text(prop, "Smooth Radius", "Smooth falloff added after solid paint area.");
/*
* Effect
*/
prop= RNA_def_property(srna, "do_paint", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DO_PAINT);
RNA_def_property_ui_text(prop, "Affect Paint", "Makes this painter to affect paint data.");
prop= RNA_def_property(srna, "do_wet", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DO_WETNESS);
RNA_def_property_ui_text(prop, "Affect Wetness", "Makes this painter to affect wetness data.");
prop= RNA_def_property(srna, "do_displace", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DO_DISPLACE);
RNA_def_property_ui_text(prop, "Affect Displace", "Makes this painter to affect displace data.");
/*
* Color ramps
*/
prop= RNA_def_property(srna, "paint_ramp", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "paint_ramp");
RNA_def_property_struct_type(prop, "ColorRamp");
RNA_def_property_ui_text(prop, "Paint Color Ramp", "Color ramp used to define proximity falloff.");
}
void RNA_def_dynamic_paint(BlenderRNA *brna)
{
rna_def_dynamic_paint_canvas_settings(brna);
rna_def_dynamic_paint_painter_settings(brna);
}
#endif

@ -138,6 +138,7 @@ void RNA_def_constraint(struct BlenderRNA *brna);
void RNA_def_context(struct BlenderRNA *brna);
void RNA_def_controller(struct BlenderRNA *brna);
void RNA_def_curve(struct BlenderRNA *brna);
void RNA_def_dynamic_paint(struct BlenderRNA *brna);
void RNA_def_fluidsim(struct BlenderRNA *brna);
void RNA_def_fcurve(struct BlenderRNA *brna);
void RNA_def_gameproperty(struct BlenderRNA *brna);

@ -47,6 +47,7 @@
#include "BKE_animsys.h"
#include "BKE_bmesh.h" /* For BevelModifierData */
#include "BKE_dynamicpaint.h" /* For dynamicPaint_Modifier_free & *_createType */
#include "BKE_multires.h"
#include "BKE_smoke.h" /* For smokeModifier_free & smokeModifier_createType */
@ -91,6 +92,7 @@ EnumPropertyItem modifier_type_items[] ={
{eModifierType_Smoke, "SMOKE", ICON_MOD_SMOKE, "Smoke", ""},
{eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""},
{eModifierType_Surface, "SURFACE", ICON_MOD_PHYSICS, "Surface", ""},
{eModifierType_DynamicPaint, "DYNAMIC_PAINT", ICON_MOD_FLUIDSIM, "Dynamic Paint", ""},
{0, NULL, 0, NULL, NULL}};
#ifdef RNA_RUNTIME
@ -183,6 +185,8 @@ static StructRNA* rna_Modifier_refine(struct PointerRNA *ptr)
return &RNA_ScrewModifier;
case eModifierType_Warp:
return &RNA_WarpModifier;
case eModifierType_DynamicPaint:
return &RNA_DynamicPaintModifier;
default:
return &RNA_Modifier;
}
@ -279,6 +283,21 @@ static void rna_Smoke_set_type(Main *bmain, Scene *scene, PointerRNA *ptr)
rna_Modifier_dependency_update(bmain, scene, ptr);
}
static void rna_DynamicPaint_set_type(Main *bmain, Scene *scene, PointerRNA *ptr)
{
DynamicPaintModifierData *pmd= (DynamicPaintModifierData *)ptr->data;
// nothing changed
if((pmd->type & MOD_DYNAMICPAINT_TYPE_CANVAS) && pmd->canvas)
return;
dynamicPaint_Modifier_free(pmd);
dynamicPaint_Modifier_createType(pmd); // create regarding of selected type
// update dependancy
rna_Modifier_dependency_update(bmain, scene, ptr);
}
static void rna_ExplodeModifier_vgroup_get(PointerRNA *ptr, char *value)
{
ExplodeModifierData *emd= (ExplodeModifierData*)ptr->data;
@ -1902,6 +1921,38 @@ static void rna_def_modifier_smoke(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Smoke_set_type");
}
static void rna_def_modifier_dynamic_paint(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
static EnumPropertyItem prop_dynamicpaint_type_items[] = {
{0, "NONE", 0, "None", ""},
{MOD_DYNAMICPAINT_TYPE_CANVAS, "CANVAS", 0, "Canvas", ""},
{MOD_DYNAMICPAINT_TYPE_PAINT, "PAINT", 0, "Paint", ""},
{0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "DynamicPaintModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Dynamic Paint Modifier", "Dynamic Paint modifier");
RNA_def_struct_sdna(srna, "DynamicPaintModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_FLUIDSIM);
prop= RNA_def_property(srna, "canvas_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "canvas");
RNA_def_property_ui_text(prop, "Canvas Settings", "");
prop= RNA_def_property(srna, "paint_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "paint");
RNA_def_property_ui_text(prop, "Paint Settings", "");
prop= RNA_def_property(srna, "dynamicpaint_type", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, prop_dynamicpaint_type_items);
RNA_def_property_ui_text(prop, "Type", "");
RNA_def_property_update(prop, 0, "rna_DynamicPaint_set_type");
}
static void rna_def_modifier_collision(BlenderRNA *brna)
{
StructRNA *srna;
@ -2462,6 +2513,7 @@ void RNA_def_modifier(BlenderRNA *brna)
rna_def_modifier_smoke(brna);
rna_def_modifier_solidify(brna);
rna_def_modifier_screw(brna);
rna_def_modifier_dynamic_paint(brna);
}
#endif

@ -49,6 +49,7 @@ set(SRC
intern/MOD_curve.c
intern/MOD_decimate.c
intern/MOD_displace.c
intern/MOD_dynamicpaint.c
intern/MOD_edgesplit.c
intern/MOD_explode.c
intern/MOD_fluidsim.c

@ -72,6 +72,7 @@ extern ModifierTypeInfo modifierType_ShapeKey;
extern ModifierTypeInfo modifierType_Solidify;
extern ModifierTypeInfo modifierType_Screw;
extern ModifierTypeInfo modifierType_Warp;
extern ModifierTypeInfo modifierType_DynamicPaint;
/* MOD_util.c */
void modifier_type_init(ModifierTypeInfo *types[]);

@ -0,0 +1,109 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* Contributor(s): Miika Hämäläinen
*
* ***** END GPL LICENSE BLOCK *****
*
*/
#include "stddef.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "MEM_guardedalloc.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_modifier.h"
#include "BKE_dynamicpaint.h"
#include "depsgraph_private.h"
#include "MOD_util.h"
static void initData(ModifierData *md)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
pmd->canvas = NULL;
pmd->paint = NULL;
pmd->baking = 0;
pmd->time = -1;
pmd->type = 0;
}
static void copyData(ModifierData *md, ModifierData *target)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*)md;
DynamicPaintModifierData *tpmd = (DynamicPaintModifierData*)target;
dynamicPaint_Modifier_copy(pmd, tpmd);
}
static void freeData(ModifierData *md)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
dynamicPaint_Modifier_free (pmd);
}
static CustomDataMask requiredDataMask(Object *ob, ModifierData *md)
{
CustomDataMask dataMask = 0;
dataMask |= (1 << CD_MTFACE);
return dataMask;
}
static void deformVerts(
ModifierData *md, Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
DerivedMesh *dm = get_cddm(ob, NULL, derivedData, vertexCos);
dynamicPaint_Modifier_do(pmd, md->scene, ob, dm);
if(dm != derivedData)
dm->release(dm);
}
static int dependsOnTime(ModifierData *md)
{
return 1;
}
ModifierTypeInfo modifierType_DynamicPaint = {
/* name */ "Dynamic Paint",
/* structName */ "DynamicPaintModifierData",
/* structSize */ sizeof(DynamicPaintModifierData),
/* type */ eModifierTypeType_OnlyDeform,
/* flags */ eModifierTypeFlag_AcceptsMesh
| eModifierTypeFlag_Single,
/* copyData */ copyData,
/* deformVerts */ deformVerts,
/* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
/* applyModifierEM */ 0,
/* initData */ initData,
/* requiredDataMask */ requiredDataMask,
/* freeData */ freeData,
/* isDisabled */ 0,
/* updateDepgraph */ 0,
/* dependsOnTime */ dependsOnTime,
/* foreachObjectLink */ 0,
/* foreachIDLink */ 0,
};

@ -279,5 +279,6 @@ void modifier_type_init(ModifierTypeInfo *types[])
INIT_TYPE(Solidify);
INIT_TYPE(Screw);
INIT_TYPE(Warp);
INIT_TYPE(DynamicPaint);
#undef INIT_TYPE
}

@ -201,6 +201,8 @@ int multitex_ext_safe(struct Tex *tex, float *texvec, struct TexResult *texres);
int multitex_nodes(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres,
short thread, short which_output, struct ShadeInput *shi, struct MTex *mtex);
void texco_mapping_ext(float *facenor, struct Tex* tex, struct MTex* mtex, float* co, float* dx, float* dy, float* texvec);
/* shaded view and bake */
struct Render;
struct Image;

@ -43,6 +43,7 @@ typedef struct VoxelDataHeader
int frames;
} VoxelDataHeader;
void cache_voxeldata(Tex *tex, int scene_frame);
void make_voxeldata(struct Render *re);
void free_voxeldata(struct Render *re);
int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres);

@ -1672,6 +1672,21 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa
}
}
void texco_mapping_ext(float *facenor, Tex* tex, MTex* mtex, float* co, float* dx, float* dy, float* texvec)
{
ShadeInput dum_shi;
float null_v3[3] = {0.0f, 0.0f, 0.0f};
memset (&dum_shi,0,sizeof(ShadeInput));
// Make sure values used by texco_mapping() are correct
dum_shi.osatex = NULL;
dum_shi.vlr = NULL;
VECCOPY(dum_shi.facenor, facenor);
texco_mapping(&dum_shi, tex, mtex, co, dx, dy, texvec, null_v3, null_v3);
}
/* Bump code from 2.5 development cycle, has a number of bugs, but here for compatibility */
typedef struct CompatibleBump {

@ -303,7 +303,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
return;
}
static void cache_voxeldata(struct Render *re, Tex *tex)
void cache_voxeldata(Tex *tex, int scene_frame)
{
VoxelData *vd = tex->vd;
FILE *fp;
@ -311,7 +311,7 @@ static void cache_voxeldata(struct Render *re, Tex *tex)
char path[sizeof(vd->source_path)];
/* only re-cache if dataset needs updating */
if ((vd->flag & TEX_VD_STILL) || (vd->cachedframe == re->r.cfra))
if ((vd->flag & TEX_VD_STILL) || (vd->cachedframe == scene_frame))
if (vd->ok) return;
/* clear out old cache, ready for new */
@ -323,7 +323,7 @@ static void cache_voxeldata(struct Render *re, Tex *tex)
if (vd->flag & TEX_VD_STILL)
curframe = vd->still_frame;
else
curframe = re->r.cfra;
curframe = scene_frame;
BLI_strncpy(path, vd->source_path, sizeof(path));
@ -332,7 +332,7 @@ static void cache_voxeldata(struct Render *re, Tex *tex)
load_frame_image_sequence(vd, tex);
return;
case TEX_VD_SMOKE:
init_frame_smoke(vd, re->r.cfra);
init_frame_smoke(vd, scene_frame);
return;
case TEX_VD_BLENDERVOXEL:
BLI_path_abs(path, G.main->name);
@ -367,7 +367,7 @@ void make_voxeldata(struct Render *re)
/* XXX: should be doing only textures used in this render */
for (tex= re->main->tex.first; tex; tex= tex->id.next) {
if(tex->id.us && tex->type==TEX_VOXELDATA) {
cache_voxeldata(re, tex);
cache_voxeldata(tex, re->r.cfra);
}
}

@ -121,6 +121,7 @@ int multitex_thread(struct Tex *tex, float *texvec, float *dxt, float *dyt, int
int multitex_ext(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres){return 0;}
int multitex_ext_safe(struct Tex *tex, float *texvec, struct TexResult *texres){return 0;}
int multitex_nodes(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres, short thread, short which_output, struct ShadeInput *shi, struct MTex *mtex) {return 0;}
void texco_mapping_ext(float *facenor, struct Tex* tex, struct MTex* mtex, float* co, float* dx, float* dy, float* texvec){}
/* nodes */
struct RenderResult *RE_GetResult(struct Render *re){return (struct RenderResult *) NULL;}
@ -145,9 +146,12 @@ double elbeemEstimateMemreq(int res, float sx, float sy, float sz, int refine, c
struct Render *RE_NewRender(const char *name){return (struct Render*) NULL;}
void RE_SwapResult(struct Render *re, struct RenderResult **rr){}
void RE_BlenderFrame(struct Render *re, struct Scene *scene, int frame){}
void cache_voxeldata(struct Tex *tex, int scene_frame){}
/* rna */
float *give_cursor(struct Scene *scene, struct View3D *v3d){return (float *) NULL;}
void WM_timecursor(struct wmWindow *win, int nr){}
void WM_cursor_restore(struct wmWindow *win){}
void WM_menutype_free(void){}
void WM_menutype_freelink(struct MenuType* mt){}
int WM_menutype_add(struct MenuType *mt) {return 0;}
@ -174,11 +178,13 @@ void ED_armature_edit_bone_remove(struct bArmature *arm, struct EditBone *exBone
void object_test_constraints (struct Object *owner){}
void ED_object_parent(struct Object *ob, struct Object *par, int type, const char *substr){}
void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con){}
int ED_operator_object_active_editable(struct bContext *C){return 0;}
void ED_node_composit_default(struct Scene *sce){}
void *ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *custumdata, int type){return 0;} /* XXX this one looks weird */
void *ED_region_draw_cb_customdata(void *handle){return 0;} /* XXX This one looks wrong also */
void ED_region_draw_cb_exit(struct ARegionType *art, void *handle){}
void ED_area_headerprint(struct ScrArea *sa, char *str){}
void ED_update_for_newframe(struct Main *bmain, struct Scene *scene, struct bScreen *screen, int mute){}
struct EditBone *ED_armature_bone_get_mirrored(struct ListBase *edbo, struct EditBone *ebo){return (struct EditBone *) NULL;}
struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, char *name){return (struct EditBone*) NULL;}