[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38284] branches/soc-2011-salad: Merged latest commits from soc-2011-carrot into soc-2011-salad.

Miika Hamalainen miika.hamalainen at kolumbus.fi
Sun Jul 10 18:24:03 CEST 2011


Revision: 38284
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38284
Author:   miikah
Date:     2011-07-10 16:24:03 +0000 (Sun, 10 Jul 2011)
Log Message:
-----------
Merged latest commits from soc-2011-carrot into soc-2011-salad.

Modified Paths:
--------------
    branches/soc-2011-salad/source/blender/blenkernel/intern/dynamicpaint.c
    branches/soc-2011-salad/source/blender/editors/interface/interface_templates.c
    branches/soc-2011-salad/source/blender/makesrna/intern/rna_dynamicpaint.c

Property Changed:
----------------
    branches/soc-2011-salad/


Property changes on: branches/soc-2011-salad
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30783,30792-30793,30797-30798,30815
/branches/soc-2011-carrot:36854,37548,37564,37602,37622,37848,38043,38064,38226,38231
/branches/soc-2011-cucumber:36829-36994
/branches/soc-2011-onion:36833-37529
/branches/soc-2011-pepper:36830-38208
/branches/soc-2011-tomato:36831-38239
/trunk/blender:36834-38238
   + /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30783,30792-30793,30797-30798,30815
/branches/soc-2011-carrot:36854,37548,37564,37602,37622,37848,38043,38064,38226,38231,38282
/branches/soc-2011-cucumber:36829-36994
/branches/soc-2011-onion:36833-37529
/branches/soc-2011-pepper:36830-38208
/branches/soc-2011-tomato:36831-38239
/trunk/blender:36834-38238

Modified: branches/soc-2011-salad/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- branches/soc-2011-salad/source/blender/blenkernel/intern/dynamicpaint.c	2011-07-10 16:18:48 UTC (rev 38283)
+++ branches/soc-2011-salad/source/blender/blenkernel/intern/dynamicpaint.c	2011-07-10 16:24:03 UTC (rev 38284)
@@ -2603,13 +2603,15 @@
 */
 static void dynamicPaint_updatePointData(DynamicPaintSurface *surface, unsigned int index, DynamicPaintBrushSettings *brush, float paint[4], float strength, float depth, float timescale)
 {
-		PaintSurfaceData *sData = surface->data;	
+		PaintSurfaceData *sData = surface->data;
 
+		strength *= brush->alpha;
+
 		/* mix paint surface */
 		if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
 
 			float paintWetness = brush->wetness * strength;
-			float paintAlpha = paint[3] * strength;
+			float paintAlpha = strength;
 			if (paintAlpha > 1.0f) paintAlpha = 1.0f;
 
 			dynamicPaint_mixPaintColors(surface, index, brush->flags, paint, &paintAlpha, &paintWetness, &timescale);
@@ -2649,6 +2651,9 @@
 #define VECADDVAL(v,val) 	{*(v)+=(val); *(v+1)+=(val); *(v+2)+=(val);}
 #define VECMULVAL(v,val) 	{*(v)*=(val); *(v+1)*=(val); *(v+2)*=(val);}
 
+#define HIT_VOLUME 1
+#define HIT_PROXIMITY 2
+
 /*
 *	Paint a brush object mesh to the surface
 */
@@ -2692,10 +2697,10 @@
 				{
 					int ss, samples = bData->s_num[index];
 					float total_sample = (float)samples;
-					float brushFactor = 0.0f;	/* brush influence factor */
+					float brushStrength = 0.0f;	/* brush influence factor */
 					float depth = 0.0f;		/* displace depth */
 
-					float paintColor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+					float paintColor[3] = {0.0f};
 					int numOfHits = 0;
 
 					/* for image sequence anti-aliasing, use gaussian factors */
@@ -2707,14 +2712,13 @@
 					{
 
 						float ray_start[3], ray_dir[3] = {0.0f};
+						float colorband[4] = {0.0f};
 						float sample_factor;
+						float sampleStrength = 0.0f;
 						BVHTreeRayHit hit;
 						BVHTreeNearest nearest;
 						short hit_found = 0;
 
-						/* If it's a proximity hit, store distance rate */
-						float distRate = -1.0f;
-
 						/* hit data	*/
 						float hitCoord[3];		/* mid-sample hit coordinate */
 						int hitFace = -1;		/* mid-sample hit face */
@@ -2780,8 +2784,8 @@
 
 								if(hit.index != -1) {
 									/* Add factor on supersample filter	*/
-									brushFactor += sample_factor;
-									hit_found = 1;
+									sampleStrength += sample_factor;
+									hit_found = HIT_VOLUME;
 
 									/*
 									*	Mark hit info
@@ -2795,13 +2799,17 @@
 						}	// end of raycast
 					
 						/* Check proximity collision	*/
-						if ((brush->collision == MOD_DPAINT_COL_DIST || brush->collision == MOD_DPAINT_COL_VOLDIST))
+						if ((brush->collision == MOD_DPAINT_COL_DIST || brush->collision == MOD_DPAINT_COL_VOLDIST) &&
+							(!hit_found || (brush->flags & MOD_DPAINT_INVERSE_PROX)))
 						{
 							float proxDist = -1.0f;
 							float hitCo[3];
 							short hQuad;
 							int face;
 
+							/* if inverse prox and no hit found, skip this sample */
+							if (brush->flags & MOD_DPAINT_INVERSE_PROX && !hit_found) continue;
+
 							/*
 							*	If pure distance proximity, find the nearest point on the mesh
 							*/
@@ -2829,38 +2837,29 @@
 							}
 
 							/* If a hit was found, calculate required values	*/
-							if (proxDist >= 0.0f) {
+							if (proxDist >= 0.0f && proxDist <= brush->paint_distance) {
 								float dist_rate = proxDist / brush->paint_distance;
 								float prox_influence = 0.0f;
 
-								/* Smooth range or color ramp	*/
-								if (brush->proximity_falloff == MOD_DPAINT_PRFALL_SMOOTH ||
-									brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP) {
-
-									/* Limit distance to 0.0 - 1.0 */
-									if (dist_rate > 1.0f) dist_rate = 1.0f;
-									if (dist_rate < 0.0f) dist_rate = 0.0f;
-
-									/* if using smooth falloff, multiply gaussian factor */
-									if (brush->proximity_falloff == MOD_DPAINT_PRFALL_SMOOTH) {
-										prox_influence = (1.0f - dist_rate) * sample_factor;
-									}
-									else prox_influence = sample_factor;
-
-									if (hitFace == -1) {
-										distRate = dist_rate;
-									}
+								/* in case of inverse prox also undo volume effect */
+								if (brush->flags & MOD_DPAINT_INVERSE_PROX) {
+									sampleStrength -= sample_factor;
+									dist_rate = 1.0f - dist_rate;
 								}
-								else prox_influence = sample_factor;
 
-								hit_found = 1;
-								if (brush->flags & MOD_DPAINT_INVERSE_PROX) {
-									brushFactor -= prox_influence;
-									distRate = -distRate;
+								/* if using color ramp*/
+								if (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP && do_colorband(brush->paint_ramp, dist_rate, colorband))
+									prox_influence = colorband[3];
+								/* if using smooth falloff, multiply gaussian factor */
+								else if (brush->proximity_falloff == MOD_DPAINT_PRFALL_SMOOTH) {
+									prox_influence = (1.0f - dist_rate) * sample_factor;
 								}
-								else 
-									brushFactor += prox_influence;
+								else prox_influence = (brush->flags & MOD_DPAINT_INVERSE_PROX) ? 0.0f : 1.0f;
 
+								hit_found = HIT_PROXIMITY;
+								sampleStrength += prox_influence*sample_factor;
+
+								/* if no volume hit, use prox point face info */
 								if (hitFace == -1) {
 									copy_v3_v3(hitCoord, hitCo);
 									hitQuad = hQuad;
@@ -2869,52 +2868,53 @@
 							}
 						}
 
+						if (!hit_found) continue;
+
 						/*
 						*	Process hit color and alpha
 						*/
-						if (hit_found && surface->type == MOD_DPAINT_SURFACE_T_PAINT)
+						if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
 						{
 							float sampleColor[3];
-							float sampleAlpha = 1.0f;
-							float bandres[4];
+							float alpha_factor = 1.0f;
 
 							sampleColor[0] = brush->r;
 							sampleColor[1] = brush->g;
 							sampleColor[2] = brush->b;
 						
 							/* Get material+textures color on hit point if required	*/
-							if (brush->flags & MOD_DPAINT_USE_MATERIAL) dynamicPaint_getMaterialColor(sampleColor, &sampleAlpha, brushOb, &bData->realCoord[(bData->s_index[index]+ss)*3], hitCoord, hitFace, hitQuad, brush->dm, brush->mat);
+							if (brush->flags & MOD_DPAINT_USE_MATERIAL) dynamicPaint_getMaterialColor(sampleColor, &alpha_factor, brushOb, &bData->realCoord[(bData->s_index[index]+ss)*3], hitCoord, hitFace, hitQuad, brush->dm, brush->mat);
 
 							/* Sample colorband if required	*/
-							if ((distRate >= 0.0f) && (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP) && do_colorband(brush->paint_ramp, distRate, bandres)) {
+							if ((hit_found == HIT_PROXIMITY) && (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP)) {
 								if (!(brush->flags & MOD_DPAINT_RAMP_ALPHA)) {
-									sampleColor[0] = bandres[0];
-									sampleColor[1] = bandres[1];
-									sampleColor[2] = bandres[2];
+									sampleColor[0] = colorband[0];
+									sampleColor[1] = colorband[1];
+									sampleColor[2] = colorband[2];
 								}
-								sampleAlpha *= bandres[3];
 							}
 
 							/* Add AA sample */
 							paintColor[0] += sampleColor[0];
 							paintColor[1] += sampleColor[1];
 							paintColor[2] += sampleColor[2];
-
-							paintColor[3] += sampleAlpha;
+							sampleStrength *= alpha_factor;
 							numOfHits++;
 						}
+
+						/* apply sample strength */
+						brushStrength += sampleStrength;
 					} // end supersampling
 
 
 					/* if any sample was inside paint range	*/
-					if (brushFactor > 0.01f) {
+					if (brushStrength > 0.01f) {
 
 						/* apply supersampling results	*/
 						if (samples > 1) {
-							brushFactor /= total_sample;
+							brushStrength /= total_sample;
 						}
-						CLAMP(brushFactor, 0.0f, 1.0f);
-						brushFactor *= brush->alpha;
+						CLAMP(brushStrength, 0.0f, 1.0f);
 
 						if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
 							/* Get final pixel color and alpha	*/
@@ -2929,7 +2929,7 @@
 							depth /= bData->bPoint[index].normal_scale * total_sample;
 						}
 						
-						dynamicPaint_updatePointData(surface, index, brush, paintColor, brushFactor, depth, timescale);
+						dynamicPaint_updatePointData(surface, index, brush, paintColor, brushStrength, depth, timescale);
 					}
 				}
 			}
@@ -3081,7 +3081,6 @@
 				paintColor[0] = brush->r;
 				paintColor[1] = brush->g;
 				paintColor[2] = brush->b;
-				paintColor[3] = brush->alpha;
 			}
 			else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
 					 surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
@@ -3111,30 +3110,40 @@
 	for (index = 0; index < sData->total_points; index++)
 	{
 		float distance = len_v3v3(pointCoord, &bData->realCoord[(bData->s_index[index])*3]);
+		float colorband[4] = {0.0f};
 		float strength;
 
+		if (distance>brush->paint_distance) continue;
+
 		/* Smooth range or color ramp	*/
 		if (brush->proximity_falloff == MOD_DPAINT_PRFALL_SMOOTH ||
 			brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP) {
-
-			if (brush->proximity_falloff == MOD_DPAINT_PRFALL_SMOOTH) {
-				strength = distance / brush->paint_distance;
-				CLAMP(strength, 0.0f, 1.0f);
-				strength = 1.0f - strength;
-			}
-			else strength = 1.0f;
+			
+			strength = 1.0f - distance / brush->paint_distance;
+			CLAMP(strength, 0.0f, 1.0f);
 		}
 		else strength = 1.0f;
 
 		if (strength >= 0.001f) {
-			float paintColor[4] = {0.0f};
+			float paintColor[3] = {0.0f};
 			float depth = 0.0f;
 
+			/* color ramp */

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list