Revision: 29554
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29554
Author:   jwilkins
Date:     2010-06-19 04:54:17 +0200 (Sat, 19 Jun 2010)

Log Message:
-----------
* Bug Fix: corrected behavior or grab when symmetry is enabled

Modified Paths:
--------------
    branches/soc-2010-jwilkins/source/blender/blenlib/BLI_pbvh.h
    branches/soc-2010-jwilkins/source/blender/blenlib/intern/pbvh.c
    
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
    branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt_undo.c

Modified: branches/soc-2010-jwilkins/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenlib/BLI_pbvh.h        
2010-06-18 23:48:52 UTC (rev 29553)
+++ branches/soc-2010-jwilkins/source/blender/blenlib/BLI_pbvh.h        
2010-06-19 02:54:17 UTC (rev 29554)
@@ -36,6 +36,10 @@
 typedef struct PBVH PBVH;
 typedef struct PBVHNode PBVHNode;
 
+typedef struct {
+       float (*co)[3];
+} PBVHProxyNode;
+
 /* Callbacks */
 
 /* returns 1 if the search should continue from this node, 0 otherwise */
@@ -222,6 +226,10 @@
                } \
        }
 
+void BLI_pbvh_node_get_proxies(PBVHNode* node, PBVHProxyNode** proxies, int* 
proxy_count);
+void BLI_pbvh_node_free_proxies(PBVHNode* node);
+PBVHProxyNode* BLI_pbvh_node_add_proxy(PBVH* bvh, PBVHNode* node);
+void BLI_pbvh_gather_proxies(PBVH* pbvh, PBVHNode*** nodes,  int* totnode);
 
 #endif /* BLI_PBVH_H */
 

Modified: branches/soc-2010-jwilkins/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenlib/intern/pbvh.c     
2010-06-18 23:48:52 UTC (rev 29553)
+++ branches/soc-2010-jwilkins/source/blender/blenlib/intern/pbvh.c     
2010-06-19 02:54:17 UTC (rev 29554)
@@ -92,6 +92,9 @@
        char flag;
 
        float tmin; // used for raycasting, is how close bb is to the ray point
+
+       int proxy_count;
+       PBVHProxyNode* proxies;
 };
 
 struct PBVH {
@@ -1190,6 +1193,18 @@
        copy_v3_v3(bb_max, node->orig_vb.bmax);
 }
 
+void BLI_pbvh_node_get_proxies(PBVHNode* node, PBVHProxyNode** proxies, int* 
proxy_count)
+{
+       if (node->proxy_count > 0) {
+               if (proxies) *proxies = node->proxies;
+               if (proxy_count) *proxy_count = node->proxy_count;
+       }
+       else {
+               if (proxies) *proxies = 0;
+               if (proxy_count) *proxy_count = 0;
+       }
+}
+
 /********************************* Raycast ***********************************/
 
 typedef struct {
@@ -1467,3 +1482,79 @@
        bvh->gridfaces= gridfaces;
 }
 
+/* Proxies */
+
+PBVHProxyNode* BLI_pbvh_node_add_proxy(PBVH* bvh, PBVHNode* node)
+{
+       int index, totverts;
+
+       index = node->proxy_count;
+
+       node->proxy_count++;
+
+       if (node->proxies)
+               node->proxies= MEM_reallocN(node->proxies, 
node->proxy_count*sizeof(PBVHProxyNode));
+       else
+               node->proxies= MEM_mallocN(sizeof(PBVHProxyNode), 
"PBVHNodeProxy");
+
+       if (bvh->grids)
+               totverts = node->totprim*bvh->gridsize*bvh->gridsize;
+       else 
+               totverts = node->uniq_verts;
+
+       node->proxies[index].co= MEM_callocN(sizeof(float[3])*totverts, 
"PBVHNodeProxy.co");
+
+       return node->proxies + index;
+}
+
+void BLI_pbvh_node_free_proxies(PBVHNode* node)
+{
+       int p;
+
+       for (p= 0; p < node->proxy_count; p++) {
+               MEM_freeN(node->proxies[p].co);
+               node->proxies[p].co= 0;
+       }
+
+       MEM_freeN(node->proxies);
+       node->proxies = 0;
+
+       node->proxy_count= 0;
+}
+
+void BLI_pbvh_gather_proxies(PBVH* pbvh, PBVHNode*** r_array,  int* r_tot)
+{
+       PBVHNode **array= NULL, **newarray, *node;
+       int tot= 0, space= 0;
+       int n;
+
+       for (n= 0; n < pbvh->totnode; n++) {
+               node = pbvh->nodes + n;
+
+               if(node->proxy_count > 0) {
+                       if(tot == space) {
+                               /* resize array if needed */
+                               space= (tot == 0)? 32: space*2;
+                               newarray= MEM_callocN(sizeof(PBVHNode)*space, 
"BLI_pbvh_gather_proxies");
+
+                               if (array) {
+                                       memcpy(newarray, array, 
sizeof(PBVHNode)*tot);
+                                       MEM_freeN(array);
+                               }
+
+                               array= newarray;
+                       }
+
+                       array[tot]= node;
+                       tot++;
+               }
+       }
+
+       if(tot == 0 && array) {
+               MEM_freeN(array);
+               array= NULL;
+       }
+
+       *r_array= array;
+       *r_tot= tot;
+}

Modified: 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c   
    2010-06-18 23:48:52 UTC (rev 29553)
+++ 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c   
    2010-06-19 02:54:17 UTC (rev 29554)
@@ -176,7 +176,7 @@
        if (!loaded) {
                //GLfloat largest_supported_anisotropy;
 
-               glGenTextures(1, &(brush->overlay_texture));
+               glGenTextures(1, (GLint*)(&(brush->overlay_texture)));
                glBindTexture(GL_TEXTURE_2D, brush->overlay_texture);
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 16, 0, GL_RGBA, 
GL_UNSIGNED_BYTE, grid_texture0);
                glTexImage2D(GL_TEXTURE_2D, 1, GL_RGB,  8,  8, 0, GL_RGBA, 
GL_UNSIGNED_BYTE, grid_texture1);
@@ -210,10 +210,9 @@
        int i, j;
        float xlim, ylim;
 
-       // XXX there has to be a better way to guess if a texture is procedural
        int procedural = 1;//brush->mtex.tex && brush->mtex.tex->type != 
TEX_IMAGE;
 
-       if (brush->overlay_texture) glDeleteTextures(1, 
&brush->overlay_texture);
+       if (brush->overlay_texture) glDeleteTextures(1, 
(GLint*)(&brush->overlay_texture));
 
        width = height = 256;
 
@@ -274,7 +273,7 @@
                }
        }
 
-       glGenTextures(1, &(brush->overlay_texture));
+       glGenTextures(1, (GLint*)(&(brush->overlay_texture)));
 
        glBindTexture(GL_TEXTURE_2D, brush->overlay_texture);
 
@@ -618,11 +617,12 @@
 
                if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_TILED && 
brush->flag & BRUSH_TEXTURE_OVERLAY) {
                        const float diameter = 2*brush->size;
-                       float inv_scale_x , inv_scale_y;
-                       int procedural;
+                       //float inv_scale_x , inv_scale_y;
+                       //int procedural;
 
                        //load_grid(brush);
-                       procedural = load_tex(brush, &vc);
+                       //procedural = load_tex(brush, &vc);
+                       load_tex(brush, &vc);
 
                        glEnable(GL_TEXTURE_2D);
                        glBindTexture(GL_TEXTURE_2D, brush->overlay_texture);
@@ -634,21 +634,21 @@
                        glMatrixMode(GL_TEXTURE);
                        glLoadIdentity();
 
-                       if (!procedural) {
-                               glTranslatef(0.5f, 0.5f, 0);
-                               glTranslatef(-brush->texture_center_x, 
-brush->texture_center_y, 0);
+                       //if (!procedural) {
+                       //      glTranslatef(0.5f, 0.5f, 0);
+                       //      glTranslatef(-brush->texture_center_x, 
-brush->texture_center_y, 0);
 
-                               inv_scale_x = 10000.0f / 
(brush->texture_scale_x*brush->texture_scale_percentage);
-                               inv_scale_y = 10000.0f / 
(brush->texture_scale_y*brush->texture_scale_percentage);
+                       //      inv_scale_x = 10000.0f / 
(brush->texture_scale_x*brush->texture_scale_percentage);
+                       //      inv_scale_y = 10000.0f / 
(brush->texture_scale_y*brush->texture_scale_percentage);
 
-                               glScalef(inv_scale_x, inv_scale_y, 0);
+                       //      glScalef(inv_scale_x, inv_scale_y, 0);
 
-                               glRotatef(-brush->mtex.rot * 180.0f/M_PI, 0, 0, 
1);
+                       //      glRotatef(-brush->mtex.rot * 180.0f/M_PI, 0, 0, 
1);
 
-                               glScalef(viewport[2] / diameter, viewport[3] / 
diameter, 0);
+                       //      glScalef(viewport[2] / diameter, viewport[3] / 
diameter, 0);
 
-                               glTranslatef(-0.5f, -0.5f, 0);
-                       }
+                       //      glTranslatef(-0.5f, -0.5f, 0);
+                       //}
 
                        glColor4f(1.0f, 1.0f, 1.0f, 
brush->texture_overlay_alpha / 100.0f);
                        glBegin(GL_QUADS);

Modified: 
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c     
2010-06-18 23:48:52 UTC (rev 29553)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c     
2010-06-19 02:54:17 UTC (rev 29554)
@@ -95,6 +95,63 @@
 //#include <omp.h>
 //#endif
 
+void ED_sculpt_force_update(bContext *C)
+{
+       Object *ob= CTX_data_active_object(C);
+
+       if(ob && (ob->mode & OB_MODE_SCULPT))
+               multires_force_update(ob);
+}
+
+/* Sculpt mode handles multires differently from regular meshes, but only if
+   it's the last modifier on the stack and it is not on the first level */
+struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob)
+{
+       ModifierData *md, *nmd;
+       
+       for(md= modifiers_getVirtualModifierList(ob); md; md= md->next) {
+               if(md->type == eModifierType_Multires) {
+                       MultiresModifierData *mmd= (MultiresModifierData*)md;
+
+                       /* Check if any of the modifiers after multires are 
active
+                        * if not it can use the multires struct */
+                       for(nmd= md->next; nmd; nmd= nmd->next)
+                               if(modifier_isEnabled(scene, nmd, 
eModifierMode_Realtime))
+                                       break;
+
+                       if(!nmd && mmd->sculptlvl > 0)
+                               return mmd;
+               }
+       }
+
+       return NULL;
+}
+
+/* Checks whether full update mode (slower) needs to be used to work with 
modifiers */
+int sculpt_modifiers_active(Scene *scene, Object *ob)
+{
+       ModifierData *md;
+       MultiresModifierData *mmd= sculpt_multires_active(scene, ob);
+
+       /* check if there are any modifiers after what we are sculpting,
+          for a multires modifier with a deform modifier in front, we
+          do no need to recalculate the modifier stack. note that this
+          needs to be in sync with ccgDM_use_grid_pbvh! */
+       if(mmd)
+               md= mmd->modifier.next;
+       else
+               md= modifiers_getVirtualModifierList(ob);
+       
+       /* exception for shape keys because we can edit those */
+       for(; md; md= md->next) {
+               if(modifier_isEnabled(scene, md, eModifierMode_Realtime))
+                       if(md->type != eModifierType_ShapeKey)
+                               return 1;
+       }
+
+       return 0;
+}
+
 /* ===== STRUCTS =====
  *
  */
@@ -366,18 +423,7 @@
        //}
 }
 
-/* area of overlap of two circles of radius 1 seperated by d units from their 
centers */
-static float circle_overlap(float d)
-{
-       return (2*acos(d/2)-(1/2)*d*sqrt(4-d*d));
-}
 
-/* percentage of overlap of two circles of radius 1 seperated by d units from 
their centers */
-static float circle_overlap_percent(float d)
-{
-       return circle_overlap(d) / M_PI;
-}
-
 /* ===== Sculpting =====
  *
  */
@@ -460,6 +506,18 @@
 
 }
 
+/* area of overlap of two circles of radius 1 seperated by d units from their 
centers */
+static float circle_overlap(float d)
+{
+       return (2*acos(d/2)-(1/2)*d*sqrt(4-d*d));
+}
+
+/* percentage of overlap of two circles of radius 1 seperated by d units from 
their centers */
+static float circle_overlap_percent(float d)
+{
+       return circle_overlap(d) / M_PI;
+}
+
 /* Return modified brush strength. Includes the direction of the brush, 
positive
    values pull vertices, negative values push. Uses tablet pressure and a
    special multiplier found experimentally to scale the strength factor. */
@@ -468,7 +526,7 @@
        Brush *brush = paint_brush(&sd->paint);
 
        /* Primary strength input; square it to make lower values more 
sensitive */
-       float alpha = brush->alpha * brush->alpha * brush->strength_multiplier;
+       float alpha    = brush->alpha * brush->alpha * 
brush->strength_multiplier;
        float dir      = brush->flag & BRUSH_DIR_IN ? -1 : 1;
        float pressure = brush->flag & BRUSH_ALPHA_PRESSURE ? cache->pressure : 
1;
        float flip     = cache->flip ? -1 : 1;
@@ -1144,22 +1202,20 @@
                PBVHVertexIter vd;
                SculptBrushTest test;
                float (*origco)[3];
+               float (*proxy)[3];
        

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to