[Bf-committers] A question about making a modifier.

Banlu Kemiyatorn object at gmail.com
Sun Sep 28 01:54:41 CEST 2008


Hello, I wonder if this is the right place to ask the question
but I already try to subscribe the web forum several times w/o any success.
/* It keeps saying that I enter wrong value for image verification code */

I try to construct a new face with a modifier.

static DerivedMesh *dummyModifier_applyModifier(
                ModifierData *md, Object *ob, DerivedMesh *derivedData,
  int useRenderParams, int isFinalCalc)
{
        DerivedMesh *result;
        DummyModifierData *emd = (DummyModifierData *) md;
        int maxVerts = derivedData->getNumVerts(derivedData);
        int maxEdges = derivedData->getNumEdges(derivedData);
        int maxFaces = derivedData->getNumFaces(derivedData);
        int a,b;

        DerivedMesh *dm = derivedData;

        if (maxEdges < 1) return dm;


        /* new face will be attached to the first edge so I need more 2
verts, 3 edges and 1 face */
        result = CDDM_from_template(dm, maxVerts + 2, maxEdges + 3, maxFaces
+ 1);

        /* copy existing datas to new mesh */
        DM_copy_vert_data(dm, result, 0, 0, maxVerts);
        DM_copy_edge_data(dm, result, 0, 0, maxEdges);
        DM_copy_face_data(dm, result, 0, 0, maxFaces);

        /* get the verts from the first edge */
        a = CDDM_get_edge(result,0)->v1;
        b = CDDM_get_edge(result,0)->v2;

        /* build 1 face */
        {
                MFace *targetMF;
                targetMF = CDDM_get_face(result, 0);
                targetMF = CDDM_get_face(result, maxFaces);

                targetMF->v1 = a;               targetMF->v2 = b;
                targetMF->v4 = maxVerts + 1;    targetMF->v3 = maxVerts;

                DM_copy_vert_data(result, result, a, maxVerts + 1, 1);
                DM_copy_vert_data(result, result, b, maxVerts, 1);

                targetMF->mat_nr = 0;
                targetMF->edcode = 0;
                targetMF->flag = 0;

                test_index_face(targetMF, &result->faceData, 0, 4);
        }

        /* build 3 edges */
        {
                MEdge *anEdge = CDDM_get_edge(result, maxEdges);
                bzero(anEdge, sizeof(MEdge) * 3);

                anEdge->v1 = a;
                anEdge->v2 = maxVerts + 1;      /* |   */
                anEdge++;
                anEdge->v1 = b;
                anEdge->v2 = maxVerts;          /* | | */
                anEdge++;
                anEdge->v1 = maxVerts;
                anEdge->v2 = maxVerts + 1;      /* |_| */
        }

        return result;

}


The input mesh can be a single edge. The code will crash when I enter edit
mode.
What could be wrong?

#0  0x08295f3f in draw_em_fancy__setFaceOpts ()
#1  0x085145a6 in cdDM_drawMappedFaces ()
#2  0x082a02b5 in draw_em_fancy ()
#3  0x082a1155 in draw_mesh_object ()

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-committers/attachments/20080928/0aec78a1/attachment-0001.htm 


More information about the Bf-committers mailing list