[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42323] trunk/blender/source/blender/ blenkernel/intern/dynamicpaint.c: dynamic paint, possible use of uninitialized value - fix.
Campbell Barton
ideasman42 at gmail.com
Thu Dec 1 19:49:42 CET 2011
Revision: 42323
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42323
Author: campbellbarton
Date: 2011-12-01 18:49:42 +0000 (Thu, 01 Dec 2011)
Log Message:
-----------
dynamic paint, possible use of uninitialized value - fix.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c
Modified: trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c 2011-12-01 18:38:03 UTC (rev 42322)
+++ trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c 2011-12-01 18:49:42 UTC (rev 42323)
@@ -3572,7 +3572,7 @@
float radius = 0.0f;
float strength = 0.0f;
float velocity_val = 0.0f;
- int part_index;
+ int part_index= -1;
/*
* With predefined radius, there is no variation between particles.
@@ -3644,10 +3644,12 @@
part_index = nearest[n].index;
/* If inside solid range and no disp depth required, no need to seek further */
- if (s_range < 0.0f)
- if (surface->type != MOD_DPAINT_SURFACE_T_DISPLACE &&
- surface->type != MOD_DPAINT_SURFACE_T_WAVE)
+ if ( (s_range < 0.0f) &&
+ (surface->type != MOD_DPAINT_SURFACE_T_DISPLACE) &&
+ (surface->type != MOD_DPAINT_SURFACE_T_WAVE))
+ {
break;
+ }
}
if (nearest) MEM_freeN(nearest);
@@ -3675,7 +3677,7 @@
float depth = 0.0f;
/* apply velocity */
- if (brush->flags & MOD_DPAINT_USES_VELOCITY) {
+ if ((brush->flags & MOD_DPAINT_USES_VELOCITY) && (part_index != -1)) {
float velocity[3];
ParticleData *pa = psys->particles + part_index;
mul_v3_v3fl(velocity, pa->state.vel, particle_timestep);
@@ -3687,8 +3689,9 @@
velocity_val = len_v3(velocity);
/* store brush velocity for smudge */
- if (surface->type == MOD_DPAINT_SURFACE_T_PAINT &&
- brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity) {
+ if ( (surface->type == MOD_DPAINT_SURFACE_T_PAINT) &&
+ (brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity))
+ {
copy_v3_v3(&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;
@@ -3696,12 +3699,11 @@
}
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
- paintColor[0] = brush->r;
- paintColor[1] = brush->g;
- paintColor[2] = brush->b;
+ copy_v3_v3(paintColor, &brush->r);
}
- else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
- surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
+ else if ( (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) ||
+ (surface->type == MOD_DPAINT_SURFACE_T_WAVE))
+ {
/* get displace depth */
disp_intersect = (1.0f - sqrtf(disp_intersect / radius)) * radius;
depth = (radius - disp_intersect) / bData->bNormal[index].normal_scale;
More information about the Bf-blender-cvs
mailing list