Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-11-15 06:05:32 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-15 06:05:32 +0400
commite59ab6486f9e7285815671044b785c28365d5165 (patch)
tree4a9406c8181a817a8b96243ae167acc740ed20f7 /source/blender/blenkernel/intern/dynamicpaint.c
parent35ab6cabbf62187290e417dba6d8b18cd4fe18de (diff)
parentb1019a56b54294fc91293c5c43ef46d54950ae84 (diff)
svn merge -r41751:41779 ^/trunk/blender
Diffstat (limited to 'source/blender/blenkernel/intern/dynamicpaint.c')
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c91
1 files changed, 54 insertions, 37 deletions
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 1522497bb04..c71a8f2bfc7 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -677,7 +677,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
volume = td[0]*td[1]*td[2];
/* determine final grid size by trying to fit average 10.000 points per grid cell */
- dim_factor = pow(volume / ((double)sData->total_points / 10000.f), 1.0f/axis);
+ dim_factor = (float)pow(volume / ((double)sData->total_points / 10000.0), 1.0/(double)axis);
/* define final grid size using dim_factor, use min 3 for active axises */
for (i=0; i<3; i++) {
@@ -3175,13 +3175,20 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
{
float ray_start[3], ray_dir[3];
- float colorband[4] = {0.0f};
- float sample_factor;
+ float sample_factor = 0.0f;
float sampleStrength = 0.0f;
BVHTreeRayHit hit;
BVHTreeNearest nearest;
short hit_found = 0;
+ /* volume sample */
+ float volume_factor = 0.0f;
+ /* proximity sample */
+ float proximity_factor = 0.0f;
+ float prox_colorband[4] = {0.0f};
+ int inner_proximity = (brush->flags & MOD_DPAINT_INVERSE_PROX &&
+ brush->collision == MOD_DPAINT_COL_VOLDIST);
+
/* hit data */
float hitCoord[3];
int hitFace = -1;
@@ -3236,7 +3243,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
if(hit.index != -1) {
/* Add factor on supersample filter */
- sampleStrength += sample_factor;
+ volume_factor = 1.0f;
hit_found = HIT_VOLUME;
/* Mark hit info */
@@ -3256,8 +3263,6 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
float hitCo[3];
short hQuad;
int face;
- int inner_proximity = (brush->flags & MOD_DPAINT_INVERSE_PROX &&
- brush->collision == MOD_DPAINT_COL_VOLDIST);
/* if inverse prox and no hit found, skip this sample */
if (inner_proximity && !hit_found) continue;
@@ -3299,25 +3304,12 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* If a hit was found, calculate required values */
if (proxDist >= 0.0f && proxDist <= brush->paint_distance) {
- float dist_rate = proxDist / brush->paint_distance;
- float prox_influence = 0.0f;
-
- /* in case of inverse prox also undo volume effect */
- if (inner_proximity) {
- sampleStrength -= sample_factor;
- dist_rate = 1.0f - dist_rate;
- }
-
- /* if using proximity color ramp use it's alpha */
- if (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP && do_colorband(brush->paint_ramp, dist_rate, colorband))
- prox_influence = colorband[3];
- else if (brush->proximity_falloff == MOD_DPAINT_PRFALL_SMOOTH) {
- prox_influence = (1.0f - dist_rate) * sample_factor;
- }
- else prox_influence = inner_proximity ? 0.0f : 1.0f;
+ proximity_factor = proxDist / brush->paint_distance;
+ CLAMP(proximity_factor, 0.0f, 1.0f);
+ if (!inner_proximity)
+ proximity_factor = 1.0f - proximity_factor;
hit_found = HIT_PROXIMITY;
- sampleStrength += prox_influence*sample_factor;
/* if no volume hit, use prox point face info */
if (hitFace == -1) {
@@ -3328,7 +3320,32 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
}
}
- if (!hit_found) continue;
+ /* mix final sample strength depending on brush settings */
+ if (hit_found) {
+ /* if "negate volume" enabled, negate all factors within volume*/
+ if (brush->collision == MOD_DPAINT_COL_VOLDIST && brush->flags & MOD_DPAINT_NEGATE_VOLUME) {
+ volume_factor = 1.0f - volume_factor;
+ if (inner_proximity)
+ proximity_factor = 1.0f - proximity_factor;
+ }
+
+ /* apply final sample depending on final hit type */
+ if (hit_found == HIT_VOLUME) {
+ sampleStrength = volume_factor;
+ }
+ else if (hit_found == HIT_PROXIMITY) {
+ /* apply falloff curve to the proximity_factor */
+ if (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP && do_colorband(brush->paint_ramp, (1.0f-proximity_factor), prox_colorband))
+ proximity_factor = prox_colorband[3];
+ else if (brush->proximity_falloff == MOD_DPAINT_PRFALL_CONSTANT)
+ proximity_factor = (!inner_proximity || brush->flags & MOD_DPAINT_NEGATE_VOLUME) ? 1.0f : 0.0f;
+ /* apply sample */
+ sampleStrength = proximity_factor;
+ }
+
+ sampleStrength *= sample_factor;
+ }
+ else continue;
/* velocity brush, only do on main sample */
if (brush->flags & MOD_DPAINT_USES_VELOCITY && ss==0 && brushVelocity) {
@@ -3395,9 +3412,9 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* Sample proximity colorband if required */
if ((hit_found == HIT_PROXIMITY) && (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP)) {
if (!(brush->flags & MOD_DPAINT_RAMP_ALPHA)) {
- sampleColor[0] = colorband[0];
- sampleColor[1] = colorband[1];
- sampleColor[2] = colorband[2];
+ sampleColor[0] = prox_colorband[0];
+ sampleColor[1] = prox_colorband[1];
+ sampleColor[2] = prox_colorband[2];
}
}
@@ -3478,7 +3495,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
float range = solidradius + smooth;
float particle_timestep = 0.04f * part->timetweak;
- Bounds3D part_bb;
+ Bounds3D part_bb = {0};
if (psys->totpart < 1) return 1;
@@ -3678,7 +3695,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
/* get displace depth */
- disp_intersect = (1.0f - sqrt(disp_intersect / radius)) * radius;
+ disp_intersect = (1.0f - sqrtf(disp_intersect / radius)) * radius;
depth = (radius - disp_intersect) / bData->bNormal[index].normal_scale;
if (depth<0.0f) depth = 0.0f;
}
@@ -3786,7 +3803,7 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po
else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
/* get displace depth */
- float disp_intersect = (1.0f - sqrt((brush->paint_distance-distance) / brush->paint_distance)) * brush->paint_distance;
+ float disp_intersect = (1.0f - sqrtf((brush->paint_distance-distance) / brush->paint_distance)) * brush->paint_distance;
depth = (brush->paint_distance - disp_intersect) / bData->bNormal[index].normal_scale;
if (depth<0.0f) depth = 0.0f;
}
@@ -3846,7 +3863,7 @@ static void dynamicPaint_prepareNeighbourData(DynamicPaintSurface *surface, int
int numOfNeighs = adj_data->n_num[index];
for (i=0; i<numOfNeighs; i++) {
- bData->average_dist += bNeighs[adj_data->n_index[index]+i].dist;
+ bData->average_dist += (double)bNeighs[adj_data->n_index[index]+i].dist;
}
}
bData->average_dist /= adj_data->total_targets;
@@ -3905,18 +3922,18 @@ void surface_determineForceTargetPoints(PaintSurfaceData *sData, int index, floa
/* get drip factor based on force dir in relation to angle between those neighbours */
temp = dot_v3v3(bNeighs[closest_id[0]].dir, force_proj);
CLAMP(temp, -1.0f, 1.0f); /* float precision might cause values > 1.0f that return infinite */
- closest_d[1] = acos(temp)/neigh_diff;
+ closest_d[1] = acosf(temp)/neigh_diff;
closest_d[0] = 1.0f - closest_d[1];
/* and multiply depending on how deeply force intersects surface */
temp = fabs(force_intersect);
CLAMP(temp, 0.0f, 1.0f);
- closest_d[0] *= acos(temp)/1.57079633f;
- closest_d[1] *= acos(temp)/1.57079633f;
+ closest_d[0] *= acosf(temp)/1.57079633f;
+ closest_d[1] *= acosf(temp)/1.57079633f;
}
else {
/* if only single neighbour, still linearize force intersection effect */
- closest_d[0] = 1.0f - acos(closest_d[0])/1.57079633f;
+ closest_d[0] = 1.0f - acosf(closest_d[0])/1.57079633f;
}
}
@@ -4482,7 +4499,7 @@ static int dynamicPaint_surfaceHasMoved(DynamicPaintSurface *surface, Object *ob
return ret;
}
-static int surface_needsVelocityData(DynamicPaintSurface *surface, Scene *scene, Object *UNUSED(ob))
+static int surface_needsVelocityData(DynamicPaintSurface *surface, Scene *scene)
{
if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP)
return 1;
@@ -4509,7 +4526,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc
PaintBakeData *bData = sData->bData;
DerivedMesh *dm = surface->canvas->dm;
int index, new_bdata = 0;
- int do_velocity_data = surface_needsVelocityData(surface, scene, ob);
+ int do_velocity_data = surface_needsVelocityData(surface, scene);
int do_accel_data = surface_needsAccelerationData(surface);
int canvasNumOfVerts = dm->getNumVerts(dm);