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
path: root/source
diff options
context:
space:
mode:
authorMiika Hamalainen <blender@miikah.org>2011-06-17 22:04:56 +0400
committerMiika Hamalainen <blender@miikah.org>2011-06-17 22:04:56 +0400
commit71211818be68b3bf810270e0c9c716f3274e1cf0 (patch)
tree32cea6e3ce51c787980621633cf672a019cac4c4 /source
parent2987b68b0f3b3bac30653fb40c35b754a790c110 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c167
-rw-r--r--source/blender/editors/space_view3d/drawmesh.c16
-rw-r--r--source/blender/editors/space_view3d/drawobject.c23
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h4
-rw-r--r--source/blender/makesdna/DNA_dynamicpaint_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_dynamicpaint.c4
6 files changed, 121 insertions, 94 deletions
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 79a45568ee1..93a6cec2cc0 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -133,7 +133,6 @@ typedef struct Vec3f {
/* 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 @@ typedef struct PaintBakePoint {
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 @@ static void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas)
}
}
-/* 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 @@ static DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSett
sprintf(surface->image_output_path, "%sdynamicpaint/", "/tmp/");
dynamicPaintSurface_setUniqueName(surface, "Surface");
-
dynamicPaintSurface_updateType(surface);
BLI_addtail(&canvas->surfaces, surface);
@@ -609,6 +612,7 @@ int dynamicPaint_resetSurface(DynamicPaintSurface *surface)
/* 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 @@ void dynamicPaint_mixPaintColors(DynamicPaintSurface *surface, int index, int pa
/*
* 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 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *
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 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *
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 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *
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 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *
if (dot>=0)
{
/* Add factor on supersample filter */
- ssFactor += gaus_factor;
+ brushFactor += gaus_factor;
depth += hit.dist;
hit_found = 1;
@@ -2414,7 +2412,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *
} // 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,36 +2448,43 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *
/* 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;
-
- hit_found = 1;
+ else prox_influence = gaus_factor;
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 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *
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 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *
/* 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 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *
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 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *
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 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, PaintBakePoint *
/*
* 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;
ParticleSettings *part=psys->part;
@@ -2643,7 +2649,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, PaintBakePo
int n, particles = 0;
float range = psys->part->size + smooth;
- particles = BLI_kdtree_range_search(tree, range, bPoint[index].realCoord, NULL, &nearest);
+ particles = BLI_kdtree_range_search(tree, range, &bData->realCoord[(index*sData->samples)*3], NULL, &nearest);
for(n=0; n<particles; n++) {
/*
@@ -2689,7 +2695,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, PaintBakePo
radius = solidradius + smooth;
/* Find nearest particle and get distance to it */
- BLI_kdtree_find_nearest(tree, bPoint[index].realCoord, NULL, &nearest);
+ BLI_kdtree_find_nearest(tree, &bData->realCoord[(index*sData->samples)*3], NULL, &nearest);
if (nearest.dist > radius) continue;
/* distances inside solid radius have maximum influence -> dist = 0 */
@@ -2727,7 +2733,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, PaintBakePo
/* change falloff type to inverse square to match real displace depth */
disp_intersect = (1.0f - sqrt(disp_intersect / radius)) * radius;
/* get displace depth */
- sdepth = (radius - disp_intersect) / bPoint[index].normal_scale;
+ sdepth = (radius - disp_intersect) / bData->bPoint[index].normal_scale;
if (sdepth<0.0f) sdepth = 0.0f;
if (value[index] < sdepth) value[index] = sdepth;
@@ -2743,7 +2749,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, PaintBakePo
/* Prepare for surface step by creating PaintBakePoint data */
-static int dynamicPaint_prepareSurfaceStep(DynamicPaintSurface *surface, PaintBakePoint *bPoint, Object *ob, DerivedMesh *dm, float timescale) {
+static int dynamicPaint_prepareSurfaceStep(DynamicPaintSurface *surface, PaintBakeData *bData, Object *ob, DerivedMesh *dm, float timescale) {
PaintSurfaceData *sData = surface->data;
MVert *mvert = dm->getVertArray(dm);
@@ -2841,11 +2847,15 @@ static int dynamicPaint_prepareSurfaceStep(DynamicPaintSurface *surface, PaintBa
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
float n1[3], n2[3], n3[3];
PaintTexturePoint *tPoint = &((PaintTexturePoint*)sData->format_data)[index];
+ int ss;
- interp_v3_v3v3v3( bPoint[index].realCoord,
+ /* per sample coordinates */
+ for (ss=0; ss<sData->samples; ss++) {
+ interp_v3_v3v3v3( &bData->realCoord[(index*sData->samples+ss)*3],
canvasVerts[tPoint->v1].v,
canvasVerts[tPoint->v2].v,
- canvasVerts[tPoint->v3].v, tPoint->barycentricWeights[0].v);
+ canvasVerts[tPoint->v3].v, tPoint->barycentricWeights[ss].v);
+ }
/* Calculate current pixel surface normal */
if(mface[tPoint->face_index].flag & ME_SMOOTH) {
@@ -2853,29 +2863,29 @@ static int dynamicPaint_prepareSurfaceStep(DynamicPaintSurface *surface, PaintBa
normal_short_to_float_v3(n2, mvert[tPoint->v2].no);
normal_short_to_float_v3(n3, mvert[tPoint->v3].no);
- interp_v3_v3v3v3( bPoint[index].invNorm,
+ interp_v3_v3v3v3( bData->bPoint[index].invNorm,
n1, n2, n3, tPoint->barycentricWeights[0].v);
- mul_mat3_m4_v3(ob->obmat, bPoint[index].invNorm);
- normalize_v3(bPoint[index].invNorm);
- negate_v3(bPoint[index].invNorm);
+ mul_mat3_m4_v3(ob->obmat, bData->bPoint[index].invNorm);
+ normalize_v3(bData->bPoint[index].invNorm);
+ negate_v3(bData->bPoint[index].invNorm);
}
else {
- if (tPoint->quad) {VECCOPY(bPoint[index].invNorm, canvasInvNormals[tPoint->face_index].no_q);}
- else {VECCOPY(bPoint[index].invNorm, canvasInvNormals[tPoint->face_index].no);}
+ if (tPoint->quad) {VECCOPY(bData->bPoint[index].invNorm, canvasInvNormals[tPoint->face_index].no_q);}
+ else {VECCOPY(bData->bPoint[index].invNorm, canvasInvNormals[tPoint->face_index].no);}
}
}
else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
/* In case of verted data */
- /* location */
- VECCOPY(bPoint[index].realCoord, canvasVerts[index].v);
+ /* location, currently vertex format can have only one sample */
+ VECCOPY(&bData->realCoord[index*3], canvasVerts[index].v);
/* normal */
- normal_short_to_float_v3(bPoint[index].invNorm, mvert[index].no);
- mul_mat3_m4_v3(ob->obmat, bPoint[index].invNorm);
- normalize_v3(bPoint[index].invNorm);
+ normal_short_to_float_v3(bData->bPoint[index].invNorm, mvert[index].no);
+ mul_mat3_m4_v3(ob->obmat, bData->bPoint[index].invNorm);
+ normalize_v3(bData->bPoint[index].invNorm);
//mul_qt_v3(ob->quat, bPoint[index].invNorm);
- negate_v3(bPoint[index].invNorm);
+ negate_v3(bData->bPoint[index].invNorm);
}
/* Prepare special data for surface types */
@@ -2887,7 +2897,7 @@ static int dynamicPaint_prepareSurfaceStep(DynamicPaintSurface *surface, PaintBa
else {temp_nor[0]=0.0f;temp_nor[1]=0.0f;temp_nor[2]=1.0f;}
mul_v3_v3 (temp_nor, ob->size);
- bPoint[index].normal_scale = len_v3(temp_nor);
+ bData->bPoint[index].normal_scale = len_v3(temp_nor);
}
/*
@@ -2929,15 +2939,17 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
{
PaintSurfaceData *sData = surface->data;
DynamicPaintCanvasSettings *canvas = surface->canvas;
- PaintBakePoint *bPoint;
+ PaintBakeData bData;
if (!sData || sData->total_points < 1) return 0;
/* Init surface current frame position data */
- bPoint = (struct PaintBakePoint *) MEM_mallocN(sData->total_points*sizeof(struct PaintBakePoint), "Dynamic Paint step data");
- if (bPoint == NULL) return printError(canvas, "Not enough free memory.");
+ bData.bPoint = (struct PaintBakePoint *) MEM_mallocN(sData->total_points*sizeof(struct PaintBakePoint), "Dynamic Paint step data");
+ if (bData.bPoint == NULL) return printError(canvas, "Not enough free memory.");
+ bData.realCoord = (float *) MEM_mallocN(sData->total_points*3*sData->samples*sizeof(float), "Dynamic Paint step coords");
+ if (bData.realCoord == NULL) return printError(canvas, "Not enough free memory.");
- if (!dynamicPaint_prepareSurfaceStep(surface, bPoint, ob, canvas->dm, timescale))
+ if (!dynamicPaint_prepareSurfaceStep(surface, &bData, ob, canvas->dm, timescale))
return printError(canvas, "Not enough free memory.");
/*
@@ -3013,14 +3025,14 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
/*
* Paint a particle system
*/
- dynamicPaint_paintParticles(surface, bPoint, brush->psys, brush, ob, timescale);
+ dynamicPaint_paintParticles(surface, &bData, brush->psys, brush, ob, timescale);
}
}
else {
/*
* Paint a object mesh
*/
- dynamicPaint_paintMesh(surface, bPoint, brush, ob, brushObj, timescale);
+ dynamicPaint_paintMesh(surface, &bData, brush, ob, brushObj, timescale);
}
/* return object to it's original state */
@@ -3034,7 +3046,8 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
}
}
- MEM_freeN(bPoint);
+ MEM_freeN(bData.bPoint);
+ MEM_freeN(bData.realCoord);
return 1;
}
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index f070bae4e54..7e9a3411171 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -437,6 +437,11 @@ static int draw_tface__set_draw_legacy(MTFace *tface, MCol *mcol, int matnr)
return 1; /* Set color from mcol */
}
}
+static int draw_mcol__set_draw_legacy(MTFace *tface, MCol *mcol, int matnr)
+{
+ if (mcol) return 1;
+ else return 2;
+}
static int draw_tface__set_draw(MTFace *tface, MCol *mcol, int matnr)
{
if (tface && (tface->mode&TF_INVISIBLE)) return 0;
@@ -653,7 +658,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
ddm->release(ddm);
}
-void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int faceselect)
+void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags)
{
Mesh *me= ob->data;
@@ -668,7 +673,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o
if(ob->mode & OB_MODE_EDIT) {
dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, me->edit_mesh);
- } else if(faceselect) {
+ } else if(draw_flags & DRAW_IS_PAINT_SEL) {
if(ob->mode & OB_MODE_WEIGHT_PAINT)
dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1, GPU_enable_material);
else
@@ -676,7 +681,10 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o
}
else {
if( GPU_buffer_legacy(dm) )
- dm->drawFacesTex(dm, draw_tface__set_draw_legacy);
+ if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)
+ dm->drawFacesTex(dm, draw_mcol__set_draw_legacy);
+ else
+ dm->drawFacesTex(dm, draw_tface__set_draw_legacy);
else {
if( !CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL) )
add_tface_color_layer(dm);
@@ -691,7 +699,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o
draw_textured_end();
/* draw edges and selected faces over textured mesh */
- if(!(ob == scene->obedit) && faceselect)
+ if(!(ob == scene->obedit) && (draw_flags & DRAW_IS_PAINT_SEL))
draw_tfaces3D(rv3d, me, dm, ob->mode & OB_MODE_WEIGHT_PAINT);
/* reset from negative scale correction */
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 2ea77aa6c05..b99f4f81f21 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -2576,26 +2576,23 @@ static int wpaint__setSolidDrawOptions(void *UNUSED(userData), int UNUSED(index)
return 1;
}
-#define DRAW_MODE_DYNAMIC_PAINT_PREVIEW 1
-
static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag)
{
Object *ob= base->object;
Mesh *me = ob->data;
Material *ma= give_current_material(ob, 1);
const short hasHaloMat = (ma && (ma->material_type == MA_TYPE_HALO));
- const short is_paint_sel= (ob==OBACT && paint_facesel_test(ob));
int draw_wire = 0;
int /* totvert,*/ totedge, totface;
DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask);
ModifierData *md = NULL;
- int draw_mode = 0;
+ int draw_flags = (ob==OBACT && paint_facesel_test(ob)) ? DRAW_IS_PAINT_SEL : 0;
if(!dm)
return;
/* check to draw dynamic paint colors */
- if (md = modifiers_findByType(ob, eModifierType_DynamicPaint))
+ if ((md = modifiers_findByType(ob, eModifierType_DynamicPaint)))
{
/* check if target has an active dp modifier */
if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
@@ -2605,7 +2602,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
if (pmd->type & MOD_DYNAMICPAINT_TYPE_CANVAS && pmd->canvas &&
pmd->canvas->flags & MOD_DPAINT_PREVIEW_READY &&
DM_get_face_data_layer(dm, CD_WEIGHT_MCOL)) {
- draw_mode |= DRAW_MODE_DYNAMIC_PAINT_PREVIEW;
+ draw_flags |= DRAW_DYNAMIC_PAINT_PREVIEW;
}
}
}
@@ -2623,7 +2620,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
// Unwanted combination.
- if (is_paint_sel) draw_wire = 0;
+ if (draw_flags & DRAW_IS_PAINT_SEL) draw_wire = 0;
if(dt==OB_BOUNDBOX) {
if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
@@ -2637,14 +2634,14 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
else if(dt==OB_WIRE || totface==0) {
draw_wire = 1; /* draw wire only, no depth buffer stuff */
}
- else if( (is_paint_sel || (ob==OBACT && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
+ else if( (draw_flags & DRAW_IS_PAINT_SEL || (ob==OBACT && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
CHECK_OB_DRAWTEXTURE(v3d, dt))
{
- if ((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !(G.f&G_PICKSEL || is_paint_sel) && !draw_wire) {
+ if ((v3d->flag&V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) && (base->flag&SELECT) && !(G.f&G_PICKSEL || (draw_flags & DRAW_IS_PAINT_SEL)) && !draw_wire) {
draw_mesh_object_outline(v3d, ob, dm);
}
- if(draw_glsl_material(scene, ob, v3d, dt)) {
+ if(draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)) {
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
dm->drawFacesGLSL(dm, GPU_enable_material);
@@ -2655,10 +2652,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
glFrontFace(GL_CCW);
}
else {
- draw_mesh_textured(scene, v3d, rv3d, ob, dm, is_paint_sel);
+ draw_mesh_textured(scene, v3d, rv3d, ob, dm, draw_flags);
}
- if(!is_paint_sel) {
+ if(!(draw_flags & DRAW_IS_PAINT_SEL)) {
if(base->flag & SELECT)
UI_ThemeColor((ob==OBACT)?TH_ACTIVE:TH_SELECT);
else
@@ -2694,7 +2691,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
/* since we already draw wire as wp guide, dont draw over the top */
draw_wire= 0;
}
- else if (draw_mode & DRAW_MODE_DYNAMIC_PAINT_PREVIEW) {
+ else if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW) {
/* for object selection draws no shade */
if (flag & (DRAW_PICKING|DRAW_CONSTCOLOR)) {
dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index cd6bff1ebba..6e0e1f337dd 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -59,6 +59,10 @@ struct bMotionPath;
#define DRAW_CONSTCOLOR 2
#define DRAW_SCENESET 4
+/* draw_mesh_fancy draw_flags */
+#define DRAW_DYNAMIC_PAINT_PREVIEW 1
+#define DRAW_IS_PAINT_SEL 2
+
/* view3d_header.c */
void view3d_header_buttons(const struct bContext *C, struct ARegion *ar);
void VIEW3D_OT_layers(struct wmOperatorType *ot);
diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h
index 327153e1640..faead0a264f 100644
--- a/source/blender/makesdna/DNA_dynamicpaint_types.h
+++ b/source/blender/makesdna/DNA_dynamicpaint_types.h
@@ -118,6 +118,7 @@ typedef struct DynamicPaintCanvasSettings {
#define MOD_DPAINT_RAMP_ALPHA (1<<4) /* only read falloff ramp alpha */
#define MOD_DPAINT_PROX_FACEALIGNED (1<<5) /* do proximity check only in normal dir */
+#define MOD_DPAINT_INVERSE_PROX (1<<6) /* inverse proximity painting */
//#define MOD_DPAINT_EDGE_DISP (1<<6) /* add displacement to intersection edges */
/* collision type */
diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c
index 7dccce8571e..45f9a11f8c2 100644
--- a/source/blender/makesrna/intern/rna_dynamicpaint.c
+++ b/source/blender/makesrna/intern/rna_dynamicpaint.c
@@ -627,6 +627,10 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna)
prop= RNA_def_property(srna, "prox_facealigned", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_PROX_FACEALIGNED);
RNA_def_property_ui_text(prop, "Face Aligned", "Check proximity in face normal direction only.");
+
+ prop= RNA_def_property(srna, "prox_inverse", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_INVERSE_PROX);
+ RNA_def_property_ui_text(prop, "Inverse", "Invert proximity to reduce volume effect.");
/*