bugfix [#23595] Texture paint with a node based brush produces artifacts
authorCampbell Barton <ideasman42@gmail.com>
Thu, 23 Sep 2010 12:03:34 +0000 (12:03 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 23 Sep 2010 12:03:34 +0000 (12:03 +0000)
also changed displace modifier not to link object depgraph when not using object texturespace.

12 files changed:
source/blender/blenkernel/BKE_brush.h
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/particle.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/modifiers/intern/MOD_displace.c
source/blender/modifiers/intern/MOD_solidify.c
source/blender/render/extern/include/RE_render_ext.h
source/blender/render/intern/source/renderdatabase.c
source/blender/render/intern/source/texture.c

index 0e406a1..25d0eb5 100644 (file)
@@ -62,7 +62,7 @@ float brush_curve_strength_clamp(struct Brush *br, float p, const float len);
 float brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */
 
 /* sampling */
-void brush_sample_tex(struct Brush *brush, float *xy, float *rgba);
+void brush_sample_tex(struct Brush *brush, float *xy, float *rgba, const int thread);
 void brush_imbuf_new(struct Brush *brush, short flt, short texfalloff, int size,
        struct ImBuf **imbuf);
 
index 90ea562..c67db93 100644 (file)
@@ -480,7 +480,7 @@ int brush_clone_image_delete(Brush *brush)
 }
 
 /* Brush Sampling */
-void brush_sample_tex(Brush *brush, float *xy, float *rgba)
+void brush_sample_tex(Brush *brush, float *xy, float *rgba, const int thread)
 {
        MTex *mtex= &brush->mtex;
 
@@ -493,7 +493,7 @@ void brush_sample_tex(Brush *brush, float *xy, float *rgba)
                co[1]= xy[1]/radius;
                co[2]= 0.0f;
 
-               hasrgb= externtex(mtex, co, &tin, &tr, &tg, &tb, &ta);
+               hasrgb= externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, thread);
 
                if (hasrgb) {
                        rgba[0]= tr;
@@ -547,12 +547,12 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
                                        dstf[3]= alpha*brush_curve_strength_clamp(brush, dist, radius);
                                }
                                else if (texfall == 1) {
-                                       brush_sample_tex(brush, xy, dstf);
+                                       brush_sample_tex(brush, xy, dstf, 0);
                                }
                                else {
                                        dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]);
 
-                                       brush_sample_tex(brush, xy, rgba);
+                                       brush_sample_tex(brush, xy, rgba, 0);
 
                                        dstf[0] = rgba[0]*brush->rgb[0];
                                        dstf[1] = rgba[1]*brush->rgb[1];
@@ -583,7 +583,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
                                        dst[3]= FTOCHAR(alpha*brush_curve_strength(brush, dist, radius));
                                }
                                else if (texfall == 1) {
-                                       brush_sample_tex(brush, xy, rgba);
+                                       brush_sample_tex(brush, xy, rgba, 0);
                                        dst[0]= FTOCHAR(rgba[0]);
                                        dst[1]= FTOCHAR(rgba[1]);
                                        dst[2]= FTOCHAR(rgba[2]);
@@ -592,7 +592,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
                                else {
                                        dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]);
 
-                                       brush_sample_tex(brush, xy, rgba);
+                                       brush_sample_tex(brush, xy, rgba, 0);
                                        dst[0] = FTOCHAR(rgba[0]*brush->rgb[0]);
                                        dst[1] = FTOCHAR(rgba[1]*brush->rgb[1]);
                                        dst[2] = FTOCHAR(rgba[2]*brush->rgb[2]);
@@ -739,7 +739,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
                                        xy[0] = x + xoff;
                                        xy[1] = y + yoff;
 
-                                       brush_sample_tex(brush, xy, tf);
+                                       brush_sample_tex(brush, xy, tf, 0);
                                }
 
                                bf[0] = tf[0]*mf[0];
@@ -770,7 +770,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
                                        xy[0] = x + xoff;
                                        xy[1] = y + yoff;
 
-                                       brush_sample_tex(brush, xy, rgba);
+                                       brush_sample_tex(brush, xy, rgba, 0);
                                        t[0]= FTOCHAR(rgba[0]);
                                        t[1]= FTOCHAR(rgba[1]);
                                        t[2]= FTOCHAR(rgba[2]);
index 07b712c..6b75f5d 100644 (file)
@@ -3686,7 +3686,7 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float
                        else
                                VECCOPY(texco,orco);
 
-                       externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3);
+                       externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3, 0);
                        if((event & mtex->pmapto) & MAP_PA_TIME){
                                if((setvars&MAP_PA_TIME)==0){
                                        ptex->time=0.0;
@@ -3740,7 +3740,7 @@ void psys_get_texture(ParticleSimulationData *sim, Material *ma, ParticleData *p
                                psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,0,0,0,texco, 0);
                        }
 
-                       externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3);
+                       externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3, 0);
 
                        if((event & mtex->pmapto) & MAP_PA_TIME){
                                /* the first time has to set the base value for time regardless of blend mode */
index bc1cdea..7316e24 100644 (file)
@@ -4450,7 +4450,7 @@ void vertexnoise(Object *obedit, EditMesh *em)
                        }
                        else {
                                float tin, dum;
-                               externtex(ma->mtex[0], eve->co, &tin, &dum, &dum, &dum, &dum);
+                               externtex(ma->mtex[0], eve->co, &tin, &dum, &dum, &dum, &dum, 0);
                                eve->co[2]+= 0.05*tin;
                        }
                }
index e7a06f2..6e921b5 100644 (file)
@@ -3757,7 +3757,7 @@ static void *do_projectpaint_thread(void *ph_v)
 
                                        if (falloff > 0.0f) {
                                                if (ps->is_texbrush) {
-                                                       brush_sample_tex(ps->brush, projPixel->projCoSS, rgba);
+                                                       brush_sample_tex(ps->brush, projPixel->projCoSS, rgba, thread_index);
                                                        alpha = rgba[3];
                                                } else {
                                                        alpha = 1.0f;
index 10af35a..2e192a0 100644 (file)
@@ -724,7 +724,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float *point, const floa
                /* Get strength by feeding the vertex 
                   location directly into a texture */
                externtex(mtex, point, &avg,
-                         &jnk, &jnk, &jnk, &jnk);
+                         &jnk, &jnk, &jnk, &jnk, 0);
        }
        else if(ss->texcache) {
                float rotation = -mtex->rot;
index aa12eb9..e83a17c 100644 (file)
@@ -1306,7 +1306,7 @@ static void rna_def_modifier_displace(BlenderRNA *brna)
        RNA_def_property_enum_sdna(prop, NULL, "texmapping");
        RNA_def_property_enum_items(prop, prop_texture_coordinates_items);
        RNA_def_property_ui_text(prop, "Texture Coordinates", "");
-       RNA_def_property_update(prop, 0, "rna_Modifier_update");
+       RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
 
        prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "uvlayer_name");
index 29ace80..efe5741 100644 (file)
@@ -134,7 +134,7 @@ static void updateDepgraph(
 {
        DisplaceModifierData *dmd = (DisplaceModifierData*) md;
 
-       if(dmd->map_object) {
+       if(dmd->map_object && dmd->texmapping == MOD_DISP_MAP_OBJECT) {
                DagNode *curNode = dag_get_node(forest, dmd->map_object);
 
                dag_add_relation(forest, curNode, obNode,
index a6d99ad..ee608c7 100644 (file)
@@ -442,11 +442,11 @@ static DerivedMesh *applyModifier(ModifierData *md,
                                j= 2;
                        }
 
-                       for(; j>=0; j--) {
+                       do {
                                vidx = *(&mf->v1 + j);
                                vert_accum[vidx] += face_angles[j];
                                vert_angles[vidx]+= shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * face_angles[j];
-                       }
+                       } while(j--);
                }
 
                /* vertex group support */
index 9872089..b04f724 100644 (file)
@@ -51,7 +51,7 @@ struct ImBuf;
 //void    RE_zbufferall_radio(struct RadView *vw, struct RNode **rg_elem, int rg_totelem, struct Render *re);
 
 /* particle.c, effect.c, editmesh_modes.c and brush.c, returns 1 if rgb, 0 otherwise */
-int    externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta);
+int    externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta, const int thread);
 
 /* particle.c */
 void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg, int blendtype);
index ce55935..91d58b7 100644 (file)
@@ -1019,7 +1019,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma,   float *vec,   f
                                }
                        }
 
-                       externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta);
+                       externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta, 0);
 
                        yn= tin*mtex->colfac;
                        zn= tin*mtex->alphafac;
@@ -1151,7 +1151,7 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater
                                VECCOPY(texvec, orco);
                        }
 
-                       externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta);
+                       externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta, 0);
 
                        //yn= tin*mtex->colfac;
                        //zn= tin*mtex->alphafac;
index 0e98069..be2c83a 100644 (file)
@@ -3016,7 +3016,7 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef
 
 /* ------------------------------------------------------------------------- */
 
-int externtex(MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta)
+int externtex(MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta, const int thread)
 {
        Tex *tex;
        TexResult texr;
@@ -3042,7 +3042,7 @@ int externtex(MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *t
                do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt);
        }
        
-       rgb= multitex(tex, texvec, dxt, dyt, 0, &texr, 0, mtex->which_output);
+       rgb= multitex(tex, texvec, dxt, dyt, 0, &texr, thread, mtex->which_output);
        
        if(rgb) {
                texr.tin= (0.35*texr.tr+0.45*texr.tg+0.2*texr.tb);