[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39001] branches/soc-2011-carrot: Dynamic Paint:
Miika Hamalainen
miika.hamalainen at kolumbus.fi
Wed Aug 3 20:31:48 CEST 2011
Revision: 39001
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39001
Author: miikah
Date: 2011-08-03 18:31:48 +0000 (Wed, 03 Aug 2011)
Log Message:
-----------
Dynamic Paint:
* Object velocity can now be used to determine brush influence and color.
* Brushes can now be set to "smudge" existing paint.
* Added new operators to easily add and remove surface output mesh data layers from Dynamic Paint ui.
* Fixed drip effect algorithm to work properly on forces pointing towards surface.
* Adjusted drip effect speed.
* Drip effect can now use canvas velocity and acceleration to influence drip direction.
* Fixed texture mapping for material enabled brushes.
* "Object Center" type brushes can now use "material color" as well.
* Improved surface partitioning grid generation algorithm.
* Fixed possible invalid brush collision detection when OpenMP enabled.
* Fixed incorrect random sized particle displace/wave influence.
* Fixed "Object Center" brush color ramp falloff.
* Fixed invalid zero alpha sampling when rendering vertex colors.
* Lots of smaller tweaking.
Modified Paths:
--------------
branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h
branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
branches/soc-2011-carrot/source/blender/blenloader/intern/readfile.c
branches/soc-2011-carrot/source/blender/blenloader/intern/writefile.c
branches/soc-2011-carrot/source/blender/editors/include/ED_mesh.h
branches/soc-2011-carrot/source/blender/editors/mesh/mesh_data.c
branches/soc-2011-carrot/source/blender/editors/physics/physics_intern.h
branches/soc-2011-carrot/source/blender/editors/physics/physics_ops.c
branches/soc-2011-carrot/source/blender/makesdna/DNA_dynamicpaint_types.h
branches/soc-2011-carrot/source/blender/makesrna/intern/rna_dynamicpaint.c
branches/soc-2011-carrot/source/blender/modifiers/intern/MOD_dynamicpaint.c
branches/soc-2011-carrot/source/blender/render/extern/include/RE_shader_ext.h
branches/soc-2011-carrot/source/blender/render/intern/source/render_texture.c
branches/soc-2011-carrot/source/blender/render/intern/source/shadeinput.c
branches/soc-2011-carrot/source/blenderplayer/bad_level_call_stubs/stubs.c
Modified: branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
===================================================================
--- branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py 2011-08-03 18:28:40 UTC (rev 39000)
+++ branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py 2011-08-03 18:31:48 UTC (rev 39001)
@@ -119,6 +119,19 @@
if (brush.wave_type != "REFLECT"):
split = layout.split(percentage=0.6)
split.prop(brush, "wave_factor")
+ elif (brush.brush_settings_context == "VELOCITY"):
+ col = layout.row().column()
+ col.prop(brush, "velocity_alpha")
+ col.prop(brush, "velocity_color")
+ col.prop(brush, "velocity_depth")
+ col = layout.row().column()
+ sub = col.column()
+ sub.active = (brush.velocity_alpha or brush.velocity_color)
+ sub.prop(brush, "max_velocity")
+ sub.template_color_ramp(brush, "velocity_ramp", expand=True)
+ layout.separator()
+ layout.prop(brush, "do_smudge")
+ layout.prop(brush, "smudge_strength")
else:
layout.label(text="-WIP-")
@@ -199,17 +212,31 @@
# vertex format outputs
if (surface.surface_format == "VERTEX"):
if (surface.surface_type == "PAINT"):
+ # paintmap output
row = layout.row()
row.prop_search(surface, "output_name", ob.data, "vertex_colors", text="Paintmap layer: ")
- #col = row.column(align=True)
- #col.operator("dpaint.output_add", icon='ZOOMIN', text="")
+ 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: ")
- #col = row.column(align=True)
- #col.operator("dpaint.output_add", icon='ZOOMIN', text="")
+ 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"):
- layout.prop_search(surface, "output_name", ob, "vertex_groups", text="Vertex Group: ")
+ 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"):
@@ -280,7 +307,15 @@
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()
Modified: branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h 2011-08-03 18:28:40 UTC (rev 39000)
+++ branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h 2011-08-03 18:31:48 UTC (rev 39001)
@@ -58,8 +58,6 @@
short state; /* 0 = neutral
* 1 = obstacle
* 2 = reflect only */
- float foam;
-
} PaintWavePoint;
struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm);
@@ -70,6 +68,7 @@
void dynamicPaint_clearSurface(DynamicPaintSurface *surface);
int dynamicPaint_resetSurface(struct DynamicPaintSurface *surface);
int dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface);
+int dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, struct Object *ob, int index);
void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface);
void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, char *basename);
Modified: branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c 2011-08-03 18:28:40 UTC (rev 39000)
+++ branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c 2011-08-03 18:31:48 UTC (rev 39001)
@@ -58,12 +58,14 @@
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h" /* to get temp file path */
+#include "ED_mesh.h"
+#include "ED_screen.h"
+
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
/* for bake operator */
-#include "ED_screen.h"
#include "WM_types.h"
#include "WM_api.h"
@@ -154,17 +156,27 @@
/* Temp surface data used to process a frame */
typedef struct PaintBakeData {
+ /* point space data */
PaintBakeNormal *bNormal;
unsigned int *s_pos; /* index to start reading point sample realCoord */
unsigned int *s_num; /* num of samples for each point */
Vec3f *realCoord; /* current pixel center world-space coordinates * numOfSamples
* ordered as (s_pos+sample_num)*/
+ /* adjacency */
BakeNeighPoint *bNeighs; /* current frame neighbour distances, if required */
+ double average_dist;
+ /* space partitioning */
VolumeGrid *grid; /* space partitioning grid to optimize brush checks */
- MVert *prev_verts; /* copy of previous frame vertices. used observe surface movement */
+ /* velocity and movement */
+ Vec3f *velocity; /* speed vector in global space, if required */
+ Vec3f *prev_velocity;
+ float *brush_velocity; /* special temp data for post-p velocity based brushes like smear
+ * 3 float dir vec + 1 float str */
+ MVert *prev_verts; /* copy of previous frame vertices. used to observe surface movement */
float prev_obmat[4][4]; /* previous frame object matrix */
+ int clear;
} PaintBakeData;
@@ -322,6 +334,29 @@
dynamicPaint_resetPreview(surface->canvas);
}
+int dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object *ob, int index)
+{
+ char *name;
+
+ if (index == 0)
+ name = surface->output_name;
+ else if (index == 1)
+ name = surface->output_name2;
+ else
+ return 0;
+
+ if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
+ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
+ Mesh *me = ob->data;
+ return (CustomData_get_named_layer_index(&me->fdata, CD_MCOL, name) != -1);
+ }
+ else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)
+ return (defgroup_name_index(ob, surface->output_name) != -1);
+ }
+
+ return 0;
+}
+
static int surfaceDublicateNameExists(void *arg, const char *name)
{
DynamicPaintSurface *t_surface = (DynamicPaintSurface*)arg;
@@ -370,6 +405,108 @@
t_color[2] = t_color[2]*invFact + s_color[2]*factor;
}
+#define UPDATE_PARENTS (1<<0)
+#define UPDATE_MESH (1<<1)
+#define UPDATE_EVERYTHING (UPDATE_PARENTS|UPDATE_MESH)
+
+static void subframe_updateObject(Scene *scene, Object *ob, int flags, float frame)
+{
+ int oflags;
+ DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
+
+ /* if other is dynamic paint canvas, dont update */
+ if (pmd && pmd->canvas)
+ return;
+
+ /* if object has parent, update it too */
+ if ((flags & UPDATE_PARENTS) && ob->parent) subframe_updateObject(scene, ob->parent, 0, frame);
+ if ((flags & UPDATE_PARENTS) && ob->track) subframe_updateObject(scene, ob->track, 0, frame);
+
+ /* for curve */
+ if(ob->type==OB_CURVE) {
+ Curve *cu= ob->data;
+ BKE_animsys_evaluate_animdata(&cu->id, cu->adt, frame, ADT_RECALC_ANIM);
+ }
+
+ /* backup object flags */
+ oflags = ob->recalc;
+
+ ob->recalc |= OB_RECALC_ALL;
+ ob->recalc |= OB_RECALC_DATA;
+ BKE_animsys_evaluate_animdata(&ob->id, ob->adt, frame, ADT_RECALC_ANIM);
+ if (flags & UPDATE_MESH)
+ object_handle_update(scene, ob);
+ else
+ where_is_object_time(scene, ob, frame);
+
+ /* restore object flags */
+ ob->recalc = oflags;
+}
+
+static void scene_setSubframe(Scene *scene, float subframe)
+{
+ /* dynamic paint subframes must be done on previous frame */
+ scene->r.cfra -= 1;
+ scene->r.subframe = subframe;
+}
+
+#define BRUSH_USES_VELOCITY (1<<0)
+
+static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene, Object *ob)
+{
+ Base *base = NULL;
+ GroupObject *go = NULL;
+ Object *brushObj = NULL;
+ ModifierData *md = NULL;
+
+ int flags = 0;
+
+ if(surface->brush_group)
+ go = surface->brush_group->gobject.first;
+ else
+ base = scene->base.first;
+
+ while (base || go)
+ {
+ brushObj = NULL;
+
+ /* select object */
+ if(surface->brush_group) {
+ if(go->ob) brushObj = go->ob;
+ }
+ else
+ brushObj = base->object;
+
+ if(!brushObj)
+ {
+ if(surface->brush_group) go = go->next;
+ else base= base->next;
+ continue;
+ }
+
+ if(surface->brush_group)
+ go = go->next;
+ else
+ base= base->next;
+
+ md = modifiers_findByType(brushObj, eModifierType_DynamicPaint);
+ if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
+ {
+ DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md;
+
+ if (pmd2->brush)
+ {
+ DynamicPaintBrushSettings *brush = pmd2->brush;
+
+ if (brush->flags & MOD_DPAINT_USES_VELOCITY)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list