Revision: 14323
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14323
Author:   jhk
Date:     2008-04-03 01:59:25 +0200 (Thu, 03 Apr 2008)

Log Message:
-----------
Fix for bug: [#8610] Hair Particle 'cut' edit mode not respecting backface 
culling / z-depth
-Cut-brush didn't use depth testing at all, now it does, but unfortunately this 
changes the behavior of the brush so that cutting is not perfect for hairs that 
are partly visible from behind an edge of the emitter (this change effects the 
brush only when z-buf clipping is used of course)

Modified Paths:
--------------
    trunk/blender/source/blender/src/editparticle.c

Modified: trunk/blender/source/blender/src/editparticle.c
===================================================================
--- trunk/blender/source/blender/src/editparticle.c     2008-04-02 23:12:05 UTC 
(rev 14322)
+++ trunk/blender/source/blender/src/editparticle.c     2008-04-02 23:59:25 UTC 
(rev 14323)
@@ -294,7 +294,8 @@
        y=wco[1];
 
        if(G.vd->depths && x<G.vd->depths->w && y<G.vd->depths->h){
-               if((float)uz>G.vd->depths->depths[y*G.vd->depths->w+x])
+               /* the 0.0001 is an experimental threshold to make selecting 
keys right next to a surface work better */
+               if((float)uz - 0.0001 > 
G.vd->depths->depths[y*G.vd->depths->w+x])
                        return 0;
                else
                        return 1;
@@ -305,7 +306,7 @@
 
                glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
 
-               if((float)uz>depth)
+               if((float)uz - 0.0001 > depth)
                        return 0;
                else
                        return 1;
@@ -2075,7 +2076,7 @@
 }
 static void brush_cut(ParticleSystem *psys, int index, void *userData)
 {
-       struct { short *mval; float rad; rcti* rect; int selected; float 
cutfac;} *data = userData;
+       struct { short *mval; float rad; rcti* rect; int selected; float 
cutfac; bglMats mats;} *data = userData;
        ParticleData *pa= &psys->particles[index];
        ParticleCacheKey *key = psys->pathcache[index];
        float rad2, cut_time = 1.0;
@@ -2101,7 +2102,7 @@
        xo1 = x1 - o1;
 
        /* check if root is inside circle */
-       if(xo0*xo0 + xo1*xo1 < rad2) {
+       if(xo0*xo0 + xo1*xo1 < rad2 && test_key_depth(key->co,&(data->mats))) {
                cut_time = -1.0f;
                cut = 1;
        }
@@ -2110,6 +2111,15 @@
                for(k=1, key++; k<=keys; k++, key++){
                        project_short_noclip(key->co, vertco);
 
+                       if(test_key_depth(key->co,&(data->mats)) == 0) {
+                               x0 = (float)vertco[0];
+                               x1 = (float)vertco[1];
+
+                               xo0 = x0 - o0;
+                               xo1 = x1 - o1;
+                               continue;
+                       }
+
                        v0 = (float)vertco[0] - x0;
                        v1 = (float)vertco[1] - x1;
 
@@ -2628,7 +2638,7 @@
                                }
                                case PE_BRUSH_CUT:
                                {
-                                       struct { short *mval; float rad; rcti* 
rect; int selected; float cutfac;} data;
+                                       struct { short *mval; float rad; rcti* 
rect; int selected; float cutfac; bglMats mats;} data;
 
                                        data.mval = mval;
                                        data.rad = (float)brush->size;
@@ -2637,6 +2647,8 @@
 
                                        data.cutfac = (float)(brush->strength / 
100.0f);
 
+                                       bgl_get_mats(&(data.mats));
+
                                        if(selected)
                                                foreach_selected_element(psys, 
brush_cut, &data);
                                        else


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to