[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42970] branches/bmesh/blender/source/ blender: bmesh mirror modifier cleanup

Daniel Salazar - 3Developer.com zanqdo at gmail.com
Fri Dec 30 00:02:26 CET 2011


Can anything be done so you dont have to create the empty vgroups by hand
or at all?

Daniel Salazar
3Developer.com


On Thu, Dec 29, 2011 at 4:52 PM, Michael Fox <mfoxdogg at gmail.com> wrote:

> NO and is not hacky at all as it does dose Front and back aswell and it
> uses the same function for flipping as  anything else, does, and truth
> be told im not a fan of the vgroup mods as they seem to be too hackish
> On 30/12/11 09:39, Daniel Salazar - 3Developer.com wrote:
> > Currently I see it as very hacky, there arent tools to create the needed
> > mirrored vgroups, the mirror direction is hardcoded and no where to be
> seen
> > on the UI. Maybe this functionality should better go to a vgroup modifier
> > instead
> >
> > cheers
> >
> > Daniel Salazar
> > 3Developer.com
> >
> >
> > On Thu, Dec 29, 2011 at 4:31 PM, Michael Fox<mfoxdogg at gmail.com>  wrote:
> >
> >> Off by default is fine, but removal all together i will not allow, it
> >> has helped me and many other users immensely modelling a symmetrical
> >> object but having each side independently animated, all this does is
> >> mirror weights in vgroup .L to vgroup .R
> >>
> >>
> >> On 30/12/11 09:24, Daniel Salazar - 3Developer.com wrote:
> >>> maybe bmesh is an opportunity to kill vertex group mirroring in vgroup
> >>> modifier or at least have it off by default. I still can't imagine any
> >> real
> >>> use for this
> >>>
> >>> cheers
> >>>
> >>> Daniel Salazar
> >>> 3Developer.com
> >>>
> >>>
> >>> On Thu, Dec 29, 2011 at 3:15 AM, Campbell Barton<ideasman42 at gmail.com
> >>> wrote:
> >>>
> >>>> Revision: 42970
> >>>>
> >>>>
> >>
> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42970
> >>>> Author:   campbellbarton
> >>>> Date:     2011-12-29 09:15:06 +0000 (Thu, 29 Dec 2011)
> >>>> Log Message:
> >>>> -----------
> >>>> bmesh mirror modifier cleanup
> >>>> * vertex map was a dynamicly realloc'd array when the final size was
> >>>> known, use a fixed array instead.
> >>>> * vertex map was being calculated even when not used.
> >>>> * face tesselation was being called twice.
> >>>> * an unused deform group array was being created.
> >>>>
> >>>> Modified Paths:
> >>>> --------------
> >>>>
> >> branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
> >>>>
>  branches/bmesh/blender/source/blender/modifiers/intern/MOD_mirror.c
> >>>>
> >>>> Modified:
> >>>>
> branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
> >>>> ===================================================================
> >>>> ---
> >>>>
> branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
> >>>> 2011-12-29 07:29:44 UTC (rev 42969)
> >>>> +++
> >>>>
> branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
> >>>> 2011-12-29 09:15:06 UTC (rev 42970)
> >>>> @@ -2268,15 +2268,16 @@
> >>>>    }
> >>>>
> >>>>    #if 1
> >>>> -/*merge verts
> >>>> -
> >>>> -  vtargetmap is a table that maps vertices to target vertices.  a
> value
> >>>> of -1
> >>>> -  indicates a vertex is a target, and is to be kept.
> >>>> -
> >>>> -  this frees dm, and returns a new one.
> >>>> -
> >>>> -  this is a really horribly written function.  ger. - joeedh
> >>>> -
> >>>> +/* merge verts
> >>>> + *
> >>>> + * vtargetmap is a table that maps vertices to target vertices.  a
> >> value
> >>>> of -1
> >>>> + * indicates a vertex is a target, and is to be kept.
> >>>> + *
> >>>> + * this frees dm, and returns a new one.
> >>>> + *
> >>>> + * this is a really horribly written function.  ger. - joeedh
> >>>> + *
> >>>> + * note, CDDM_recalc_tesselation has to run on the returned DM if you
> >>>> want to access tessfaces.
> >>>>    */
> >>>>    DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, int *vtargetmap)
> >>>>    {
> >>>> @@ -2437,8 +2438,6 @@
> >>>>          memcpy(cddm2->mloop, mloop,
> >> sizeof(MLoop)*BLI_array_count(mloop));
> >>>>          memcpy(cddm2->mpoly, mpoly,
> >> sizeof(MPoly)*BLI_array_count(mpoly));
> >>>>          BLI_array_free(mvert); BLI_array_free(medge);
> >>>> BLI_array_free(mloop); BLI_array_free(mpoly);
> >>>> -
> >>>> -       CDDM_recalc_tesselation((DerivedMesh*)cddm2);
> >>>>
> >>>>          if (newv)
> >>>>                  MEM_freeN(newv);
> >>>>
> >>>> Modified:
> >>>> branches/bmesh/blender/source/blender/modifiers/intern/MOD_mirror.c
> >>>> ===================================================================
> >>>> ---
> branches/bmesh/blender/source/blender/modifiers/intern/MOD_mirror.c
> >>>> 2011-12-29 07:29:44 UTC (rev 42969)
> >>>> +++
> branches/bmesh/blender/source/blender/modifiers/intern/MOD_mirror.c
> >>>> 2011-12-29 09:15:06 UTC (rev 42970)
> >>>> @@ -100,37 +100,22 @@
> >>>>    {
> >>>>          float tolerance_sq;
> >>>>          DerivedMesh *cddm, *origdm;
> >>>> -       bDeformGroup *def;
> >>>> -       bDeformGroup **vector_def = NULL;
> >>>>          MVert *mv, *ov;
> >>>>          MEdge *me;
> >>>>          MLoop *ml;
> >>>>          MPoly *mp;
> >>>>          float mtx[4][4];
> >>>> -       int i, j, *vtargetmap = NULL;
> >>>> -       BLI_array_declare(vtargetmap);
> >>>> -       int vector_size=0, a, totshape;
> >>>> +       int i, j;
> >>>> +       int a, totshape;
> >>>> +       int *vtargetmap, *vtmap_a, *vtmap_b;
> >>>> +       const int do_vtargetmap = !(mmd->flag&   MOD_MIR_NO_MERGE);
> >>>>
> >>>>          tolerance_sq = mmd->tolerance * mmd->tolerance;
> >>>>
> >>>>          origdm = dm;
> >>>>          if (!CDDM_Check(dm))
> >>>>                  dm = CDDM_copy(dm, 0);
> >>>> -
> >>>> -       if (mmd->flag&   MOD_MIR_VGROUP) {
> >>>> -               /* calculate the number of deformedGroups */
> >>>> -               for(vector_size = 0, def = ob->defbase.first; def;
> >>>> -                       def = def->next, vector_size++);
> >>>>
> >>>> -               /* load the deformedGroups for fast access */
> >>>> -               vector_def =
> >>>> -                       (bDeformGroup
> >> **)MEM_mallocN(sizeof(bDeformGroup*)
> >>>> * vector_size,
> >>>> -
> >>>>          "group_index");
> >>>> -               for(a = 0, def = ob->defbase.first; def; def =
> >> def->next,
> >>>> a++) {
> >>>> -                       vector_def[a] = def;
> >>>> -               }
> >>>> -       }
> >>>> -
> >>>>          /*mtx is the mirror transformation*/
> >>>>          unit_m4(mtx);
> >>>>          mtx[axis][axis] = -1.0;
> >>>> @@ -166,20 +151,30 @@
> >>>>          CustomData_copy_data(&dm->vertData,&cddm->vertData, 0,
> >>>> dm->numVertData, dm->numVertData);
> >>>>          CustomData_copy_data(&dm->edgeData,&cddm->edgeData, 0,
> >>>> dm->numEdgeData, dm->numEdgeData);
> >>>>          CustomData_copy_data(&dm->polyData,&cddm->polyData, 0,
> >>>> dm->numPolyData, dm->numPolyData);
> >>>> -
> >>>> +
> >>>> +       if (do_vtargetmap) {
> >>>> +               /* second half is filled with -1 */
> >>>> +               vtargetmap = MEM_mallocN(sizeof(int) *
> dm->numVertData *
> >>>> 2, "MOD_mirror tarmap");
> >>>> +
> >>>> +               vtmap_a = vtargetmap;
> >>>> +               vtmap_b = vtargetmap + dm->numVertData;
> >>>> +       }
> >>>> +
> >>>>          /*mirror vertex coordinates*/
> >>>>          ov = CDDM_get_verts(cddm);
> >>>>          mv = ov + dm->numVertData;
> >>>>          for (i=0; i<dm->numVertData; i++, mv++, ov++) {
> >>>>                  mul_m4_v3(mtx, mv->co);
> >>>> -               /*compare location of the original and mirrored
> vertex,
> >> to
> >>>> see if they
> >>>> -                 should be mapped for merging*/
> >>>> -               if (len_squared_v3v3(ov->co, mv->co)<   tolerance_sq)
> {
> >>>> -                       BLI_array_append(vtargetmap,
> i+dm->numVertData);
> >>>> +
> >>>> +               if (do_vtargetmap) {
> >>>> +                       /* compare location of the original and
> mirrored
> >>>> vertex, to see if they
> >>>> +                        * should be mapped for merging */
> >>>> +                       *vtmap_a = (len_squared_v3v3(ov->co, mv->co)<
> >>>> tolerance_sq) ? dm->numVertData + i : -1;
> >>>> +                       *vtmap_b = -1; /* fill here to avoid 2x loops
> */
> >>>> +
> >>>> +                       vtmap_a++;
> >>>> +                       vtmap_b++;
> >>>>                  }
> >>>> -               else {
> >>>> -                       BLI_array_append(vtargetmap, -1);
> >>>> -               }
> >>>>          }
> >>>>
> >>>>          /*handle shape keys*/
> >>>> @@ -191,10 +186,6 @@
> >>>>                  }
> >>>>          }
> >>>>
> >>>> -       for (i=0; i<dm->numVertData; i++) {
> >>>> -               BLI_array_append(vtargetmap, -1);
> >>>> -       }
> >>>> -
> >>>>          /*adjust mirrored edge vertex indices*/
> >>>>          me = CDDM_get_edges(cddm) + dm->numEdgeData;
> >>>>          for (i=0; i<dm->numEdgeData; i++, me++) {
> >>>> @@ -250,8 +241,6 @@
> >>>>                  }
> >>>>          }
> >>>>
> >>>> -       CDDM_recalc_tesselation(cddm);
> >>>> -
> >>>>          /*handle vgroup stuff*/
> >>>>          if ((mmd->flag&   MOD_MIR_VGROUP)&&
> >>>> CustomData_has_layer(&cddm->vertData, CD_MDEFORMVERT)) {
> >>>>                  MDeformVert *dvert =
> >> CustomData_get_layer(&cddm->vertData,
> >>>> CD_MDEFORMVERT);
> >>>> @@ -259,18 +248,19 @@
> >>>>
> >>>>                  flip_map= defgroup_flip_map(ob,&flip_map_len, FALSE);
> >>>>
> >>>> -               for (i=0; i<dm->numVertData; i++, dvert++) {
> >>>> +               for (i = dm->numVertData; i-->   0; dvert++) {
> >>>>                          defvert_flip(dvert, flip_map, flip_map_len);
> >>>>                  }
> >>>>          }
> >>>> -
> >>>> -       if (!(mmd->flag&   MOD_MIR_NO_MERGE))
> >>>> +
> >>>> +       if (do_vtargetmap) {
> >>>> +               /* this calls CDDM_recalc_tesselation, so dont do
> twice
> >> */
> >>>>                  cddm = CDDM_merge_verts(cddm, vtargetmap);
> >>>> +               MEM_freeN(vtargetmap);
> >>>> +       }
> >>>> +
> >>>> +       CDDM_recalc_tesselation(cddm);
> >>>>
> >>>> -       BLI_array_free(vtargetmap);
> >>>> -
> >>>> -       if (vector_def) MEM_freeN(vector_def);
> >>>> -
> >>>>          if (dm != origdm) {
> >>>>                  dm->needsFree = 1;
> >>>>                  dm->release(dm);
> >>>>
> >>>> _______________________________________________
> >>>> Bf-blender-cvs mailing list
> >>>> Bf-blender-cvs at blender.org
> >>>> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
> >>>>
> >>> _______________________________________________
> >>> Bf-committers mailing list
> >>> Bf-committers at blender.org
> >>> http://lists.blender.org/mailman/listinfo/bf-committers
> >>>
> >> _______________________________________________
> >> Bf-committers mailing list
> >> Bf-committers at blender.org
> >> http://lists.blender.org/mailman/listinfo/bf-committers
> >>
> > _______________________________________________
> > Bf-committers mailing list
> > Bf-committers at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-committers
> >
>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>


More information about the Bf-committers mailing list