[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39009] branches/soc-2011-carrot: Dynamic Paint:
Miika Hamalainen
miika.hamalainen at kolumbus.fi
Thu Aug 4 09:09:22 CEST 2011
Revision: 39009
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39009
Author: miikah
Date: 2011-08-04 07:09:21 +0000 (Thu, 04 Aug 2011)
Log Message:
-----------
Dynamic Paint:
* Smudge now works properly with substeps.
* Velocity brush speed clamping now works for all brush types.
* Small tweaking on velocity brush ui.
Modified Paths:
--------------
branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.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-04 06:44:08 UTC (rev 39008)
+++ branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py 2011-08-04 07:09:21 UTC (rev 39009)
@@ -121,15 +121,19 @@
split.prop(brush, "wave_factor")
elif (brush.brush_settings_context == "VELOCITY"):
col = layout.row().column()
+ col.label(text="Velocity Settings:")
+ split = layout.split()
+ col = split.column()
col.prop(brush, "velocity_alpha")
col.prop(brush, "velocity_color")
+ col = split.column()
col.prop(brush, "velocity_depth")
- col = layout.row().column()
- sub = col.column()
- sub.active = (brush.velocity_alpha or brush.velocity_color)
+ 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()
+ layout.label(text="Smudge:")
layout.prop(brush, "do_smudge")
layout.prop(brush, "smudge_strength")
else:
Modified: branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c 2011-08-04 06:44:08 UTC (rev 39008)
+++ branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c 2011-08-04 07:09:21 UTC (rev 39009)
@@ -170,9 +170,9 @@
VolumeGrid *grid; /* space partitioning grid to optimize brush checks */
/* velocity and movement */
- Vec3f *velocity; /* speed vector in global space, if required */
+ Vec3f *velocity; /* speed vector in global space movement per frame, if required */
Vec3f *prev_velocity;
- float *brush_velocity; /* special temp data for post-p velocity based brushes like smear
+ float *brush_velocity; /* special temp data for post-p velocity based brushes like smudge
* 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 */
@@ -3085,6 +3085,9 @@
/* Sample velocity colorband if required */
if (brush->flags & (MOD_DPAINT_VELOCITY_ALPHA|MOD_DPAINT_VELOCITY_COLOR|MOD_DPAINT_VELOCITY_DEPTH)) {
float coba_res[4];
+ vel_factor /= brush->max_velocity;
+ CLAMP(vel_factor, 0.0f, 1.0f);
+
if (do_colorband(brush->vel_ramp, vel_factor, coba_res)) {
if (brush->flags & MOD_DPAINT_VELOCITY_COLOR) {
paint[0] = coba_res[0];
@@ -3538,7 +3541,6 @@
/* substract canvas point velocity */
VECSUB(velocity, brushPointVelocity, bData->velocity[index].v);
-
velocity_val = len_v3(velocity);
/* */
@@ -3547,9 +3549,6 @@
mul_v3_fl(&bData->brush_velocity[index*4], 1.0f/velocity_val);
bData->brush_velocity[index*4+3] = velocity_val;
}
-
- velocity_val /= brush->max_velocity;
- CLAMP(velocity_val, 0.0f, 1.0f);
}
/*
@@ -3839,8 +3838,10 @@
{
float velocity[3];
ParticleData *pa = psys->particles + part_index;
+ mul_v3_v3fl(velocity, pa->state.vel, particle_timestep);
- mul_v3_v3fl(velocity, pa->state.vel, particle_timestep);
+ /* substract canvas point velocity */
+ VECSUB(velocity, velocity, bData->velocity[index].v);
velocity_val = len_v3(velocity);
if (brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity) {
@@ -3848,9 +3849,6 @@
mul_v3_fl(&bData->brush_velocity[index*4], 1.0f/velocity_val);
bData->brush_velocity[index*4+3] = velocity_val;
}
-
- velocity_val /= brush->max_velocity;
- CLAMP(velocity_val, 0.0f, 1.0f);
}
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
@@ -3890,12 +3888,9 @@
PaintSurfaceData *sData = surface->data;
PaintBakeData *bData = sData->bData;
Vec3f brushVel;
- float velocity_val = 0.0f;
- if (brush->flags & MOD_DPAINT_USES_VELOCITY) {
+ if (brush->flags & MOD_DPAINT_USES_VELOCITY)
dynamicPaint_brushObjectCalculateVelocity(scene, brushOb, brush, &brushVel, timescale);
- velocity_val = len_v3(brushVel.v);
- }
/*
* Loop through every surface point
@@ -3921,6 +3916,7 @@
if (strength >= 0.001f) {
float paintColor[3] = {0.0f};
float depth = 0.0f;
+ float velocity_val = 0.0f;
/* material */
if (brush->flags & MOD_DPAINT_USE_MATERIAL) {
@@ -3938,8 +3934,14 @@
strength = colorband[3];
if (brush->flags & MOD_DPAINT_USES_VELOCITY) {
+ float velocity[3];
+
+ /* substract canvas point velocity */
+ VECSUB(velocity, brushVel.v, bData->velocity[index].v);
+ velocity_val = len_v3(velocity);
+
if (brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity) {
- VECCOPY(&bData->brush_velocity[index*4], brushVel.v);
+ VECCOPY(&bData->brush_velocity[index*4], velocity);
mul_v3_fl(&bData->brush_velocity[index*4], 1.0f/velocity_val);
bData->brush_velocity[index*4+3] = velocity_val;
}
@@ -4031,7 +4033,7 @@
bData->average_dist /= adj_data->total_targets;
}
-static void dynamicPaint_doSmudge(DynamicPaintSurface *surface, DynamicPaintBrushSettings *brush)
+static void dynamicPaint_doSmudge(DynamicPaintSurface *surface, DynamicPaintBrushSettings *brush, float timescale)
{
PaintSurfaceData *sData = surface->data;
PaintBakeData *bData = sData->bData;
@@ -4047,13 +4049,12 @@
if (vel > max_velocity) max_velocity = vel;
}
- steps = (int)ceil(max_velocity / bData->average_dist);
+ steps = (int)ceil(max_velocity / bData->average_dist * timescale);
CLAMP(steps, 0, 12);
+ eff_scale = brush->smudge_strength/(float)steps*timescale;
for (step=0; step<steps; step++) {
- eff_scale = brush->smudge_strength/(float)steps;
-
for (index = 0; index < sData->total_points; index++) {
int i;
int numOfNeighs = sData->adj_data->n_num[index];
@@ -5018,7 +5019,7 @@
/* process special brush effects, like smudge */
if (bData->brush_velocity) {
if (brush->flags & MOD_DPAINT_DO_SMUDGE)
- dynamicPaint_doSmudge(surface, brush);
+ dynamicPaint_doSmudge(surface, brush, timescale);
MEM_freeN(bData->brush_velocity);
bData->brush_velocity = NULL;
}
More information about the Bf-blender-cvs
mailing list