- add comments to BKE_DerivedMesh.h about which functions are called in editmode
authorDaniel Dunbar <daniel@zuster.org>
Thu, 21 Jul 2005 21:19:38 +0000 (21:19 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 21 Jul 2005 21:19:38 +0000 (21:19 +0000)
 - gcc warning fixes
 - start work to make CCGDerivedMesh able to run in object mode (hint: more
   speed improvements)
 - fix modifier move down tooltip

source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/src/buttons_object.c

index da7c053bb9cb32b10b861f8b4644ae50293898d4..2fd1eed2a3ea2d4c802b07d0d4d0d7f67fbeea25 100644 (file)
@@ -57,7 +57,9 @@ typedef struct DerivedMesh DerivedMesh;
 struct DerivedMesh {
        /* Misc. Queries */
 
+               /* Also called in Editmode */
        int (*getNumVerts)(DerivedMesh *dm);
+               /* Also called in Editmode */
        int (*getNumFaces)(DerivedMesh *dm);
 
        void (*getMappedVertCoEM)(DerivedMesh *dm, void *vert, float co_r[3]);
@@ -65,7 +67,10 @@ struct DerivedMesh {
                /* Convert to new DispListMesh, should be free'd by caller */
        struct DispListMesh* (*convertToDispListMesh)(DerivedMesh *dm);
 
-               /* Iterate over all vertex points, calling DO_MINMAX with given args */
+               /* Iterate over all vertex points, calling DO_MINMAX with given args.
+                *
+                * Also called in Editmode
+                */
        void (*getMinMax)(DerivedMesh *dm, float min_r[3], float max_r[3]);
 
        /* Direct Access Operations */
@@ -100,6 +105,8 @@ struct DerivedMesh {
                         *  o Set face normal or vertex normal based on inherited face flag
                         *  o Use inherited face material index to call setMaterial
                         *  o Only if setMaterial returns true
+                        *
+                        * Also called in Editmode
                         */
        void (*drawFacesSolid)(DerivedMesh *dm, int (*setMaterial)(int));
 
index 399f2afb6d42bd0359e1ab56d17bfabc188c5854..b58e28603d9ed0bbe6d1ce78b6a83c27f1e0d728 100644 (file)
@@ -1060,7 +1060,7 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedM
                        if (!deformedVerts) {
                                if (dm) {
                                                /* Deforming a derived mesh, read the vertex locations out of the mesh and
-                                                * deform them. Once done with this run of deformers will be written back.
+                                                * deform them. Once done with this run of deformers verts will be written back.
                                                 */
                                        numVerts = dm->getNumVerts(dm);
                                        deformedVerts = MEM_mallocN(sizeof(*deformedVerts)*numVerts, "dfmv");
index 140c4d7482226d2d363b175a8e49d07f6ca7f501..1949915b2aa1dae55d95515c25d08add8c6f5b03 100644 (file)
@@ -66,6 +66,8 @@
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
+#include "BIF_editdeform.h"
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
index 044c79711f816fffc7e75d1ac6ad6bb9bb19cb5e..ad52d58a35f43fd7b601d51599cac5cfca8c71b3 100644 (file)
@@ -103,8 +103,9 @@ static void subsurfModifier_freeData(ModifierData *md)
        }
 }      
 
-static void *subsurfModifier_applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int useRenderParams)
+static void *subsurfModifier_applyModifier(ModifierData *md, Object *ob, void *derivedData, float (*vertexCos)[3], int useRenderParams)
 {
+       DerivedMesh *dm = derivedData;
        SubsurfModifierData *smd = (SubsurfModifierData*) md;
        Mesh *me = ob->data;
 
@@ -145,8 +146,9 @@ static int buildModifier_dependsOnTime(ModifierData *md)
        return 1;
 }
 
-static void *buildModifier_applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int useRenderParams)
+static void *buildModifier_applyModifier(ModifierData *md, Object *ob, void *derivedData, float (*vertexCos)[3], int useRenderParams)
 {
+       DerivedMesh *dm = derivedData;
        BuildModifierData *bmd = (BuildModifierData*) md;
        DispListMesh *dlm=NULL, *ndlm = MEM_callocN(sizeof(*ndlm), "build_dlm");
        MVert *mvert;
@@ -368,8 +370,9 @@ static void mirrorModifier_initData(ModifierData *md)
        mmd->tolerance = 0.001;
 }
 
-static void *mirrorModifier_applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int useRenderParams)
+static void *mirrorModifier_applyModifier(ModifierData *md, Object *ob, void *derivedData, float (*vertexCos)[3], int useRenderParams)
 {
+       DerivedMesh *dm = derivedData;
        MirrorModifierData *mmd = (MirrorModifierData*) md;
        DispListMesh *dlm=NULL, *ndlm = MEM_callocN(sizeof(*dlm), "mm_dlm");
        MVert *mvert;
@@ -470,8 +473,8 @@ static void *mirrorModifier_applyModifier(ModifierData *md, Object *ob, DerivedM
        for (i=0; i<totface; i++) {
                MFace *mf = &ndlm->mface[i];
                MFace *nmf = &ndlm->mface[ndlm->totface];
-               TFace *tf, *ntf;
-               MCol *mc, *nmc;
+               TFace *tf=NULL, *ntf=NULL; /* gcc's mother is uninitialized! */
+               MCol *mc=NULL, *nmc=NULL; /* gcc's mother is uninitialized! */
 
                memcpy(nmf, mf, sizeof(*mf));
                if (tface) {
index 4212efa5af27a037aa583aa1254105b2fa3a4e25..7c5022e3fde2788a8ef819b33af2e5e4a780b5a9 100644 (file)
@@ -573,6 +573,7 @@ typedef struct {
        DerivedMesh dm;
 
        CCGSubSurf *ss;
+       int fromEditmesh;
 } CCGDerivedMesh;
 
 static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) {
@@ -662,11 +663,13 @@ static void ccgDM_drawEdges(DerivedMesh *dm) {
 
        for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) {
                CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
-               EditEdge *eed = ccgSubSurf_getEdgeEdgeHandle(ss, e);
                VertData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
 
-               if (eed->h!=0)
-                       continue;
+               if (ccgdm->fromEditmesh) {
+                       EditEdge *eed = ccgSubSurf_getEdgeEdgeHandle(ss, e);
+                       if (eed->h!=0)
+                               continue;
+               }
 
                if (useAging && !(G.f&G_BACKBUFSEL)) {
                        int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4;
@@ -687,11 +690,13 @@ static void ccgDM_drawEdges(DerivedMesh *dm) {
 
        for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
                CCGFace *f = ccgFaceIterator_getCurrent(fi);
-               EditFace *efa = ccgSubSurf_getFaceFaceHandle(ss, f);
                int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(ss, f);
 
-               if (efa->h!=0)
-                       continue;
+               if (ccgdm->fromEditmesh) {
+                       EditFace *efa = ccgSubSurf_getFaceFaceHandle(ss, f);
+                       if (efa->h!=0)
+                               continue;
+               }
 
                for (S=0; S<numVerts; S++) {
                        VertData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
@@ -770,15 +775,24 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int)) {
 
        for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
                CCGFace *f = ccgFaceIterator_getCurrent(fi);
-               EditFace *efa = ccgSubSurf_getFaceFaceHandle(ss, f);
                int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(ss, f);
-               int isSmooth = efa->flag&ME_SMOOTH;
-
-               if (efa->h!=0)
-                       continue;
+               int isSmooth;
+
+               if (ccgdm->fromEditmesh) {
+                       EditFace *efa = ccgSubSurf_getFaceFaceHandle(ss, f);
+                       isSmooth = efa->flag&ME_SMOOTH;
+                       if (efa->h!=0)
+                               continue;
+                       if (!setMaterial(efa->mat_nr+1))
+                               continue;
+               } else {
+                               // XXX, can't do these correctly, handle info could have been
+                               // free'd if came from a dlm
+                       isSmooth = 0;
+//                     if (!setMaterial(efa->mat_nr+1))
+//                             continue;
+               }
 
-               if (!setMaterial(efa->mat_nr+1))
-                       continue;
 
                glShadeModel(isSmooth?GL_SMOOTH:GL_FLAT);
                for (S=0; S<numVerts; S++) {
@@ -965,7 +979,7 @@ static void ccgDM_release(DerivedMesh *dm) {
        MEM_freeN(ccgdm);
 }
 
-static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss) {
+static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, int fromEditmesh) {
        CCGDerivedMesh *ccgdm = MEM_mallocN(sizeof(*ccgdm), "ccgdm");
 
        ccgdm->dm.getMinMax = ccgDM_getMinMax;
@@ -974,6 +988,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss) {
        ccgdm->dm.getMappedVertCoEM = ccgDM_getMappedVertCoEM;
        ccgdm->dm.convertToDispListMesh = ccgDM_convertToDispListMesh;
 
+       //ccgdm->dm.getVertCos = ccgdm_getVertCos; // XXX fixme
+
        ccgdm->dm.drawVerts = ccgDM_drawVerts;
        ccgdm->dm.drawEdges = ccgDM_drawEdges;
        ccgdm->dm.drawMappedEdges = ccgDM_drawMappedEdges;
@@ -991,6 +1007,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss) {
        ccgdm->dm.release = ccgDM_release;
        
        ccgdm->ss = ss;
+       ccgdm->fromEditmesh = fromEditmesh;
 
        return ccgdm;
 }
@@ -1003,7 +1020,7 @@ DerivedMesh *subsurf_make_derived_from_editmesh(EditMesh *em, SubsurfModifierDat
 
        ss_sync_from_editmesh(ss, em, useSimple);
 
-       return (DerivedMesh*) getCCGDerivedMesh(ss);
+       return (DerivedMesh*) getCCGDerivedMesh(ss, 1);
 }
 
 DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, DispListMesh *dlm, SubsurfModifierData *smd, int useRenderParams, float (*vertCos)[3]) {
@@ -1041,7 +1058,7 @@ DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, DispListMesh *dlm, Subsurf
                } else {
                        ccgSubSurf_free(ss);
                }
-               
+
                return derivedmesh_from_displistmesh(dlm);
        }
 }
index 5333bf1a61d3f24e8096bb84eee40eaeb26c6ccf..e3f9a57ffc2fed8df92423fcb986daabea1eb7c5 100644 (file)
@@ -1831,7 +1831,7 @@ static void object_panel_modifiers(Object *ob)
 
                        but = uiDefBut(block, BUT, B_MAKEDISP, "Move Up", 760, 380, 80, 19, 0, 0, 0, 0, 0, "Move modifier up in stack");
                        uiButSetFunc(but, modifiers_moveUp, ob, md);
-                       but = uiDefBut(block, BUT, B_MAKEDISP, "Move Down", 840, 380, 80, 19, 0, 0, 0, 0, 0, "Move modifier up in stack");
+                       but = uiDefBut(block, BUT, B_MAKEDISP, "Move Down", 840, 380, 80, 19, 0, 0, 0, 0, 0, "Move modifier down in stack");
                        uiButSetFunc(but, modifiers_moveDown, ob, md);
 
                        sprintf(str, "Modifier: %s", mti->name);