2009-05-16 16:18:08 +00:00
|
|
|
/**
|
|
|
|
|
* $Id: editderivedbmesh.c 18571 2009-01-19 06:04:57Z joeedh $
|
|
|
|
|
*
|
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 59 Tbmple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "PIL_time.h"
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_effect_types.h"
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_key_types.h"
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
#include "DNA_modifier_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_object_force.h"
|
|
|
|
|
#include "DNA_object_fluidsim.h" // N_T
|
|
|
|
|
#include "DNA_scene_types.h" // N_T
|
|
|
|
|
#include "DNA_texture_types.h"
|
|
|
|
|
#include "DNA_view3d_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
|
#include "DNA_particle_types.h"
|
|
|
|
|
|
2011-05-09 04:06:48 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-11-23 14:41:22 +00:00
|
|
|
#include "BLI_math.h"
|
2009-05-16 16:18:08 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_editVert.h"
|
|
|
|
|
#include "BLI_edgehash.h"
|
|
|
|
|
#include "BLI_linklist.h"
|
|
|
|
|
#include "BLI_memarena.h"
|
2009-05-23 16:53:03 +00:00
|
|
|
#include "BLI_scanfill.h"
|
2009-06-23 05:35:49 +00:00
|
|
|
#include "BLI_ghash.h"
|
2009-09-17 23:05:33 +00:00
|
|
|
#include "BLI_array.h"
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
#include "BKE_cdderivedmesh.h"
|
|
|
|
|
#include "BKE_customdata.h"
|
|
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
|
#include "BKE_deform.h"
|
|
|
|
|
#include "BKE_displist.h"
|
|
|
|
|
#include "BKE_effect.h"
|
|
|
|
|
#include "BKE_fluidsim.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_key.h"
|
|
|
|
|
#include "BKE_material.h"
|
|
|
|
|
#include "BKE_modifier.h"
|
|
|
|
|
#include "BKE_mesh.h"
|
|
|
|
|
#include "BKE_object.h"
|
|
|
|
|
#include "BKE_subsurf.h"
|
|
|
|
|
#include "BKE_texture.h"
|
|
|
|
|
#include "BKE_particle.h"
|
|
|
|
|
#include "BKE_tessmesh.h"
|
|
|
|
|
|
|
|
|
|
#include "BLO_sys_types.h" // for intptr_t support
|
|
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
|
|
|
|
#include "GPU_draw.h"
|
|
|
|
|
#include "GPU_extensions.h"
|
|
|
|
|
#include "GPU_material.h"
|
|
|
|
|
|
|
|
|
|
#include "bmesh.h"
|
|
|
|
|
|
2009-05-26 04:17:47 +00:00
|
|
|
BMEditMesh *BMEdit_Create(BMesh *bm)
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
2009-05-18 08:46:04 +00:00
|
|
|
BMEditMesh *tm = MEM_callocN(sizeof(BMEditMesh), "tm");
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
tm->bm = bm;
|
|
|
|
|
|
2009-05-26 04:17:47 +00:00
|
|
|
BMEdit_RecalcTesselation(tm);
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
return tm;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-26 04:17:47 +00:00
|
|
|
BMEditMesh *BMEdit_Copy(BMEditMesh *tm)
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
2009-05-18 14:55:34 +00:00
|
|
|
BMEditMesh *tm2 = MEM_callocN(sizeof(BMEditMesh), "tm2");
|
2009-05-16 16:18:08 +00:00
|
|
|
*tm2 = *tm;
|
2009-05-18 14:55:34 +00:00
|
|
|
|
|
|
|
|
tm2->derivedCage = tm2->derivedFinal = NULL;
|
2009-05-19 00:33:54 +00:00
|
|
|
|
|
|
|
|
tm2->looptris = NULL;
|
2009-05-16 16:18:08 +00:00
|
|
|
tm2->bm = BM_Copy_Mesh(tm->bm);
|
2009-05-26 04:17:47 +00:00
|
|
|
BMEdit_RecalcTesselation(tm2);
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2009-05-23 16:53:03 +00:00
|
|
|
tm2->vert_index = NULL;
|
|
|
|
|
tm2->edge_index = NULL;
|
|
|
|
|
tm2->face_index = NULL;
|
2009-05-19 00:33:54 +00:00
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
return tm2;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
static void BMEdit_RecalcTesselation_intern(BMEditMesh *tm)
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
|
|
|
|
BMesh *bm = tm->bm;
|
|
|
|
|
BMLoop **looptris = NULL;
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_declare(looptris);
|
2009-05-16 16:18:08 +00:00
|
|
|
BMIter iter, liter;
|
|
|
|
|
BMFace *f;
|
|
|
|
|
BMLoop *l;
|
2010-07-19 04:44:37 +00:00
|
|
|
int i = 0, j;
|
2009-05-19 00:33:54 +00:00
|
|
|
|
|
|
|
|
if (tm->looptris) MEM_freeN(tm->looptris);
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2009-09-10 01:46:52 +00:00
|
|
|
#if 0 //simple quad/triangle code for performance testing purposes
|
|
|
|
|
looptris = MEM_callocN(sizeof(void*)*bm->totface*8, "looptris");
|
|
|
|
|
|
|
|
|
|
f = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL);
|
|
|
|
|
for ( ; f; f=BMIter_Step(&iter)) {
|
|
|
|
|
EditVert *v, *lastv=NULL, *firstv=NULL;
|
|
|
|
|
EditEdge *e;
|
|
|
|
|
EditFace *efa;
|
|
|
|
|
|
|
|
|
|
/*don't consider two-edged faces*/
|
|
|
|
|
if (f->len < 3) continue;
|
|
|
|
|
|
2009-09-17 23:05:33 +00:00
|
|
|
//BLI_array_growone(looptris);
|
|
|
|
|
//BLI_array_growone(looptris);
|
|
|
|
|
//BLI_array_growone(looptris);
|
2009-09-10 01:46:52 +00:00
|
|
|
|
|
|
|
|
looptris[i*3] = f->loopbase;
|
|
|
|
|
looptris[i*3+1] = f->loopbase->head.next;
|
|
|
|
|
looptris[i*3+2] = f->loopbase->head.next->next;
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
if (f->len > 3) {
|
2009-09-17 23:05:33 +00:00
|
|
|
//BLI_array_growone(looptris);
|
|
|
|
|
//BLI_array_growone(looptris);
|
|
|
|
|
//BLI_array_growone(looptris);
|
2009-09-10 01:46:52 +00:00
|
|
|
|
|
|
|
|
looptris[i*3] = f->loopbase;
|
|
|
|
|
looptris[i*3+1] = f->loopbase->head.next->next;
|
|
|
|
|
looptris[i*3+2] = f->loopbase->head.next->next->next;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tm->tottri = i;
|
|
|
|
|
tm->looptris = looptris;
|
|
|
|
|
return;
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
f = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL);
|
|
|
|
|
for ( ; f; f=BMIter_Step(&iter)) {
|
2009-07-26 13:12:55 +00:00
|
|
|
EditVert *v, *lastv=NULL, *firstv=NULL;
|
|
|
|
|
EditEdge *e;
|
|
|
|
|
EditFace *efa;
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
/*don't consider two-edged faces*/
|
|
|
|
|
if (f->len < 3) continue;
|
|
|
|
|
|
2011-04-16 23:58:49 +00:00
|
|
|
BLI_begin_edgefill();
|
2009-07-26 13:12:55 +00:00
|
|
|
/*scanfill time*/
|
|
|
|
|
l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f);
|
|
|
|
|
for (j=0; l; l=BMIter_Step(&liter), j++) {
|
|
|
|
|
/*mark order*/
|
2010-07-14 22:06:10 +00:00
|
|
|
l->_index = j;
|
2009-07-26 13:12:55 +00:00
|
|
|
|
|
|
|
|
v = BLI_addfillvert(l->v->co);
|
|
|
|
|
v->tmp.p = l;
|
|
|
|
|
|
|
|
|
|
if (lastv) {
|
|
|
|
|
e = BLI_addfilledge(lastv, v);
|
2009-05-23 16:53:03 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-26 13:12:55 +00:00
|
|
|
lastv = v;
|
|
|
|
|
if (firstv==NULL) firstv = v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*complete the loop*/
|
|
|
|
|
BLI_addfilledge(firstv, v);
|
|
|
|
|
|
2011-04-11 01:38:20 +00:00
|
|
|
BLI_edgefill(2);
|
2009-07-26 13:12:55 +00:00
|
|
|
|
|
|
|
|
for (efa = fillfacebase.first; efa; efa=efa->next) {
|
|
|
|
|
BMLoop *l1, *l2, *l3;
|
2009-05-23 16:53:03 +00:00
|
|
|
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_growone(looptris);
|
|
|
|
|
BLI_array_growone(looptris);
|
|
|
|
|
BLI_array_growone(looptris);
|
2009-05-23 16:53:03 +00:00
|
|
|
|
2009-07-26 13:12:55 +00:00
|
|
|
looptris[i*3] = l1 = efa->v1->tmp.p;
|
|
|
|
|
looptris[i*3+1] = l2 = efa->v2->tmp.p;
|
|
|
|
|
looptris[i*3+2] = l3 = efa->v3->tmp.p;
|
|
|
|
|
|
2010-07-14 22:06:10 +00:00
|
|
|
if (l1->_index > l2->_index) {
|
2009-07-26 13:12:55 +00:00
|
|
|
SWAP(BMLoop*, l1, l2);
|
|
|
|
|
}
|
2010-07-14 22:06:10 +00:00
|
|
|
if (l2->_index > l3->_index) {
|
2009-07-26 13:12:55 +00:00
|
|
|
SWAP(BMLoop*, l2, l3);
|
|
|
|
|
}
|
2010-07-14 22:06:10 +00:00
|
|
|
if (l1->_index > l2->_index) {
|
2009-07-26 13:12:55 +00:00
|
|
|
SWAP(BMLoop*, l1, l2);
|
2009-05-23 16:53:03 +00:00
|
|
|
}
|
2009-07-26 13:12:55 +00:00
|
|
|
|
|
|
|
|
looptris[i*3] = l1;
|
|
|
|
|
looptris[i*3+1] = l2;
|
|
|
|
|
looptris[i*3+2] = l3;
|
|
|
|
|
|
|
|
|
|
i += 1;
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
2009-07-26 13:12:55 +00:00
|
|
|
|
|
|
|
|
BLI_end_edgefill();
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tm->tottri = i;
|
2011-05-10 23:48:09 +00:00
|
|
|
tm->looptris = (BMLoop *(*)[3])looptris;
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
void BMEdit_RecalcTesselation(BMEditMesh *tm)
|
|
|
|
|
{
|
|
|
|
|
BMEdit_RecalcTesselation_intern(tm);
|
|
|
|
|
|
|
|
|
|
if (tm->derivedFinal && tm->derivedFinal == tm->derivedCage) {
|
|
|
|
|
if (tm->derivedFinal->recalcTesselation)
|
|
|
|
|
tm->derivedFinal->recalcTesselation(tm->derivedFinal);
|
|
|
|
|
} else if (tm->derivedFinal) {
|
|
|
|
|
if (tm->derivedCage->recalcTesselation)
|
|
|
|
|
tm->derivedCage->recalcTesselation(tm->derivedCage);
|
|
|
|
|
if (tm->derivedFinal->recalcTesselation)
|
|
|
|
|
tm->derivedFinal->recalcTesselation(tm->derivedFinal);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-30 21:30:07 +00:00
|
|
|
void BMEdit_UpdateLinkedCustomData(BMEditMesh *em)
|
|
|
|
|
{
|
|
|
|
|
BMesh *bm = em->bm;
|
|
|
|
|
int act;
|
|
|
|
|
|
|
|
|
|
if (CustomData_has_layer(&bm->pdata, CD_MTEXPOLY)) {
|
|
|
|
|
act = CustomData_get_active_layer(&bm->pdata, CD_MTEXPOLY);
|
|
|
|
|
CustomData_set_layer_active(&bm->ldata, CD_MLOOPUV, act);
|
|
|
|
|
|
|
|
|
|
act = CustomData_get_render_layer(&bm->pdata, CD_MTEXPOLY);
|
|
|
|
|
CustomData_set_layer_render(&bm->ldata, CD_MLOOPUV, act);
|
|
|
|
|
|
|
|
|
|
act = CustomData_get_clone_layer(&bm->pdata, CD_MTEXPOLY);
|
|
|
|
|
CustomData_set_layer_clone(&bm->ldata, CD_MLOOPUV, act);
|
|
|
|
|
|
2010-01-05 22:33:41 +00:00
|
|
|
act = CustomData_get_stencil_layer(&bm->pdata, CD_MTEXPOLY);
|
|
|
|
|
CustomData_set_layer_stencil(&bm->ldata, CD_MLOOPUV, act);
|
2009-08-30 21:30:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-18 08:46:04 +00:00
|
|
|
/*does not free the BMEditMesh struct itself*/
|
2009-05-26 04:17:47 +00:00
|
|
|
void BMEdit_Free(BMEditMesh *em)
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
|
|
|
|
if(em->derivedFinal) {
|
|
|
|
|
if (em->derivedFinal!=em->derivedCage) {
|
|
|
|
|
em->derivedFinal->needsFree= 1;
|
|
|
|
|
em->derivedFinal->release(em->derivedFinal);
|
|
|
|
|
}
|
|
|
|
|
em->derivedFinal= NULL;
|
|
|
|
|
}
|
|
|
|
|
if(em->derivedCage) {
|
|
|
|
|
em->derivedCage->needsFree= 1;
|
|
|
|
|
em->derivedCage->release(em->derivedCage);
|
|
|
|
|
em->derivedCage= NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
em->retopo_paint_data= NULL;
|
|
|
|
|
|
|
|
|
|
if (em->looptris) MEM_freeN(em->looptris);
|
2009-05-18 15:53:30 +00:00
|
|
|
|
|
|
|
|
if (em->vert_index) MEM_freeN(em->vert_index);
|
|
|
|
|
if (em->edge_index) MEM_freeN(em->edge_index);
|
|
|
|
|
if (em->face_index) MEM_freeN(em->face_index);
|
2009-05-26 04:17:47 +00:00
|
|
|
|
2011-03-29 05:48:18 +00:00
|
|
|
if (em->bm)
|
|
|
|
|
BM_Free_Mesh(em->bm);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ok, basic design:
|
|
|
|
|
|
|
|
|
|
the bmesh derivedmesh exposes the mesh as triangles. it stores pointers
|
|
|
|
|
to three loops per triangle. the derivedmesh stores a cache of tesselations
|
|
|
|
|
for each face. this cache will smartly update as needed (though at first
|
|
|
|
|
it'll simply be more brute force). keeping track of face/edge counts may
|
|
|
|
|
be a small problbm.
|
|
|
|
|
|
|
|
|
|
this won't be the most efficient thing, considering that internal edges and
|
|
|
|
|
faces of tesselations are exposed. looking up an edge by index in particular
|
|
|
|
|
is likely to be a little slow.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
typedef struct EditDerivedBMesh {
|
|
|
|
|
DerivedMesh dm;
|
|
|
|
|
|
|
|
|
|
Object *ob;
|
2009-05-18 08:46:04 +00:00
|
|
|
BMEditMesh *tc;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
float (*vertexCos)[3];
|
|
|
|
|
float (*vertexNos)[3];
|
|
|
|
|
float (*faceNos)[3];
|
2009-06-23 05:35:49 +00:00
|
|
|
|
|
|
|
|
/*lookup caches; these are rebuilt on dm->RecalcTesselation()
|
|
|
|
|
(or when the derivedmesh is created, of course)*/
|
|
|
|
|
GHash *vhash, *ehash, *fhash;
|
|
|
|
|
BMVert **vtable;
|
|
|
|
|
BMEdge **etable;
|
|
|
|
|
BMFace **ftable;
|
|
|
|
|
|
|
|
|
|
/*private variables, for number of verts/edges/faces
|
|
|
|
|
within the above hash/table members*/
|
|
|
|
|
int tv, te, tf;
|
2009-05-16 16:18:08 +00:00
|
|
|
} EditDerivedBMesh;
|
|
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
static void bmdm_recalc_lookups(EditDerivedBMesh *bmdm)
|
|
|
|
|
{
|
|
|
|
|
BMIter iter;
|
|
|
|
|
BMHeader *h;
|
|
|
|
|
int a, i, iters[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, BM_FACES_OF_MESH};
|
|
|
|
|
|
|
|
|
|
bmdm->tv = bmdm->tc->bm->totvert;
|
|
|
|
|
bmdm->te = bmdm->tc->bm->totedge;
|
|
|
|
|
bmdm->tf = bmdm->tc->bm->totface;
|
|
|
|
|
|
|
|
|
|
if (bmdm->vhash) BLI_ghash_free(bmdm->vhash, NULL, NULL);
|
|
|
|
|
if (bmdm->ehash) BLI_ghash_free(bmdm->ehash, NULL, NULL);
|
|
|
|
|
if (bmdm->fhash) BLI_ghash_free(bmdm->fhash, NULL, NULL);
|
|
|
|
|
|
2010-07-19 04:44:37 +00:00
|
|
|
bmdm->vhash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh derived");
|
|
|
|
|
bmdm->ehash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh derived");
|
|
|
|
|
bmdm->fhash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh derived");
|
2009-06-23 05:35:49 +00:00
|
|
|
|
|
|
|
|
if (bmdm->vtable) MEM_freeN(bmdm->vtable);
|
|
|
|
|
if (bmdm->etable) MEM_freeN(bmdm->etable);
|
|
|
|
|
if (bmdm->ftable) MEM_freeN(bmdm->ftable);
|
|
|
|
|
|
2009-07-14 06:13:43 +00:00
|
|
|
if (bmdm->tc->bm->totvert)
|
|
|
|
|
bmdm->vtable = MEM_mallocN(sizeof(void**)*bmdm->tc->bm->totvert, "bmdm->vtable");
|
|
|
|
|
else bmdm->vtable = NULL;
|
|
|
|
|
|
|
|
|
|
if (bmdm->tc->bm->totedge)
|
|
|
|
|
bmdm->etable = MEM_mallocN(sizeof(void**)*bmdm->tc->bm->totedge, "bmdm->etable");
|
|
|
|
|
else bmdm->etable = NULL;
|
|
|
|
|
|
|
|
|
|
if (bmdm->tc->bm->totface)
|
|
|
|
|
bmdm->ftable = MEM_mallocN(sizeof(void**)*bmdm->tc->bm->totface, "bmdm->ftable");
|
|
|
|
|
else bmdm->ftable = NULL;
|
2009-06-23 05:35:49 +00:00
|
|
|
|
|
|
|
|
for (a=0; a<3; a++) {
|
|
|
|
|
h = BMIter_New(&iter, bmdm->tc->bm, iters[a], NULL);
|
|
|
|
|
for (i=0; h; h=BMIter_Step(&iter), i++) {
|
|
|
|
|
switch (a) {
|
|
|
|
|
case 0:
|
|
|
|
|
bmdm->vtable[i] = (BMVert*) h;
|
|
|
|
|
BLI_ghash_insert(bmdm->vhash, h, SET_INT_IN_POINTER(i));
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
bmdm->etable[i] = (BMEdge*) h;
|
|
|
|
|
BLI_ghash_insert(bmdm->ehash, h, SET_INT_IN_POINTER(i));
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
bmdm->ftable[i] = (BMFace*) h;
|
|
|
|
|
BLI_ghash_insert(bmdm->fhash, h, SET_INT_IN_POINTER(i));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-09 14:32:55 +00:00
|
|
|
static void bmDM_recalcTesselation(DerivedMesh *UNUSED(dm))
|
2009-06-23 05:35:49 +00:00
|
|
|
{
|
2010-07-19 04:44:37 +00:00
|
|
|
//EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
2009-06-23 05:35:49 +00:00
|
|
|
|
2009-09-10 01:46:52 +00:00
|
|
|
//bmdm_recalc_lookups(bmdm);
|
2009-06-23 05:35:49 +00:00
|
|
|
}
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
static void bmDM_foreachMappedVert(DerivedMesh *dm, void (*func)(void *userData, int index, float *co, float *no_f, short *no_s), void *userData)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
BMVert *eve;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
eve = BMIter_New(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL);
|
|
|
|
|
for (i=0; eve; i++, eve=BMIter_Step(&iter)) {
|
|
|
|
|
if (bmdm->vertexCos) {
|
|
|
|
|
func(userData, i, bmdm->vertexCos[i], bmdm->vertexNos[i], NULL);
|
|
|
|
|
} else {
|
|
|
|
|
func(userData, i, eve->co, eve->no, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
static void bmDM_foreachMappedEdge(DerivedMesh *dm, void (*func)(void *userData, int index, float *v0co, float *v1co), void *userData)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
BMEdge *eed;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (bmdm->vertexCos) {
|
|
|
|
|
BMVert *eve;
|
|
|
|
|
BMIter viter;
|
|
|
|
|
|
|
|
|
|
eve = BMIter_New(&viter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL);
|
|
|
|
|
for (i=0; eve; eve=BMIter_Step(&viter), i++) {
|
|
|
|
|
BMINDEX_SET(eve, i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eed = BMIter_New(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL);
|
|
|
|
|
for(i=0; eed; i++,eed=BMIter_Step(&iter))
|
|
|
|
|
func(userData, i,
|
2011-03-31 00:52:12 +00:00
|
|
|
bmdm->vertexCos[BMINDEX_GET(eed->v1)],
|
|
|
|
|
bmdm->vertexCos[BMINDEX_GET(eed->v2)]);
|
2009-05-16 16:18:08 +00:00
|
|
|
} else {
|
|
|
|
|
eed = BMIter_New(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL);
|
|
|
|
|
for(i=0; eed; i++,eed=BMIter_Step(&iter))
|
|
|
|
|
func(userData, i, eed->v1->co, eed->v2->co);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
BMEdge *eed;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (bmdm->vertexCos) {
|
|
|
|
|
BMVert *eve;
|
|
|
|
|
BMIter viter;
|
|
|
|
|
|
|
|
|
|
eve = BMIter_New(&viter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL);
|
2009-07-24 10:43:58 +00:00
|
|
|
for (i=0; eve; eve=BMIter_Step(&viter), i++) {
|
2009-05-16 16:18:08 +00:00
|
|
|
BMINDEX_SET(eve, i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
eed = BMIter_New(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL);
|
|
|
|
|
for(i=0; eed; i++,eed=BMIter_Step(&iter)) {
|
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, i)) {
|
|
|
|
|
glVertex3fv(bmdm->vertexCos[BMINDEX_GET(eed->v1)]);
|
|
|
|
|
glVertex3fv(bmdm->vertexCos[BMINDEX_GET(eed->v2)]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
eed = BMIter_New(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL);
|
|
|
|
|
for(i=0; eed; i++,eed=BMIter_Step(&iter)) {
|
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, i)) {
|
|
|
|
|
glVertex3fv(eed->v1->co);
|
|
|
|
|
glVertex3fv(eed->v2->co);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-09 14:32:55 +00:00
|
|
|
static void bmDM_drawEdges(DerivedMesh *dm, int UNUSED(drawLooseEdges), int UNUSED(drawAllEdges))
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
|
|
|
|
bmDM_drawMappedEdges(dm, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_drawMappedEdgesInterp(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void (*setDrawInterpOptions)(void *userData, int index, float t), void *userData)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
BMEdge *eed;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (bmdm->vertexCos) {
|
|
|
|
|
BMVert *eve;
|
|
|
|
|
|
|
|
|
|
eve = BMIter_New(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL);
|
|
|
|
|
for (i=0; eve; eve=BMIter_Step(&iter), i++)
|
|
|
|
|
BMINDEX_SET(eve, i);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
eed = BMIter_New(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL);
|
|
|
|
|
for(i=0; eed; i++,eed=BMIter_Step(&iter)) {
|
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, i)) {
|
|
|
|
|
setDrawInterpOptions(userData, i, 0.0);
|
|
|
|
|
glVertex3fv(bmdm->vertexCos[(int) BMINDEX_GET(eed->v1)]);
|
|
|
|
|
setDrawInterpOptions(userData, i, 1.0);
|
|
|
|
|
glVertex3fv(bmdm->vertexCos[(int) BMINDEX_GET(eed->v2)]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
} else {
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
eed = BMIter_New(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL);
|
|
|
|
|
for(i=0; eed; i++,eed=BMIter_Step(&iter)) {
|
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, i)) {
|
|
|
|
|
setDrawInterpOptions(userData, i, 0.0);
|
|
|
|
|
glVertex3fv(eed->v1->co);
|
|
|
|
|
setDrawInterpOptions(userData, i, 1.0);
|
|
|
|
|
glVertex3fv(eed->v2->co);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_drawUVEdges(DerivedMesh *dm)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
2011-02-27 06:19:40 +00:00
|
|
|
BMEditMesh *em = bmdm->tc;
|
2009-05-16 16:18:08 +00:00
|
|
|
BMFace *efa;
|
2011-02-27 06:19:40 +00:00
|
|
|
BMIter iter;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
2011-02-27 06:19:40 +00:00
|
|
|
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
|
|
|
|
|
BMIter liter;
|
|
|
|
|
BMLoop *l;
|
|
|
|
|
MLoopUV *lastluv = NULL, *firstluv = NULL;
|
|
|
|
|
|
|
|
|
|
if (BM_TestHFlag(efa, BM_HIDDEN))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
|
|
|
|
|
MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
|
|
|
|
|
|
|
|
|
|
if (luv) {
|
|
|
|
|
if (lastluv)
|
|
|
|
|
glVertex2fv(luv->uv);
|
|
|
|
|
glVertex2fv(luv->uv);
|
|
|
|
|
|
|
|
|
|
lastluv = luv;
|
|
|
|
|
if (!firstluv)
|
|
|
|
|
firstluv = luv;
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-02-27 06:19:40 +00:00
|
|
|
|
|
|
|
|
if (lastluv) {
|
|
|
|
|
glVertex2fv(lastluv->uv);
|
|
|
|
|
glVertex2fv(firstluv->uv);
|
|
|
|
|
}
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-27 06:19:40 +00:00
|
|
|
static void bmDM__calcFaceCent(BMesh *bm, BMFace *efa, float cent[3],
|
|
|
|
|
float (*vertexCos)[3])
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
|
|
|
|
BMIter iter;
|
|
|
|
|
BMLoop *l;
|
|
|
|
|
int tot = 0;
|
|
|
|
|
|
|
|
|
|
cent[0] = cent[1] = cent[2] = 0.0f;
|
|
|
|
|
|
|
|
|
|
/*simple (and stupid) median (average) based method :/ */
|
2009-07-24 10:43:58 +00:00
|
|
|
|
|
|
|
|
if (vertexCos) {
|
|
|
|
|
l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, efa);
|
|
|
|
|
for (; l; l=BMIter_Step(&iter)) {
|
|
|
|
|
VECADD(cent, cent, vertexCos[BMINDEX_GET(l->v)]);
|
|
|
|
|
tot++;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, efa);
|
|
|
|
|
for (; l; l=BMIter_Step(&iter)) {
|
|
|
|
|
VECADD(cent, cent, l->v->co);
|
|
|
|
|
tot++;
|
|
|
|
|
}
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tot==0) return;
|
2011-02-27 06:19:40 +00:00
|
|
|
mul_v3_fl(cent, 1.0f/(float)tot);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *userData, int index, float *co, float *no), void *userData)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
BMVert *eve;
|
|
|
|
|
BMFace *efa;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
float cent[3];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (bmdm->vertexCos) {
|
|
|
|
|
eve = BMIter_New(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL);
|
2009-07-24 10:43:58 +00:00
|
|
|
for (i=0; eve; eve=BMIter_Step(&iter), i++)
|
2009-05-16 16:18:08 +00:00
|
|
|
BMINDEX_SET(eve, i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
efa = BMIter_New(&iter, bmdm->tc->bm, BM_FACES_OF_MESH, NULL);
|
|
|
|
|
for (i=0; efa; efa=BMIter_Step(&iter), i++) {
|
|
|
|
|
bmDM__calcFaceCent(bmdm->tc->bm, efa, cent, bmdm->vertexCos);
|
|
|
|
|
func(userData, i, cent, bmdm->vertexCos?bmdm->faceNos[i]:efa->no);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-15 01:19:13 +00:00
|
|
|
static void bmDM_drawMappedFaces(DerivedMesh *dm,
|
|
|
|
|
int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r),
|
|
|
|
|
void *userData, int useColors,
|
|
|
|
|
int (*setMaterial)(int, void *attribs))
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
BMFace *efa;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
int i, draw;
|
|
|
|
|
|
2011-05-09 14:32:55 +00:00
|
|
|
/*BMESH_TODO*/
|
|
|
|
|
(void)useColors;
|
|
|
|
|
(void)setMaterial;
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
if (bmdm->vertexCos) {
|
|
|
|
|
BMVert *eve;
|
|
|
|
|
|
|
|
|
|
eve = BMIter_New(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL);
|
2009-07-24 10:43:58 +00:00
|
|
|
for (i=0; eve; eve=BMIter_Step(&iter), i++)
|
2009-05-16 16:18:08 +00:00
|
|
|
BMINDEX_SET(eve, i);
|
|
|
|
|
|
|
|
|
|
efa = BMIter_New(&iter, bmdm->tc->bm, BM_FACES_OF_MESH, NULL);
|
|
|
|
|
for (i=0; efa; efa=BMIter_Step(&iter), i++)
|
|
|
|
|
BMINDEX_SET(efa, i);
|
|
|
|
|
|
|
|
|
|
for (i=0; i<bmdm->tc->tottri; i++) {
|
|
|
|
|
BMLoop **l = bmdm->tc->looptris[i];
|
|
|
|
|
int drawSmooth;
|
|
|
|
|
|
|
|
|
|
efa = l[0]->f;
|
2009-07-24 10:43:58 +00:00
|
|
|
drawSmooth = (efa->head.flag & BM_SMOOTH);
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, BMINDEX_GET(efa), &drawSmooth);
|
|
|
|
|
if(draw) {
|
|
|
|
|
if (draw==2) { /* enabled with stipple */
|
|
|
|
|
glEnable(GL_POLYGON_STIPPLE);
|
|
|
|
|
glPolygonStipple(stipple_quarttone);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
|
|
|
|
|
|
|
|
if (!drawSmooth) {
|
2009-07-24 10:43:58 +00:00
|
|
|
glNormal3fv(bmdm->faceNos[i]);
|
2009-05-16 16:18:08 +00:00
|
|
|
glVertex3fv(bmdm->vertexCos[(int) BMINDEX_GET(l[0]->v)]);
|
|
|
|
|
glVertex3fv(bmdm->vertexCos[(int) BMINDEX_GET(l[1]->v)]);
|
|
|
|
|
glVertex3fv(bmdm->vertexCos[(int) BMINDEX_GET(l[2]->v)]);
|
|
|
|
|
} else {
|
|
|
|
|
glNormal3fv(bmdm->vertexNos[(int) BMINDEX_GET(l[0]->v)]);
|
|
|
|
|
glVertex3fv(bmdm->vertexCos[(int) BMINDEX_GET(l[0]->v)]);
|
|
|
|
|
glNormal3fv(bmdm->vertexNos[(int) BMINDEX_GET(l[1]->v)]);
|
|
|
|
|
glVertex3fv(bmdm->vertexCos[(int) BMINDEX_GET(l[1]->v)]);
|
|
|
|
|
glNormal3fv(bmdm->vertexNos[(int) BMINDEX_GET(l[2]->v)]);
|
|
|
|
|
glVertex3fv(bmdm->vertexCos[(int) BMINDEX_GET(l[2]->v)]);
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
if (draw==2)
|
|
|
|
|
glDisable(GL_POLYGON_STIPPLE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
efa = BMIter_New(&iter, bmdm->tc->bm, BM_FACES_OF_MESH, NULL);
|
|
|
|
|
for (i=0; efa; efa=BMIter_Step(&iter), i++)
|
|
|
|
|
BMINDEX_SET(efa, i);
|
|
|
|
|
|
|
|
|
|
for (i=0; i<bmdm->tc->tottri; i++) {
|
|
|
|
|
BMLoop **l = bmdm->tc->looptris[i];
|
|
|
|
|
int drawSmooth;
|
|
|
|
|
|
|
|
|
|
efa = l[0]->f;
|
|
|
|
|
drawSmooth = (efa->head.flag & BM_SMOOTH);
|
|
|
|
|
|
|
|
|
|
draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, BMINDEX_GET(efa), &drawSmooth);
|
|
|
|
|
if(draw) {
|
|
|
|
|
if (draw==2) { /* enabled with stipple */
|
|
|
|
|
glEnable(GL_POLYGON_STIPPLE);
|
|
|
|
|
glPolygonStipple(stipple_quarttone);
|
|
|
|
|
}
|
|
|
|
|
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
|
|
|
|
|
|
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
|
|
|
if (!drawSmooth) {
|
|
|
|
|
glNormal3fv(efa->no);
|
|
|
|
|
glVertex3fv(l[0]->v->co);
|
|
|
|
|
glVertex3fv(l[1]->v->co);
|
|
|
|
|
glVertex3fv(l[2]->v->co);
|
|
|
|
|
} else {
|
|
|
|
|
glNormal3fv(l[0]->v->no);
|
|
|
|
|
glVertex3fv(l[0]->v->co);
|
|
|
|
|
glNormal3fv(l[1]->v->no);
|
|
|
|
|
glVertex3fv(l[1]->v->co);
|
|
|
|
|
glNormal3fv(l[2]->v->no);
|
|
|
|
|
glVertex3fv(l[2]->v->co);
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
|
|
if (draw==2)
|
|
|
|
|
glDisable(GL_POLYGON_STIPPLE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-24 10:43:58 +00:00
|
|
|
static void bmdm_get_tri_tex(BMesh *bm, BMLoop **ls, MLoopUV *luv[3], MLoopCol *lcol[3],
|
|
|
|
|
int has_uv, int has_col)
|
|
|
|
|
{
|
|
|
|
|
if (has_uv) {
|
|
|
|
|
luv[0] = CustomData_bmesh_get(&bm->ldata, ls[0]->head.data, CD_MLOOPUV);
|
|
|
|
|
luv[1] = CustomData_bmesh_get(&bm->ldata, ls[1]->head.data, CD_MLOOPUV);
|
|
|
|
|
luv[2] = CustomData_bmesh_get(&bm->ldata, ls[2]->head.data, CD_MLOOPUV);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (has_col) {
|
|
|
|
|
lcol[0] = CustomData_bmesh_get(&bm->ldata, ls[0]->head.data, CD_MLOOPCOL);
|
|
|
|
|
lcol[1] = CustomData_bmesh_get(&bm->ldata, ls[1]->head.data, CD_MLOOPCOL);
|
|
|
|
|
lcol[2] = CustomData_bmesh_get(&bm->ldata, ls[2]->head.data, CD_MLOOPCOL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
static void bmDM_drawFacesTex_common(DerivedMesh *dm,
|
2009-07-24 10:43:58 +00:00
|
|
|
int (*drawParams)(MTFace *tface, int has_vcol, int matnr),
|
2009-05-16 16:18:08 +00:00
|
|
|
int (*drawParamsMapped)(void *userData, int index),
|
|
|
|
|
void *userData)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
2009-07-24 10:43:58 +00:00
|
|
|
BMEditMesh *em = bmdm->tc;
|
2009-05-16 16:18:08 +00:00
|
|
|
BMesh *bm= bmdm->tc->bm;
|
|
|
|
|
float (*vertexCos)[3]= bmdm->vertexCos;
|
|
|
|
|
float (*vertexNos)[3]= bmdm->vertexNos;
|
|
|
|
|
BMFace *efa;
|
2009-07-24 10:43:58 +00:00
|
|
|
BMVert *eve;
|
2009-05-16 16:18:08 +00:00
|
|
|
BMIter iter;
|
2011-05-09 04:06:48 +00:00
|
|
|
MLoopUV *luv[3], dummyluv = {{0}};
|
2009-07-24 10:43:58 +00:00
|
|
|
MLoopCol *lcol[3], dummylcol = {0};
|
|
|
|
|
int i, has_vcol = CustomData_has_layer(&bm->ldata, CD_MLOOPCOL);
|
|
|
|
|
int has_uv = CustomData_has_layer(&bm->pdata, CD_MTEXPOLY);
|
|
|
|
|
|
|
|
|
|
luv[0] = luv[1] = luv[2] = &dummyluv;
|
|
|
|
|
lcol[0] = lcol[1] = lcol[2] = &dummylcol;
|
|
|
|
|
|
|
|
|
|
dummylcol.a = dummylcol.r = dummylcol.g = dummylcol.b = 255;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
/* always use smooth shading even for flat faces, else vertex colors wont interpolate */
|
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
|
|
2009-07-24 10:43:58 +00:00
|
|
|
i = 0;
|
|
|
|
|
BM_ITER(efa, &iter, bm, BM_FACES_OF_MESH, NULL)
|
|
|
|
|
BMINDEX_SET(efa, i++);
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2009-07-24 10:43:58 +00:00
|
|
|
if (vertexCos) {
|
|
|
|
|
i = 0;
|
|
|
|
|
BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL)
|
2009-05-16 16:18:08 +00:00
|
|
|
BMINDEX_SET(eve, i++);
|
2009-07-24 10:43:58 +00:00
|
|
|
|
2009-07-25 14:13:26 +00:00
|
|
|
glBegin(GL_TRIANGLES);
|
2009-07-24 10:43:58 +00:00
|
|
|
for (i=0; i<em->tottri; i++) {
|
|
|
|
|
BMLoop **ls = em->looptris[i];
|
|
|
|
|
MTexPoly *tp= CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY);
|
2011-05-09 04:06:48 +00:00
|
|
|
MTFace mtf = {{{0}}};
|
2009-05-16 16:18:08 +00:00
|
|
|
unsigned char *cp= NULL;
|
2009-07-25 14:13:26 +00:00
|
|
|
int drawSmooth= BM_TestHFlag(ls[0]->f, BM_SMOOTH);
|
2009-05-16 16:18:08 +00:00
|
|
|
int flag;
|
|
|
|
|
|
2009-07-24 10:43:58 +00:00
|
|
|
efa = ls[0]->f;
|
|
|
|
|
|
|
|
|
|
if (has_uv) {
|
|
|
|
|
mtf.flag = tp->flag;
|
|
|
|
|
mtf.tpage = tp->tpage;
|
|
|
|
|
mtf.transp = tp->transp;
|
|
|
|
|
mtf.mode = tp->mode;
|
|
|
|
|
mtf.tile = tp->tile;
|
|
|
|
|
mtf.unwrap = tp->unwrap;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
if(drawParams)
|
2009-07-24 10:43:58 +00:00
|
|
|
flag= drawParams(&mtf, has_vcol, efa->mat_nr);
|
2009-05-16 16:18:08 +00:00
|
|
|
else if(drawParamsMapped)
|
2009-07-24 10:43:58 +00:00
|
|
|
flag= drawParamsMapped(userData, BMINDEX_GET(efa));
|
2009-05-16 16:18:08 +00:00
|
|
|
else
|
|
|
|
|
flag= 1;
|
|
|
|
|
|
|
|
|
|
if(flag != 0) { /* flag 0 == the face is hidden or invisible */
|
|
|
|
|
|
|
|
|
|
/* we always want smooth here since otherwise vertex colors dont interpolate */
|
2009-07-24 10:43:58 +00:00
|
|
|
if (!has_vcol) {
|
2009-05-16 16:18:08 +00:00
|
|
|
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!drawSmooth) {
|
|
|
|
|
glNormal3fv(bmdm->faceNos[i]);
|
2009-07-24 10:43:58 +00:00
|
|
|
|
|
|
|
|
bmdm_get_tri_tex(bm, ls, luv, lcol, has_uv, has_vcol);
|
|
|
|
|
|
|
|
|
|
glTexCoord2fv(luv[0]->uv);
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[0]->b, lcol[0]->g, lcol[0]->r);
|
2009-07-24 10:43:58 +00:00
|
|
|
glVertex3fv(vertexCos[BMINDEX_GET(ls[0]->v)]);
|
|
|
|
|
|
|
|
|
|
glTexCoord2fv(luv[1]->uv);
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[1]->b, lcol[1]->g, lcol[1]->r);
|
2009-07-24 10:43:58 +00:00
|
|
|
glVertex3fv(vertexCos[BMINDEX_GET(ls[1]->v)]);
|
|
|
|
|
|
|
|
|
|
glTexCoord2fv(luv[2]->uv);
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[2]->b, lcol[2]->g, lcol[2]->r);
|
2009-07-24 10:43:58 +00:00
|
|
|
glVertex3fv(vertexCos[BMINDEX_GET(ls[2]->v)]);
|
|
|
|
|
} else {
|
|
|
|
|
bmdm_get_tri_tex(bm, ls, luv, lcol, has_uv, has_vcol);
|
|
|
|
|
|
|
|
|
|
glTexCoord2fv(luv[0]->uv);
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[0]->b, lcol[0]->g, lcol[0]->r);
|
2009-07-24 10:43:58 +00:00
|
|
|
glNormal3fv(vertexNos[BMINDEX_GET(ls[0]->v)]);
|
2009-07-25 14:13:26 +00:00
|
|
|
glVertex3fv(vertexCos[BMINDEX_GET(ls[0]->v)]);
|
2009-07-24 10:43:58 +00:00
|
|
|
|
|
|
|
|
glTexCoord2fv(luv[1]->uv);
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[1]->b, lcol[1]->g, lcol[1]->r);
|
2009-07-24 10:43:58 +00:00
|
|
|
glNormal3fv(vertexNos[BMINDEX_GET(ls[1]->v)]);
|
2009-07-25 14:13:26 +00:00
|
|
|
glVertex3fv(vertexCos[BMINDEX_GET(ls[1]->v)]);
|
2009-07-24 10:43:58 +00:00
|
|
|
|
|
|
|
|
glTexCoord2fv(luv[2]->uv);
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[2]->b, lcol[2]->g, lcol[2]->r);
|
2009-07-24 10:43:58 +00:00
|
|
|
glNormal3fv(vertexNos[BMINDEX_GET(ls[2]->v)]);
|
2009-07-25 14:13:26 +00:00
|
|
|
glVertex3fv(vertexCos[BMINDEX_GET(ls[2]->v)]);
|
2009-07-24 10:43:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-25 14:13:26 +00:00
|
|
|
glEnd();
|
2009-07-24 10:43:58 +00:00
|
|
|
} else {
|
|
|
|
|
i = 0;
|
|
|
|
|
BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL)
|
|
|
|
|
BMINDEX_SET(eve, i++);
|
|
|
|
|
|
|
|
|
|
for (i=0; i<em->tottri; i++) {
|
|
|
|
|
BMLoop **ls = em->looptris[i];
|
|
|
|
|
MTexPoly *tp= CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY);
|
2011-05-09 04:06:48 +00:00
|
|
|
MTFace mtf = {{{0}}};
|
2009-07-24 10:43:58 +00:00
|
|
|
unsigned char *cp= NULL;
|
2009-07-25 14:13:26 +00:00
|
|
|
int drawSmooth= BM_TestHFlag(ls[0]->f, BM_SMOOTH);
|
2009-07-24 10:43:58 +00:00
|
|
|
int flag;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2009-07-24 10:43:58 +00:00
|
|
|
efa = ls[0]->f;
|
|
|
|
|
|
|
|
|
|
if (has_uv) {
|
|
|
|
|
mtf.flag = tp->flag;
|
|
|
|
|
mtf.tpage = tp->tpage;
|
|
|
|
|
mtf.transp = tp->transp;
|
|
|
|
|
mtf.mode = tp->mode;
|
|
|
|
|
mtf.tile = tp->tile;
|
|
|
|
|
mtf.unwrap = tp->unwrap;
|
|
|
|
|
}
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2009-07-24 10:43:58 +00:00
|
|
|
if(drawParams)
|
|
|
|
|
flag= drawParams(&mtf, has_vcol, efa->mat_nr);
|
|
|
|
|
else if(drawParamsMapped)
|
|
|
|
|
flag= drawParamsMapped(userData, BMINDEX_GET(efa));
|
|
|
|
|
else
|
|
|
|
|
flag= 1;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2009-07-24 10:43:58 +00:00
|
|
|
if(flag != 0) { /* flag 0 == the face is hidden or invisible */
|
|
|
|
|
|
|
|
|
|
/* we always want smooth here since otherwise vertex colors dont interpolate */
|
|
|
|
|
if (!has_vcol) {
|
|
|
|
|
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glBegin(GL_TRIANGLES);
|
|
|
|
|
if (!drawSmooth) {
|
|
|
|
|
glNormal3fv(efa->no);
|
|
|
|
|
|
|
|
|
|
bmdm_get_tri_tex(bm, ls, luv, lcol, has_uv, has_vcol);
|
|
|
|
|
|
2009-10-07 21:19:58 +00:00
|
|
|
if (luv[0])
|
|
|
|
|
glTexCoord2fv(luv[0]->uv);
|
|
|
|
|
if (lcol[0])
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[0]->b, lcol[0]->g, lcol[0]->r);
|
2009-10-07 21:19:58 +00:00
|
|
|
else glColor3ub(0, 0, 0);
|
2009-07-24 10:43:58 +00:00
|
|
|
glVertex3fv(ls[0]->v->co);
|
|
|
|
|
|
2009-10-07 21:19:58 +00:00
|
|
|
if (luv[1])
|
|
|
|
|
glTexCoord2fv(luv[1]->uv);
|
|
|
|
|
if (lcol[1])
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[1]->b, lcol[1]->g, lcol[1]->r);
|
2009-10-07 21:19:58 +00:00
|
|
|
else glColor3ub(0, 0, 0);
|
2009-07-24 10:43:58 +00:00
|
|
|
glVertex3fv(ls[1]->v->co);
|
|
|
|
|
|
2009-10-07 21:19:58 +00:00
|
|
|
if (luv[2])
|
|
|
|
|
glTexCoord2fv(luv[2]->uv);
|
|
|
|
|
if (lcol[2])
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[2]->b, lcol[2]->g, lcol[2]->r);
|
2009-10-07 21:19:58 +00:00
|
|
|
else glColor3ub(0, 0, 0);
|
2009-07-24 10:43:58 +00:00
|
|
|
glVertex3fv(ls[2]->v->co);
|
2009-05-16 16:18:08 +00:00
|
|
|
} else {
|
2009-07-24 10:43:58 +00:00
|
|
|
bmdm_get_tri_tex(bm, ls, luv, lcol, has_uv, has_vcol);
|
|
|
|
|
|
2009-10-07 21:19:58 +00:00
|
|
|
if (luv[0])
|
|
|
|
|
glTexCoord2fv(luv[0]->uv);
|
|
|
|
|
if (lcol[0])
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[0]->b, lcol[0]->g, lcol[0]->r);
|
2009-10-07 21:19:58 +00:00
|
|
|
else glColor3ub(0, 0, 0);
|
2009-07-24 10:43:58 +00:00
|
|
|
glNormal3fv(ls[0]->v->no);
|
2009-07-25 14:13:26 +00:00
|
|
|
glVertex3fv(ls[0]->v->co);
|
2009-07-24 10:43:58 +00:00
|
|
|
|
2009-10-07 21:19:58 +00:00
|
|
|
if (luv[1])
|
|
|
|
|
glTexCoord2fv(luv[1]->uv);
|
|
|
|
|
if (lcol[1])
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[1]->b, lcol[1]->g, lcol[1]->r);
|
2009-10-07 21:19:58 +00:00
|
|
|
else glColor3ub(0, 0, 0);
|
2009-07-24 10:43:58 +00:00
|
|
|
glNormal3fv(ls[1]->v->no);
|
2009-07-25 14:13:26 +00:00
|
|
|
glVertex3fv(ls[1]->v->co);
|
2009-07-24 10:43:58 +00:00
|
|
|
|
2009-10-07 21:19:58 +00:00
|
|
|
if (luv[2])
|
|
|
|
|
glTexCoord2fv(luv[2]->uv);
|
|
|
|
|
if (lcol[2])
|
2009-10-22 23:22:05 +00:00
|
|
|
glColor3ub(lcol[2]->b, lcol[2]->g, lcol[2]->r);
|
2009-10-07 21:19:58 +00:00
|
|
|
else glColor3ub(0, 0, 0);
|
2009-07-24 10:43:58 +00:00
|
|
|
glNormal3fv(ls[2]->v->no);
|
2009-07-25 14:13:26 +00:00
|
|
|
glVertex3fv(ls[2]->v->co);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-24 10:43:58 +00:00
|
|
|
}
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-24 10:43:58 +00:00
|
|
|
static void bmDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tface, int has_vcol, int matnr))
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
|
|
|
|
bmDM_drawFacesTex_common(dm, setDrawOptions, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_drawMappedFacesTex(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
|
|
|
|
|
{
|
|
|
|
|
bmDM_drawFacesTex_common(dm, NULL, setDrawOptions, userData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_drawMappedFacesGLSL(DerivedMesh *dm,
|
|
|
|
|
int (*setMaterial)(int, void *attribs),
|
2011-05-09 14:32:55 +00:00
|
|
|
int (*setDrawOptions)(void *userData, int index), void *userData)
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
2011-05-10 17:01:26 +00:00
|
|
|
#if 0
|
2011-05-09 14:32:55 +00:00
|
|
|
(void)dm;
|
|
|
|
|
(void)setMaterial;
|
|
|
|
|
(void)setDrawOptions;
|
|
|
|
|
(void)userData;
|
|
|
|
|
#else /*BMESH_TODO*/
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
BMesh *bm= bmdm->tc->bm;
|
2011-05-10 17:01:26 +00:00
|
|
|
BMEditMesh *em = bmdm->tc;
|
2009-05-16 16:18:08 +00:00
|
|
|
float (*vertexCos)[3]= bmdm->vertexCos;
|
|
|
|
|
float (*vertexNos)[3]= bmdm->vertexNos;
|
|
|
|
|
BMVert *eve;
|
|
|
|
|
BMFace *efa;
|
2011-05-10 17:01:26 +00:00
|
|
|
BMIter iter;
|
|
|
|
|
BMLoop **ltri;
|
2009-05-16 16:18:08 +00:00
|
|
|
DMVertexAttribs attribs;
|
|
|
|
|
GPUVertexAttribs gattribs;
|
2011-05-10 17:01:26 +00:00
|
|
|
MTexPoly *tp;
|
2009-05-16 16:18:08 +00:00
|
|
|
int transp, new_transp, orig_transp, tfoffset;
|
|
|
|
|
int i, b, matnr, new_matnr, dodraw, layer;
|
|
|
|
|
|
|
|
|
|
dodraw = 0;
|
|
|
|
|
matnr = -1;
|
|
|
|
|
|
|
|
|
|
transp = GPU_get_material_blend_mode();
|
|
|
|
|
orig_transp = transp;
|
|
|
|
|
|
|
|
|
|
memset(&attribs, 0, sizeof(attribs));
|
|
|
|
|
|
|
|
|
|
/* always use smooth shading even for flat faces, else vertex colors wont interpolate */
|
|
|
|
|
glShadeModel(GL_SMOOTH);
|
2011-05-10 17:01:26 +00:00
|
|
|
BM_ITER_INDEX(eve, &iter, bm, BM_VERTS_OF_MESH, NULL, i) {
|
|
|
|
|
BMINDEX_SET(eve, i);
|
|
|
|
|
}
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2011-05-10 17:01:26 +00:00
|
|
|
#define PASSATTRIB(loop, eve, vert) { \
|
2009-05-16 16:18:08 +00:00
|
|
|
if(attribs.totorco) { \
|
2011-05-10 17:01:26 +00:00
|
|
|
float *orco = attribs.orco.array[BMINDEX_GET(eve)]; \
|
2009-05-16 16:18:08 +00:00
|
|
|
glVertexAttrib3fvARB(attribs.orco.glIndex, orco); \
|
|
|
|
|
} \
|
|
|
|
|
for(b = 0; b < attribs.tottface; b++) { \
|
2011-05-10 17:01:26 +00:00
|
|
|
MLoopUV *_luv = CustomData_bmesh_get_n(&bm->ldata, loop->head.data, CD_MLOOPUV, b);\
|
|
|
|
|
glVertexAttrib2fvARB(attribs.tface[b].glIndex, _luv->uv); \
|
2009-05-16 16:18:08 +00:00
|
|
|
} \
|
|
|
|
|
for(b = 0; b < attribs.totmcol; b++) { \
|
2011-05-10 17:01:26 +00:00
|
|
|
MLoopCol *_cp = CustomData_bmesh_get_n(&bm->ldata, loop->head.data, CD_MLOOPCOL, b);\
|
|
|
|
|
GLubyte _col[4]; \
|
|
|
|
|
_col[0]= _cp->b; _col[1]= _cp->g; _col[2]= _cp->r; _col[3]= _cp->a; \
|
|
|
|
|
glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, _col); \
|
2009-05-16 16:18:08 +00:00
|
|
|
} \
|
|
|
|
|
if(attribs.tottang) { \
|
|
|
|
|
float *tang = attribs.tang.array[i*4 + vert]; \
|
|
|
|
|
glVertexAttrib3fvARB(attribs.tang.glIndex, tang); \
|
|
|
|
|
} \
|
2011-05-10 17:01:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BM_ITER_INDEX(efa, &iter, bm, BM_FACES_OF_MESH, NULL, i) {
|
|
|
|
|
BMINDEX_SET(efa, i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i=0, ltri=em->looptris[0]; i<em->tottri; i++, ltri += 3) {
|
|
|
|
|
int drawSmooth;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2011-05-10 17:01:26 +00:00
|
|
|
efa = ltri[0]->f;
|
|
|
|
|
drawSmooth= BM_TestHFlag(efa, BM_SMOOTH);
|
|
|
|
|
|
|
|
|
|
if(setDrawOptions && !setDrawOptions(userData, BMINDEX_GET(efa)))
|
2009-05-16 16:18:08 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
new_matnr = efa->mat_nr + 1;
|
|
|
|
|
if(new_matnr != matnr) {
|
|
|
|
|
dodraw = setMaterial(matnr = new_matnr, &gattribs);
|
|
|
|
|
if(dodraw)
|
|
|
|
|
DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-10 17:01:26 +00:00
|
|
|
if(attribs.tottface) {
|
|
|
|
|
tp = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY);
|
|
|
|
|
new_transp = tp->transp;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
if(new_transp != transp) {
|
|
|
|
|
if(new_transp == GPU_BLEND_SOLID && orig_transp != GPU_BLEND_SOLID)
|
|
|
|
|
GPU_set_material_blend_mode(orig_transp);
|
|
|
|
|
else
|
|
|
|
|
GPU_set_material_blend_mode(new_transp);
|
|
|
|
|
transp = new_transp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(dodraw) {
|
2011-05-10 17:01:26 +00:00
|
|
|
glBegin(GL_TRIANGLES);
|
2009-05-16 16:18:08 +00:00
|
|
|
if (!drawSmooth) {
|
|
|
|
|
if(vertexCos) glNormal3fv(bmdm->faceNos[i]);
|
2011-05-10 17:01:26 +00:00
|
|
|
else glNormal3fv(efa->no);
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2011-05-10 17:01:26 +00:00
|
|
|
PASSATTRIB(ltri[0], ltri[0]->v, 0);
|
|
|
|
|
if(vertexCos) glVertex3fv(vertexCos[BMINDEX_GET(ltri[0]->v)]);
|
|
|
|
|
else glVertex3fv(ltri[0]->v->co);
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2011-05-10 17:01:26 +00:00
|
|
|
PASSATTRIB(ltri[1], ltri[1]->v, 1);
|
|
|
|
|
if(vertexCos) glVertex3fv(vertexCos[BMINDEX_GET(ltri[1]->v)]);
|
|
|
|
|
else glVertex3fv(ltri[1]->v->co);
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2011-05-10 17:01:26 +00:00
|
|
|
PASSATTRIB(ltri[2], ltri[2]->v, 2);
|
|
|
|
|
if(vertexCos) glVertex3fv(vertexCos[BMINDEX_GET(ltri[2]->v)]);
|
|
|
|
|
else glVertex3fv(ltri[2]->v->co);
|
2009-05-16 16:18:08 +00:00
|
|
|
} else {
|
2011-05-10 17:01:26 +00:00
|
|
|
PASSATTRIB(ltri[0], ltri[0]->v, 0);
|
2009-05-16 16:18:08 +00:00
|
|
|
if(vertexCos) {
|
2011-05-10 17:01:26 +00:00
|
|
|
glNormal3fv(vertexNos[BMINDEX_GET(ltri[0]->v)]);
|
|
|
|
|
glVertex3fv(vertexCos[BMINDEX_GET(ltri[0]->v)]);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2011-05-10 17:01:26 +00:00
|
|
|
glNormal3fv(ltri[0]->v->no);
|
|
|
|
|
glVertex3fv(ltri[0]->v->co);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-10 17:01:26 +00:00
|
|
|
PASSATTRIB(ltri[1], ltri[1]->v, 1);
|
2009-05-16 16:18:08 +00:00
|
|
|
if(vertexCos) {
|
2011-05-10 17:01:26 +00:00
|
|
|
glNormal3fv(vertexNos[BMINDEX_GET(ltri[1]->v)]);
|
|
|
|
|
glVertex3fv(vertexCos[BMINDEX_GET(ltri[1]->v)]);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2011-05-10 17:01:26 +00:00
|
|
|
glNormal3fv(ltri[1]->v->no);
|
|
|
|
|
glVertex3fv(ltri[1]->v->co);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-10 17:01:26 +00:00
|
|
|
PASSATTRIB(ltri[2], ltri[2]->v, 2);
|
2009-05-16 16:18:08 +00:00
|
|
|
if(vertexCos) {
|
2011-05-10 17:01:26 +00:00
|
|
|
glNormal3fv(vertexNos[BMINDEX_GET(ltri[2]->v)]);
|
|
|
|
|
glVertex3fv(vertexCos[BMINDEX_GET(ltri[2]->v)]);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2011-05-10 17:01:26 +00:00
|
|
|
glNormal3fv(ltri[2]->v->no);
|
|
|
|
|
glVertex3fv(ltri[2]->v->co);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
glEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_drawFacesGLSL(DerivedMesh *dm,
|
|
|
|
|
int (*setMaterial)(int, void *attribs))
|
|
|
|
|
{
|
|
|
|
|
dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
BMVert *eve;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
int i;
|
|
|
|
|
|
2010-07-14 22:06:10 +00:00
|
|
|
if (bmdm->tc->bm->totvert) {
|
2009-05-16 16:18:08 +00:00
|
|
|
eve = BMIter_New(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL);
|
|
|
|
|
for (i=0; eve; eve=BMIter_Step(&iter), i++) {
|
|
|
|
|
if (bmdm->vertexCos) {
|
|
|
|
|
DO_MINMAX(bmdm->vertexCos[i], min_r, max_r);
|
|
|
|
|
} else {
|
|
|
|
|
DO_MINMAX(eve->co, min_r, max_r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
min_r[0] = min_r[1] = min_r[2] = max_r[0] = max_r[1] = max_r[2] = 0.0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
static int bmDM_getNumVerts(DerivedMesh *dm)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
|
|
|
|
|
return bmdm->tc->bm->totvert;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int bmDM_getNumEdges(DerivedMesh *dm)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
|
|
|
|
|
return bmdm->tc->bm->totedge;
|
|
|
|
|
}
|
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
static int bmDM_getNumTessFaces(DerivedMesh *dm)
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
|
|
|
|
|
return bmdm->tc->tottri;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
static int bmDM_getNumFaces(DerivedMesh *dm)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
|
|
|
|
|
return bmdm->tc->bm->totface;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-14 22:06:10 +00:00
|
|
|
static int bmvert_to_mvert(BMesh *bm, BMVert *ev, MVert *vert_r)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
{
|
|
|
|
|
VECCOPY(vert_r->co, ev->co);
|
|
|
|
|
|
|
|
|
|
vert_r->no[0] = (short)(ev->no[0] * 32767.0f);
|
|
|
|
|
vert_r->no[1] = (short)(ev->no[1] * 32767.0f);
|
|
|
|
|
vert_r->no[2] = (short)(ev->no[2] * 32767.0f);
|
|
|
|
|
|
|
|
|
|
vert_r->flag = BMFlags_To_MEFlags(ev);
|
2010-07-14 22:06:10 +00:00
|
|
|
|
|
|
|
|
if (CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) {
|
|
|
|
|
vert_r->bweight = (unsigned char) (BM_GetCDf(&bm->vdata, ev, CD_BWEIGHT)*255.0f);
|
|
|
|
|
}
|
2010-07-19 04:44:37 +00:00
|
|
|
|
|
|
|
|
return 1;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
}
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
static void bmDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
|
|
|
|
|
{
|
|
|
|
|
BMVert *ev;
|
|
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
if (index < 0 || index >= ((EditDerivedBMesh *)dm)->tv) {
|
2009-05-16 16:18:08 +00:00
|
|
|
printf("error in bmDM_getVert.\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
ev = ((EditDerivedBMesh *)dm)->vtable[index];
|
2010-07-14 22:06:10 +00:00
|
|
|
bmvert_to_mvert(((EditDerivedBMesh *)dm)->tc->bm, ev, vert_r);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_getEdge(DerivedMesh *dm, int index, MEdge *edge_r)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
|
|
|
|
|
BMesh *bm = ((EditDerivedBMesh *)dm)->tc->bm;
|
|
|
|
|
BMEdge *e;
|
|
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
if (index < 0 || index >= ((EditDerivedBMesh *)dm)->te) {
|
|
|
|
|
printf("error in bmDM_getEdge.\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e = bmdm->etable[index];
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2010-07-14 22:06:10 +00:00
|
|
|
if (CustomData_has_layer(&bm->edata, CD_BWEIGHT)) {
|
|
|
|
|
edge_r->bweight = (unsigned char) (BM_GetCDf(&bm->edata, e, CD_BWEIGHT)*255.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CustomData_has_layer(&bm->edata, CD_CREASE)) {
|
|
|
|
|
edge_r->crease = (unsigned char) (BM_GetCDf(&bm->edata, e, CD_CREASE)*255.0f);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
edge_r->flag = ME_EDGEDRAW|ME_EDGERENDER;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
edge_r->flag |= BMFlags_To_MEFlags(e);
|
2009-05-16 16:18:08 +00:00
|
|
|
#if 0
|
|
|
|
|
/* this needs setup of f2 field */
|
|
|
|
|
if (!ee->f2) edge_r->flag |= ME_LOOSEEDGE;
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
edge_r->v1 = GET_INT_FROM_POINTER(BLI_ghash_lookup(bmdm->vhash, e->v1));
|
|
|
|
|
edge_r->v2 = GET_INT_FROM_POINTER(BLI_ghash_lookup(bmdm->vhash, e->v2));
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
static void bmDM_getTessFace(DerivedMesh *dm, int index, MFace *face_r)
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
2009-06-23 05:35:49 +00:00
|
|
|
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
|
2009-05-16 16:18:08 +00:00
|
|
|
BMFace *ef;
|
|
|
|
|
BMLoop **l;
|
|
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
if (index < 0 || index >= ((EditDerivedBMesh *)dm)->tf) {
|
|
|
|
|
printf("error in bmDM_getTessFace.\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
l = ((EditDerivedBMesh *)dm)->tc->looptris[index];
|
|
|
|
|
|
|
|
|
|
ef = l[0]->f;
|
|
|
|
|
|
|
|
|
|
face_r->mat_nr = (unsigned char) ef->mat_nr;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
face_r->flag = BMFlags_To_MEFlags(ef);
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2009-06-23 05:35:49 +00:00
|
|
|
face_r->v1 = GET_INT_FROM_POINTER(BLI_ghash_lookup(bmdm->vhash, l[0]->v));
|
|
|
|
|
face_r->v2 = GET_INT_FROM_POINTER(BLI_ghash_lookup(bmdm->vhash, l[1]->v));
|
|
|
|
|
face_r->v3 = GET_INT_FROM_POINTER(BLI_ghash_lookup(bmdm->vhash, l[2]->v));
|
2009-05-16 16:18:08 +00:00
|
|
|
face_r->v4 = 0;
|
|
|
|
|
|
|
|
|
|
test_index_face(face_r, NULL, 0, 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_copyVertArray(DerivedMesh *dm, MVert *vert_r)
|
|
|
|
|
{
|
|
|
|
|
BMesh *bm = ((EditDerivedBMesh *)dm)->tc->bm;
|
|
|
|
|
BMVert *ev;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
|
|
|
|
|
ev = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
|
|
|
|
|
for( ; ev; ev = BMIter_Step(&iter), ++vert_r) {
|
|
|
|
|
VECCOPY(vert_r->co, ev->co);
|
|
|
|
|
|
|
|
|
|
vert_r->no[0] = (short) (ev->no[0] * 32767.0);
|
|
|
|
|
vert_r->no[1] = (short) (ev->no[1] * 32767.0);
|
|
|
|
|
vert_r->no[2] = (short) (ev->no[2] * 32767.0);
|
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
vert_r->flag = BMFlags_To_MEFlags(ev);
|
2010-07-14 22:06:10 +00:00
|
|
|
|
|
|
|
|
if (CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) {
|
|
|
|
|
vert_r->bweight = (unsigned char) (BM_GetCDf(&bm->vdata, ev, CD_BWEIGHT)*255.0f);
|
|
|
|
|
}
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_copyEdgeArray(DerivedMesh *dm, MEdge *edge_r)
|
|
|
|
|
{
|
|
|
|
|
BMesh *bm = ((EditDerivedBMesh *)dm)->tc->bm;
|
|
|
|
|
BMEdge *ee;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
BMVert *ev;
|
2011-03-27 03:29:27 +00:00
|
|
|
int has_bweight = CustomData_has_layer(&bm->edata, CD_BWEIGHT);
|
|
|
|
|
int i, has_crease = CustomData_has_layer(&bm->edata, CD_CREASE);
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
/* store vertex indices in tmp union */
|
|
|
|
|
ev = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
|
|
|
|
|
for (i=0; ev; ev=BMIter_Step(&iter), i++)
|
|
|
|
|
BMINDEX_SET(ev, i);
|
|
|
|
|
|
|
|
|
|
ee = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL);
|
|
|
|
|
for( ; ee; ee=BMIter_Step(&iter)) {
|
2011-03-27 03:29:27 +00:00
|
|
|
if (has_bweight) {
|
2010-07-14 22:06:10 +00:00
|
|
|
edge_r->bweight = (unsigned char) (BM_GetCDf(&bm->edata, ee, CD_BWEIGHT)*255.0f);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-27 03:29:27 +00:00
|
|
|
if (has_crease) {
|
2010-07-14 22:06:10 +00:00
|
|
|
edge_r->crease = (unsigned char) (BM_GetCDf(&bm->edata, ee, CD_CREASE)*255.0f);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
edge_r->flag = ME_EDGEDRAW|ME_EDGERENDER;
|
|
|
|
|
if (ee->head.flag & BM_SEAM) edge_r->flag |= ME_SEAM;
|
|
|
|
|
if (ee->head.flag & BM_SHARP) edge_r->flag |= ME_SHARP;
|
|
|
|
|
#if 0
|
2011-03-27 03:29:27 +00:00
|
|
|
/* this needs setup of f2 (edge draw flags, if I remember right) field */
|
2009-05-16 16:18:08 +00:00
|
|
|
if (!ee->f2) edge_r->flag |= ME_LOOSEEDGE;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
edge_r->v1 = (int)BMINDEX_GET(ee->v1);
|
|
|
|
|
edge_r->v2 = (int)BMINDEX_GET(ee->v2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bmDM_copyFaceArray(DerivedMesh *dm, MFace *face_r)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
|
|
|
|
|
BMesh *bm = ((EditDerivedBMesh *)dm)->tc->bm;
|
|
|
|
|
BMFace *ef;
|
|
|
|
|
BMVert *ev;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
BMLoop **l;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* store vertexes indices in tmp union */
|
|
|
|
|
ev = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
|
|
|
|
|
for (i=0; ev; ev=BMIter_Step(&iter), i++)
|
|
|
|
|
BMINDEX_SET(ev, i);
|
|
|
|
|
|
|
|
|
|
for (i=0; i<bmdm->tc->tottri; i++) {
|
|
|
|
|
l = bmdm->tc->looptris[i];
|
|
|
|
|
ef = l[0]->f;
|
|
|
|
|
|
|
|
|
|
face_r->mat_nr = (unsigned char) ef->mat_nr;
|
|
|
|
|
|
|
|
|
|
/*HACK/TODO: need to convert this*/
|
|
|
|
|
face_r->flag = ef->head.flag;
|
|
|
|
|
|
|
|
|
|
face_r->v1 = BMINDEX_GET(l[0]->v);
|
|
|
|
|
face_r->v2 = BMINDEX_GET(l[1]->v);
|
|
|
|
|
face_r->v3 = BMINDEX_GET(l[2]->v);
|
|
|
|
|
face_r->v4 = 0;
|
|
|
|
|
|
|
|
|
|
test_index_face(face_r, NULL, 0, 3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void *bmDM_getFaceDataArray(DerivedMesh *dm, int type)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
BMesh *bm= bmdm->tc->bm;
|
|
|
|
|
BMFace *efa;
|
|
|
|
|
char *data, *bmdata;
|
|
|
|
|
void *datalayer;
|
|
|
|
|
int index, offset, size, i;
|
|
|
|
|
|
2009-08-15 17:31:28 +00:00
|
|
|
datalayer = DM_get_tessface_data_layer(dm, type);
|
2009-05-16 16:18:08 +00:00
|
|
|
if(datalayer)
|
|
|
|
|
return datalayer;
|
|
|
|
|
|
|
|
|
|
/* layers are store per face for editmesh, we convert to a tbmporary
|
|
|
|
|
* data layer array in the derivedmesh when these are requested */
|
|
|
|
|
if(type == CD_MTFACE || type == CD_MCOL) {
|
|
|
|
|
index = CustomData_get_layer_index(&bm->pdata, type);
|
|
|
|
|
|
|
|
|
|
if(index != -1) {
|
|
|
|
|
offset = bm->pdata.layers[index].offset;
|
|
|
|
|
size = CustomData_sizeof(type);
|
|
|
|
|
|
2009-08-15 17:31:28 +00:00
|
|
|
DM_add_tessface_layer(dm, type, CD_CALLOC, NULL);
|
2009-05-16 16:18:08 +00:00
|
|
|
index = CustomData_get_layer_index(&dm->faceData, type);
|
|
|
|
|
dm->faceData.layers[index].flag |= CD_FLAG_TEMPORARY;
|
|
|
|
|
|
2009-08-15 17:31:28 +00:00
|
|
|
data = datalayer = DM_get_tessface_data_layer(dm, type);
|
2009-05-16 16:18:08 +00:00
|
|
|
for (i=0; i<bmdm->tc->tottri; i++, data+=size) {
|
|
|
|
|
efa = bmdm->tc->looptris[i][0]->f;
|
2009-06-23 05:35:49 +00:00
|
|
|
/*BMESH_TODO: need to still add tface data,
|
|
|
|
|
derived from the loops.*/
|
|
|
|
|
bmdata = CustomData_bmesh_get(&bm->pdata, efa->head.data, type);
|
2009-05-16 16:18:08 +00:00
|
|
|
memcpy(data, bmdata, size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return datalayer;
|
|
|
|
|
}
|
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
typedef struct bmDM_loopIter {
|
|
|
|
|
DMLoopIter head;
|
|
|
|
|
|
|
|
|
|
BMFace *f;
|
|
|
|
|
BMLoop *l, *nextl;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
BMesh *bm;
|
|
|
|
|
} bmDM_loopIter;
|
|
|
|
|
|
|
|
|
|
typedef struct bmDM_faceIter {
|
|
|
|
|
DMFaceIter head;
|
|
|
|
|
|
|
|
|
|
BMFace *f, *nextf;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
BMesh *bm;
|
|
|
|
|
|
|
|
|
|
bmDM_loopIter loopiter;
|
|
|
|
|
} bmDM_faceIter;
|
|
|
|
|
|
2011-05-09 22:16:31 +00:00
|
|
|
static void bmDM_faceIterStep(void *self)
|
2009-05-16 16:18:08 +00:00
|
|
|
{
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
bmDM_faceIter *iter = self;
|
|
|
|
|
|
2010-01-28 00:45:30 +00:00
|
|
|
if (iter->f) {
|
|
|
|
|
iter->f->mat_nr = iter->head.mat_nr;
|
|
|
|
|
iter->f->head.flag = MEFlags_To_BMFlags(iter->head.flags, BM_FACE);
|
|
|
|
|
}
|
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
iter->f = iter->nextf;
|
|
|
|
|
|
|
|
|
|
iter->head.mat_nr = iter->f->mat_nr;
|
|
|
|
|
iter->head.flags = BMFlags_To_MEFlags(iter->f);
|
|
|
|
|
iter->head.index++;
|
|
|
|
|
|
2009-08-18 20:05:08 +00:00
|
|
|
iter->head.len = iter->f->len;
|
|
|
|
|
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
iter->nextf = BMIter_Step(&iter->iter);
|
|
|
|
|
|
|
|
|
|
if (!iter->nextf) iter->head.done = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-09 22:16:31 +00:00
|
|
|
static void *bmDM_getFaceCDData(void *self, int type, int layer)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
{
|
|
|
|
|
bmDM_faceIter *iter = self;
|
|
|
|
|
|
|
|
|
|
if (layer == -1)
|
2009-06-23 05:35:49 +00:00
|
|
|
return CustomData_bmesh_get(&iter->bm->pdata, iter->f->head.data, type);
|
|
|
|
|
else return CustomData_bmesh_get_n(&iter->bm->pdata, iter->f->head.data, type, layer);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-09 22:16:31 +00:00
|
|
|
static void bmDM_loopIterStep(void *self)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
{
|
|
|
|
|
bmDM_loopIter *iter = self;
|
|
|
|
|
|
2009-08-18 20:05:08 +00:00
|
|
|
iter->l = BMIter_Step(&iter->iter);
|
|
|
|
|
if (!iter->l) {
|
|
|
|
|
iter->head.done = 1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
|
2010-07-14 22:06:10 +00:00
|
|
|
bmvert_to_mvert(iter->bm, iter->l->v, &iter->head.v);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
iter->head.index++;
|
|
|
|
|
iter->head.vindex = BMINDEX_GET(iter->l->v);
|
|
|
|
|
iter->head.eindex = BMINDEX_GET(iter->l->e);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-09 22:16:31 +00:00
|
|
|
static void *bmDM_getLoopCDData(void *self, int type, int layer)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
{
|
|
|
|
|
bmDM_loopIter *iter = self;
|
|
|
|
|
|
|
|
|
|
if (layer == -1)
|
2009-06-23 05:35:49 +00:00
|
|
|
return CustomData_bmesh_get(&iter->bm->ldata, iter->l->head.data, type);
|
|
|
|
|
else return CustomData_bmesh_get_n(&iter->bm->ldata, iter->l->head.data, type, layer);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-09 22:16:31 +00:00
|
|
|
static void *bmDM_getVertCDData(void *self, int type, int layer)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
{
|
|
|
|
|
bmDM_loopIter *iter = self;
|
|
|
|
|
|
|
|
|
|
if (layer == -1)
|
2009-06-23 05:35:49 +00:00
|
|
|
return CustomData_bmesh_get(&iter->bm->vdata, iter->l->v->head.data, type);
|
|
|
|
|
else return CustomData_bmesh_get_n(&iter->bm->vdata, iter->l->v->head.data, type, layer);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void bmDM_iterFree(void *self)
|
|
|
|
|
{
|
|
|
|
|
MEM_freeN(self);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-09 22:16:31 +00:00
|
|
|
static void bmDM_nulliterFree(void *UNUSED(self))
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DMLoopIter *bmDM_newLoopsIter(void *faceiter)
|
|
|
|
|
{
|
|
|
|
|
bmDM_faceIter *fiter = faceiter;
|
|
|
|
|
bmDM_loopIter *iter = &fiter->loopiter;
|
|
|
|
|
|
|
|
|
|
memset(&fiter->loopiter, 0, sizeof(bmDM_loopIter));
|
|
|
|
|
|
|
|
|
|
iter->bm = fiter->bm;
|
|
|
|
|
iter->f = fiter->f;
|
2009-08-18 20:05:08 +00:00
|
|
|
iter->l = BMIter_New(&iter->iter, iter->bm, BM_LOOPS_OF_FACE, iter->f);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
|
|
|
|
|
iter->head.step = bmDM_loopIterStep;
|
|
|
|
|
iter->head.getLoopCDData = bmDM_getLoopCDData;
|
|
|
|
|
iter->head.getVertCDData = bmDM_getVertCDData;
|
|
|
|
|
|
2010-07-14 22:06:10 +00:00
|
|
|
bmvert_to_mvert(iter->bm, iter->l->v, &iter->head.v);
|
2009-08-18 20:05:08 +00:00
|
|
|
iter->head.vindex = BMINDEX_GET(iter->l->v);
|
|
|
|
|
iter->head.eindex = BMINDEX_GET(iter->l->e);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
|
|
|
|
|
return (DMLoopIter*) iter;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-15 01:19:13 +00:00
|
|
|
static DMFaceIter *bmDM_getFaceIter(DerivedMesh *dm)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
{
|
2011-04-15 01:19:13 +00:00
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh*)dm;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
bmDM_faceIter *iter = MEM_callocN(sizeof(bmDM_faceIter), "bmDM_faceIter");
|
|
|
|
|
BMIter biter;
|
|
|
|
|
BMVert *v;
|
|
|
|
|
BMEdge *e;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
iter->bm = bmdm->tc->bm;
|
2009-06-23 05:35:49 +00:00
|
|
|
iter->f = iter->nextf = BMIter_New(&iter->iter, iter->bm, BM_FACES_OF_MESH, NULL);
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
|
|
|
|
|
iter->head.step = bmDM_faceIterStep;
|
|
|
|
|
iter->head.free = bmDM_iterFree;
|
|
|
|
|
iter->head.getCDData = bmDM_getFaceCDData;
|
|
|
|
|
iter->head.getLoopsIter = bmDM_newLoopsIter;
|
|
|
|
|
|
|
|
|
|
iter->head.mat_nr = iter->f->mat_nr;
|
|
|
|
|
iter->head.flags = BMFlags_To_MEFlags(iter->f);
|
|
|
|
|
|
|
|
|
|
/*set up vert/edge indices*/
|
|
|
|
|
i = 0;
|
|
|
|
|
BM_ITER(v, &biter, iter->bm, BM_VERTS_OF_MESH, NULL) {
|
|
|
|
|
BMINDEX_SET(v, i);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
BM_ITER(e, &biter, iter->bm, BM_EDGES_OF_MESH, NULL) {
|
|
|
|
|
BMINDEX_SET(e, i);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (DMFaceIter*) iter;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-09 22:16:31 +00:00
|
|
|
static void bmDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3])
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *emdm= (EditDerivedBMesh*) dm;
|
|
|
|
|
BMVert *eve;
|
|
|
|
|
BMIter iter;
|
|
|
|
|
int i;
|
2011-05-10 23:48:09 +00:00
|
|
|
|
|
|
|
|
i= 0;
|
2011-05-09 22:16:31 +00:00
|
|
|
BM_ITER(eve, &iter, emdm->tc->bm, BM_VERTS_OF_MESH, NULL) {
|
|
|
|
|
if (emdm->vertexCos) {
|
|
|
|
|
copy_v3_v3(cos_r[i], emdm->vertexCos[i]);
|
|
|
|
|
} else {
|
|
|
|
|
copy_v3_v3(cos_r[i], eve->co);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-15 01:19:13 +00:00
|
|
|
static void bmDM_release(DerivedMesh *dm)
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
{
|
2011-04-15 01:19:13 +00:00
|
|
|
EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
if (DM_release(dm)) {
|
|
|
|
|
if (bmdm->vertexCos) {
|
|
|
|
|
MEM_freeN(bmdm->vertexCos);
|
|
|
|
|
MEM_freeN(bmdm->vertexNos);
|
|
|
|
|
MEM_freeN(bmdm->faceNos);
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-10 01:46:52 +00:00
|
|
|
if (bmdm->fhash) BLI_ghash_free(bmdm->fhash, NULL, NULL);
|
|
|
|
|
if (bmdm->ehash) BLI_ghash_free(bmdm->ehash, NULL, NULL);
|
|
|
|
|
if (bmdm->vhash) BLI_ghash_free(bmdm->vhash, NULL, NULL);
|
2009-07-14 06:13:43 +00:00
|
|
|
|
|
|
|
|
if (bmdm->vtable) MEM_freeN(bmdm->vtable);
|
|
|
|
|
if (bmdm->etable) MEM_freeN(bmdm->etable);
|
|
|
|
|
if (bmdm->ftable) MEM_freeN(bmdm->ftable);
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
MEM_freeN(bmdm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 20:05:08 +00:00
|
|
|
CustomData *bmDm_getVertDataLayout(DerivedMesh *dm)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm = (EditDerivedBMesh*)dm;
|
|
|
|
|
|
|
|
|
|
return &bmdm->tc->bm->vdata;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomData *bmDm_getEdgeDataLayout(DerivedMesh *dm)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm = (EditDerivedBMesh*)dm;
|
|
|
|
|
|
|
|
|
|
return &bmdm->tc->bm->edata;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomData *bmDm_getTessFaceDataLayout(DerivedMesh *dm)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm = (EditDerivedBMesh*)dm;
|
|
|
|
|
|
2011-05-10 17:01:26 +00:00
|
|
|
return &bmdm->dm.faceData;
|
2009-08-18 20:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomData *bmDm_getLoopDataLayout(DerivedMesh *dm)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm = (EditDerivedBMesh*)dm;
|
|
|
|
|
|
|
|
|
|
return &bmdm->tc->bm->ldata;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomData *bmDm_getFaceDataLayout(DerivedMesh *dm)
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm = (EditDerivedBMesh*)dm;
|
|
|
|
|
|
|
|
|
|
return &bmdm->tc->bm->pdata;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-05-09 14:32:55 +00:00
|
|
|
DerivedMesh *getEditDerivedBMesh(BMEditMesh *em, Object *UNUSED(ob),
|
2009-05-16 16:18:08 +00:00
|
|
|
float (*vertexCos)[3])
|
|
|
|
|
{
|
|
|
|
|
EditDerivedBMesh *bmdm = MEM_callocN(sizeof(*bmdm), "bmdm");
|
|
|
|
|
BMesh *bm = em->bm;
|
2009-08-18 20:05:08 +00:00
|
|
|
int i;
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
bmdm->tc = em;
|
|
|
|
|
|
2010-01-13 07:26:11 +00:00
|
|
|
DM_init((DerivedMesh*)bmdm, DM_TYPE_EDITBMESH, em->bm->totvert,
|
|
|
|
|
em->bm->totedge, em->tottri, em->bm->totloop, em->bm->totface);
|
2009-08-18 20:05:08 +00:00
|
|
|
|
2011-05-10 17:01:26 +00:00
|
|
|
CustomData_from_bmeshpoly(&bmdm->dm.faceData, &em->bm->pdata, &em->bm->ldata, 0);
|
|
|
|
|
|
2009-08-18 20:05:08 +00:00
|
|
|
bmdm->dm.numVertData = bm->totvert;
|
|
|
|
|
bmdm->dm.numEdgeData = bm->totedge;
|
|
|
|
|
bmdm->dm.numFaceData = em->tottri;
|
|
|
|
|
bmdm->dm.numLoopData = bm->totloop;
|
|
|
|
|
bmdm->dm.numPolyData = bm->totface;
|
2011-05-09 22:16:31 +00:00
|
|
|
|
|
|
|
|
bmdm->dm.getVertCos = bmDM_getVertCos;
|
2009-05-16 16:18:08 +00:00
|
|
|
bmdm->dm.getMinMax = bmDM_getMinMax;
|
|
|
|
|
|
2009-08-18 20:05:08 +00:00
|
|
|
bmdm->dm.getVertDataLayout = bmDm_getVertDataLayout;
|
|
|
|
|
bmdm->dm.getEdgeDataLayout = bmDm_getEdgeDataLayout;
|
|
|
|
|
bmdm->dm.getTessFaceDataLayout = bmDm_getTessFaceDataLayout;
|
|
|
|
|
bmdm->dm.getLoopDataLayout = bmDm_getLoopDataLayout;
|
|
|
|
|
bmdm->dm.getFaceDataLayout = bmDm_getFaceDataLayout;
|
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
bmdm->dm.getNumVerts = bmDM_getNumVerts;
|
|
|
|
|
bmdm->dm.getNumEdges = bmDM_getNumEdges;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
bmdm->dm.getNumTessFaces = bmDM_getNumTessFaces;
|
2009-06-23 05:35:49 +00:00
|
|
|
bmdm->dm.getNumFaces = bmDM_getNumFaces;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
bmdm->dm.getVert = bmDM_getVert;
|
|
|
|
|
bmdm->dm.getEdge = bmDM_getEdge;
|
2009-06-23 05:35:49 +00:00
|
|
|
bmdm->dm.getTessFace = bmDM_getTessFace;
|
2009-05-16 16:18:08 +00:00
|
|
|
bmdm->dm.copyVertArray = bmDM_copyVertArray;
|
|
|
|
|
bmdm->dm.copyEdgeArray = bmDM_copyEdgeArray;
|
(NOTE: DO NOT TEST)
Start of planned DerivedMesh refactoring. The mface
interfaces in DerivedMesh have been renamed to reflect
their new status as tesselated face interfaces (rather
then the primary ones, which are now stored in mpolys).
short review: mpolys store "primary" face data, while
mfaces store the tesselated form of the mesh (generally
as triangles). mpolys are defined by mloops, and each
mpoly defines a range of loops it "owns" in the main
mloop array.
I've also added basic read-only face iterators, which
are implemented for CDDM, ccgsubsurf, and the bmeditmesh
derivedmesh. Since faces are now variable-length things,
trying to implement the same interface as mfaces would not
have worked well (especially since faces are stored as
an mpoly + a range of mloops).
I figure first we can evaluate these simple read-only
face iterators, then decide if a) we like using iterators
in DerivedMesh, b) how much of it should use them, and c)
if we want write-capable iterators.
I plan to write official docs on this design after I get
it more stable; I'm committing now because there's a rather
lot of changes, and I might do a merge soon.
2009-06-10 10:06:25 +00:00
|
|
|
bmdm->dm.copyTessFaceArray = bmDM_copyFaceArray;
|
|
|
|
|
bmdm->dm.getTessFaceDataArray = bmDM_getFaceDataArray;
|
|
|
|
|
|
|
|
|
|
bmdm->dm.newFaceIter = bmDM_getFaceIter;
|
2009-06-23 05:35:49 +00:00
|
|
|
bmdm->dm.recalcTesselation = bmDM_recalcTesselation;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
|
|
|
|
bmdm->dm.foreachMappedVert = bmDM_foreachMappedVert;
|
|
|
|
|
bmdm->dm.foreachMappedEdge = bmDM_foreachMappedEdge;
|
|
|
|
|
bmdm->dm.foreachMappedFaceCenter = bmDM_foreachMappedFaceCenter;
|
|
|
|
|
|
|
|
|
|
bmdm->dm.drawEdges = bmDM_drawEdges;
|
|
|
|
|
bmdm->dm.drawMappedEdges = bmDM_drawMappedEdges;
|
|
|
|
|
bmdm->dm.drawMappedEdgesInterp = bmDM_drawMappedEdgesInterp;
|
|
|
|
|
bmdm->dm.drawMappedFaces = bmDM_drawMappedFaces;
|
|
|
|
|
bmdm->dm.drawMappedFacesTex = bmDM_drawMappedFacesTex;
|
|
|
|
|
bmdm->dm.drawMappedFacesGLSL = bmDM_drawMappedFacesGLSL;
|
|
|
|
|
bmdm->dm.drawFacesTex = bmDM_drawFacesTex;
|
|
|
|
|
bmdm->dm.drawFacesGLSL = bmDM_drawFacesGLSL;
|
|
|
|
|
bmdm->dm.drawUVEdges = bmDM_drawUVEdges;
|
|
|
|
|
|
|
|
|
|
bmdm->dm.release = bmDM_release;
|
|
|
|
|
|
|
|
|
|
bmdm->vertexCos = vertexCos;
|
|
|
|
|
|
|
|
|
|
if(CustomData_has_layer(&bm->vdata, CD_MDEFORMVERT)) {
|
|
|
|
|
BMIter iter;
|
|
|
|
|
BMVert *eve;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
DM_add_vert_layer(&bmdm->dm, CD_MDEFORMVERT, CD_CALLOC, NULL);
|
|
|
|
|
|
|
|
|
|
eve = BMIter_New(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL);
|
|
|
|
|
for (i=0; eve; eve=BMIter_Step(&iter), i++)
|
|
|
|
|
DM_set_vert_data(&bmdm->dm, i, CD_MDEFORMVERT,
|
2009-06-23 05:35:49 +00:00
|
|
|
CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MDEFORMVERT));
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(vertexCos) {
|
|
|
|
|
BMVert *eve;
|
|
|
|
|
BMIter iter;
|
2009-07-24 10:43:58 +00:00
|
|
|
int totface = bmdm->tc->tottri;
|
2009-05-16 16:18:08 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
eve=BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
|
|
|
|
|
for (i=0; eve; eve=BMIter_Step(&iter), i++)
|
|
|
|
|
BMINDEX_SET(eve, i);
|
|
|
|
|
|
|
|
|
|
bmdm->vertexNos = MEM_callocN(sizeof(*bmdm->vertexNos)*i, "bmdm_vno");
|
|
|
|
|
bmdm->faceNos = MEM_mallocN(sizeof(*bmdm->faceNos)*totface, "bmdm_vno");
|
|
|
|
|
|
|
|
|
|
for (i=0; i<bmdm->tc->tottri; i++) {
|
|
|
|
|
BMLoop **l = bmdm->tc->looptris[i];
|
|
|
|
|
float *v1 = vertexCos[(int) BMINDEX_GET(l[0]->v)];
|
|
|
|
|
float *v2 = vertexCos[(int) BMINDEX_GET(l[1]->v)];
|
|
|
|
|
float *v3 = vertexCos[(int) BMINDEX_GET(l[2]->v)];
|
|
|
|
|
float *no = bmdm->faceNos[i];
|
|
|
|
|
|
2009-11-23 14:41:22 +00:00
|
|
|
normal_tri_v3( no,v1, v2, v3);
|
|
|
|
|
add_v3_v3v3(bmdm->vertexNos[BMINDEX_GET(l[0]->v)], bmdm->vertexNos[BMINDEX_GET(l[0]->v)], no);
|
|
|
|
|
add_v3_v3v3(bmdm->vertexNos[BMINDEX_GET(l[1]->v)], bmdm->vertexNos[BMINDEX_GET(l[1]->v)], no);
|
|
|
|
|
add_v3_v3v3(bmdm->vertexNos[BMINDEX_GET(l[2]->v)], bmdm->vertexNos[BMINDEX_GET(l[2]->v)], no);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eve=BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
|
|
|
|
|
for (i=0; eve; eve=BMIter_Step(&iter), i++) {
|
|
|
|
|
float *no = bmdm->vertexNos[i];
|
|
|
|
|
/* following Mesh convention; we use vertex coordinate itself
|
|
|
|
|
* for normal in this case */
|
2009-11-23 14:41:22 +00:00
|
|
|
if (normalize_v3(no)==0.0) {
|
2009-05-16 16:18:08 +00:00
|
|
|
VECCOPY(no, vertexCos[i]);
|
2009-11-23 14:41:22 +00:00
|
|
|
normalize_v3(no);
|
2009-05-16 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-10 01:46:52 +00:00
|
|
|
//bmdm_recalc_lookups(bmdm);
|
2009-06-23 05:35:49 +00:00
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
return (DerivedMesh*) bmdm;
|
|
|
|
|
}
|