Revision: 28543
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28543
Author:   joeedh
Date:     2010-05-03 12:04:25 +0200 (Mon, 03 May 2010)

Log Message:
-----------
mask modifier properly works in weightpaint and edit modes now.  note that 
modifiers should not have to provide a applyModifierEM function, there's really 
no reason to not pull the result from applyModifier if applyModifierEM doesn't 
exist, it's not like we don't have a dozen *EM functions that do just that, 
anyway.  fixes 22192

Modified Paths:
--------------
    branches/render25/source/blender/blenkernel/intern/DerivedMesh.c
    branches/render25/source/blender/modifiers/intern/MOD_collision.c
    branches/render25/source/blender/modifiers/intern/MOD_mask.c

Modified: branches/render25/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/DerivedMesh.c    
2010-05-03 08:43:00 UTC (rev 28542)
+++ branches/render25/source/blender/blenkernel/intern/DerivedMesh.c    
2010-05-03 10:04:25 UTC (rev 28543)
@@ -2017,7 +2017,9 @@
                                }
                        }
 
-                       mti->deformVertsEM(md, ob, em, dm, deformedVerts, 
numVerts);
+                       if (mti->deformVertsEM)
+                               mti->deformVertsEM(md, ob, em, dm, 
deformedVerts, numVerts);
+                       else mti->deformVerts(md, ob, dm, deformedVerts, 
numVerts, 0, 0);
                } else {
                        DerivedMesh *ndm;
 
@@ -2053,8 +2055,12 @@
 
                                mask &= ~CD_MASK_ORCO;
                                DM_set_only_copy(orcodm, mask);
-                               ndm = mti->applyModifierEM(md, ob, em, orcodm);
 
+                               if (mti->applyModifierEM)
+                                       ndm = mti->applyModifierEM(md, ob, em, 
orcodm);
+                               else
+                                       ndm = mti->applyModifier(md, ob, 
orcodm, 0, 0);
+
                                if(ndm) {
                                        /* if the modifier returned a new dm, 
release the old one */
                                        if(orcodm && orcodm != ndm) 
orcodm->release(orcodm);
@@ -2069,7 +2075,10 @@
                                if(!CustomData_has_layer(&dm->faceData, 
CD_ORIGSPACE))
                                        DM_add_face_layer(dm, CD_ORIGSPACE, 
CD_DEFAULT, NULL);
                        
-                       ndm = mti->applyModifierEM(md, ob, em, dm);
+                       if (mti->applyModifierEM)
+                               ndm = mti->applyModifierEM(md, ob, em, dm);
+                       else
+                               ndm = mti->applyModifier(md, ob, dm, 0, 0);
 
                        if (ndm) {
                                if(dm && dm != ndm)

Modified: branches/render25/source/blender/modifiers/intern/MOD_collision.c
===================================================================
--- branches/render25/source/blender/modifiers/intern/MOD_collision.c   
2010-05-03 08:43:00 UTC (rev 28542)
+++ branches/render25/source/blender/modifiers/intern/MOD_collision.c   
2010-05-03 10:04:25 UTC (rev 28543)
@@ -46,6 +46,7 @@
 {
        CollisionModifierData *collmd = (CollisionModifierData*) md;
        
+       collmd->xold = NULL;
        collmd->x = NULL;
        collmd->xnew = NULL;
        collmd->current_x = NULL;
@@ -64,6 +65,8 @@
        {
                if(collmd->bvhtree)
                        BLI_bvhtree_free(collmd->bvhtree);
+               if(collmd->xold)
+                       MEM_freeN(collmd->xold);
                if(collmd->x)
                        MEM_freeN(collmd->x);
                if(collmd->xnew)
@@ -143,6 +146,8 @@
                                }
                                
                                collmd->xnew = MEM_dupallocN(collmd->x); // 
frame end position
+
+                               collmd->xold = MEM_dupallocN(collmd->x);
                                collmd->current_x = MEM_dupallocN(collmd->x); 
// inter-frame
                                collmd->current_xnew = 
MEM_dupallocN(collmd->x); // inter-frame
                                collmd->current_v = MEM_dupallocN(collmd->x); 
// inter-frame
@@ -153,19 +158,21 @@
                                collmd->numfaces = dm->getNumFaces(dm);
                                
                                // create bounding box hierarchy
-                               collmd->bvhtree = 
bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, 
ob->pd->pdef_sboft);
+                               collmd->bvhtree = 
bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, 
collmd->numverts, ob->pd->pdef_sboft);
                                
                                collmd->time = current_time;
                        }
                        else if(numverts == collmd->numverts)
                        {
+                               MVert *mv = dm->getVertArray(dm);
+
                                // put positions to old positions
-                               tempVert = collmd->x;
+                               tempVert = collmd->xold;
+                               collmd->xold = collmd->x;
                                collmd->x = collmd->xnew;
                                collmd->xnew = tempVert;
-                               
-                               memcpy(collmd->xnew, dm->getVertArray(dm), 
numverts*sizeof(MVert));
-                               
+
+                               memcpy(collmd->xnew, mv, 
sizeof(MVert)*numverts); // frame start position
                                for ( i = 0; i < numverts; i++ )
                                {
                                        // we save global positions
@@ -181,7 +188,7 @@
                                        if(ob->pd->pdef_sboft != 
BLI_bvhtree_getepsilon(collmd->bvhtree))
                                        {
                                                
BLI_bvhtree_free(collmd->bvhtree);
-                                               collmd->bvhtree = 
bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, 
numverts, ob->pd->pdef_sboft);
+                                               collmd->bvhtree = 
bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, 
collmd->numverts, ob->pd->pdef_sboft);
                                        }
                        
                                }
@@ -189,12 +196,12 @@
                                /* happens on file load (ONLY when i decomment 
changes in readfile.c) */
                                if(!collmd->bvhtree)
                                {
-                                       collmd->bvhtree = 
bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, 
numverts, ob->pd->pdef_sboft);
+                                       collmd->bvhtree = 
bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, 
collmd->numverts, ob->pd->pdef_sboft);
                                }
                                else
                                {
                                        // recalc static bounding boxes
-                                       bvhtree_update_from_mvert ( 
collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, 
collmd->current_xnew, collmd->numverts, 1 );
+                                       
bvhtree_update_from_mvert(collmd->bvhtree, collmd->mfaces, collmd->numfaces, 
collmd->x, collmd->xnew, collmd->numverts, 1);
                                }
                                
                                collmd->time = current_time;

Modified: branches/render25/source/blender/modifiers/intern/MOD_mask.c
===================================================================
--- branches/render25/source/blender/modifiers/intern/MOD_mask.c        
2010-05-03 08:43:00 UTC (rev 28542)
+++ branches/render25/source/blender/modifiers/intern/MOD_mask.c        
2010-05-03 10:04:25 UTC (rev 28543)
@@ -32,6 +32,7 @@
 
 #include "DNA_armature_types.h"
 #include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
 
 #include "BLI_ghash.h"
 
@@ -386,7 +387,7 @@
        /* structName */        "MaskModifierData",
        /* structSize */        sizeof(MaskModifierData),
        /* type */              eModifierTypeType_Nonconstructive,
-       /* flags */             eModifierTypeFlag_AcceptsMesh,
+       /* flags */             
eModifierTypeFlag_AcceptsMesh|eModifierTypeFlag_SupportsMapping|eModifierTypeFlag_SupportsEditmode,
 
        /* copyData */          copyData,
        /* deformVerts */       0,


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

Reply via email to