Merging r38296 through r38315 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 11 Jul 2011 18:18:42 +0000 (18:18 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 11 Jul 2011 18:18:42 +0000 (18:18 +0000)
14 files changed:
source/blender/avi/AVI_avi.h
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/modifiers/intern/MOD_cast.c
source/blender/modifiers/intern/MOD_displace.c
source/blender/modifiers/intern/MOD_hook.c
source/blender/modifiers/intern/MOD_meshdeform.c
source/blender/modifiers/intern/MOD_simpledeform.c
source/blender/modifiers/intern/MOD_smooth.c
source/blender/modifiers/intern/MOD_solidify.c
source/blender/modifiers/intern/MOD_util.c
source/blender/modifiers/intern/MOD_util.h
source/blender/modifiers/intern/MOD_warp.c
source/blender/modifiers/intern/MOD_wave.c

index 1446971a8ac7f34e4181e6179493c65aaa259675..97dc12f57d889733e65d4feef0335e16041f8d88 100644 (file)
@@ -60,7 +60,7 @@
 
 typedef struct _AviChunk {
   int fcc;
-  int64_t size;
+  int size;
 } AviChunk;
 
 typedef struct _AviList {
index 2f29074834b825fe981a9d8b579ae0d4c462de10..962c7fd5e863caf6b60aa7f80673b7d5304ce678 100644 (file)
@@ -550,7 +550,7 @@ Material *material_pop_id(ID *id, int index)
                                Material **mat;
 
                                if(index + 1 != (*totcol))
-                                       memmove((*matar), (*matar) + 1, (*totcol) - (index + 1));
+                                       memmove((*matar), (*matar) + 1, sizeof(void *) * ((*totcol) - (index + 1)));
 
                                (*totcol)--;
                                
index a66caf8879f2b79679d9d9032e51ac108a864b4b..67d7e7bffd6b479c77864b27d2594d2975f51a5c 100644 (file)
@@ -1176,7 +1176,8 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw
        CCGSubSurf *ss = ccgdm->ss;
        CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
        CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
-       int i, edgeSize = ccgSubSurf_getEdgeSize(ss);
+       int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss);
+       int totedge = ccgSubSurf_getNumEdges(ss);
        int gridSize = ccgSubSurf_getGridSize(ss);
        int useAging;
 
@@ -1184,13 +1185,16 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw
 
        ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL);
 
-       for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) {
-               CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
+       for (j=0; j< totedge; j++) {
+               CCGEdge *e = ccgdm->edgeMap[j].edge;
                DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
 
                if (!drawLooseEdges && !ccgSubSurf_getEdgeNumFaces(e))
                        continue;
 
+               if(ccgdm->edgeFlags && !(ccgdm->edgeFlags[j] & ME_EDGEDRAW))
+                       continue;
+
                if (useAging && !(G.f&G_BACKBUFSEL)) {
                        int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4;
                        glColor3ub(0, ageCol>0?ageCol:0, 0);
index 5cb352ef4822f81b56e4ac9a0367d3bd176aca85..14b23ba4972e376a5a65339835f521f9066d27b2 100644 (file)
@@ -177,10 +177,7 @@ static void sphere_do(
 
        /* 3) if we were given a vertex group name,
        * only those vertices should be affected */
-       defgrp_index = defgroup_name_index(ob, cmd->defgrp_name);
-
-       if ((ob->type == OB_MESH) && dm && defgrp_index >= 0)
-               dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
+       modifier_get_vgroup(ob, dm, cmd->defgrp_name, &dvert, &defgrp_index);
 
        if(flag & MOD_CAST_SIZE_FROM_RADIUS) {
                len = cmd->radius;
@@ -335,10 +332,7 @@ static void cuboid_do(
 
        /* 3) if we were given a vertex group name,
        * only those vertices should be affected */
-       defgrp_index = defgroup_name_index(ob, cmd->defgrp_name);
-
-       if ((ob->type == OB_MESH) && dm && defgrp_index >= 0)
-               dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
+       modifier_get_vgroup(ob, dm, cmd->defgrp_name, &dvert, &defgrp_index);
 
        if (ctrl_ob) {
                if(flag & MOD_CAST_USE_OB_TRANSFORM) {
index 01f1b6fb2a7f00d87fc677057d306b992e55c7d5..e0482e6b3fccc6032a2ed0fccf33700e0b129af8 100644 (file)
@@ -169,7 +169,7 @@ static void displaceModifier_do(
 {
        int i;
        MVert *mvert;
-       MDeformVert *dvert = NULL;
+       MDeformVert *dvert;
        int defgrp_index;
        float (*tex_co)[3];
        float weight= 1.0f; /* init value unused but some compilers may complain */
@@ -177,11 +177,8 @@ static void displaceModifier_do(
        if(!dmd->texture) return;
        if(dmd->strength == 0.0f) return;
 
-       defgrp_index = defgroup_name_index(ob, dmd->defgrp_name);
-
        mvert = CDDM_get_verts(dm);
-       if(defgrp_index >= 0)
-               dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
+       modifier_get_vgroup(ob, dm, dmd->defgrp_name, &dvert, &defgrp_index);
 
        tex_co = MEM_callocN(sizeof(*tex_co) * numVerts,
                                 "displaceModifier_do tex_co");
index 082c199b16fea714d99066b68ef21ef87050d043..ea8d602dd7aa9d9346e4e0dcb1b16d7c1c227659 100644 (file)
@@ -157,9 +157,8 @@ static void deformVerts(ModifierData *md, Object *ob,
        int i, *index_pt;
        const float falloff_squared= hmd->falloff * hmd->falloff; /* for faster comparisons */
        
-       int max_dvert= 0;
-       MDeformVert *dvert= NULL;
-       int defgrp_index = -1;
+       MDeformVert *dvert;
+       int defgrp_index, max_dvert;
        
        /* get world-space matrix of target, corrected for the space the verts are in */
        if (hmd->subtarget[0] && pchan) {
@@ -174,21 +173,8 @@ static void deformVerts(ModifierData *md, Object *ob,
        mul_serie_m4(mat, ob->imat, dmat, hmd->parentinv,
                         NULL, NULL, NULL, NULL, NULL);
 
-       if((defgrp_index= defgroup_name_index(ob, hmd->name)) != -1) {
-               Mesh *me = ob->data;
-               if(dm) {
-                       dvert= dm->getVertDataArray(dm, CD_MDEFORMVERT);
-                       if(dvert) {
-                               max_dvert = numVerts;
-                       }
-               }
-               else if(me->dvert) {
-                       dvert= me->dvert;
-                       if(dvert) {
-                               max_dvert = me->totvert;
-                       }
-               }
-       }
+       modifier_get_vgroup(ob, dm, hmd->name, &dvert, &defgrp_index);
+       max_dvert = (dvert)? numVerts: 0;
 
        /* Regarding index range checking below.
         *
index 5021f3a6d2e33df5f7c5f6b33dd259362392d788..3903f2602e4f7fc77baf5f383a97e55a38b86c11 100644 (file)
@@ -284,10 +284,7 @@ static void meshdeformModifier_do(
                        copy_v3_v3(dco[a], co);
        }
 
-       defgrp_index = defgroup_name_index(ob, mmd->defgrp_name);
-
-       if(dm && defgrp_index >= 0)
-               dvert= dm->getVertDataArray(dm, CD_MDEFORMVERT);
+       modifier_get_vgroup(ob, dm, mmd->defgrp_name, &dvert, &defgrp_index);
 
        /* do deformation */
        fac= 1.0f;
index ea4771b679aff6f9ac0dc9e0e6033ff7eca27cf7..5efd6cd28ecf48aac0aac55b2cde34075a9e84f8 100644 (file)
@@ -162,8 +162,8 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
        float smd_limit[2], smd_factor;
        SpaceTransform *transf = NULL, tmp_transf;
        void (*simpleDeform_callback)(const float factor, const float dcut[3], float *co) = NULL;       //Mode callback
-       int vgroup = defgroup_name_index(ob, smd->vgroup_name);
-       MDeformVert *dvert = NULL;
+       int vgroup;
+       MDeformVert *dvert;
 
        //Safe-check
        if(smd->origin == ob) smd->origin = NULL;                                       //No self references
@@ -216,17 +216,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
                smd_factor   = smd->factor / MAX2(FLT_EPSILON, smd_limit[1]-smd_limit[0]);
        }
 
-
-       if(dm)
-       {
-               dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
-       }
-       else if(ob->type == OB_LATTICE)
-       {
-               dvert = lattice_get_deform_verts(ob);
-       }
-
-
+       modifier_get_vgroup(ob, dm, smd->vgroup_name, &dvert, &vgroup);
 
        switch(smd->mode)
        {
index 5f76fad14b195b1602ebd0592a274d0c08b29da1..28a31b84ea5e4ed9182121906a2aa12ef0147120 100644 (file)
@@ -123,10 +123,7 @@ static void smoothModifier_do(
        medges = dm->getEdgeArray(dm);
        numDMEdges = dm->getNumEdges(dm);
 
-       defgrp_index = defgroup_name_index(ob, smd->defgrp_name);
-
-       if (defgrp_index >= 0)
-               dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
+       modifier_get_vgroup(ob, dm, smd->defgrp_name, &dvert, &defgrp_index);
 
        /* NOTICE: this can be optimized a little bit by moving the
        * if (dvert) out of the loop, if needed */
index 1b7b724835cc248c8e7e38d458395cec3e52b40f..390a780e9e6f4d4380875cce1e283f52f4f33977 100644 (file)
@@ -48,6 +48,7 @@
 
 
 #include "MOD_modifiertypes.h"
+#include "MOD_util.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -235,12 +236,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
        float const ofs_new= smd->offset        - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset);
 
        /* weights */
-       MDeformVert *dvert= NULL, *dv= NULL;
+       MDeformVert *dvert, *dv= NULL;
        const int defgrp_invert = ((smd->flag & MOD_SOLIDIFY_VGROUP_INV) != 0);
-       const int defgrp_index= defgroup_name_index(ob, smd->defgrp_name);
+       int defgrp_index;
 
-       if (defgrp_index >= 0)
-               dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
+       modifier_get_vgroup(ob, dm, smd->defgrp_name, &dvert, &defgrp_index);
 
        orig_mface = dm->getFaceArray(dm);
        orig_medge = dm->getEdgeArray(dm);
index 9fe37e2d174a334382603dd28440665eb76651e1..e9b835eab81f25422ca9de14dcc07bb1895ed588 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <string.h>
 
+#include "DNA_lattice_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
 #include "DNA_curve_types.h"
@@ -47,6 +48,8 @@
 #include "BLI_math_matrix.h"
 
 #include "BKE_cdderivedmesh.h"
+#include "BKE_deform.h"
+#include "BKE_lattice.h"
 #include "BKE_mesh.h"
 #include "BKE_displist.h"
 
@@ -239,6 +242,19 @@ DerivedMesh *get_dm(Object *ob, struct EditMesh *em, DerivedMesh *dm, float (*ve
        return dm;
 }
 
+void modifier_get_vgroup(Object *ob, DerivedMesh *dm, const char *name, MDeformVert **dvert, int *defgrp_index)
+{
+       *defgrp_index = defgroup_name_index(ob, name);
+       *dvert = NULL;
+
+       if(*defgrp_index >= 0) {
+               if(ob->type == OB_LATTICE)
+                       *dvert = lattice_get_deform_verts(ob);
+               else if(dm)
+                       *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
+       }
+}
+
 /* only called by BKE_modifier.h/modifier.c */
 void modifier_type_init(ModifierTypeInfo *types[])
 {
index b786240345940e7aa5bbece502e8f0db4760a279..b9b5c8a064a1796749445e3b1750e3fc4018d562 100644 (file)
 /* so modifier types match their defines */
 #include "MOD_modifiertypes.h"
 
-struct Tex;
-struct TexResult;
 struct CustomData;
 struct DerivedMesh;
-struct Object;
-struct Scene;
 struct EditMesh;
+struct MDeformVert;
 struct ModifierData;
+struct Object;
+struct Scene;
+struct Tex;
+struct TexResult;
 
 void get_texture_value(struct Tex *texture, float *tex_co, struct TexResult *texres);
 void get_texture_coords(struct MappingInfoModifierData *dmd, struct Object *ob, struct DerivedMesh *dm, float (*co)[3], float (*texco)[3], int numVerts);
@@ -51,5 +52,6 @@ void modifier_vgroup_cache(struct ModifierData *md, float (*vertexCos)[3]);
 void validate_layer_name(const struct CustomData *data, int type, char *name, char *outname);
 struct DerivedMesh *get_cddm(struct Object *ob, struct EditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3]);
 struct DerivedMesh *get_dm(struct Object *ob, struct EditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3], int orco);
+void modifier_get_vgroup(struct Object *ob, DerivedMesh *dm, const char *name, struct MDeformVert **dvert, int *defgrp_index);
 
 #endif /* MOD_UTIL_H */
index 27add27deb13dc1d4d7ceac3846359ef5ad9efc4..2c77b4862632bd02d1241477b03d2decdf29fd1d 100644 (file)
@@ -85,8 +85,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
        CustomDataMask dataMask = 0;
 
        /* ask for vertexgroups if we need them */
-       if(wmd->defgrp_name[0]) dataMask |= (1 << CD_MDEFORMVERT);
-       dataMask |= (1 << CD_MDEFORMVERT);
+       if(wmd->defgrp_name[0]) dataMask |= (CD_MASK_MDEFORMVERT);
+       dataMask |= (CD_MASK_MDEFORMVERT);
 
        /* ask for UV coordinates if we need them */
        if(wmd->texmapping == MOD_DISP_MAP_UV) dataMask |= (1 << CD_MTFACE);
@@ -174,14 +174,16 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
        float strength = wmd->strength;
        float fac = 1.0f, weight;
        int i;
-       int defgrp_index = defgroup_name_index(ob, wmd->defgrp_name);
-       MDeformVert *dv= NULL;
+       int defgrp_index;
+       MDeformVert *dvert, *dv= NULL;
 
        float (*tex_co)[3]= NULL;
 
        if(!(wmd->object_from && wmd->object_to))
                return;
 
+       modifier_get_vgroup(ob, dm, wmd->defgrp_name, &dvert, &defgrp_index);
+
        if(wmd->curfalloff==NULL) /* should never happen, but bad lib linking could cause it */
                wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
 
@@ -221,8 +223,8 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
                        ((fac=len_v3v3(co, mat_from[3])) < wmd->falloff_radius && (fac=(wmd->falloff_radius-fac)/wmd->falloff_radius)) ) {
 
                        /* skip if no vert group found */
-                       if(defgrp_index >= 0) {
-                               dv = dm->getVertData(dm, i, CD_MDEFORMVERT);
+                       if(dvert && defgrp_index >= 0) {
+                               dv = &dvert[i];
 
                                if(dv) {
                                        weight = defvert_find_weight(dv, defgrp_index) * wmd->strength;
index 6dfe53141316cd7f924697cb8f98dc9a6b0a2830..ca8161fe3642cb302819d555843c94d966214222 100644 (file)
@@ -256,7 +256,7 @@ static void waveModifier_do(WaveModifierData *md,
 {
        WaveModifierData *wmd = (WaveModifierData*) md;
        MVert *mvert = NULL;
-       MDeformVert *dvert = NULL;
+       MDeformVert *dvert;
        int defgrp_index;
        float ctime = BKE_curframe(scene);
        float minfac =
@@ -281,11 +281,7 @@ static void waveModifier_do(WaveModifierData *md,
        }
 
        /* get the index of the deform group */
-       defgrp_index = defgroup_name_index(ob, wmd->defgrp_name);
-
-       if(defgrp_index >= 0){
-               dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
-       }
+       modifier_get_vgroup(ob, dm, wmd->defgrp_name, &dvert, &defgrp_index);
 
        if(wmd->damp == 0) wmd->damp = 10.0f;