Dynamic Paint merge:

Commit Dynamic Paint from "soc-2011-carrot" branch into trunk.

End-user documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Modifiers/Simulation/Dynamic_Paint

GSoC wiki page:
http://wiki.blender.org/index.php/User:MiikaH/GSoC-2011-DynamicPaint
This commit is contained in:
Miika Hamalainen 2011-11-10 10:24:34 +00:00
commit afeb0eeaf0
78 changed files with 14394 additions and 6861 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

After

Width:  |  Height:  |  Size: 196 KiB

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

@ -230,6 +230,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
row.prop(md, "mid_level")
row.prop(md, "strength")
def DYNAMIC_PAINT(self, layout, ob, md):
layout.label(text="Settings can be found inside the Physics context")
def EDGE_SPLIT(self, layout, ob, md):
split = layout.split()

@ -65,6 +65,7 @@ class PHYSICS_PT_add(PhysicButtonsPanel, 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_DYNAMICPAINT', True)
col = split.column()
@ -106,7 +107,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
layout.label(text=cache.info)
else:
if cachetype == 'SMOKE':
if cachetype in {'SMOKE', 'DYNAMIC_PAINT'}:
if not bpy.data.is_saved:
layout.label(text="Cache is disabled until the file is saved")
layout.enabled = False
@ -118,17 +119,17 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
row = layout.row(align=True)
if cachetype != 'PSYS':
if cachetype not in {'PSYS', 'DYNAMIC_PAINT'}:
row.enabled = enabled
row.prop(cache, "frame_start")
row.prop(cache, "frame_end")
if cachetype not in {'SMOKE', 'CLOTH'}:
if cachetype not in {'SMOKE', 'CLOTH', 'DYNAMIC_PAINT'}:
row.prop(cache, "frame_step")
row.prop(cache, "use_quick_cache")
if cachetype != 'SMOKE':
layout.label(text=cache.info)
if cachetype != 'SMOKE':
if cachetype not in {'SMOKE', 'DYNAMIC_PAINT'}:
split = layout.split()
split.enabled = enabled and bpy.data.is_saved

@ -0,0 +1,497 @@
# ##### 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
from bl_ui.properties_physics_common import (
point_cache_ui,
effector_weights_ui,
)
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, "ui_type", expand=True)
if (md.ui_type == "CANVAS"):
canvas = md.canvas_settings
if (not canvas):
layout.operator("dpaint.type_toggle", text="Add Canvas").type = 'CANVAS'
else:
layout.operator("dpaint.type_toggle", text="Remove Canvas", icon='X').type = 'CANVAS'
surface = canvas.canvas_surfaces.active
row = layout.row()
row.template_list(canvas, "canvas_surfaces", canvas.canvas_surfaces, "active_index", rows=2)
col = row.column(align=True)
col.operator("dpaint.surface_slot_add", icon='ZOOMIN', text="")
col.operator("dpaint.surface_slot_remove", icon='ZOOMOUT', text="")
if surface:
layout.prop(surface, "name")
layout.prop(surface, "surface_format", expand=False)
col = layout.column()
if surface.surface_format != "VERTEX":
col.label(text="Quality:")
col.prop(surface, "image_resolution")
col.prop(surface, "use_antialiasing")
col = layout.column()
col.label(text="Frames:")
split = col.split()
col = split.column(align=True)
col.prop(surface, "frame_start", text="Start")
col.prop(surface, "frame_end", text="End")
col = split.column()
col.prop(surface, "frame_substeps")
elif (md.ui_type == "BRUSH"):
brush = md.brush_settings
engine = context.scene.render.engine
if (not brush):
layout.operator("dpaint.type_toggle", text="Add Brush").type = 'BRUSH'
else:
layout.operator("dpaint.type_toggle", text="Remove Brush", icon='X').type = 'BRUSH'
split = layout.split()
col = split.column()
col.prop(brush, "absolute_alpha")
col.prop(brush, "paint_erase")
col.prop(brush, "paint_wetness", text="Wetness")
col = split.column()
if (engine == 'BLENDER_RENDER'):
sub = col.column()
sub.active = (brush.paint_source != "PARTICLE_SYSTEM");
sub.prop(brush, "use_material")
if brush.use_material and brush.paint_source != "PARTICLE_SYSTEM" and (engine == 'BLENDER_RENDER'):
col.prop(brush, "material", text="")
col.prop(brush, "paint_alpha", text="Alpha Factor")
else:
col.prop(brush, "paint_color", text="")
col.prop(brush, "paint_alpha", text="Alpha")
class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint Advanced"
@classmethod
def poll(cls, context):
md = context.dynamic_paint
return md and (md.ui_type == "CANVAS") and (md.canvas_settings) and (md.canvas_settings.canvas_surfaces.active)
def draw(self, context):
layout = self.layout
canvas = context.dynamic_paint.canvas_settings
surface = canvas.canvas_surfaces.active
ob = context.object
layout.prop(surface, "surface_type", expand=False)
layout.separator()
# dissolve
if (surface.surface_type == "PAINT"):
split = layout.split(percentage=0.35)
col = split.column()
col.label(text="Wetmap drying:")
col = split.column()
split = col.split(percentage=0.7)
col = split.column()
col.prop(surface, "dry_speed", text="Time")
col = split.column()
col.prop(surface, "use_dry_log", text="Slow")
if (surface.surface_type != "WAVE"):
split = layout.split(percentage=0.35)
col = split.column()
if (surface.surface_type == "DISPLACE"):
col.prop(surface, "use_dissolve", text="Dissolve:")
elif (surface.surface_type == "WEIGHT"):
col.prop(surface, "use_dissolve", text="Fade:")
else:
col.prop(surface, "use_dissolve", text="Dissolve:")
col = split.column()
col.active = surface.use_dissolve
split = col.split(percentage=0.7)
col = split.column()
col.prop(surface, "dissolve_speed", text="Time")
col = split.column()
col.prop(surface, "use_dissolve_log", text="Slow")
# per type settings
if (surface.surface_type == "DISPLACE"):
layout.prop(surface, "use_incremental_displace")
if (surface.surface_format == "VERTEX"):
split = layout.split()
col = split.column()
col.prop(surface, "depth_clamp")
col = split.column()
col.prop(surface, "displace_factor")
if (surface.surface_type == "WAVE"):
layout.prop(surface, "wave_open_borders")
split = layout.split()
col = split.column(align=True)
col.prop(surface, "wave_timescale")
col.prop(surface, "wave_speed")
col = split.column(align=True)
col.prop(surface, "wave_damping")
col.prop(surface, "wave_spring")
layout.separator()
layout.prop(surface, "brush_group", text="Brush Group")
class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint Output"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
if (not (md and (md.ui_type == "CANVAS") and (md.canvas_settings))):
return 0
surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
return (surface and not (surface.surface_format=="VERTEX" and (surface.surface_type=="DISPLACE" or surface.surface_type=="WAVE")))
def draw(self, context):
layout = self.layout
canvas = context.dynamic_paint.canvas_settings
surface = canvas.canvas_surfaces.active
ob = context.object
# vertex format outputs
if (surface.surface_format == "VERTEX"):
if (surface.surface_type == "PAINT"):
# toggle active preview
layout.prop(surface, "preview_id")
# paintmap output
row = layout.row()
row.prop_search(surface, "output_name", ob.data, "vertex_colors", text="Paintmap layer: ")
ic = 'ZOOMIN'
if (surface.output_exists(object=ob, index=0)):
ic = 'ZOOMOUT'
col = row.column(align=True)
col.operator("dpaint.output_toggle", icon=ic, text="").index = 0
# wetmap output
row = layout.row()
row.prop_search(surface, "output_name2", ob.data, "vertex_colors", text="Wetmap layer: ")
ic = 'ZOOMIN'
if (surface.output_exists(object=ob, index=1)):
ic = 'ZOOMOUT'
col = row.column(align=True)
col.operator("dpaint.output_toggle", icon=ic, text="").index = 1
if (surface.surface_type == "WEIGHT"):
row = layout.row()
row.prop_search(surface, "output_name", ob, "vertex_groups", text="Vertex Group: ")
ic = 'ZOOMIN'
if (surface.output_exists(object=ob, index=0)):
ic = 'ZOOMOUT'
col = row.column(align=True)
col.operator("dpaint.output_toggle", icon=ic, text="").index = 0
# image format outputs
if (surface.surface_format == "IMAGE"):
col = layout.column()
col.operator("dpaint.bake", text="Bake Image Sequence", icon='MOD_DYNAMICPAINT')
col.prop_search(surface, "uv_layer", ob.data, "uv_textures", text="UV layer:")
layout.separator()
col.separator()
col = layout.column()
col.prop(surface, "image_output_path", text="")
split = layout.split()
col = split.column()
col.prop(surface, "image_fileformat", text="")
col = split.column()
col.prop(surface, "premultiply", text="Premultiply alpha")
col.separator()
if (surface.surface_type == "PAINT"):
split = layout.split(percentage=0.4)
col = split.column()
col.prop(surface, "do_output1", text="Paintmaps:")
sub = split.column()
sub.active = surface.do_output1
sub.prop(surface, "output_name", text="")
split = layout.split(percentage=0.4)
col = split.column()
col.prop(surface, "do_output2", text="Wetmaps:")
sub = split.column()
sub.active = surface.do_output2
sub.prop(surface, "output_name2", text="")
else:
col = layout.column()
col.prop(surface, "output_name", text="Filename: ")
if (surface.surface_type == "DISPLACE"):
col.prop(surface, "displace_type", text="Displace Type")
col.prop(surface, "depth_clamp")
if (surface.surface_type == "WAVE"):
col.prop(surface, "depth_clamp", text="Wave Clamp")
class PHYSICS_PT_dp_canvas_initial_color(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint Initial Color"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
if (not (md and (md.ui_type == "CANVAS") and (md.canvas_settings))):
return 0
surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
return (surface and surface.surface_type=="PAINT")
def draw(self, context):
layout = self.layout
canvas = context.dynamic_paint.canvas_settings
surface = canvas.canvas_surfaces.active
ob = context.object
layout.prop(surface, "init_color_type", expand=False)
layout.separator()
# dissolve
if (surface.init_color_type == "COLOR"):
layout.prop(surface, "init_color")
if (surface.init_color_type == "TEXTURE"):
layout.prop(surface, "init_texture")
layout.prop_search(surface, "init_layername", ob.data, "uv_textures", text="UV Layer:")
if (surface.init_color_type == "VERTEX_COLOR"):
layout.prop_search(surface, "init_layername", ob.data, "vertex_colors", text="Color Layer: ")
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
if (not (md and (md.ui_type == "CANVAS") and (md.canvas_settings))):
return False;
surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
return surface and (surface.surface_type == "PAINT")
def draw(self, context):
layout = self.layout
canvas = context.dynamic_paint.canvas_settings
surface = canvas.canvas_surfaces.active
layout.prop(surface, "effect_ui", expand=True)
if surface.effect_ui == "SPREAD":
layout.prop(surface, "use_spread")
col = layout.column()
col.active = surface.use_spread
split = col.split()
sub = split.column()
sub.prop(surface, "spread_speed")
sub = split.column()
sub.prop(surface, "color_spread_speed")
elif surface.effect_ui == "DRIP":
layout.prop(surface, "use_drip")
col = layout.column()
col.active = surface.use_drip
effector_weights_ui(self, context, surface.effector_weights)
split = layout.split()
layout.label(text="Surface Movement:")
split = layout.split()
col = split.column()
col.prop(surface, "drip_velocity", slider=True)
col = split.column()
col.prop(surface, "drip_acceleration", slider=True)
elif surface.effect_ui == "SHRINK":
layout.prop(surface, "use_shrink")
col = layout.column()
col.active = surface.use_shrink
col.prop(surface, "shrink_speed")
class PHYSICS_PT_dp_cache(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint Cache"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
return md and (md.ui_type == "CANVAS") and (md.canvas_settings) and \
(md.canvas_settings.canvas_surfaces.active) and (md.canvas_settings.canvas_surfaces.active.uses_cache)
def draw(self, context):
layout = self.layout
surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
cache = surface.point_cache
point_cache_ui(self, context, cache, (cache.is_baked is False), 'DYNAMIC_PAINT')
class PHYSICS_PT_dp_brush_source(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint Source"
@classmethod
def poll(cls, context):
md = context.dynamic_paint
return md and (md.ui_type == "BRUSH") and (md.brush_settings)
def draw(self, context):
layout = self.layout
brush = context.dynamic_paint.brush_settings
ob = context.object
split = layout.split()
col = split.column()
col.prop(brush, "paint_source")
if brush.paint_source == "PARTICLE_SYSTEM":
col.prop_search(brush, "particle_system", ob, "particle_systems", text="")
if brush.particle_system:
col.label(text="Particle effect:")
sub = col.column()
sub.active = not brush.use_particle_radius
sub.prop(brush, "solid_radius", text="Solid Radius")
col.prop(brush, "use_particle_radius", text="Use Particle's Radius")
col.prop(brush, "smooth_radius", text="Smooth radius")
if brush.paint_source in {'DISTANCE', 'VOLUME_DISTANCE', 'POINT'}:
col.prop(brush, "paint_distance", text="Paint Distance")
split = layout.row().split(percentage=0.4)
sub = split.column()
if brush.paint_source == 'DISTANCE':
sub.prop(brush, "proximity_project")
if brush.paint_source == "VOLUME_DISTANCE":
sub.prop(brush, "proximity_inverse")
sub = split.column()
if brush.paint_source == 'DISTANCE':
column = sub.column()
column.active = brush.proximity_project
column.prop(brush, "ray_direction")
sub.prop(brush, "proximity_falloff")
if brush.proximity_falloff == "RAMP":
col = layout.row().column()
col.separator()
col.prop(brush, "proximity_ramp_alpha", text="Only Use Alpha")
col.template_color_ramp(brush, "paint_ramp", expand=True)
class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint Velocity"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
return md and (md.ui_type == "BRUSH") and (md.brush_settings)
def draw(self, context):
layout = self.layout
brush = context.dynamic_paint.brush_settings
ob = context.object
split = layout.split()
col = split.column()
col.prop(brush, "velocity_alpha")
col.prop(brush, "velocity_color")
col = split.column()
col.prop(brush, "velocity_depth")
sub = layout.row().column()
sub.active = (brush.velocity_alpha or brush.velocity_color or brush.velocity_depth)
sub.prop(brush, "max_velocity")
sub.template_color_ramp(brush, "velocity_ramp", expand=True)
layout.separator()
split = layout.split()
col = split.column()
col.prop(brush, "do_smudge")
col = split.column()
col.active = brush.do_smudge
col.prop(brush, "smudge_strength")
class PHYSICS_PT_dp_brush_wave(PhysicButtonsPanel, bpy.types.Panel):
bl_label = "Dynamic Paint Waves"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
md = context.dynamic_paint
return md and (md.ui_type == "BRUSH") and (md.brush_settings)
def draw(self, context):
layout = self.layout
brush = context.dynamic_paint.brush_settings
ob = context.object
layout.prop(brush, "wave_type")
if (brush.wave_type != "REFLECT"):
split = layout.split(percentage=0.5)
col = split.column()
col.prop(brush, "wave_factor")
col = split.column()
col.prop(brush, "wave_clamp")
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.register_module(__name__)
if __name__ == "__main__":
register()

@ -144,6 +144,7 @@ class TIME_MT_cache(Menu):
col.prop(st, "cache_particles")
col.prop(st, "cache_cloth")
col.prop(st, "cache_smoke")
col.prop(st, "cache_dynamicpaint")
class TIME_MT_frame(Menu):

@ -39,6 +39,7 @@ set(SRC_DNA_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_curve_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_customdata_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_documentation.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_dynamicpaint_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_effect_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_fileglobal_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_genfile.h

@ -105,6 +105,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 bvhtree_ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, const float v0[3], const float v1[3], const float v2[3]);
float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const float v2[3], const float p[3], int *v, int *e, float nearest[3]);
/*
* BVHCache

@ -278,6 +278,8 @@ const char *CustomData_layertype_name(int type);
/* make sure the name of layer at index is unique */
void CustomData_set_layer_unique_name(struct CustomData *data, int index);
void CustomData_validate_layer_name(const struct CustomData *data, int type, char *name, char *outname);
/* for file reading compatibility, returns false if the layer was freed,
only after this test passes, layer->data should be assigned */
int CustomData_verify_versions(struct CustomData *data, int index);

@ -0,0 +1,89 @@
/**
* ***** 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_
struct bContext;
struct wmOperator;
/* Actual surface point */
typedef struct PaintSurfaceData {
void *format_data; /* special data for each surface "format" */
void *type_data; /* data used by specific surface type */
struct PaintAdjData *adj_data; /* adjacency data for current surface */
struct PaintBakeData *bData; /* temporary per step data used for frame calculation */
unsigned int total_points;
} PaintSurfaceData;
/* Paint type surface point */
typedef struct PaintPoint {
/* 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;
float color[3];
float alpha;
} PaintPoint;
/* heigh field waves */
typedef struct PaintWavePoint {
float height;
float velocity;
short state;
} PaintWavePoint;
struct DerivedMesh *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_copy(struct DynamicPaintModifierData *pmd, struct DynamicPaintModifierData *tsmd);
int dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, struct Scene *scene);
struct DynamicPaintSurface *dynamicPaint_createNewSurface(struct DynamicPaintCanvasSettings *canvas, struct Scene *scene);
void dynamicPaint_clearSurface(struct DynamicPaintSurface *surface);
int dynamicPaint_resetSurface(struct DynamicPaintSurface *surface);
void dynamicPaint_freeSurface(struct DynamicPaintSurface *surface);
void dynamicPaint_freeCanvas(struct DynamicPaintModifierData *pmd);
void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd);
void dynamicPaint_freeSurfaceData(struct DynamicPaintSurface *surface);
void dynamicPaint_cacheUpdateFrames(struct DynamicPaintSurface *surface);
int dynamicPaint_surfaceHasColorPreview(struct DynamicPaintSurface *surface);
int dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, struct Object *ob, int index);
void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface);
void dynamicPaintSurface_setUniqueName(struct DynamicPaintSurface *surface, char *basename);
void dynamicPaint_resetPreview(struct DynamicPaintCanvasSettings *canvas);
struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings *canvas);
/* image sequence baking */
int dynamicPaint_createUVSurface(struct DynamicPaintSurface *surface);
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);
/* PaintPoint state */
#define DPAINT_PAINT_NONE -1
#define DPAINT_PAINT_DRY 0
#define DPAINT_PAINT_WET 1
#define DPAINT_PAINT_NEW 2
/* PaintWavePoint state */
#define DPAINT_WAVE_NONE 0
#define DPAINT_WAVE_OBSTACLE 1
#define DPAINT_WAVE_REFLECT_ONLY 2
#endif /* BKE_DYNAMIC_PAINT_H_ */

@ -33,6 +33,7 @@
*/
#include "DNA_ID.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_object_force.h"
#include "DNA_boid_types.h"
#include <stdio.h> /* for FILE */
@ -65,6 +66,7 @@
#define PTCACHE_TYPE_CLOTH 2
#define PTCACHE_TYPE_SMOKE_DOMAIN 3
#define PTCACHE_TYPE_SMOKE_HIGHRES 4
#define PTCACHE_TYPE_DYNAMICPAINT 5
/* high bits reserved for flags that need to be stored in file */
#define PTCACHE_TYPEFLAG_COMPRESS (1<<16)
@ -138,7 +140,7 @@ typedef struct PTCacheID {
/* copies point data to cache data */
int (*write_stream)(PTCacheFile *pf, void *calldata);
/* copies cache cata to point data */
void (*read_stream)(PTCacheFile *pf, void *calldata);
int (*read_stream)(PTCacheFile *pf, void *calldata);
/* copies custom extradata to cache data */
void (*write_extra_data)(void *calldata, struct PTCacheMem *pm, int cfra);
@ -254,6 +256,7 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct Soft
void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys);
void BKE_ptcache_id_from_cloth(PTCacheID *pid, struct Object *ob, struct ClothModifierData *clmd);
void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd);
void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, struct Object *ob, struct DynamicPaintSurface *surface);
void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob, struct Scene *scene, int duplis);

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

@ -1921,7 +1921,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
Mesh *me = ob->data;
ModifierData *firstmd, *md;
LinkNode *datamasks, *curr;
CustomDataMask mask, nextmask;
CustomDataMask mask, nextmask, append_mask = 0;
float (*deformedVerts)[3] = NULL;
DerivedMesh *dm, *orcodm, *clothorcodm, *finaldm;
int numVerts = me->totvert;
@ -2140,6 +2140,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
mask= (CustomDataMask)GET_INT_FROM_POINTER(curr->link);
/* needMapping check here fixes bug [#28112], otherwise its
* possible that it wont be copied */
mask |= append_mask;
DM_set_only_copy(dm, mask | (needMapping ? CD_MASK_ORIGINDEX : 0));
/* add cloth rest shape key if need */
@ -2198,6 +2199,10 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
clothorcodm = ndm;
}
}
/* in case of dynamic paint, make sure preview mask remains for following modifiers */
if (md->type == eModifierType_DynamicPaint)
append_mask |= CD_MASK_WEIGHT_MCOL;
}
isPrevDeform= (mti->type == eModifierTypeType_OnlyDeform);

@ -48,7 +48,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[3], const float v1[3], const float v2[3])
float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_dist), const float v0[3], const float v1[3], const float v2[3])
{
float dist;
@ -81,7 +81,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[3], const float v1[3], const float v2[3], const float p[3], int *v, int *e, float nearest[3])
float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const float v2[3], const float p[3], int *v, int *e, float nearest[3])
{
float diff[3];
float e0[3];
@ -456,7 +456,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
{
float dist;
if(data->sphere_radius == 0.0f)
dist = ray_tri_intersection(ray, hit->dist, t0, t1, t2);
dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
else
dist = sphereray_tri_intersection(ray, data->sphere_radius, hit->dist, t0, t1, t2);

@ -878,7 +878,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
if(useColors && mc)
cp = (unsigned char *)&mc[i * 4];
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
/* no need to set shading mode to flat because
* normals are already used to change shading */
glShadeModel(GL_SMOOTH);
glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
if (!drawSmooth) {

@ -2350,6 +2350,25 @@ void CustomData_set_layer_unique_name(CustomData *data, int index)
BLI_uniquename_cb(customdata_unique_check, &data_arg, typeInfo->defaultname, '.', nlayer->name, sizeof(nlayer->name));
}
void CustomData_validate_layer_name(const CustomData *data, int type, char *name, char *outname)
{
int index = -1;
/* if a layer name was given, try to find that layer */
if(name[0])
index = CustomData_get_named_layer_index(data, type, name);
if(index < 0) {
/* either no layer was specified, or the layer we want has been
* deleted, so assign the active layer to name
*/
index = CustomData_get_active_layer_index(data, type);
strcpy(outname, data->layers[index].name);
}
else
strcpy(outname, name);
}
int CustomData_verify_versions(struct CustomData *data, int index)
{
const LayerTypeInfo *typeInfo;

File diff suppressed because it is too large Load Diff

@ -45,6 +45,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"
@ -3453,6 +3454,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->brush && pmd->brush->psys)
if(pmd->brush->psys == psys)
pmd->brush->psys = NULL;
}
/* clear modifier */
psmd= psys_get_modifier(ob, psys);
BLI_remlink(&ob->modifiers, psmd);

@ -38,6 +38,7 @@
#include "DNA_ID.h"
#include "DNA_cloth_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
@ -58,6 +59,7 @@
#include "BKE_blender.h"
#include "BKE_cloth.h"
#include "BKE_depsgraph.h"
#include "BKE_dynamicpaint.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
@ -601,7 +603,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
return ret;
}
static void ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
@ -650,6 +652,8 @@ static void ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
ptcache_file_compressed_read(pf, (unsigned char*)tcw, out_len);
}
}
return 1;
}
#else // WITH_SMOKE
static int ptcache_smoke_totpoint(void *UNUSED(smoke_v), int UNUSED(cfra)) { return 0; };
@ -657,6 +661,84 @@ static void ptcache_smoke_read(PTCacheFile *UNUSED(pf), void *UNUSED(smoke_v)) {
static int ptcache_smoke_write(PTCacheFile *UNUSED(pf), void *UNUSED(smoke_v)) { return 0; }
#endif // WITH_SMOKE
static int ptcache_dynamicpaint_totpoint(void *sd, int cfra)
{
DynamicPaintSurface *surface = (DynamicPaintSurface*)sd;
if (!surface->data) return 0;
else return surface->data->total_points;
}
#define DPAINT_CACHE_VERSION "1.01"
static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
{
DynamicPaintSurface *surface = (DynamicPaintSurface*)dp_v;
int cache_compress = 1;
/* version header */
ptcache_file_write(pf, DPAINT_CACHE_VERSION, 1, sizeof(char)*4);
if(surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
unsigned int total_points=surface->data->total_points;
unsigned int in_len;
unsigned char *out;
/* cache type */
ptcache_file_write(pf, &surface->type, 1, sizeof(int));
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
in_len = sizeof(PaintPoint)*total_points;
else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
in_len = sizeof(float)*total_points;
else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE)
in_len = sizeof(PaintWavePoint)*total_points;
else return 0;
out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer");
ptcache_file_compressed_write(pf, (unsigned char *)surface->data->type_data, in_len, out, cache_compress);
MEM_freeN(out);
}
return 1;
}
static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
{
DynamicPaintSurface *surface = (DynamicPaintSurface*)dp_v;
char version[4];
/* version header */
ptcache_file_read(pf, version, 1, sizeof(char)*4);
if (strncmp(version, DPAINT_CACHE_VERSION,4)) {printf("Dynamic Paint: Invalid cache version: %s!\n",version); return 0;}
if(surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
unsigned int data_len;
int surface_type;
/* cache type */
ptcache_file_read(pf, &surface_type, 1, sizeof(int));
if (surface_type != surface->type)
return 0;
/* read surface data */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
data_len = sizeof(PaintPoint);
else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
data_len = sizeof(float);
else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE)
data_len = sizeof(PaintWavePoint);
else return 0;
ptcache_file_compressed_read(pf, (unsigned char*)surface->data->type_data, data_len*surface->data->total_points);
}
return 1;
}
/* Creating ID's */
void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
{
@ -809,6 +891,40 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo
if(sds->wt)
pid->data_types |= (1<<BPHYS_DATA_SMOKE_HIGH);
}
void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSurface *surface)
{
memset(pid, 0, sizeof(PTCacheID));
pid->ob= ob;
pid->calldata= surface;
pid->type= PTCACHE_TYPE_DYNAMICPAINT;
pid->cache= surface->pointcache;
pid->cache_ptr= &surface->pointcache;
pid->ptcaches= &surface->ptcaches;
pid->totpoint= pid->totwrite= ptcache_dynamicpaint_totpoint;
pid->write_point = NULL;
pid->read_point = NULL;
pid->interpolate_point = NULL;
pid->write_stream = ptcache_dynamicpaint_write;
pid->read_stream = ptcache_dynamicpaint_read;
pid->write_extra_data = NULL;
pid->read_extra_data = NULL;
pid->interpolate_extra_data = NULL;
pid->write_header = ptcache_basic_header_write;
pid->read_header = ptcache_basic_header_read;
pid->data_types= BPHYS_DATA_DYNAMICPAINT;
pid->info_types= 0;
pid->stack_index = pid->cache->index;
}
void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int duplis)
{
PTCacheID *pid;
@ -849,7 +965,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
BKE_ptcache_id_from_cloth(pid, ob, (ClothModifierData*)md);
BLI_addtail(lb, pid);
}
if(md->type == eModifierType_Smoke) {
else if(md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
@ -858,6 +974,19 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
BLI_addtail(lb, pid);
}
}
else if(md->type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if(pmd->canvas)
{
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
for (; surface; surface=surface->next) {
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
BKE_ptcache_id_from_dynamicpaint(pid, ob, surface);
BLI_addtail(lb, pid);
}
}
}
}
if(scene && (duplis-- > 0) && (ob->transflag & OB_DUPLI)) {
@ -1590,7 +1719,8 @@ static int ptcache_read_stream(PTCacheID *pid, int cfra)
ptcache_file_pointers_init(pf);
// we have stream reading here
pid->read_stream(pf, pid->calldata);
if (!pid->read_stream(pf, pid->calldata))
error = 1;
}
ptcache_file_close(pf);
@ -1726,15 +1856,21 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra)
return 0;
if(cfra1) {
if(pid->read_stream)
ptcache_read_stream(pid, cfra1);
if(pid->read_stream) {
if (!ptcache_read_stream(pid, cfra1))
return 0;
}
else if(pid->read_point)
ptcache_read(pid, cfra1);
}
if(cfra2) {
if(pid->read_stream)
ptcache_read_stream(pid, cfra2);
if(pid->read_stream) {
if (!ptcache_read_stream(pid, cfra2))
return 0;
}
else if(pid->read_point) {
if(cfra1 && cfra2 && pid->interpolate_point)
ptcache_interpolate(pid, cfra, cfra1, cfra2);
@ -1975,6 +2111,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
if(!pid || !pid->cache || pid->cache->flag & PTCACHE_BAKED)
return;
if (pid->cache->flag & PTCACHE_IGNORE_CLEAR)
return;
sta = pid->cache->startframe;
end = pid->cache->endframe;
@ -2288,6 +2427,8 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
smokeModifier_reset(pid->calldata);
else if(pid->type == PTCACHE_TYPE_SMOKE_HIGHRES)
smokeModifier_reset_turbulence(pid->calldata);
else if(pid->type == PTCACHE_TYPE_DYNAMICPAINT)
dynamicPaint_clearSurface((DynamicPaintSurface*)pid->calldata);
}
if(clear)
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
@ -2344,6 +2485,18 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
if(md->type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if(pmd->canvas)
{
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
for (; surface; surface=surface->next) {
BKE_ptcache_id_from_dynamicpaint(&pid, ob, surface);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
}
}
if (ob->type == OB_ARMATURE)

@ -1964,11 +1964,14 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *u
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(stipple_quarttone);
}
/* no need to set shading mode to flat because
* normals are already used to change shading */
glShadeModel(GL_SMOOTH);
for (S=0; S<numVerts; S++) {
DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
if (drawSmooth) {
glShadeModel(GL_SMOOTH);
for (y=0; y<gridFaces; y++) {
DMGridData *a, *b;
glBegin(GL_QUAD_STRIP);
@ -2003,7 +2006,6 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *u
glEnd();
}
} else {
glShadeModel(GL_FLAT);
glBegin(GL_QUADS);
for (y=0; y<gridFaces; y++) {
for (x=0; x<gridFaces; x++) {

@ -58,6 +58,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[2], const float p[2], const float l1[2], const 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]);

@ -56,6 +56,10 @@ void BLI_remove_threads(struct ListBase *threadbase);
void BLI_end_threads (struct ListBase *threadbase);
int BLI_thread_is_main(void);
void BLI_begin_threaded_malloc(void);
void BLI_end_threaded_malloc(void);
/* System Information */
int BLI_system_thread_count(void); /* gets the number of threads the system can make use of */

@ -207,6 +207,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[2], const float p[2], const float l1[2], const 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])
{

@ -669,3 +669,17 @@ void BLI_thread_queue_nowait(ThreadQueue *queue)
pthread_mutex_unlock(&queue->mutex);
}
void BLI_begin_threaded_malloc(void)
{
if(thread_levels == 0) {
MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread);
}
thread_levels++;
}
void BLI_end_threaded_malloc(void)
{
thread_levels--;
if(thread_levels==0)
MEM_set_lock_callback(NULL, NULL);
}

@ -56,6 +56,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"
@ -4192,6 +4193,40 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
}
}
else if (md->type==eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
if(pmd->canvas)
{
pmd->canvas = newdataadr(fd, pmd->canvas);
pmd->canvas->pmd = pmd;
pmd->canvas->dm = NULL;
pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
if (pmd->canvas->surfaces.first) {
DynamicPaintSurface *surface;
link_list(fd, &pmd->canvas->surfaces);
for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next) {
surface->canvas = pmd->canvas;
surface->data = NULL;
direct_link_pointcache_list(fd, &(surface->ptcaches), &(surface->pointcache), 1);
if(!(surface->effector_weights = newdataadr(fd, surface->effector_weights)))
surface->effector_weights = BKE_add_effector_weights(NULL);
}
}
}
if(pmd->brush)
{
pmd->brush = newdataadr(fd, pmd->brush);
pmd->brush->pmd = pmd;
pmd->brush->psys = newdataadr(fd, pmd->brush->psys);
pmd->brush->paint_ramp = newdataadr(fd, pmd->brush->paint_ramp);
pmd->brush->vel_ramp = newdataadr(fd, pmd->brush->vel_ramp);
pmd->brush->dm = NULL;
}
}
else if (md->type==eModifierType_Collision) {
CollisionModifierData *collmd = (CollisionModifierData*) md;
@ -11513,7 +11548,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
/* enable all cache display */
stime->cache_display |= TIME_CACHE_DISPLAY;
stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES);
stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE);
stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT);
}
}
}

@ -97,6 +97,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"
@ -1326,6 +1327,31 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
FluidsimModifierData *fluidmd = (FluidsimModifierData*) md;
writestruct(wd, DATA, "FluidsimSettings", 1, fluidmd->fss);
}
else if(md->type==eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
if(pmd->canvas)
{
DynamicPaintSurface *surface;
writestruct(wd, DATA, "DynamicPaintCanvasSettings", 1, pmd->canvas);
/* write surfaces */
for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next)
writestruct(wd, DATA, "DynamicPaintSurface", 1, surface);
/* write caches and effector weights */
for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next) {
write_pointcaches(wd, &(surface->ptcaches));
writestruct(wd, DATA, "EffectorWeights", 1, surface->effector_weights);
}
}
if(pmd->brush)
{
writestruct(wd, DATA, "DynamicPaintBrushSettings", 1, pmd->brush);
writestruct(wd, DATA, "ColorBand", 1, pmd->brush->paint_ramp);
writestruct(wd, DATA, "ColorBand", 1, pmd->brush->vel_ramp);
}
}
else if (md->type==eModifierType_Collision) {

File diff suppressed because it is too large Load Diff

@ -240,6 +240,7 @@ int ED_mesh_uv_texture_add(struct bContext *C, struct Mesh *me, const char *name
int ED_mesh_uv_texture_remove(struct bContext *C, struct Object *ob, struct Mesh *me);
int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me, const char *name, int active_set);
int ED_mesh_color_remove(struct bContext *C, struct Object *ob, struct Mesh *me);
int ED_mesh_color_remove_named(struct bContext *C, struct Object *ob, struct Mesh *me, const char *name);
#ifdef __cplusplus
}

@ -394,8 +394,8 @@ DEF_ICON(LAMP_AREA)
#ifndef DEF_ICON_BLANK_SKIP
DEF_ICON(BLANK617)
DEF_ICON(BLANK618)
DEF_ICON(BLANK619)
#endif
DEF_ICON(META_EMPTY)
DEF_ICON(META_PLANE)
DEF_ICON(META_CUBE)
DEF_ICON(META_BALL)
@ -588,8 +588,8 @@ DEF_ICON(MOD_SMOKE)
DEF_ICON(MOD_SOLIDIFY)
DEF_ICON(MOD_SCREW)
DEF_ICON(MOD_VERTEX_WEIGHT)
DEF_ICON(MOD_DYNAMICPAINT)
#ifndef DEF_ICON_BLANK_SKIP
DEF_ICON(BLANK161)
DEF_ICON(BLANK162)
DEF_ICON(BLANK163)
DEF_ICON(BLANK164)

@ -32,6 +32,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_key_types.h"
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
@ -45,6 +46,7 @@
#include "BKE_animsys.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_dynamicpaint.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
@ -691,7 +693,7 @@ static int modifier_can_delete(ModifierData *md)
static int modifier_is_simulation(ModifierData *md)
{
// Physic Tab
if(ELEM6(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke, eModifierType_Softbody, eModifierType_Surface)) {
if(ELEM7(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke, eModifierType_Softbody, eModifierType_Surface, eModifierType_DynamicPaint)) {
return 1;
}
// Particle Tab
@ -2054,6 +2056,13 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon, int
else if(RNA_struct_is_a(itemptr->type, &RNA_TextureSlot)) {
id= RNA_pointer_get(itemptr, "texture").data;
}
else if(RNA_struct_is_a(itemptr->type, &RNA_DynamicPaintSurface)) {
DynamicPaintSurface *surface= (DynamicPaintSurface*)itemptr->data;
if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) return ICON_TEXTURE_SHADED;
else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) return ICON_OUTLINER_DATA_MESH;
else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return ICON_FILE_IMAGE;
}
/* get icon from ID */
if(id) {
@ -2171,6 +2180,25 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
/* nothing else special to do... */
uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */
}
else if(itemptr->type == &RNA_DynamicPaintSurface) {
char name_final[96];
const char *enum_name;
PropertyRNA *prop = RNA_struct_find_property(itemptr, "surface_type");
DynamicPaintSurface *surface= (DynamicPaintSurface*)itemptr->data;
RNA_property_enum_name(C, itemptr, prop, RNA_property_enum_get(itemptr, prop), &enum_name);
BLI_snprintf(name_final, sizeof(name_final), "%s (%s)",name,enum_name);
uiItemL(sub, name_final, icon);
if (dynamicPaint_surfaceHasColorPreview(surface)) {
uiBlockSetEmboss(block, UI_EMBOSSN);
uiDefIconButR(block, OPTION, 0, (surface->flags & MOD_DPAINT_PREVIEW) ? ICON_RESTRICT_VIEW_OFF : ICON_RESTRICT_VIEW_ON,
0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "show_preview", 0, 0, 0, 0, 0, NULL);
uiBlockSetEmboss(block, UI_EMBOSS);
}
uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "is_active", i, 0, 0, 0, 0, NULL);
}
/* There is a last chance to display custom controls (in addition to the name/label):
* If the given item property group features a string property named as prop_list,
* this tries to add controls for all properties of the item listed in that string property.

@ -295,6 +295,25 @@ int ED_mesh_color_remove(bContext *C, Object *ob, Mesh *me)
return 1;
}
int ED_mesh_color_remove_named(bContext *C, Object *ob, Mesh *me, const char *name)
{
CustomData *data= (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata;
CustomDataLayer *cdl;
int index;
index= CustomData_get_named_layer_index(data, CD_MCOL, name);
cdl= (index == -1)? NULL: &data->layers[index];
if(!cdl)
return 0;
delete_customdata_layer(C, ob, cdl);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
return 1;
}
/*********************** UV texture operators ************************/
static int layers_poll(bContext *C)

@ -35,6 +35,7 @@ set(INC_SYS
)
set(SRC
dynamicpaint_ops.c
particle_boids.c
particle_edit.c
particle_object.c

@ -0,0 +1,421 @@
/*
* ***** 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 *****
*/
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "BLI_blenlib.h"
#include "BLI_string.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_depsgraph.h"
#include "BKE_dynamicpaint.h"
#include "BKE_global.h"
#include "BKE_modifier.h"
#include "BKE_report.h"
#include "ED_mesh.h"
#include "ED_screen.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
/* Platform independend time */
#include "PIL_time.h"
#include "WM_types.h"
#include "WM_api.h"
static int surface_slot_add_exec(bContext *C, wmOperator *op)
{
DynamicPaintModifierData *pmd = 0;
Object *cObject = CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
DynamicPaintCanvasSettings *canvas;
DynamicPaintSurface *surface;
/* Make sure we're dealing with a canvas */
pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint);
if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED;
canvas = pmd->canvas;
surface = dynamicPaint_createNewSurface(canvas, CTX_data_scene(C));
if (!surface) 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++;
}
return OPERATOR_FINISHED;
}
/* add surface slot */
void DPAINT_OT_surface_slot_add(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Add Surface Slot";
ot->idname= "DPAINT_OT_surface_slot_add";
ot->description="Add a new Dynamic Paint surface slot";
/* api callbacks */
ot->exec= surface_slot_add_exec;
ot->poll= ED_operator_object_active_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int surface_slot_remove_exec(bContext *C, wmOperator *op)
{
DynamicPaintModifierData *pmd = 0;
Object *cObject = CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
DynamicPaintCanvasSettings *canvas;
DynamicPaintSurface *surface;
int id=0;
/* Make sure we're dealing with a canvas */
pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint);
if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED;
canvas = pmd->canvas;
surface = canvas->surfaces.first;
/* find active surface and remove it */
for(; surface; surface=surface->next) {
if(id == canvas->active_sur) {
canvas->active_sur -= 1;
dynamicPaint_freeSurface(surface);
break;
}
id++;
}
dynamicPaint_resetPreview(canvas);
DAG_id_tag_update(&cObject->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, cObject);
return OPERATOR_FINISHED;
}
/* remove surface slot */
void DPAINT_OT_surface_slot_remove(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Remove Surface Slot";
ot->idname= "DPAINT_OT_surface_slot_remove";
ot->description="Remove the selected surface slot";
/* api callbacks */
ot->exec= surface_slot_remove_exec;
ot->poll= ED_operator_object_active_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int type_toggle_exec(bContext *C, wmOperator *op)
{
Object *cObject = CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
Scene *scene = CTX_data_scene(C);
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint);
int type= RNA_enum_get(op->ptr, "type");
if (!pmd) return OPERATOR_CANCELLED;
/* if type is already enabled, toggle it off */
if (type == MOD_DYNAMICPAINT_TYPE_CANVAS && pmd->canvas) {
dynamicPaint_freeCanvas(pmd);
}
else if (type == MOD_DYNAMICPAINT_TYPE_BRUSH && pmd->brush) {
dynamicPaint_freeBrush(pmd);
}
/* else create a new type */
else {
if (!dynamicPaint_createType(pmd, type, scene))
return OPERATOR_CANCELLED;
}
/* update dependancy */
DAG_id_tag_update(&cObject->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, cObject);
DAG_scene_sort(CTX_data_main(C), scene);
return OPERATOR_FINISHED;
}
void DPAINT_OT_type_toggle(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Toggle Type Active";
ot->idname= "DPAINT_OT_type_toggle";
ot->description = "Toggles whether given type is active or not";
/* api callbacks */
ot->exec= type_toggle_exec;
ot->poll= ED_operator_object_active_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "type", prop_dynamicpaint_type_items, MOD_DYNAMICPAINT_TYPE_CANVAS, "Type", "");
ot->prop= prop;
}
static int output_toggle_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
Scene *scene = CTX_data_scene(C);
DynamicPaintSurface *surface;
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
int index= RNA_int_get(op->ptr, "index");
if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED;
surface = get_activeSurface(pmd->canvas);
/* if type is already enabled, toggle it off */
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
int exists = dynamicPaint_outputLayerExists(surface, ob, index);
char *name;
if (index == 0)
name = surface->output_name;
else if (index == 1)
name = surface->output_name2;
/* Vertex Color Layer */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
if (!exists)
ED_mesh_color_add(C, scene, ob, ob->data, name, 1);
else
ED_mesh_color_remove_named(C, ob, ob->data, name);
}
/* Vertex Weight Layer */
else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
if (!exists)
ED_vgroup_add_name(ob, name);
else {
bDeformGroup *defgroup = defgroup_find_name(ob, name);
if (defgroup) ED_vgroup_delete(ob, defgroup);
}
}
}
return OPERATOR_FINISHED;
}
void DPAINT_OT_output_toggle(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name= "Toggle Output Layer";
ot->idname= "DPAINT_OT_output_toggle";
ot->description = "Adds or removes Dynamic Paint output data layer";
/* api callbacks */
ot->exec= output_toggle_exec;
ot->poll= ED_operator_object_active_editable;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_int(ot->srna, "index", 0, 0, 1, "Index", "", 0, 1);
ot->prop= prop;
}
/***************************** Image Sequence Baking ******************************/
/*
* Do actual bake operation. Loop through to-be-baked frames.
* Returns 0 on failture.
*/
static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surface, Object *cObject)
{
DynamicPaintCanvasSettings *canvas = surface->canvas;
Scene *scene= CTX_data_scene(C);
wmWindow *win = CTX_wm_window(C);
int frame = 1;
int frames;
frames = surface->end_frame - surface->start_frame + 1;
if (frames <= 0) {BLI_strncpy(canvas->error, "No frames to bake.", sizeof(canvas->error)); return 0;}
/* Set frame to start point (also inits modifier data) */
frame = surface->start_frame;
scene->r.cfra = (int)frame;
ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1);
/* Init surface */
if (!dynamicPaint_createUVSurface(surface)) return 0;
/* Loop through selected frames */
for (frame=surface->start_frame; frame<=surface->end_frame; frame++)
{
float progress = (frame - surface->start_frame) / (float)frames * 100;
surface->current_frame = frame;
/* If user requested stop (esc), quit baking */
if (blender_test_break()) return 0;
/* Update progress bar cursor */
WM_timecursor(win, (int)progress);
/* calculate a frame */
scene->r.cfra = (int)frame;
ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1);
if (!dynamicPaint_calculateFrame(surface, scene, cObject, frame)) return 0;
/*
* Save output images
*/
{
char filename[FILE_MAX];
/* make sure output path has ending slash */
BLI_add_slash(surface->image_output_path);
/* primary output layer */
if (surface->flags & MOD_DPAINT_OUT1) {
/* set filepath */
BLI_snprintf(filename, sizeof(filename), "%s%s", surface->image_output_path, surface->output_name);
BLI_path_frame(filename, frame, 4);
/* save image */
dynamicPaint_outputSurfaceImage(surface, filename, 0);
}
/* secondary output */
if (surface->flags & MOD_DPAINT_OUT2 && surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
/* set filepath */
BLI_snprintf(filename, sizeof(filename), "%s%s", surface->image_output_path, surface->output_name2);
BLI_path_frame(filename, frame, 4);
/* save image */
dynamicPaint_outputSurfaceImage(surface, filename, 1);
}
}
}
return 1;
}
/*
* Bake Dynamic Paint image sequence surface
*/
int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op)
{
DynamicPaintModifierData *pmd = NULL;
DynamicPaintCanvasSettings *canvas;
Object *ob = CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
int status = 0;
double timer = PIL_check_seconds_timer();
char result_str[80];
DynamicPaintSurface *surface;
/*
* Get modifier data
*/
pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
if (!pmd) {
BKE_report(op->reports, RPT_ERROR, "Bake Failed: No Dynamic Paint modifier found.");
return 0;
}
/* Make sure we're dealing with a canvas */
canvas = pmd->canvas;
if (!canvas) {
BKE_report(op->reports, RPT_ERROR, "Bake Failed: Invalid Canvas.");
return 0;
}
surface = get_activeSurface(canvas);
/* Set state to baking and init surface */
canvas->error[0] = '\0';
canvas->flags |= MOD_DPAINT_BAKING;
G.afbreek= 0; /* reset blender_test_break*/
/* Bake Dynamic Paint */
status = dynamicPaint_bakeImageSequence(C, surface, ob);
/* Clear bake */
canvas->flags &= ~MOD_DPAINT_BAKING;
WM_cursor_restore(CTX_wm_window(C));
dynamicPaint_freeSurfaceData(surface);
/* Bake was successful:
* Report for ended bake and how long it took */
if (status) {
/* Format time string */
char time_str[30];
double time = PIL_check_seconds_timer() - timer;
BLI_timestr(time, time_str);
/* Show bake info */
BLI_snprintf(result_str, sizeof(result_str), "Bake Complete! (%s)", time_str);
BKE_report(op->reports, RPT_INFO, result_str);
}
else {
if (strlen(canvas->error)) { /* If an error occured */
BLI_snprintf(result_str, sizeof(result_str), "Bake Failed: %s", canvas->error);
BKE_report(op->reports, RPT_ERROR, result_str);
}
else { /* User cancelled the bake */
BLI_strncpy(result_str, "Baking Cancelled!", sizeof(result_str));
BKE_report(op->reports, RPT_WARNING, result_str);
}
}
return status;
}
static int dynamicpaint_bake_exec(bContext *C, wmOperator *op)
{
/* Bake dynamic paint */
if(!dynamicPaint_initBake(C, op)) {
return OPERATOR_CANCELLED;}
return OPERATOR_FINISHED;
}
void DPAINT_OT_bake(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Dynamic Paint Bake";
ot->description= "Bake dynamic paint image sequence surface";
ot->idname= "DPAINT_OT_bake";
/* api callbacks */
ot->exec= dynamicpaint_bake_exec;
ot->poll= ED_operator_object_active_editable;
}

@ -93,6 +93,13 @@ 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);
void DPAINT_OT_surface_slot_add(struct wmOperatorType *ot);
void DPAINT_OT_surface_slot_remove(struct wmOperatorType *ot);
void DPAINT_OT_type_toggle(struct wmOperatorType *ot);
void DPAINT_OT_output_toggle(struct wmOperatorType *ot);
/* physics_pointcache.c */
void PTCACHE_OT_bake_all(struct wmOperatorType *ot);
void PTCACHE_OT_free_bake_all(struct wmOperatorType *ot);

@ -164,6 +164,17 @@ static void operatortypes_pointcache(void)
WM_operatortype_append(PTCACHE_OT_remove);
}
/********************************* dynamic paint ***********************************/
static void operatortypes_dynamicpaint(void)
{
WM_operatortype_append(DPAINT_OT_bake);
WM_operatortype_append(DPAINT_OT_surface_slot_add);
WM_operatortype_append(DPAINT_OT_surface_slot_remove);
WM_operatortype_append(DPAINT_OT_type_toggle);
WM_operatortype_append(DPAINT_OT_output_toggle);
}
//static void keymap_pointcache(wmWindowManager *wm)
//{
// wmKeyMap *keymap= WM_keymap_find(wm, "Pointcache", 0, 0);
@ -182,6 +193,7 @@ void ED_operatortypes_physics(void)
operatortypes_boids();
operatortypes_fluid();
operatortypes_pointcache();
operatortypes_dynamicpaint();
}
void ED_keymap_physics(wmKeyConfig *keyconf)

@ -684,7 +684,7 @@ const char *buttons_context_dir[] = {
"meta_ball", "lamp", "speaker", "camera", "material", "material_slot",
"texture", "texture_slot", "texture_user", "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)
{
@ -943,6 +943,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 */
}

@ -1016,6 +1016,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
case eModifierType_WeightVGMix:
case eModifierType_WeightVGProximity:
UI_icon_draw(x, y, ICON_MOD_VERTEX_WEIGHT); break;
case eModifierType_DynamicPaint:
UI_icon_draw(x, y, ICON_MOD_DYNAMICPAINT); break;
default:
UI_icon_draw(x, y, ICON_DOT); break;
}

@ -125,12 +125,14 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
case PTCACHE_TYPE_SMOKE_HIGHRES:
if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue;
break;
case PTCACHE_TYPE_DYNAMICPAINT:
if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue;
break;
}
if(pid->cache->cached_frames == NULL)
continue;
/* make sure we have stc with correct array length */
if(stc == NULL || MEM_allocN_len(stc->array) != len*2*sizeof(float)) {
if(stc) {
@ -187,6 +189,10 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
col[0] = 0.2; col[1] = 0.2; col[2] = 0.2;
col[3] = 0.1;
break;
case PTCACHE_TYPE_DYNAMICPAINT:
col[0] = 1.0; col[1] = 0.1; col[2] = 0.75;
col[3] = 0.1;
break;
}
glColor4fv(col);
@ -634,7 +640,7 @@ static void time_init(wmWindowManager *UNUSED(wm), ScrArea *sa)
/* enable all cache display */
stime->cache_display |= TIME_CACHE_DISPLAY;
stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES);
stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE);
stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT);
}
static SpaceLink *time_duplicate(SpaceLink *sl)

@ -402,6 +402,13 @@ static int draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int matnr)
return 1; /* Set color from mcol */
}
}
static int draw_mcol__set_draw_legacy(MTFace *tface, int has_mcol, int matnr)
{
if (has_mcol) return 1;
else return 2;
}
static int draw_tface__set_draw(MTFace *tface, int has_mcol, int matnr)
{
Material *ma= give_current_material(Gtexdraw.ob, matnr+1);
@ -622,7 +629,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
ddm->release(ddm);
}
void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int faceselect)
void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags)
{
Mesh *me= ob->data;
@ -644,7 +651,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, &data);
}
else if(faceselect) {
else if(draw_flags & DRAW_FACE_SELECT) {
if(ob->mode & OB_MODE_WEIGHT_PAINT)
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1, GPU_enable_material, NULL);
else
@ -652,7 +659,10 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
}
else {
if(GPU_buffer_legacy(dm)) {
dm->drawFacesTex(dm, draw_tface__set_draw_legacy);
if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)
dm->drawFacesTex(dm, draw_mcol__set_draw_legacy);
else
dm->drawFacesTex(dm, draw_tface__set_draw_legacy);
}
else {
if(!CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL))
@ -669,7 +679,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
draw_textured_end();
/* draw edges and selected faces over textured mesh */
if(!(ob == scene->obedit) && faceselect)
if(!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT))
draw_mesh_face_select(rv3d, me, dm);
/* reset from negative scale correction */
@ -778,10 +788,10 @@ static int tex_mat_set_face_editmesh_cb(void *UNUSED(userData), int index)
return !(efa->h);
}
void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int faceselect)
void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags)
{
if(!scene_use_new_shading_nodes(scene)) {
draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, faceselect);
if((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)) {
draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags);
return;
}
@ -807,7 +817,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o
/* face hiding callback depending on mode */
if(ob == scene->obedit)
set_face_cb= tex_mat_set_face_editmesh_cb;
else if(faceselect)
else if(draw_flags & DRAW_FACE_SELECT)
set_face_cb= tex_mat_set_face_mesh_cb;
else
set_face_cb= NULL;
@ -851,7 +861,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o
glMatrixMode(GL_MODELVIEW);
/* faceselect mode drawing over textured mesh */
if(!(ob == scene->obedit) && faceselect)
if(!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT))
draw_mesh_face_select(rv3d, ob->data, dm);
}

@ -36,6 +36,7 @@
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
#include "DNA_constraint_types.h" // for drawing constraint
#include "DNA_dynamicpaint_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
#include "DNA_material_types.h"
@ -2911,13 +2912,29 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
Mesh *me = ob->data;
Material *ma= give_current_material(ob, 1);
const short hasHaloMat = (ma && (ma->material_type == MA_TYPE_HALO));
const short is_paint_sel= (ob==OBACT && paint_facesel_test(ob));
int draw_wire = 0;
int /* totvert,*/ totedge, totface;
DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask);
ModifierData *md = NULL;
int draw_flags = (ob==OBACT && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0;
if(!dm)
return;
/* check to draw dynamic paint colors */
if ((md = modifiers_findByType(ob, eModifierType_DynamicPaint)))
{
/* check if target has an active dpaint modifier */
if(md && (md->mode & eModifierMode_Realtime))
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
/* if canvas is ready to preview vertex colors */
if (pmd->canvas && pmd->canvas->flags & MOD_DPAINT_PREVIEW_READY &&
DM_get_face_data_layer(dm, CD_WEIGHT_MCOL)) {
draw_flags |= DRAW_DYNAMIC_PAINT_PREVIEW;
}
}
}
if (ob->dtx&OB_DRAWWIRE) {
draw_wire = 2; /* draw wire after solid using zoffset and depth buffer adjusment */
@ -2931,7 +2948,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
// Unwanted combination.
if (is_paint_sel) draw_wire = 0;
if (draw_flags & DRAW_FACE_SELECT) draw_wire = 0;
if(dt==OB_BOUNDBOX) {
if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
@ -2945,14 +2962,14 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
else if(dt==OB_WIRE || totface==0) {
draw_wire = 1; /* draw wire only, no depth buffer stuff */
}
else if( (is_paint_sel || (ob==OBACT && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
else if( (draw_flags & DRAW_FACE_SELECT || (ob==OBACT && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
CHECK_OB_DRAWTEXTURE(v3d, dt))
{
if ((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !(G.f&G_PICKSEL || is_paint_sel) && !draw_wire) {
if ((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !(G.f&G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) && !draw_wire) {
draw_mesh_object_outline(v3d, ob, dm);
}
if(draw_glsl_material(scene, ob, v3d, dt)) {
if(draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)) {
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
dm->drawFacesGLSL(dm, GPU_enable_material);
@ -2963,10 +2980,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
glFrontFace(GL_CCW);
}
else {
draw_mesh_textured(scene, v3d, rv3d, ob, dm, is_paint_sel);
draw_mesh_textured(scene, v3d, rv3d, ob, dm, draw_flags);
}
if(!is_paint_sel) {
if(!(draw_flags & DRAW_FACE_SELECT)) {
if(base->flag & SELECT)
UI_ThemeColor((ob==OBACT)?TH_ACTIVE:TH_SELECT);
else
@ -3002,6 +3019,38 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
/* since we already draw wire as wp guide, dont draw over the top */
draw_wire= 0;
}
else if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW) {
/* for object selection draws no shade */
if (flag & (DRAW_PICKING|DRAW_CONSTCOLOR)) {
dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
}
else {
/* draw outline */
if((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !draw_wire && !ob->sculpt)
draw_mesh_object_outline(v3d, ob, dm);
/* materials arent compatible with vertex colors */
GPU_end_object_materials();
GPU_enable_material(0, NULL);
/* set default spec */
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
glEnable(GL_COLOR_MATERIAL); /* according manpages needed */
glColor3ub(120, 120, 120);
glDisable(GL_COLOR_MATERIAL);
/* diffuse */
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
dm->drawMappedFaces(dm, NULL, NULL, 1, GPU_enable_material, NULL);
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING);
GPU_disable_material();
}
}
else {
Paint *p;

@ -58,6 +58,10 @@ struct wmNDOFMotionData;
#define DRAW_CONSTCOLOR 2
#define DRAW_SCENESET 4
/* draw_mesh_fancy/draw_mesh_textured draw_flags */
#define DRAW_DYNAMIC_PAINT_PREVIEW 1
#define DRAW_FACE_SELECT 2
/* view3d_header.c */
void view3d_header_buttons(const struct bContext *C, struct ARegion *ar);
void VIEW3D_OT_layers(struct wmOperatorType *ot);

@ -0,0 +1,207 @@
/**
* ***** 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
#include "DNA_listBase.h"
struct CurveMapping;
struct PaintSurfaceData;
/* surface format */
#define MOD_DPAINT_SURFACE_F_PTEX 0
#define MOD_DPAINT_SURFACE_F_VERTEX 1
#define MOD_DPAINT_SURFACE_F_IMAGESEQ 2
/* surface type */
#define MOD_DPAINT_SURFACE_T_PAINT 0
#define MOD_DPAINT_SURFACE_T_DISPLACE 1
#define MOD_DPAINT_SURFACE_T_WEIGHT 2
#define MOD_DPAINT_SURFACE_T_WAVE 3
/* surface flags */
#define MOD_DPAINT_ACTIVE (1<<0) /* Is surface enabled */
#define MOD_DPAINT_ANTIALIAS (1<<1) /* do antialiasing */
#define MOD_DPAINT_DISSOLVE (1<<2) /* do dissolve */
#define MOD_DPAINT_MULALPHA (1<<3) /* Multiply color by alpha when saving image */
#define MOD_DPAINT_DISSOLVE_LOG (1<<4) /* Use 1/x for surface dissolve */
#define MOD_DPAINT_DRY_LOG (1<<5) /* Use 1/x for drying paint */
#define MOD_DPAINT_PREVIEW (1<<6) /* preview this surface on viewport*/
#define MOD_DPAINT_WAVE_OPEN_BORDERS (1<<7) /* passes waves through mesh edges */
#define MOD_DPAINT_DISP_INCREMENTAL (1<<8) /* builds displace on top of earlier values */
#define MOD_DPAINT_OUT1 (1<<10) /* output primary surface */
#define MOD_DPAINT_OUT2 (1<<11) /* output secondary surface */
/* image_fileformat */
#define MOD_DPAINT_IMGFORMAT_PNG 0
#define MOD_DPAINT_IMGFORMAT_OPENEXR 1
/* 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 */
/* preview_id */
#define MOD_DPAINT_SURFACE_PREV_PAINT 0
#define MOD_DPAINT_SURFACE_PREV_WETMAP 1
/* init_color_type */
#define MOD_DPAINT_INITIAL_NONE 0
#define MOD_DPAINT_INITIAL_COLOR 1
#define MOD_DPAINT_INITIAL_TEXTURE 2
#define MOD_DPAINT_INITIAL_VERTEXCOLOR 3
typedef struct DynamicPaintSurface {
struct DynamicPaintSurface *next, *prev;
struct DynamicPaintCanvasSettings *canvas; /* for fast RNA access */
struct PaintSurfaceData *data;
struct Group *brush_group;
struct EffectorWeights *effector_weights;
/* cache */
struct PointCache *pointcache;
struct ListBase ptcaches;
int current_frame;
/* surface */
char name[64];
short format, type;
short disp_type, image_fileformat;
short effect_ui; /* ui selection box */
short preview_id; /* surface output id to preview */
short init_color_type, pad_s;
int flags, effect;
int image_resolution, substeps;
int start_frame, end_frame, pad;
/* initial color */
float init_color[4];
struct Tex *init_texture;
char init_layername[40];
int dry_speed, diss_speed;
float depth_clamp, disp_factor;
float spread_speed, color_spread_speed, shrink_speed;
float drip_vel, drip_acc;
/* wave settings */
float wave_damping, wave_speed, wave_timescale, wave_spring;
int pad_;
char uvlayer_name[32];
char image_output_path[240];
char output_name[40];
char output_name2[40]; /* some surfaces have 2 outputs */
} DynamicPaintSurface;
/* canvas flags */
#define MOD_DPAINT_PREVIEW_READY (1<<0) /* if viewport preview is ready */
#define MOD_DPAINT_BAKING (1<<1) /* surface is already baking, so it wont get updated (loop) */
/* Canvas settings */
typedef struct DynamicPaintCanvasSettings {
struct DynamicPaintModifierData *pmd; /* for fast RNA access */
struct DerivedMesh *dm;
struct ListBase surfaces;
short active_sur, flags;
int pad;
char error[64]; /* Bake error description */
} DynamicPaintCanvasSettings;
/* flags */
#define MOD_DPAINT_PART_RAD (1<<0) /* use particle radius */
#define MOD_DPAINT_USE_MATERIAL (1<<1) /* use object material */
#define MOD_DPAINT_ABS_ALPHA (1<<2) /* don't increase alpha unless
paint alpha is higher than existing */
#define MOD_DPAINT_ERASE (1<<3) /* removes paint */
#define MOD_DPAINT_RAMP_ALPHA (1<<4) /* only read falloff ramp alpha */
#define MOD_DPAINT_PROX_PROJECT (1<<5) /* do proximity check only in defined dir */
#define MOD_DPAINT_INVERSE_PROX (1<<6) /* inverse proximity painting */
#define MOD_DPAINT_DO_SMUDGE (1<<8) /* brush smudges existing paint */
#define MOD_DPAINT_VELOCITY_ALPHA (1<<9) /* multiply brush influence by velocity */
#define MOD_DPAINT_VELOCITY_COLOR (1<<10) /* replace brush color by velocity color ramp */
#define MOD_DPAINT_VELOCITY_DEPTH (1<<11) /* multiply brush intersection depth by velocity */
#define MOD_DPAINT_USES_VELOCITY ((1<<8)|(1<<9)|(1<<10)|(1<<11))
/* collision type */
#define MOD_DPAINT_COL_VOLUME 0 /* paint with mesh volume */
#define MOD_DPAINT_COL_DIST 1 /* paint using distance to mesh surface */
#define MOD_DPAINT_COL_VOLDIST 2 /* use both volume and distance */
#define MOD_DPAINT_COL_PSYS 3 /* use particle system */
#define MOD_DPAINT_COL_POINT 4 /* use distance to object center point */
/* 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 */
/* wave_brush_type */
#define MOD_DPAINT_WAVEB_DEPTH 0 /* use intersection depth */
#define MOD_DPAINT_WAVEB_FORCE 1 /* act as a force on intersection area */
#define MOD_DPAINT_WAVEB_REFLECT 2 /* obstacle that reflects waves */
/* brush ray_dir */
#define MOD_DPAINT_RAY_CANVAS 0
#define MOD_DPAINT_RAY_BRUSH_AVG 1
#define MOD_DPAINT_RAY_ZPLUS 2
/* Brush settings */
typedef struct DynamicPaintBrushSettings {
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;
/* color ramps */
struct ColorBand *paint_ramp; /* Proximity paint falloff */
struct ColorBand *vel_ramp; /* Velocity paint ramp */
short proximity_falloff;
short wave_type;
short ray_dir;
short pad;
float wave_factor, wave_clamp;
float max_velocity, smudge_strength;
} DynamicPaintBrushSettings;
#endif

@ -957,4 +957,17 @@ typedef struct WeightVGProximityModifierData {
#define MOD_WVG_MASK_TEX_USE_VAL 7
#define MOD_WVG_MASK_TEX_USE_ALPHA 8
/* Dynamic paint modifier flags */
#define MOD_DYNAMICPAINT_TYPE_CANVAS (1 << 0)
#define MOD_DYNAMICPAINT_TYPE_BRUSH (1 << 1)
typedef struct DynamicPaintModifierData {
ModifierData modifier;
struct DynamicPaintCanvasSettings *canvas;
struct DynamicPaintBrushSettings *brush;
int type; /* ui display: canvas / brush */
int pad;
} DynamicPaintModifierData;
#endif

@ -136,6 +136,7 @@ typedef struct EffectorWeights {
#define BPHYS_DATA_VELOCITY 2
#define BPHYS_DATA_SMOKE_HIGH 2
#define BPHYS_DATA_ROTATION 3
#define BPHYS_DATA_DYNAMICPAINT 3
#define BPHYS_DATA_AVELOCITY 4 /* used for particles */
#define BPHYS_DATA_XCONST 4 /* used for cloth */
#define BPHYS_DATA_SIZE 5
@ -398,6 +399,7 @@ typedef struct SoftBody {
#define PTCACHE_IGNORE_LIBPATH 2048
/* high resolution cache is saved for smoke for backwards compatibility, so set this flag to know it's a "fake" cache */
#define PTCACHE_FAKE_SMOKE (1<<12)
#define PTCACHE_IGNORE_CLEAR (1<<13)
/* PTCACHE_OUTDATED + PTCACHE_FRAMES_SKIPPED */
#define PTCACHE_REDO_NEEDED 258

@ -863,6 +863,7 @@ enum {
#define TIME_CACHE_PARTICLES 4
#define TIME_CACHE_CLOTH 8
#define TIME_CACHE_SMOKE 16
#define TIME_CACHE_DYNAMICPAINT 32
/* sseq->mainb */
#define SEQ_DRAW_SEQUENCE 0

@ -133,6 +133,7 @@ const char *includefiles[] = {
"DNA_speaker_types.h",
"DNA_movieclip_types.h",
"DNA_tracking_types.h",
"DNA_dynamicpaint_types.h",
// empty string to indicate end of includefiles
""
@ -1200,4 +1201,5 @@ int main(int argc, char ** argv)
#include "DNA_speaker_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_tracking_types.h"
#include "DNA_dynamicpaint_types.h"
/* end of list */

@ -197,6 +197,10 @@ extern StructRNA RNA_Driver;
extern StructRNA RNA_DriverTarget;
extern StructRNA RNA_DriverVariable;
extern StructRNA RNA_DupliObject;
extern StructRNA RNA_DynamicPaintBrushSettings;
extern StructRNA RNA_DynamicPaintCanvasSettings;
extern StructRNA RNA_DynamicPaintModifier;
extern StructRNA RNA_DynamicPaintSurface;
extern StructRNA RNA_EdgeSplitModifier;
extern StructRNA RNA_EditBone;
extern StructRNA RNA_EffectSequence;

@ -114,6 +114,8 @@ extern EnumPropertyItem node_filter_items[];
extern EnumPropertyItem ramp_blend_items[];
extern EnumPropertyItem prop_dynamicpaint_type_items[];
struct bContext;
struct PointerRNA;
struct PropertyRNA;

@ -46,6 +46,7 @@ set(DEFSRC
rna_context.c
rna_controller.c
rna_curve.c
rna_dynamicpaint.c
rna_fcurve.c
rna_fluidsim.c
rna_gpencil.c

@ -2440,6 +2440,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,906 @@
/**
* ***** 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_dynamicpaint_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "WM_types.h"
EnumPropertyItem prop_dynamicpaint_type_items[] = {
{MOD_DYNAMICPAINT_TYPE_CANVAS, "CANVAS", 0, "Canvas", ""},
{MOD_DYNAMICPAINT_TYPE_BRUSH, "BRUSH", 0, "Brush", ""},
{0, NULL, 0, NULL, NULL}};
#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_DynamicPaintBrushSettings_path(PointerRNA *ptr)
{
DynamicPaintBrushSettings *settings = (DynamicPaintBrushSettings*)ptr->data;
ModifierData *md= (ModifierData *)settings->pmd;
return BLI_sprintfN("modifiers[\"%s\"].brush_settings", md->name);
}
static char *rna_DynamicPaintSurface_path(PointerRNA *ptr)
{
DynamicPaintSurface *surface = (DynamicPaintSurface*)ptr->data;
ModifierData *md= (ModifierData *)surface->canvas->pmd;
return BLI_sprintfN("modifiers[\"%s\"].canvas_settings.canvas_surfaces[\"%s\"]", md->name, surface->name);
}
/*
* Surfaces
*/
static void rna_DynamicPaint_redoModifier(Main *bmain, Scene *scene, PointerRNA *ptr)
{
DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
}
static void rna_DynamicPaintSurfaces_updateFrames(Main *bmain, Scene *scene, PointerRNA *ptr)
{
dynamicPaint_cacheUpdateFrames((DynamicPaintSurface*)ptr->data);
}
static void rna_DynamicPaintSurface_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
{
dynamicPaint_resetSurface((DynamicPaintSurface*)ptr->data);
rna_DynamicPaint_redoModifier(bmain, scene, ptr);
}
static void rna_DynamicPaintSurface_initialcolortype(Main *bmain, Scene *scene, PointerRNA *ptr)
{
DynamicPaintSurface *surface = (DynamicPaintSurface*)ptr->data;
surface->init_layername[0] = '\0';
dynamicPaint_clearSurface(surface);
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 *bmain, Scene *scene, PointerRNA *ptr)
{
dynamicPaintSurface_setUniqueName((DynamicPaintSurface*)ptr->data, ((DynamicPaintSurface*)ptr->data)->name);
}
static void rna_DynamicPaintSurface_changeType(Main *bmain, Scene *scene, PointerRNA *ptr)
{
dynamicPaintSurface_updateType((DynamicPaintSurface*)ptr->data);
dynamicPaint_resetSurface((DynamicPaintSurface*)ptr->data);
rna_DynamicPaintSurface_reset(bmain, scene, ptr);
}
static void rna_DynamicPaintSurfaces_changeFormat(Main *bmain, Scene *scene, PointerRNA *ptr)
{
DynamicPaintSurface *surface = (DynamicPaintSurface*)ptr->data;
surface->type = MOD_DPAINT_SURFACE_T_PAINT;
dynamicPaintSurface_updateType((DynamicPaintSurface*)ptr->data);
rna_DynamicPaintSurface_reset(bmain, scene, ptr);
}
static void rna_DynamicPaint_resetDependancy(Main *bmain, Scene *scene, PointerRNA *ptr)
{
rna_DynamicPaintSurface_reset(bmain, scene, ptr);
DAG_scene_sort(bmain, scene);
}
static PointerRNA rna_PaintSurface_active_get(PointerRNA *ptr)
{
DynamicPaintCanvasSettings *canvas= (DynamicPaintCanvasSettings*)ptr->data;
DynamicPaintSurface *surface = canvas->surfaces.first;
int id=0;
for(; surface; surface=surface->next) {
if(id == canvas->active_sur)
return rna_pointer_inherit_refine(ptr, &RNA_DynamicPaintSurface, surface);
id++;
}
return rna_pointer_inherit_refine(ptr, &RNA_DynamicPaintSurface, NULL);
}
static void rna_DynamicPaint_surfaces_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
DynamicPaintCanvasSettings *canvas= (DynamicPaintCanvasSettings*)ptr->data;
//rna_iterator_array_begin(iter, (void*)canvas->surfaces, sizeof(PaintSurface), canvas->totsur, 0, 0);
rna_iterator_listbase_begin(iter, &canvas->surfaces, NULL);
}
static int rna_Surface_active_point_index_get(PointerRNA *ptr)
{
DynamicPaintCanvasSettings *canvas= (DynamicPaintCanvasSettings*)ptr->data;
return canvas->active_sur;
}
static void rna_Surface_active_point_index_set(struct PointerRNA *ptr, int value)
{
DynamicPaintCanvasSettings *canvas= (DynamicPaintCanvasSettings*)ptr->data;
canvas->active_sur = value;
return;
}
static void rna_Surface_active_point_range(PointerRNA *ptr, int *min, int *max)
{
DynamicPaintCanvasSettings *canvas= (DynamicPaintCanvasSettings*)ptr->data;
*min= 0;
*max= BLI_countlist(&canvas->surfaces)-1;
}
/* uvlayer */
static void rna_DynamicPaint_uvlayer_set(PointerRNA *ptr, const char *value)
{
DynamicPaintCanvasSettings *canvas= ((DynamicPaintSurface*)ptr->data)->canvas;
DynamicPaintSurface *surface = canvas->surfaces.first;
int id=0;
for(; surface; surface=surface->next) {
if(id == canvas->active_sur) {
rna_object_uvlayer_name_set(ptr, value, surface->uvlayer_name, sizeof(surface->uvlayer_name));
return;
}
id++;
}
}
/* is point cache used */
static int rna_DynamicPaint_uses_cache_get(PointerRNA *ptr)
{
DynamicPaintSurface *surface= (DynamicPaintSurface*)ptr->data;
return (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) ? 1 : 0;
}
static void rna_DynamicPaint_uses_cache_set(PointerRNA *ptr, int value)
{
}
/* does output layer exist*/
static int rna_DynamicPaint_is_output_exists(DynamicPaintSurface *surface, Object *ob, int index)
{
return dynamicPaint_outputLayerExists(surface, ob, index);
}
static EnumPropertyItem *rna_DynamicPaint_surface_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
{
DynamicPaintSurface *surface= (DynamicPaintSurface*)ptr->data;
EnumPropertyItem *item= NULL;
EnumPropertyItem tmp= {0, "", 0, "", ""};
int totitem= 0;
/* Paint type - available for all formats */
tmp.value = MOD_DPAINT_SURFACE_T_PAINT;
tmp.identifier = "PAINT";
tmp.name = "Paint";
RNA_enum_item_add(&item, &totitem, &tmp);
/* Displace */
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX ||
surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
tmp.value = MOD_DPAINT_SURFACE_T_DISPLACE;
tmp.identifier = "DISPLACE";
tmp.name = "Displace";
RNA_enum_item_add(&item, &totitem, &tmp);
}
/* Weight */
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
tmp.value = MOD_DPAINT_SURFACE_T_WEIGHT;
tmp.identifier = "WEIGHT";
tmp.name = "Weight";
RNA_enum_item_add(&item, &totitem, &tmp);
}
/* Height waves */
{
tmp.value = MOD_DPAINT_SURFACE_T_WAVE;
tmp.identifier = "WAVE";
tmp.name = "Waves";
RNA_enum_item_add(&item, &totitem, &tmp);
}
RNA_enum_item_end(&item, &totitem);
*free = 1;
return item;
}
#else
/* canvas.canvas_surfaces */
static void rna_def_canvas_surfaces(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
PropertyRNA *prop;
RNA_def_property_srna(cprop, "DynamicPaintSurfaces");
srna= RNA_def_struct(brna, "DynamicPaintSurfaces", NULL);
RNA_def_struct_sdna(srna, "DynamicPaintCanvasSettings");
RNA_def_struct_ui_text(srna, "Canvas Surfaces", "Collection of Dynamic Paint Canvas surfaces");
prop= RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_funcs(prop, "rna_Surface_active_point_index_get", "rna_Surface_active_point_index_set", "rna_Surface_active_point_range");
RNA_def_property_ui_text(prop, "Active Point Cache Index", "");
prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "DynamicPaintSurface");
RNA_def_property_pointer_funcs(prop, "rna_PaintSurface_active_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Active Surface", "Active Dynamic Paint surface being displayed");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
}
static void rna_def_canvas_surface(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
PropertyRNA *parm;
FunctionRNA *func;
/* Surface format */
static EnumPropertyItem prop_dynamicpaint_surface_format[] = {
//{MOD_DPAINT_SURFACE_F_PTEX, "PTEX", ICON_TEXTURE_SHADED, "Ptex", ""},
{MOD_DPAINT_SURFACE_F_VERTEX, "VERTEX", ICON_OUTLINER_DATA_MESH, "Vertex", ""},
{MOD_DPAINT_SURFACE_F_IMAGESEQ, "IMAGE", ICON_FILE_IMAGE, "Image Sequence", ""},
{0, NULL, 0, NULL, NULL}};
/* Surface type - generated dynamically based on surface format */
static EnumPropertyItem prop_dynamicpaint_surface_type[] = {
{MOD_DPAINT_SURFACE_T_PAINT, "PAINT", 0, "Paint", ""},
{0, NULL, 0, NULL, NULL}};
/* Surface output preview. currently only paint has multiple outputs */
static 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 EnumPropertyItem prop_dynamicpaint_init_color_type[] = {
{MOD_DPAINT_INITIAL_NONE, "NONE", 0, "None", ""},
{MOD_DPAINT_INITIAL_COLOR, "COLOR", ICON_COLOR, "Color", ""},
{MOD_DPAINT_INITIAL_TEXTURE, "TEXTURE", ICON_TEXTURE, "UV Texture", ""},
{MOD_DPAINT_INITIAL_VERTEXCOLOR, "VERTEX_COLOR", ICON_GROUP_VCOL, "Vertex Color", ""},
{0, NULL, 0, NULL, NULL}};
/* 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_image_fileformat[] = {
{MOD_DPAINT_IMGFORMAT_PNG, "PNG", 0, "PNG", ""},
#ifdef WITH_OPENEXR
{MOD_DPAINT_IMGFORMAT_OPENEXR, "OPENEXR", 0, "OpenEXR", ""},
#endif
{0, NULL, 0, NULL, NULL}};
/* Displacemap type */
static EnumPropertyItem prop_dynamicpaint_displace_type[] = {
{MOD_DPAINT_DISP_DISPLACE, "DISPLACE", 0, "Displacement", ""},
{MOD_DPAINT_DISP_DEPTH, "DEPTH", 0, "Depth", ""},
{0, NULL, 0, NULL, NULL}};
/* Surface */
srna= RNA_def_struct(brna, "DynamicPaintSurface", NULL);
RNA_def_struct_sdna(srna, "DynamicPaintSurface");
RNA_def_struct_ui_text(srna, "Paint Surface", "A canvas surface layer");
RNA_def_struct_path_func(srna, "rna_DynamicPaintSurface_path");
prop= RNA_def_property(srna, "surface_format", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_sdna(prop, NULL, "format");
RNA_def_property_enum_items(prop, prop_dynamicpaint_surface_format);
RNA_def_property_ui_text(prop, "Format", "Surface Format");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaintSurfaces_changeFormat");
prop= RNA_def_property(srna, "surface_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_surface_type);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DynamicPaint_surface_type_itemf");
RNA_def_property_ui_text(prop, "Surface Type", "Surface Type");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaintSurface_changeType");
prop= RNA_def_property(srna, "is_active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ACTIVE);
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");
RNA_def_struct_name_property(srna, prop);
prop= RNA_def_property(srna, "brush_group", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Group");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Brush Group", "Only use brush objects from this group");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_resetDependancy");
/*
* Paint, wet and displace
*/
prop= RNA_def_property(srna, "use_dissolve", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DISSOLVE);
RNA_def_property_ui_text(prop, "Dissolve", "Enable to make surface changes 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", "Approximately in how many frames should dissolve happen");
prop= RNA_def_property(srna, "dry_speed", PROP_INT, PROP_NONE);
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", "Approximately in how many frames should drying happen");
/*
* Simulation settings
*/
prop= RNA_def_property(srna, "image_resolution", PROP_INT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
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", "Output image 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, "frame_start", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "start_frame");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
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");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames");
prop= RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "end_frame");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
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");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames");
prop= RNA_def_property(srna, "frame_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_antialiasing", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ANTIALIAS);
RNA_def_property_ui_text(prop, "Anti-aliasing", "Use 5x multisampling to smoothen paint edges");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaintSurface_reset");
/*
* Initial Color
*/
prop= RNA_def_property(srna, "init_color_type", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_items(prop, prop_dynamicpaint_init_color_type);
RNA_def_property_ui_text(prop, "Initial Color", "");
RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW|ND_MODIFIER, "rna_DynamicPaintSurface_initialcolortype");
prop= RNA_def_property(srna, "init_color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Color", "Initial color of the surface");
RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW|ND_MODIFIER, "rna_DynamicPaintSurface_reset");
prop= RNA_def_property(srna, "init_texture", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Texture", "");
RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW|ND_MODIFIER, "rna_DynamicPaintSurface_reset");
prop= RNA_def_property(srna, "init_layername", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Data Layer", "");
RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW|ND_MODIFIER, "rna_DynamicPaintSurface_reset");
/*
* 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_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 logarithmic drying. Makes high values to fade faster than low values");
prop= RNA_def_property(srna, "use_dissolve_log", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DISSOLVE_LOG);
RNA_def_property_ui_text(prop, "Slow", "Use logarithmic dissolve. Makes high values to fade faster than low values");
prop= RNA_def_property(srna, "use_spread", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
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");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaintSurface_reset");
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.001, 10.0);
RNA_def_property_ui_range(prop, 0.01, 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, "color_spread_speed", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "color_spread_speed");
RNA_def_property_range(prop, 0.0, 2.0);
RNA_def_property_ui_range(prop, 0.0, 2.0, 1, 2);
RNA_def_property_ui_text(prop, "Color Spread", "How fast colors get mixed within wet paint");
prop= RNA_def_property(srna, "use_drip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
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");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaintSurface_reset");
prop= RNA_def_property(srna, "use_shrink", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
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");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaintSurface_reset");
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.001, 10.0);
RNA_def_property_ui_range(prop, 0.01, 5.0, 1, 2);
RNA_def_property_ui_text(prop, "Shrink Speed", "How fast shrink effect moves on the canvas surface");
prop= RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "EffectorWeights");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Effector Weights", "");
prop= RNA_def_property(srna, "drip_velocity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "drip_vel");
RNA_def_property_range(prop, -200.0f, 200.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
RNA_def_property_ui_text(prop, "Velocity", "Defines how much surface velocity affects dripping");
prop= RNA_def_property(srna, "drip_acceleration", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "drip_acc");
RNA_def_property_range(prop, -200.0f, 200.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
RNA_def_property_ui_text(prop, "Acceleration", "Defines how much surface acceleration affects dripping");
/*
* 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, "image_output_path", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_sdna(prop, NULL, "image_output_path");
RNA_def_property_ui_text(prop, "Output Path", "Directory to save the textures");
/* output for primary surface data */
prop= RNA_def_property(srna, "output_name", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "output_name");
RNA_def_property_ui_text(prop, "Output name", "");
prop= RNA_def_property(srna, "do_output1", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_OUT1);
RNA_def_property_ui_text(prop, "Save layer", "Output name");
/* output for secondary sufrace data */
prop= RNA_def_property(srna, "output_name2", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "output_name2");
RNA_def_property_ui_text(prop, "Output name", "Output name");
prop= RNA_def_property(srna, "do_output2", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_OUT2);
RNA_def_property_ui_text(prop, "Save 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");
parm= RNA_def_pointer(func, "object", "Object", "", "");
RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
parm= RNA_def_int(func, "index", 0, 0, 1, "Index", "", 0, 1);
RNA_def_property_flag(parm, PROP_REQUIRED);
/* return type */
parm= RNA_def_boolean(func, "exists", 0, "", "");
RNA_def_function_return(func, parm);
prop= RNA_def_property(srna, "depth_clamp", PROP_FLOAT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, 0.00, 50.0);
RNA_def_property_ui_range(prop, 0.00, 5.0, 1, 2);
RNA_def_property_ui_text(prop, "Max Displace", "Maximum level of depth intersection in object space. Use 0.0 to disable");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
prop= RNA_def_property(srna, "displace_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "disp_factor");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_range(prop, -50.0, 50.0);
RNA_def_property_ui_range(prop, -5.0, 5.0, 1, 2);
RNA_def_property_ui_text(prop, "Displace Factor", "Strength of displace when applied to the mesh");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
prop= RNA_def_property(srna, "image_fileformat", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_items(prop, prop_dynamicpaint_image_fileformat);
RNA_def_property_ui_text(prop, "File Format", "");
prop= RNA_def_property(srna, "displace_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "disp_type");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_items(prop, prop_dynamicpaint_displace_type);
RNA_def_property_ui_text(prop, "Data Type", "");
prop= RNA_def_property(srna, "use_incremental_displace", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DISP_INCREMENTAL);
RNA_def_property_ui_text(prop, "Incremental", "New displace is added cumulatively on top of existing");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaintSurface_reset");
/* wave simulator settings */
prop= RNA_def_property(srna, "wave_damping", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.001, 1.0);
RNA_def_property_ui_range(prop, 0.01, 1.0, 1, 2);
RNA_def_property_ui_text(prop, "Damping", "Wave damping factor");
prop= RNA_def_property(srna, "wave_speed", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.01, 3.0);
RNA_def_property_ui_range(prop, 0.01, 1.5, 1, 2);
RNA_def_property_ui_text(prop, "Speed", "Wave propogation speed");
prop= RNA_def_property(srna, "wave_timescale", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.01, 3.0);
RNA_def_property_ui_range(prop, 0.01, 1.5, 1, 2);
RNA_def_property_ui_text(prop, "Timescale", "Wave time scaling factor");
prop= RNA_def_property(srna, "wave_spring", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.001, 1.0);
RNA_def_property_ui_range(prop, 0.01, 1.0, 1, 2);
RNA_def_property_ui_text(prop, "Spring", "Spring force that pulls water level back to zero");
prop= RNA_def_property(srna, "wave_open_borders", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_WAVE_OPEN_BORDERS);
RNA_def_property_ui_text(prop, "Open Borders", "Passes waves through mesh edges");
/* cache */
prop= RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "pointcache");
RNA_def_property_ui_text(prop, "Point Cache", "");
/* is cache used */
prop= RNA_def_property(srna, "uses_cache", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_DynamicPaint_uses_cache_get", "rna_DynamicPaint_uses_cache_set");
RNA_def_property_ui_text(prop, "Uses Cache", "");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
static void rna_def_dynamic_paint_canvas_settings(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
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");
/*
* Surface Slots
*/
prop= RNA_def_property(srna, "canvas_surfaces", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_funcs(prop, "rna_DynamicPaint_surfaces_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", NULL, NULL, NULL, NULL);
RNA_def_property_struct_type(prop, "DynamicPaintSurface");
RNA_def_property_ui_text(prop, "Paint Surface List", "Paint surface list");
rna_def_canvas_surfaces(brna, prop);
}
static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
/* paint collision type */
static EnumPropertyItem prop_dynamicpaint_collisiontype[] = {
{MOD_DPAINT_COL_PSYS, "PARTICLE_SYSTEM", ICON_PARTICLES, "Particle System", ""},
{MOD_DPAINT_COL_POINT, "POINT", ICON_META_EMPTY, "Object Center", ""},
{MOD_DPAINT_COL_DIST, "DISTANCE", ICON_META_EMPTY, "Proximity", ""},
{MOD_DPAINT_COL_VOLDIST, "VOLUME_DISTANCE", ICON_META_CUBE, "Mesh Volume + Proximity", ""},
{MOD_DPAINT_COL_VOLUME, "VOLUME", ICON_MESH_CUBE, "Mesh Volume", ""},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem prop_dynamicpaint_prox_falloff[] = {
{MOD_DPAINT_PRFALL_SMOOTH, "SMOOTH", ICON_SPHERECURVE, "Smooth", ""},
{MOD_DPAINT_PRFALL_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", ""},
{MOD_DPAINT_PRFALL_RAMP, "RAMP", ICON_COLOR, "Color Ramp", ""},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem prop_dynamicpaint_brush_wave_type[] = {
{MOD_DPAINT_WAVEB_DEPTH, "DEPTH", 0, "Obstacle", ""},
{MOD_DPAINT_WAVEB_FORCE, "FORCE", 0, "Force", ""},
{MOD_DPAINT_WAVEB_REFLECT, "REFLECT", 0, "Reflect Only", ""},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem prop_dynamicpaint_brush_ray_dir[] = {
{MOD_DPAINT_RAY_CANVAS, "CANVAS", 0, "Canvas Normal", ""},
{MOD_DPAINT_RAY_BRUSH_AVG, "BRUSH", 0, "Brush Normal", ""},
{MOD_DPAINT_RAY_ZPLUS, "Z_AXIS", 0, "Z-Axis", ""},
{0, NULL, 0, NULL, NULL}};
srna = RNA_def_struct(brna, "DynamicPaintBrushSettings", NULL);
RNA_def_struct_ui_text(srna, "Brush Settings", "Brush settings");
RNA_def_struct_sdna(srna, "DynamicPaintBrushSettings");
RNA_def_struct_path_func(srna, "rna_DynamicPaintBrushSettings_path");
/*
* Paint
*/
prop= RNA_def_property(srna, "paint_color", PROP_FLOAT, PROP_COLOR_GAMMA);
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_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
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, 1.0);
RNA_def_property_ui_range(prop, 0.0, 1.0, 5, 2);
RNA_def_property_ui_text(prop, "Paint Alpha", "Paint alpha");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
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 influence");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
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);
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
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, 2);
RNA_def_property_ui_text(prop, "Paint Wetness", "Paint wetness. Visible in wetmap. Some effects only affect wet paint");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
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");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
prop= RNA_def_property(srna, "wave_type", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_items(prop, prop_dynamicpaint_brush_wave_type);
RNA_def_property_ui_text(prop, "Brush Effect", "");
prop= RNA_def_property(srna, "wave_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, -2.0, 2.0);
RNA_def_property_ui_range(prop, -1.0, 1.0, 5, 2);
RNA_def_property_ui_text(prop, "Factor", "Multiplier for wave influence of this brush");
prop= RNA_def_property(srna, "wave_clamp", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.00, 50.0);
RNA_def_property_ui_range(prop, 0.00, 5.0, 1, 2);
RNA_def_property_ui_text(prop, "Clamp Waves", "Maximum level of surface intersection used to influence waves. Use 0.0 to disable");
prop= RNA_def_property(srna, "do_smudge", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DO_SMUDGE);
RNA_def_property_ui_text(prop, "Do Smudge", "Makes this brush to smudge existing paint as it moves");
prop= RNA_def_property(srna, "smudge_strength", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_range(prop, 0.0, 1.0, 5, 2);
RNA_def_property_ui_text(prop, "Smudge Strength", "Smudge effect strength");
prop= RNA_def_property(srna, "max_velocity", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0001, 10.0);
RNA_def_property_ui_range(prop, 0.1, 2.0, 5, 2);
RNA_def_property_ui_text(prop, "Max Velocity", "Velocity considered as maximum influence. (Blender units per frame)");
prop= RNA_def_property(srna, "velocity_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_VELOCITY_ALPHA);
RNA_def_property_ui_text(prop, "Multiply Alpha", "Multiply brush influence by velocity color ramp alpha");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
prop= RNA_def_property(srna, "velocity_depth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_VELOCITY_DEPTH);
RNA_def_property_ui_text(prop, "Multiply Depth", "Multiply brush intersection depth (displace, waves) by velocity ramp alpha");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
prop= RNA_def_property(srna, "velocity_color", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_VELOCITY_COLOR);
RNA_def_property_ui_text(prop, "Replace Color", "Replace brush color by velocity color ramp");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
/*
* 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", "");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
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 from brush to mesh surface to affect paint");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
prop= RNA_def_property(srna, "proximity_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");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
prop= RNA_def_property(srna, "proximity_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, "Falloff", "Proximity falloff type");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
prop= RNA_def_property(srna, "proximity_project", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_PROX_PROJECT);
RNA_def_property_ui_text(prop, "Project", "Brush is projected to canvas from defined direction within brush proximity");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
prop= RNA_def_property(srna, "ray_direction", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "ray_dir");
RNA_def_property_enum_items(prop, prop_dynamicpaint_brush_ray_dir);
RNA_def_property_ui_text(prop, "Ray Direction", "Defines ray direction to use for projection. If brush object is located in that direction it's painted");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
prop= RNA_def_property(srna, "proximity_inverse", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_INVERSE_PROX);
RNA_def_property_ui_text(prop, "Inner Proximity", "Proximity falloff is applied inside the volume");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
/*
* Particle
*/
prop= RNA_def_property(srna, "particle_system", 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");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_resetDependancy");
prop= RNA_def_property(srna, "use_particle_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");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
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");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
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 radius");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
/*
* 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");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
prop= RNA_def_property(srna, "velocity_ramp", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "vel_ramp");
RNA_def_property_struct_type(prop, "ColorRamp");
RNA_def_property_ui_text(prop, "Velocity Color Ramp", "Color ramp used to define brush velocity effect");
RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier");
}
void RNA_def_dynamic_paint(BlenderRNA *brna)
{
rna_def_dynamic_paint_canvas_settings(brna);
rna_def_dynamic_paint_brush_settings(brna);
rna_def_canvas_surface(brna);
}
#endif

@ -136,6 +136,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);

@ -46,6 +46,7 @@
#include "BKE_animsys.h"
#include "BKE_bmesh.h" /* For BevelModifierData */
#include "BKE_dynamicpaint.h"
#include "BKE_multires.h"
#include "BKE_smoke.h" /* For smokeModifier_free & smokeModifier_createType */
@ -94,6 +95,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_DYNAMICPAINT, "Dynamic Paint", ""},
{0, NULL, 0, NULL, NULL}};
#ifdef RNA_RUNTIME
@ -192,6 +194,8 @@ static StructRNA* rna_Modifier_refine(struct PointerRNA *ptr)
return &RNA_VertexWeightMixModifier;
case eModifierType_WeightVGProximity:
return &RNA_VertexWeightProximityModifier;
case eModifierType_DynamicPaint:
return &RNA_DynamicPaintModifier;
default:
return &RNA_Modifier;
}
@ -2008,6 +2012,31 @@ 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;
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_DYNAMICPAINT);
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, "brush_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "brush");
RNA_def_property_ui_text(prop, "Brush Settings", "");
prop= RNA_def_property(srna, "ui_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", "");
}
static void rna_def_modifier_collision(BlenderRNA *brna)
{
StructRNA *srna;
@ -2880,6 +2909,7 @@ void RNA_def_modifier(BlenderRNA *brna)
rna_def_modifier_weightvgedit(brna);
rna_def_modifier_weightvgmix(brna);
rna_def_modifier_weightvgproximity(brna);
rna_def_modifier_dynamic_paint(brna);
}
#endif

@ -640,6 +640,22 @@ static char *rna_EffectorWeight_path(PointerRNA *ptr)
if (smd->domain->effector_weights == ew)
return BLI_sprintfN("modifiers[\"%s\"].settings.effector_weights", md->name);
}
/* check dynamic paint modifier */
md = (ModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
if (md) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if (pmd->canvas) {
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
for(; surface; surface=surface->next) {
if (surface->effector_weights == ew)
return BLI_sprintfN("modifiers[\"%s\"].canvas_settings.canvas_surfaces[\"%s\"].effector_weights",
md->name, surface->name);
}
}
}
}
return NULL;
}

@ -2389,6 +2389,11 @@ static void rna_def_space_time(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SMOKE);
RNA_def_property_ui_text(prop, "Smoke", "Show the active object's smoke cache");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL);
prop= RNA_def_property(srna, "cache_dynamicpaint", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DYNAMICPAINT);
RNA_def_property_ui_text(prop, "Dynamic Paint", "Show the active object's Dynamic Paint cache");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL);
}
static void rna_def_console_line(BlenderRNA *brna)

@ -55,6 +55,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

@ -74,6 +74,7 @@ extern ModifierTypeInfo modifierType_NavMesh;
extern ModifierTypeInfo modifierType_WeightVGEdit;
extern ModifierTypeInfo modifierType_WeightVGMix;
extern ModifierTypeInfo modifierType_WeightVGProximity;
extern ModifierTypeInfo modifierType_DynamicPaint;
/* MOD_util.c */
void modifier_type_init(ModifierTypeInfo *types[]);

@ -0,0 +1,178 @@
/*
* ***** 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_dynamicpaint_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_dynamicpaint.h"
#include "BKE_modifier.h"
#include "depsgraph_private.h"
#include "MOD_util.h"
static void initData(ModifierData *md)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
pmd->canvas = NULL;
pmd->brush = NULL;
pmd->type = MOD_DYNAMICPAINT_TYPE_CANVAS;
}
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)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*)md;
CustomDataMask dataMask = 0;
if (pmd->canvas) {
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
for(; surface; surface=surface->next) {
/* tface */
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ ||
surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE) {
dataMask |= (1 << CD_MTFACE);
}
/* mcol */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT ||
surface->init_color_type == MOD_DPAINT_INITIAL_VERTEXCOLOR) {
dataMask |= (1 << CD_MCOL);
}
/* CD_MDEFORMVERT */
if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
dataMask |= (1 << CD_MDEFORMVERT);
}
}
}
if (pmd->brush) {
if (pmd->brush->flags & MOD_DPAINT_USE_MATERIAL) {
dataMask |= (1 << CD_MTFACE);
}
}
return dataMask;
}
static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
DerivedMesh *dm,
int useRenderParams,
int isFinalCalc)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
return dynamicPaint_Modifier_do(pmd, md->scene, ob, dm);
}
static void updateDepgraph(ModifierData *md, DagForest *forest,
struct Scene *scene,
Object *ob,
DagNode *obNode)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
/* add relation from canvases to all brush objects */
if(pmd && pmd->canvas)
{
Base *base = scene->base.first;
for(; base; base = base->next) {
DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)modifiers_findByType(base->object, eModifierType_DynamicPaint);
if(pmd2 && pmd2->brush && ob!=base->object)
{
DagNode *brushNode = dag_get_node(forest, base->object);
dag_add_relation(forest, brushNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Dynamic Paint Brush");
}
}
}
}
static int dependsOnTime(ModifierData *md)
{
return 1;
}
static void foreachIDLink(ModifierData *md, Object *ob,
IDWalkFunc walk, void *userData)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
if(pmd->canvas) {
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
for(; surface; surface=surface->next) {
walk(userData, ob, (ID **)&surface->brush_group);
walk(userData, ob, (ID **)&surface->init_texture);
}
}
if (pmd->brush) {
walk(userData, ob, (ID **)&pmd->brush->mat);
}
}
static void foreachTexLink(ModifierData *md, Object *ob,
TexWalkFunc walk, void *userData)
{
//walk(userData, ob, md, ""); /* re-enable when possible */
}
ModifierTypeInfo modifierType_DynamicPaint = {
/* name */ "Dynamic Paint",
/* structName */ "DynamicPaintModifierData",
/* structSize */ sizeof(DynamicPaintModifierData),
/* type */ eModifierTypeType_Constructive,
/* flags */ eModifierTypeFlag_AcceptsMesh
| eModifierTypeFlag_UsesPointCache
| eModifierTypeFlag_Single,
/* copyData */ copyData,
/* deformVerts */ 0,
/* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
/* applyModifierEM */ 0,
/* initData */ initData,
/* requiredDataMask */ requiredDataMask,
/* freeData */ freeData,
/* isDisabled */ 0,
/* updateDepgraph */ updateDepgraph,
/* dependsOnTime */ dependsOnTime,
/* dependsOnNormals */ 0,
/* foreachObjectLink */ 0,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,
};

@ -105,7 +105,7 @@ void get_texture_coords(MappingInfoModifierData *dmd, Object *ob,
char uvname[32];
MTFace *tf;
validate_layer_name(&dm->faceData, CD_MTFACE, dmd->uvlayer_name, uvname);
CustomData_validate_layer_name(&dm->faceData, CD_MTFACE, dmd->uvlayer_name, uvname);
tf = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname);
/* verts are given the UV from the first face that uses them */
@ -176,25 +176,6 @@ void modifier_vgroup_cache(ModifierData *md, float (*vertexCos)[3])
/* lattice/mesh modifier too */
}
void validate_layer_name(const CustomData *data, int type, char *name, char *outname)
{
int index = -1;
/* if a layer name was given, try to find that layer */
if(name[0])
index = CustomData_get_named_layer_index(data, type, name);
if(index < 0) {
/* either no layer was specified, or the layer we want has been
* deleted, so assign the active layer to name
*/
index = CustomData_get_active_layer_index(data, type);
strcpy(outname, data->layers[index].name);
}
else
strcpy(outname, name);
}
/* returns a cdderivedmesh if dm == NULL or is another type of derivedmesh */
DerivedMesh *get_cddm(Object *ob, struct EditMesh *em, DerivedMesh *dm, float (*vertexCos)[3])
{
@ -296,5 +277,6 @@ void modifier_type_init(ModifierTypeInfo *types[])
INIT_TYPE(WeightVGEdit);
INIT_TYPE(WeightVGMix);
INIT_TYPE(WeightVGProximity);
INIT_TYPE(DynamicPaint);
#undef INIT_TYPE
}

@ -47,7 +47,6 @@ struct TexResult;
void get_texture_value(struct Tex *texture, float *tex_co, struct TexResult *texres);
void get_texture_coords(struct MappingInfoModifierData *dmd, struct Object *ob, struct DerivedMesh *dm, float (*co)[3], float (*texco)[3], int numVerts);
void modifier_vgroup_cache(struct ModifierData *md, float (*vertexCos)[3]);
void validate_layer_name(const struct CustomData *data, int type, char *name, char *outname);
struct DerivedMesh *get_cddm(struct Object *ob, struct EditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3]);
struct DerivedMesh *get_dm(struct Object *ob, struct EditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3], int orco);
void modifier_get_vgroup(struct Object *ob, struct DerivedMesh *dm, const char *name, struct MDeformVert **dvert, int *defgrp_index);

@ -174,7 +174,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
if(!CustomData_has_layer(&dm->faceData, CD_MTFACE)) return dm;
/* make sure we're using an existing layer */
validate_layer_name(&dm->faceData, CD_MTFACE, umd->uvlayer_name, uvname);
CustomData_validate_layer_name(&dm->faceData, CD_MTFACE, umd->uvlayer_name, uvname);
/* calculate a projection matrix and normal for each projector */
for(i = 0; i < num_projectors; ++i) {

@ -196,7 +196,7 @@ static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob,
char uvname[32];
MTFace *tf;
validate_layer_name(&dm->faceData, CD_MTFACE, wmd->uvlayer_name, uvname);
CustomData_validate_layer_name(&dm->faceData, CD_MTFACE, wmd->uvlayer_name, uvname);
tf = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname);
/* verts are given the UV from the first face that uses them */

@ -117,6 +117,8 @@ void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mo
*texco |= TEXCO_NORM|NEED_UV; break;
case GEOM_OUT_VCOL:
*texco |= NEED_UV; *mode |= MA_VERTEXCOL; break;
case GEOM_OUT_VCOL_ALPHA:
*texco |= NEED_UV; *mode |= MA_VERTEXCOL; break;
}
}
}

@ -92,7 +92,8 @@ typedef struct ShaderCallData {
#define GEOM_OUT_UV 4
#define GEOM_OUT_NORMAL 5
#define GEOM_OUT_VCOL 6
#define GEOM_OUT_FRONTBACK 7
#define GEOM_OUT_VCOL_ALPHA 7
#define GEOM_OUT_FRONTBACK 8
/* input socket defines */

@ -45,6 +45,7 @@ static bNodeSocketTemplate sh_node_geom_out[]= {
{ SOCK_VECTOR, 0, "UV"},
{ SOCK_VECTOR, 0, "Normal"},
{ SOCK_RGBA, 0, "Vertex Color"},
{ SOCK_FLOAT, 0, "Vertex Alpha"},
{ SOCK_FLOAT, 0, "Front/Back"},
{ -1, 0, "" }
};
@ -91,10 +92,13 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(i
}
copy_v3_v3(out[GEOM_OUT_VCOL]->vec, scol->col);
out[GEOM_OUT_VCOL]->vec[3]= 1.0f;
out[GEOM_OUT_VCOL]->vec[3]= scol->col[3];
out[GEOM_OUT_VCOL_ALPHA]->vec[0]= scol->col[3];
}
else
else {
memcpy(out[GEOM_OUT_VCOL]->vec, defaultvcol, sizeof(defaultvcol));
out[GEOM_OUT_VCOL_ALPHA]->vec[0]= 1.0f;
}
if(shi->osatex) {
out[GEOM_OUT_GLOB]->data= shi->dxgl;

@ -48,6 +48,7 @@ struct RNode;
struct Render;
struct MTex;
struct ImBuf;
struct DerivedMesh;
// RADIO REMOVED, Maybe this will be useful later
//void RE_zbufferall_radio(struct RadView *vw, struct RNode **rg_elem, int rg_totelem, struct Render *re);
@ -63,5 +64,11 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
void ibuf_sample(struct ImBuf *ibuf, float fx, float fy, float dx, float dy, float *result);
void antialias_tagbuf(int xsize, int ysize, char *rectmove);
/* dynamicpaint.c */
struct Material *RE_init_sample_material(struct Material *orig_mat, struct Scene *scene);
void RE_free_sample_material(struct Material *mat);
void RE_sample_material_color(struct Material *mat, float color[3], float *alpha, const float volume_co[3], const float surface_co[3],
int face_index, short hit_quad, struct DerivedMesh *orcoDm, struct Object *ob);
#endif /* RE_RENDER_EXT_H */

@ -90,7 +90,7 @@ typedef struct ShadeInputUV {
} ShadeInputUV;
typedef struct ShadeInputCol {
float col[3];
float col[4];
char *name;
} ShadeInputCol;

@ -40,6 +40,7 @@
struct Render;
struct TexResult;
void cache_pointdensity(struct Render *re, struct Tex *tex);
void make_pointdensities(struct Render *re);
void free_pointdensities(struct Render *re);
int pointdensitytex(struct Tex *tex, float *texvec, struct TexResult *texres);

@ -70,9 +70,9 @@ struct ImBuf;
void do_halo_tex(struct HaloRen *har, float xn, float yn, float col_r[4]);
void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float hor[3], float zen[3], float *blend, int skyflag, short thread);
void do_material_tex(struct ShadeInput *shi);
void do_material_tex(struct ShadeInput *shi, struct Render *re);
void do_lamp_tex(LampRen *la, const float lavec[3], struct ShadeInput *shi, float col_r[3], int effect);
void do_volume_tex(struct ShadeInput *shi, const float xyz[3], int mapto_flag, float col[3], float *val);
void do_volume_tex(struct ShadeInput *shi, const float xyz[3], int mapto_flag, float col[3], float *val, struct Render *re);
void init_render_textures(Render *re);
void end_render_textures(Render *re);

@ -42,6 +42,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, const float texvec[3], struct TexResult *texres);

@ -2290,7 +2290,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
shi->displace[0]= shi->displace[1]= shi->displace[2]= 0.0;
do_material_tex(shi);
do_material_tex(shi, re);
//printf("no=%f, %f, %f\nbefore co=%f, %f, %f\n", vr->n[0], vr->n[1], vr->n[2],
//vr->co[0], vr->co[1], vr->co[2]);

@ -239,7 +239,7 @@ static void pointdensity_cache_object(Render *re, PointDensity *pd, Object *ob)
dm->release(dm);
}
static void cache_pointdensity(Render *re, Tex *tex)
void cache_pointdensity(Render *re, Tex *tex)
{
PointDensity *pd = tex->pd;

@ -38,6 +38,7 @@
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
#include "DNA_texture_types.h"
#include "DNA_object_types.h"
#include "DNA_lamp_types.h"
@ -55,10 +56,12 @@
#include "BKE_node.h"
#include "BKE_plugin_types.h"
#include "BKE_animsys.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_scene.h"
#include "BKE_library.h"
#include "BKE_image.h"
@ -66,6 +69,8 @@
#include "BKE_key.h"
#include "BKE_ipo.h"
#include "MEM_guardedalloc.h"
#include "envmap.h"
#include "pointdensity.h"
#include "voxeldata.h"
@ -2141,7 +2146,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
return rgbnor;
}
void do_material_tex(ShadeInput *shi)
void do_material_tex(ShadeInput *shi, Render *re)
{
CompatibleBump compat_bump;
NTapBump ntap_bump;
@ -2159,7 +2164,7 @@ void do_material_tex(ShadeInput *shi)
compatible_bump_init(&compat_bump);
ntap_bump_init(&ntap_bump);
if (R.r.scemode & R_NO_TEX) return;
if (re->r.scemode & R_NO_TEX) return;
/* here: test flag if there's a tex (todo) */
for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
@ -2395,7 +2400,7 @@ void do_material_tex(ShadeInput *shi)
float len= normalize_v3(texres.nor);
// can be optimized... (ton)
mul_mat3_m4_v3(shi->obr->ob->obmat, texres.nor);
mul_mat3_m4_v3(R.viewmat, texres.nor);
mul_mat3_m4_v3(re->viewmat, texres.nor);
normalize_v3(texres.nor);
mul_v3_fl(texres.nor, len);
}
@ -2428,7 +2433,7 @@ void do_material_tex(ShadeInput *shi)
ImBuf *ibuf = BKE_image_get_ibuf(ima, &tex->iuser);
/* don't linearize float buffers, assumed to be linear */
if (ibuf && !(ibuf->rect_float) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT)
if (ibuf && !(ibuf->rect_float) && re->r.color_mgt_flag & R_COLOR_MANAGEMENT)
srgb_to_linearrgb_v3_v3(tcol, tcol);
}
@ -2498,12 +2503,12 @@ void do_material_tex(ShadeInput *shi)
if(mtex->normapspace == MTEX_NSPACE_CAMERA);
else if(mtex->normapspace == MTEX_NSPACE_WORLD) {
mul_mat3_m4_v3(R.viewmat, nor);
mul_mat3_m4_v3(re->viewmat, nor);
}
else if(mtex->normapspace == MTEX_NSPACE_OBJECT) {
if(shi->obr && shi->obr->ob)
mul_mat3_m4_v3(shi->obr->ob->obmat, nor);
mul_mat3_m4_v3(R.viewmat, nor);
mul_mat3_m4_v3(re->viewmat, nor);
}
normalize_v3(nor);
@ -2651,9 +2656,9 @@ void do_material_tex(ShadeInput *shi)
if(shi->amb<0.0f) shi->amb= 0.0f;
else if(shi->amb>1.0f) shi->amb= 1.0f;
shi->ambr= shi->amb*R.wrld.ambr;
shi->ambg= shi->amb*R.wrld.ambg;
shi->ambb= shi->amb*R.wrld.ambb;
shi->ambr= shi->amb*re->wrld.ambr;
shi->ambg= shi->amb*re->wrld.ambg;
shi->ambb= shi->amb*re->wrld.ambb;
}
}
}
@ -2667,7 +2672,7 @@ void do_material_tex(ShadeInput *shi)
}
void do_volume_tex(ShadeInput *shi, const float xyz[3], int mapto_flag, float col[3], float *val)
void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col, float *val, Render *re)
{
MTex *mtex;
Tex *tex;
@ -2676,7 +2681,7 @@ void do_volume_tex(ShadeInput *shi, const float xyz[3], int mapto_flag, float co
float co[3], texvec[3];
float fact, stencilTin=1.0;
if (R.r.scemode & R_NO_TEX) return;
if (re->r.scemode & R_NO_TEX) return;
/* here: test flag if there's a tex (todo) */
for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
@ -2718,7 +2723,7 @@ void do_volume_tex(ShadeInput *shi, const float xyz[3], int mapto_flag, float co
}
else if(mtex->texco==TEXCO_GLOB) {
copy_v3_v3(co, xyz);
mul_m4_v3(R.viewinv, co);
mul_m4_v3(re->viewinv, co);
}
else continue; // can happen when texco defines disappear and it renders old files
@ -3472,4 +3477,260 @@ void render_realtime_texture(ShadeInput *shi, Image *ima)
shi->vcol[3]*= texr.ta;
}
/* A modified part of shadeinput.c -> shade_input_set_uv()
* Used for sampling UV mapped texture color */
static void textured_face_generate_uv(float *uv, float *normal, float *hit, float *v1, float *v2, float *v3)
{
float detsh, t00, t10, t01, t11, xn, yn, zn;
int axis1, axis2;
/* find most stable axis to project */
xn= fabs(normal[0]);
yn= fabs(normal[1]);
zn= fabs(normal[2]);
if(zn>=xn && zn>=yn) { axis1= 0; axis2= 1; }
else if(yn>=xn && yn>=zn) { axis1= 0; axis2= 2; }
else { axis1= 1; axis2= 2; }
/* compute u,v and derivatives */
t00= v3[axis1]-v1[axis1]; t01= v3[axis2]-v1[axis2];
t10= v3[axis1]-v2[axis1]; t11= v3[axis2]-v2[axis2];
detsh= 1.0f/(t00*t11-t10*t01);
t00*= detsh; t01*=detsh;
t10*=detsh; t11*=detsh;
uv[0] = (hit[axis1]-v3[axis1])*t11-(hit[axis2]-v3[axis2])*t10;
uv[1] = (hit[axis2]-v3[axis2])*t00-(hit[axis1]-v3[axis1])*t01;
/* u and v are in range -1 to 0, we allow a little bit extra but not too much, screws up speedvectors */
CLAMP(uv[0], -2.0f, 1.0f);
CLAMP(uv[1], -2.0f, 1.0f);
}
/* Generate an updated copy of material to use for color sampling. */
Material *RE_init_sample_material(Material *orig_mat, Scene *scene)
{
Tex *tex = NULL;
Material *mat;
int tex_nr;
if (!orig_mat) return NULL;
/* copy material */
mat = localize_material(orig_mat);
/* update material anims */
BKE_animsys_evaluate_animdata(scene, &mat->id, mat->adt, BKE_curframe(scene), ADT_RECALC_ANIM);
/* strip material copy from unsupported flags */
for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
if(mat->septex & (1<<tex_nr)) continue;
if(mat->mtex[tex_nr]) {
MTex *mtex = mat->mtex[tex_nr];
/* only keep compatible texflags */
mtex->texflag = mtex->texflag & (MTEX_RGBTOINT | MTEX_STENCIL | MTEX_NEGATIVE | MTEX_ALPHAMIX);
/* depending of material type, strip non-compatible mapping modes */
if (mat->material_type == MA_TYPE_SURFACE) {
if (!ELEM4(mtex->texco, TEXCO_ORCO, TEXCO_OBJECT, TEXCO_GLOB, TEXCO_UV)) {
/* ignore this texture */
mtex->texco = 0;
continue;
}
/* strip all mapto flags except color and alpha */
mtex->mapto = (mtex->mapto & MAP_COL) | (mtex->mapto & MAP_ALPHA);
}
else if (mat->material_type == MA_TYPE_VOLUME) {
if (!ELEM3(mtex->texco, TEXCO_OBJECT, TEXCO_ORCO, TEXCO_GLOB)) {
/* ignore */
mtex->texco = 0;
continue;
}
/* strip all mapto flags except color and alpha */
mtex->mapto = mtex->mapto & (MAP_TRANSMISSION_COL | MAP_REFLECTION_COL | MAP_DENSITY);
}
/* if mapped to an object, calculate inverse matrices */
if(mtex->texco==TEXCO_OBJECT) {
Object *ob= mtex->object;
if(ob) {
invert_m4_m4(ob->imat, ob->obmat);
copy_m4_m4(ob->imat_ren, ob->imat);
}
}
/* copy texture */
tex= mtex->tex = localize_texture(mtex->tex);
/* update texture anims */
BKE_animsys_evaluate_animdata(scene, &tex->id, tex->adt, BKE_curframe(scene), ADT_RECALC_ANIM);
/* update texture cache if required */
if(tex->type==TEX_VOXELDATA) {
cache_voxeldata(tex, (int)scene->r.cfra);
}
if(tex->type==TEX_POINTDENSITY) {
/* set dummy values for render and do cache */
Render dummy_re = {0};
dummy_re.scene = scene;
unit_m4(dummy_re.viewinv);
unit_m4(dummy_re.viewmat);
unit_m4(dummy_re.winmat);
dummy_re.winx = dummy_re.winy = 128;
cache_pointdensity(&dummy_re, tex);
}
/* update image sequences and movies */
if(tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
if(tex->iuser.flag & IMA_ANIM_ALWAYS)
BKE_image_user_calc_frame(&tex->iuser, (int)scene->r.cfra, 0);
}
}
}
return mat;
}
/* free all duplicate data allocated by RE_init_sample_material() */
void RE_free_sample_material(Material *mat)
{
int tex_nr;
/* free textures */
for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
if(mat->septex & (1<<tex_nr)) continue;
if(mat->mtex[tex_nr]) {
MTex *mtex= mat->mtex[tex_nr];
free_texture(mtex->tex);
MEM_freeN(mtex->tex);
mtex->tex = NULL;
}
}
free_material(mat);
MEM_freeN(mat);
}
/*
* Get material diffuse color and alpha (including linked textures) in given coordinates
*
* color,alpha : input/output color values
* volume_co : sample coordinate in global space. used by volumetric materials
* surface_co : sample surface coordinate in global space. used by "surface" materials
* face_index : surface face index
* hit_quad : whether point is on second "half" of a quad
* orcoDm : orco state derived mesh
*/
void RE_sample_material_color(Material *mat, float color[3], float *alpha, const float volume_co[3], const float surface_co[3], int face_index, short hit_quad, DerivedMesh *orcoDm, Object *ob)
{
MFace *mface;
int v1, v2, v3;
MVert *mvert;
float uv[3], normal[3];
ShadeInput shi = {0};
Render re = {0};
/* Get face data */
mvert = orcoDm->getVertArray(orcoDm);
mface = orcoDm->getFaceArray(orcoDm);
if (!mvert || !mface || !mat) return;
v1=mface[face_index].v1, v2=mface[face_index].v2, v3=mface[face_index].v3;
if (hit_quad) {v2=mface[face_index].v3; v3=mface[face_index].v4;}
normal_tri_v3( normal, mvert[v1].co, mvert[v2].co, mvert[v3].co);
/* generate shadeinput with data required */
shi.mat = mat;
/* fill shadeinput data depending on material type */
if (mat->material_type == MA_TYPE_SURFACE) {
/* global coordinates */
copy_v3_v3(shi.gl, surface_co);
/* object space coordinates */
copy_v3_v3(shi.co, surface_co);
mul_m4_v3(ob->imat, shi.co);
/* orco coordinates */
{
float l;
/* Get generated UV */
textured_face_generate_uv(uv, normal, shi.co, mvert[v1].co, mvert[v2].co, mvert[v3].co);
l= 1.0f+uv[0]+uv[1];
/* calculate generated coordinate */
shi.lo[0]= l*mvert[v3].co[0]-uv[0]*mvert[v1].co[0]-uv[1]*mvert[v2].co[0];
shi.lo[1]= l*mvert[v3].co[1]-uv[0]*mvert[v1].co[1]-uv[1]*mvert[v2].co[1];
shi.lo[2]= l*mvert[v3].co[2]-uv[0]*mvert[v1].co[2]-uv[1]*mvert[v2].co[2];
}
/* uv coordinates */
{
int i, layers = CustomData_number_of_layers(&orcoDm->faceData, CD_MTFACE);
int layer_index = CustomData_get_layer_index(&orcoDm->faceData, CD_MTFACE);
/* for every uv layer set coords and name */
for (i=0; i<layers; i++) {
if(layer_index >= 0) {
float *uv1, *uv2, *uv3;
float l;
CustomData *data = &orcoDm->faceData;
MTFace *tface = (MTFace*) data->layers[layer_index+i].data;
float uv[3];
/* point layer name from actual layer data */
shi.uv[i].name = data->layers[i].name;
/* Get generated coordinates to calculate UV from */
textured_face_generate_uv(uv, normal, shi.co, mvert[v1].co, mvert[v2].co, mvert[v3].co);
/* Get UV mapping coordinate */
l= 1.0f+uv[0]+uv[1];
uv1= tface[face_index].uv[0];
uv2= (hit_quad) ? tface[face_index].uv[2] : tface[face_index].uv[1];
uv3= (hit_quad) ? tface[face_index].uv[3] : tface[face_index].uv[2];
shi.uv[i].uv[0]= -1.0f + 2.0f*(l*uv3[0]-uv[0]*uv1[0]-uv[1]*uv2[0]);
shi.uv[i].uv[1]= -1.0f + 2.0f*(l*uv3[1]-uv[0]*uv1[1]-uv[1]*uv2[1]);
shi.uv[i].uv[2]= 0.0f; /* texture.c assumes there are 3 coords */
}
}
/* active uv layer */
shi.actuv = CustomData_get_active_layer_index(&orcoDm->faceData,CD_MTFACE) - layer_index;
shi.totuv = layers;
}
/* apply initial values from material */
shi.r = mat->r;
shi.g = mat->g;
shi.b = mat->b;
shi.alpha = mat->alpha;
/* do texture */
do_material_tex(&shi, &re);
/* apply result */
color[0] = shi.r;
color[1] = shi.g;
color[2] = shi.b;
*alpha = shi.alpha;
}
else if (mat->material_type == MA_TYPE_VOLUME) {
ObjectInstanceRen obi = {0};
obi.ob = ob;
shi.obi = &obi;
unit_m4(re.viewinv);
color[0] = mat->vol.reflection_col[0];
color[1] = mat->vol.reflection_col[1];
color[2] = mat->vol.reflection_col[2];
*alpha = mat->vol.density;
/* do texture */
do_volume_tex(&shi, volume_co, (MAP_TRANSMISSION_COL | MAP_REFLECTION_COL | MAP_DENSITY),
color, alpha, &re);
}
}
/* eof */

@ -469,17 +469,20 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert
scol->col[0]= cp[3]/255.0f;
scol->col[1]= cp[2]/255.0f;
scol->col[2]= cp[1]/255.0f;
scol->col[3]= cp[0]/255.0f;
}
if(shi->totcol) {
shi->vcol[0]= shi->col[shi->actcol].col[0];
shi->vcol[1]= shi->col[shi->actcol].col[1];
shi->vcol[2]= shi->col[shi->actcol].col[2];
shi->vcol[3]= shi->col[shi->actcol].col[3];
}
else {
shi->vcol[0]= 0.0f;
shi->vcol[1]= 0.0f;
shi->vcol[2]= 0.0f;
shi->vcol[3]= 0.0f;
}
}
@ -512,6 +515,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert
shi->vcol[0]= 1.0f;
shi->vcol[1]= 1.0f;
shi->vcol[2]= 1.0f;
shi->vcol[3]= 1.0f;
}
}
}
@ -528,6 +532,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert
shi->vcol[0]= 1.0f;
shi->vcol[1]= 1.0f;
shi->vcol[2]= 1.0f;
shi->vcol[3]= 1.0f;
}
}
@ -1096,6 +1101,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
for (i=0; (mcol=RE_vlakren_get_mcol(obr, vlr, i, &name, 0)); i++) {
ShadeInputCol *scol= &shi->col[i];
char *cp1, *cp2, *cp3;
float a[3];
shi->totcol++;
scol->name= name;
@ -1103,17 +1109,29 @@ void shade_input_set_shade_texco(ShadeInput *shi)
cp1= (char *)(mcol+j1);
cp2= (char *)(mcol+j2);
cp3= (char *)(mcol+j3);
scol->col[0]= (l*((float)cp3[3]) - u*((float)cp1[3]) - v*((float)cp2[3]))/255.0f;
scol->col[1]= (l*((float)cp3[2]) - u*((float)cp1[2]) - v*((float)cp2[2]))/255.0f;
scol->col[2]= (l*((float)cp3[1]) - u*((float)cp1[1]) - v*((float)cp2[1]))/255.0f;
/* alpha values */
a[0] = ((float)cp1[0])/255.f;
a[1] = ((float)cp2[0])/255.f;
a[2] = ((float)cp3[0])/255.f;
scol->col[3]= l*a[2] - u*a[0] - v*a[1];
/* sample premultiplied color value */
scol->col[0]= (l*((float)cp3[3])*a[2] - u*((float)cp1[3])*a[0] - v*((float)cp2[3])*a[1])/255.f;
scol->col[1]= (l*((float)cp3[2])*a[2] - u*((float)cp1[2])*a[0] - v*((float)cp2[2])*a[1])/255.f;
scol->col[2]= (l*((float)cp3[1])*a[2] - u*((float)cp1[1])*a[0] - v*((float)cp2[1])*a[1])/255.f;
/* if not zero alpha, restore non-multiplied color */
if (scol->col[3]) {
mul_v3_fl(scol->col, 1.0f/scol->col[3]);
}
}
if(shi->totcol) {
shi->vcol[0]= shi->col[shi->actcol].col[0];
shi->vcol[1]= shi->col[shi->actcol].col[1];
shi->vcol[2]= shi->col[shi->actcol].col[2];
shi->vcol[3]= 1.0f;
shi->vcol[3]= shi->col[shi->actcol].col[3];
}
else {
shi->vcol[0]= 0.0f;

@ -864,16 +864,22 @@ void shade_color(ShadeInput *shi, ShadeResult *shr)
{
Material *ma= shi->mat;
if(ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE)) {
if(ma->mode & (MA_FACETEXTURE)) {
shi->r= shi->vcol[0];
shi->g= shi->vcol[1];
shi->b= shi->vcol[2];
if(ma->mode & (MA_FACETEXTURE_ALPHA))
shi->alpha= shi->vcol[3];
}
else if(ma->mode & (MA_VERTEXCOLP)) {
float neg_alpha = 1.0f - shi->vcol[3];
shi->r= shi->r*neg_alpha + shi->vcol[0]*shi->vcol[3];
shi->g= shi->g*neg_alpha + shi->vcol[1]*shi->vcol[3];
shi->b= shi->b*neg_alpha + shi->vcol[2]*shi->vcol[3];
}
if(ma->texco)
do_material_tex(shi);
do_material_tex(shi, &R);
if(ma->fresnel_tra!=0.0f)
shi->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra);
@ -1655,15 +1661,21 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
/* material color itself */
if(passflag & (SCE_PASS_COMBINED|SCE_PASS_RGBA)) {
if(ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE)) {
if(ma->mode & (MA_FACETEXTURE)) {
shi->r= shi->vcol[0];
shi->g= shi->vcol[1];
shi->b= shi->vcol[2];
if(ma->mode & (MA_FACETEXTURE_ALPHA))
shi->alpha= (shi->mode & MA_TRANSP) ? shi->vcol[3] : 1.0f;
shi->alpha= shi->vcol[3];
}
else if(ma->mode & (MA_VERTEXCOLP)) {
float neg_alpha = 1.0f - shi->vcol[3];
shi->r= shi->r*neg_alpha + shi->vcol[0]*shi->vcol[3];
shi->g= shi->g*neg_alpha + shi->vcol[1]*shi->vcol[3];
shi->b= shi->b*neg_alpha + shi->vcol[2]*shi->vcol[3];
}
if(ma->texco){
do_material_tex(shi);
do_material_tex(shi, &R);
if (!(shi->mode & MA_TRANSP)) shi->alpha = 1.0f;
}

@ -289,7 +289,7 @@ float vol_get_density(struct ShadeInput *shi, const float co[3])
float density_scale = shi->mat->vol.density_scale;
if (shi->mat->mapto_textured & MAP_DENSITY)
do_volume_tex(shi, co, MAP_DENSITY, NULL, &density);
do_volume_tex(shi, co, MAP_DENSITY, NULL, &density, &R);
// if meta-object, modulate by metadensity without increasing it
if (shi->obi->obr->ob->type == OB_MBALL) {
@ -311,11 +311,11 @@ static void vol_get_reflection_color(ShadeInput *shi, float ref_col[3], const fl
copy_v3_v3(ref_col, shi->mat->vol.reflection_col);
if (shi->mat->mapto_textured & (MAP_SCATTERING+MAP_REFLECTION_COL))
do_volume_tex(shi, co, MAP_SCATTERING+MAP_REFLECTION_COL, ref_col, &scatter);
do_volume_tex(shi, co, MAP_SCATTERING+MAP_REFLECTION_COL, ref_col, &scatter, &R);
/* only one single float parameter at a time... :s */
if (shi->mat->mapto_textured & (MAP_REFLECTION))
do_volume_tex(shi, co, MAP_REFLECTION, NULL, &reflection);
do_volume_tex(shi, co, MAP_REFLECTION, NULL, &reflection, &R);
ref_col[0] = reflection * ref_col[0] * scatter;
ref_col[1] = reflection * ref_col[1] * scatter;
@ -330,7 +330,7 @@ static void vol_get_emission(ShadeInput *shi, float emission_col[3], const float
copy_v3_v3(emission_col, shi->mat->vol.emission_col);
if (shi->mat->mapto_textured & (MAP_EMISSION+MAP_EMISSION_COL))
do_volume_tex(shi, co, MAP_EMISSION+MAP_EMISSION_COL, emission_col, &emission);
do_volume_tex(shi, co, MAP_EMISSION+MAP_EMISSION_COL, emission_col, &emission, &R);
emission_col[0] = emission_col[0] * emission;
emission_col[1] = emission_col[1] * emission;
@ -350,7 +350,7 @@ static void vol_get_sigma_t(ShadeInput *shi, float sigma_t[3], const float co[3]
float scattering = shi->mat->vol.scattering;
if (shi->mat->mapto_textured & (MAP_SCATTERING+MAP_TRANSMISSION_COL))
do_volume_tex(shi, co, MAP_SCATTERING+MAP_TRANSMISSION_COL, transmission_col, &scattering);
do_volume_tex(shi, co, MAP_SCATTERING+MAP_TRANSMISSION_COL, transmission_col, &scattering, &R);
sigma_t[0] = (1.0f - transmission_col[0]) + scattering;
sigma_t[1] = (1.0f - transmission_col[1]) + scattering;

@ -309,7 +309,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
#endif
}
static void cache_voxeldata(struct Render *re, Tex *tex)
void cache_voxeldata(Tex *tex, int scene_frame)
{
VoxelData *vd = tex->vd;
FILE *fp;
@ -317,7 +317,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 */
@ -329,7 +329,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));
@ -338,7 +338,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);
@ -373,7 +373,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);
}
}

@ -126,6 +126,11 @@ int multitex_ext(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osa
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;}
struct Material *RE_init_sample_material(struct Material *orig_mat, struct Scene *scene) {return (struct Material *)NULL;}
void RE_free_sample_material(struct Material *mat) {}
void RE_sample_material_color(struct Material *mat, float color[3], float *alpha, const float volume_co[3], const float surface_co[3],
int face_index, short hit_quad, struct DerivedMesh *orcoDm, struct Object *ob) {}
/* nodes */
struct RenderResult *RE_GetResult(struct Render *re){return (struct RenderResult *) NULL;}
struct Render *RE_GetRender(const char *name){return (struct Render *) NULL;}