[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37602] branches/soc-2011-carrot: Dynamic Paint:
Miika Hamalainen
miika.hamalainen at kolumbus.fi
Fri Jun 17 20:04:56 CEST 2011
Revision: 37602
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37602
Author: miikah
Date: 2011-06-17 18:04:56 +0000 (Fri, 17 Jun 2011)
Log Message:
-----------
Dynamic Paint:
* Image sequence anti-aliasing works again.
* Vertex color viewport preview now works with GLSL and textured view modes too.
* Added a new "inverse" setting for "volume + proximity" brush. With it brush only has effect within volume but effect is lower near the mesh surface.
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
branches/soc-2011-carrot/source/blender/editors/space_view3d/drawmesh.c
branches/soc-2011-carrot/source/blender/editors/space_view3d/drawobject.c
branches/soc-2011-carrot/source/blender/editors/space_view3d/view3d_intern.h
branches/soc-2011-carrot/source/blender/makesdna/DNA_dynamicpaint_types.h
branches/soc-2011-carrot/source/blender/makesrna/intern/rna_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-06-17 18:04:26 UTC (rev 37601)
+++ branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py 2011-06-17 18:04:56 UTC (rev 37602)
@@ -310,12 +310,15 @@
col.prop(brush, "paint_distance", text="Paint Distance")
split = layout.row().split()
sub = split.column()
- sub.prop(brush, "prox_facealigned", text="Face Aligned")
+ sub.prop(brush, "prox_facealigned")
sub = split.column()
sub.prop(brush, "prox_falloff", text="Falloff")
+ if brush.paint_source == "VOLDIST":
+ col = layout.row().column()
+ col.prop(brush, "prox_inverse")
if brush.prox_falloff == "RAMP":
col = layout.row().column()
- col.label(text="Falloff Ramp:")
+ col.separator()
col.prop(brush, "prox_ramp_alpha", text="Only Use Alpha")
col.template_color_ramp(brush, "paint_ramp", expand=True)
Modified: branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c 2011-06-17 18:04:26 UTC (rev 37601)
+++ branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c 2011-06-17 18:04:56 UTC (rev 37602)
@@ -133,7 +133,6 @@
/* Surface data used while processing a frame */
typedef struct PaintBakePoint {
- float realCoord[3]; /* current pixel center world-space coordinates */
float invNorm[3]; /* current pixel world-space inverted normal. depends on face shading mode */
float normal_scale; /* normal directional scale for displace mapping */
@@ -144,6 +143,11 @@
float gravity_rate; /* Gravity strength. (Depends on surface angle.) */
} PaintBakePoint;
+typedef struct PaintBakeData {
+ PaintBakePoint *bPoint;
+ float *realCoord; /* current pixel center world-space coordinates * numOfSamples */
+} PaintBakeData;
+
/* UV Image sequence format point */
typedef struct PaintTexturePoint {
@@ -234,7 +238,7 @@
}
}
-/* set preview to first previewable surface */
+/* set preview to defined surface */
static void dynamicPaint_setPreview(DynamicPaintSurface *t_surface)
{
DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
@@ -417,7 +421,6 @@
sprintf(surface->image_output_path, "%sdynamicpaint/", "/tmp/");
dynamicPaintSurface_setUniqueName(surface, "Surface");
-
dynamicPaintSurface_updateType(surface);
BLI_addtail(&canvas->surfaces, surface);
@@ -609,6 +612,7 @@
/* allocate data depending on surface type and format */
surface->data->total_points = numOfPoints;
+ surface->data->samples = 1;
dynamicPaint_allocateSurfaceType(surface);
dynamicPaint_surfaceSetInitialValues(surface);
@@ -2284,7 +2288,7 @@
/*
* Paint a brush object mesh to the surface
*/
-static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *bPoint, DynamicPaintBrushSettings *brush, Object *canvasOb, Object *brushOb, float timescale)
+static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakeData *bData, DynamicPaintBrushSettings *brush, Object *canvasOb, Object *brushOb, float timescale)
{
DerivedMesh *dm = NULL;
MVert *mvert = NULL;
@@ -2325,10 +2329,8 @@
for (index = 0; index < sData->total_points; index++)
{
{
- //DynamicPaintSurfacePoint *cPoint = (&surface->point[xx+tWidth*yy]);
-
int ss;
- float ssFactor = 0.0f; /* super-sampling factor */
+ float brushFactor = 0.0f; /* brush influence factor */
float depth = 0.0f; /* displace depth */
float paintColor[3] = {0.0f, 0.0f, 0.0f};
@@ -2336,7 +2338,7 @@
float paintAlpha = 0.0f;
/* Supersampling */
- for (ss=0; ss<1; ss++)
+ for (ss=0; ss<sData->samples; ss++)
{
float ray_start[3], ray_dir[3];
@@ -2354,20 +2356,16 @@
short hitQuad; /* mid-sample hit quad status */
/* Supersampling factor */
- /*if (surface->pixelSamples > 1) {
+ if (sData->samples > 1) {
gaus_factor = gaussianFactors[ss];
}
- else */{
+ else {
gaus_factor = 1.0f;
}
/* Get current sample position in world coordinates */
- /*interp_v3_v3v3v3(realPos,
- canvasVerts[cPoint->v1].v,
- canvasVerts[cPoint->v2].v,
- canvasVerts[cPoint->v3].v, cPoint->barycentricWeights[ss].v);*/
- VECCOPY(ray_start, bPoint[index].realCoord);
- VECCOPY(ray_dir, bPoint[index].invNorm);
+ VECCOPY(ray_start, &bData->realCoord[(index*sData->samples+ss)*3]);
+ VECCOPY(ray_dir, bData->bPoint[index].invNorm);
hit.index = -1;
hit.dist = 9999;
@@ -2398,7 +2396,7 @@
if (dot>=0)
{
/* Add factor on supersample filter */
- ssFactor += gaus_factor;
+ brushFactor += gaus_factor;
depth += hit.dist;
hit_found = 1;
@@ -2414,7 +2412,7 @@
} // end of raycast
/* Check proximity collision */
- if ((brush->collision == MOD_DPAINT_COL_DIST || brush->collision == MOD_DPAINT_COL_VOLDIST) && (!hit_found))
+ if ((brush->collision == MOD_DPAINT_COL_DIST || brush->collision == MOD_DPAINT_COL_VOLDIST))
{
float proxDist = -1.0f;
float hitCo[3];
@@ -2450,37 +2448,44 @@
/* If a hit was found, calculate required values */
if (proxDist >= 0.0f) {
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) {
+ /* 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;
+ /* 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) {
- ssFactor += (1.0f - dist_rate) * gaus_factor;
- }
- else ssFactor += gaus_factor;
-
- if (hitFace == -1) {
- distRate = dist_rate;
- }
+ /* if using smooth falloff, multiply gaussian factor */
+ if (brush->proximity_falloff == MOD_DPAINT_PRFALL_SMOOTH) {
+ prox_influence = (1.0f - dist_rate) * gaus_factor;
}
- else ssFactor += gaus_factor;
+ else prox_influence = gaus_factor;
- hit_found = 1;
-
if (hitFace == -1) {
- copy_v3_v3(hitCoord, hitCo);
- hitQuad = hQuad;
- hitFace = face;
+ distRate = dist_rate;
}
- } // proxDist
- } // end proximity check
+ }
+ else prox_influence = gaus_factor;
+ hit_found = 1;
+ if (brush->flags & MOD_DPAINT_INVERSE_PROX) {
+ brushFactor -= prox_influence;
+ distRate = -distRate;
+ }
+ else
+ brushFactor += prox_influence;
+
+ if (hitFace == -1) {
+ copy_v3_v3(hitCoord, hitCo);
+ hitQuad = hQuad;
+ hitFace = face;
+ }
+ }
+ }
+
/*
* Process color and alpha
*/
@@ -2495,7 +2500,7 @@
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, bPoint[index].realCoord, hitCoord, hitFace, hitQuad, brush->dm, brush->mat);
+ if (brush->flags & MOD_DPAINT_USE_MATERIAL) dynamicPaint_getMaterialColor(sampleColor, &sampleAlpha, brushOb, &bData->realCoord[(index*sData->samples+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)) {
@@ -2519,18 +2524,19 @@
/* if any sample was inside paint range */
- if (ssFactor > 0.01f) {
+ if (brushFactor > 0.01f) {
/* apply supersampling results */
- /*if (surface->pixelSamples > 1) {
- ssFactor /= gaussianTotal;
- }*/
+ if (sData->samples > 1) {
+ brushFactor /= gaussianTotal;
+ }
+ CLAMP(brushFactor, 0.0f, 1.0f);
//cPoint->state = 2;
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
- float paintWetness = brush->wetness * ssFactor;
+ float paintWetness = brush->wetness * brushFactor;
/* Get final pixel color and alpha */
paintColor[0] /= numOfHits;
@@ -2539,7 +2545,7 @@
paintAlpha /= numOfHits;
/* Multiply alpha value by the ui multiplier */
- paintAlpha = paintAlpha * ssFactor * brush->alpha;
+ paintAlpha = paintAlpha * brushFactor * brush->alpha;
if (paintAlpha > 1.0f) paintAlpha = 1.0f;
/*
@@ -2551,11 +2557,11 @@
float *value = (float*)sData->type_data;
if (brush->flags & MOD_DPAINT_ERASE) {
- value[index] *= (1.0f - ssFactor);
+ value[index] *= (1.0f - brushFactor);
if (value[index] < 0.0f) value[index] = 0.0f;
}
else {
- depth /= bPoint[index].normal_scale;
+ depth /= bData->bPoint[index].normal_scale;
/* do displace */
if (value[index] < depth) value[index] = depth;
}
@@ -2576,7 +2582,7 @@
/*
* Paint a particle system to the surface
*/
-static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, PaintBakePoint *bPoint, ParticleSystem *psys, DynamicPaintBrushSettings *brush, Object *canvasOb, float timescale)
+static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, PaintBakeData *bData, ParticleSystem *psys, DynamicPaintBrushSettings *brush, Object *canvasOb, float timescale)
{
int index;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list