Revision: 42824
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42824
Author:   mont29
Date:     2011-12-22 14:04:25 +0000 (Thu, 22 Dec 2011)
Log Message:
-----------
Some small perf tweaks to weightvg proximity: do not use indices in case all 
vertices are affected...

Modified Paths:
--------------
    trunk/blender/source/blender/modifiers/intern/MOD_weightvgproximity.c

Modified: trunk/blender/source/blender/modifiers/intern/MOD_weightvgproximity.c
===================================================================
--- trunk/blender/source/blender/modifiers/intern/MOD_weightvgproximity.c       
2011-12-22 13:26:51 UTC (rev 42823)
+++ trunk/blender/source/blender/modifiers/intern/MOD_weightvgproximity.c       
2011-12-22 14:04:25 UTC (rev 42824)
@@ -399,29 +399,37 @@
                MEM_freeN(tdw);
                return dm;
        }
-       indices = MEM_mallocN(sizeof(int) * numIdx, "WeightVGProximity 
Modifier, indices");
-       memcpy(indices, tidx, sizeof(int) * numIdx);
-       org_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity 
Modifier, org_w");
+       if(numIdx != numVerts) {
+               indices = MEM_mallocN(sizeof(int) * numIdx, "WeightVGProximity 
Modifier, indices");
+               memcpy(indices, tidx, sizeof(int) * numIdx);
+               org_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity 
Modifier, org_w");
+               memcpy(org_w, tw, sizeof(float) * numIdx);
+               dw = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, 
"WeightVGProximity Modifier, dw");
+               memcpy(dw, tdw, sizeof(MDeformWeight*) * numIdx);
+               MEM_freeN(tw);
+               MEM_freeN(tdw);
+       }
+       else {
+               org_w = tw;
+               dw = tdw;
+       }
        new_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity 
Modifier, new_w");
-       memcpy(org_w, tw, sizeof(float) * numIdx);
-       dw = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGProximity 
Modifier, dw");
-       memcpy(dw, tdw, sizeof(MDeformWeight*) * numIdx);
        MEM_freeN(tidx);
-       MEM_freeN(tw);
-       MEM_freeN(tdw);
 
        /* Get our vertex coordinates. */
-       {
+       v_cos = MEM_mallocN(sizeof(float[3]) * numIdx, "WeightVGProximity 
Modifier, v_cos");
+       if(numIdx != numVerts) {
                /* XXX In some situations, this code can be up to about 50 
times more performant
                 *     than simply using getVertCo for each affected vertex...
                 */
                float (*tv_cos)[3] = MEM_mallocN(sizeof(float[3]) * numVerts, 
"WeightVGProximity Modifier, tv_cos");
-               v_cos = MEM_mallocN(sizeof(float[3]) * numIdx, 
"WeightVGProximity Modifier, v_cos");
                dm->getVertCos(dm, tv_cos);
                for (i = 0; i < numIdx; i++)
                        copy_v3_v3(v_cos[i], tv_cos[indices[i]]);
                MEM_freeN(tv_cos);
        }
+       else
+               dm->getVertCos(dm, v_cos);
 
        /* Compute wanted distances. */
        if (wmd->proximity_mode == MOD_WVG_PROXIMITY_OBJECT) {
@@ -497,7 +505,8 @@
        MEM_freeN(org_w);
        MEM_freeN(new_w);
        MEM_freeN(dw);
-       MEM_freeN(indices);
+       if(indices)
+               MEM_freeN(indices);
        MEM_freeN(v_cos);
 
 #if DO_PROFILE

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to