2005-03-27 22:34:18 +02:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL/BL DUAL 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. The Blender
|
|
|
|
* Foundation also sells licenses for use in proprietary software under
|
|
|
|
* the Blender License. See http://www.blender.org/BL/ for information
|
|
|
|
* about this.
|
|
|
|
*
|
|
|
|
* 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 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
2005-03-29 18:43:39 +02:00
|
|
|
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
2005-03-27 22:34:18 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-07-23 21:15:08 +02:00
|
|
|
#include "PIL_time.h"
|
|
|
|
|
2005-03-27 22:34:18 +02:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "DNA_effect_types.h"
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meshdata_types.h"
|
2005-07-19 22:14:17 +02:00
|
|
|
#include "DNA_modifier_types.h"
|
2005-03-27 22:34:18 +02:00
|
|
|
#include "DNA_object_types.h"
|
2005-06-06 11:52:44 +02:00
|
|
|
#include "DNA_object_force.h"
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
#include "BLI_arithb.h"
|
2005-03-27 23:27:12 +02:00
|
|
|
#include "BLI_blenlib.h"
|
2005-03-27 22:34:18 +02:00
|
|
|
#include "BLI_editVert.h"
|
|
|
|
|
2005-07-17 06:17:33 +02:00
|
|
|
#include "BKE_utildefines.h"
|
2005-03-27 22:34:18 +02:00
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
#include "BKE_displist.h"
|
|
|
|
#include "BKE_effect.h"
|
|
|
|
#include "BKE_global.h"
|
2005-03-29 09:51:00 +02:00
|
|
|
#include "BKE_material.h"
|
2005-03-27 22:34:18 +02:00
|
|
|
#include "BKE_mesh.h"
|
|
|
|
#include "BKE_object.h"
|
2005-03-28 23:49:49 +02:00
|
|
|
#include "BKE_subsurf.h"
|
2005-07-19 02:21:01 +02:00
|
|
|
#include "BKE_deform.h"
|
2005-07-19 22:14:17 +02:00
|
|
|
#include "BKE_modifier.h"
|
2005-03-27 22:34:18 +02:00
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
|
|
///////////////////////////////////
|
|
|
|
///////////////////////////////////
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DerivedMesh dm;
|
|
|
|
|
|
|
|
Object *ob;
|
2005-07-18 21:58:23 +02:00
|
|
|
Mesh *me;
|
2005-07-17 22:12:16 +02:00
|
|
|
MVert *verts;
|
|
|
|
float *nors;
|
|
|
|
|
2005-07-19 04:36:21 +02:00
|
|
|
int freeNors, freeVerts;
|
2005-03-27 22:34:18 +02:00
|
|
|
} MeshDerivedMesh;
|
|
|
|
|
2005-07-16 23:03:28 +02:00
|
|
|
static DispListMesh *meshDM_convertToDispListMesh(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 21:58:23 +02:00
|
|
|
Mesh *me = mdm->me;
|
2005-07-16 23:03:28 +02:00
|
|
|
DispListMesh *dlm = MEM_callocN(sizeof(*dlm), "dlm");
|
|
|
|
|
|
|
|
dlm->totvert = me->totvert;
|
|
|
|
dlm->totedge = me->totedge;
|
|
|
|
dlm->totface = me->totface;
|
2005-07-17 22:12:16 +02:00
|
|
|
dlm->mvert = mdm->verts;
|
2005-07-16 23:03:28 +02:00
|
|
|
dlm->medge = me->medge;
|
|
|
|
dlm->mface = me->mface;
|
|
|
|
dlm->tface = me->tface;
|
|
|
|
dlm->mcol = me->mcol;
|
|
|
|
dlm->nors = mdm->nors;
|
2005-07-16 23:16:05 +02:00
|
|
|
dlm->dontFreeVerts = dlm->dontFreeOther = dlm->dontFreeNors = 1;
|
2005-07-16 23:03:28 +02:00
|
|
|
|
|
|
|
return dlm;
|
|
|
|
}
|
|
|
|
|
2005-07-17 06:17:33 +02:00
|
|
|
static void meshDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 21:58:23 +02:00
|
|
|
Mesh *me = mdm->me;
|
2005-07-17 06:17:33 +02:00
|
|
|
int i;
|
|
|
|
|
2005-07-18 19:33:51 +02:00
|
|
|
if (me->totvert) {
|
|
|
|
for (i=0; i<me->totvert; i++) {
|
|
|
|
DO_MINMAX(mdm->verts[i].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;
|
2005-07-17 06:17:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-18 21:58:23 +02:00
|
|
|
static void meshDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3])
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
|
|
|
Mesh *me = mdm->me;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<me->totvert; i++) {
|
|
|
|
cos_r[i][0] = mdm->verts[i].co[0];
|
|
|
|
cos_r[i][1] = mdm->verts[i].co[1];
|
|
|
|
cos_r[i][2] = mdm->verts[i].co[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-17 03:18:59 +02:00
|
|
|
static void meshDM_getVertCo(DerivedMesh *dm, int index, float co_r[3])
|
|
|
|
{
|
2005-07-17 22:12:16 +02:00
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
|
|
|
float *co = mdm->verts[index].co;
|
2005-07-17 03:18:59 +02:00
|
|
|
|
|
|
|
co_r[0] = co[0];
|
|
|
|
co_r[1] = co[1];
|
|
|
|
co_r[2] = co[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void meshDM_getVertNo(DerivedMesh *dm, int index, float no_r[3])
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-17 22:12:16 +02:00
|
|
|
short *no = mdm->verts[index].no;
|
2005-07-17 03:18:59 +02:00
|
|
|
|
|
|
|
no_r[0] = no[0]/32767.f;
|
|
|
|
no_r[1] = no[1]/32767.f;
|
|
|
|
no_r[2] = no[2]/32767.f;
|
|
|
|
}
|
|
|
|
|
2005-03-27 22:34:18 +02:00
|
|
|
static void meshDM_drawVerts(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 21:58:23 +02:00
|
|
|
Mesh *me = mdm->me;
|
2005-07-20 06:14:21 +02:00
|
|
|
int a;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
|
|
|
glBegin(GL_POINTS);
|
2005-07-20 06:14:21 +02:00
|
|
|
for(a=0; a<me->totvert; a++) {
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mdm->verts[ a].co);
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
static void meshDM_drawEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 21:58:23 +02:00
|
|
|
Mesh *me= mdm->me;
|
2005-07-20 06:14:21 +02:00
|
|
|
int a;
|
2005-03-27 22:34:18 +02:00
|
|
|
MFace *mface = me->mface;
|
|
|
|
|
2005-07-20 06:14:21 +02:00
|
|
|
if(me->medge) {
|
2005-03-27 22:34:18 +02:00
|
|
|
MEdge *medge= me->medge;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(a=me->totedge; a>0; a--, medge++) {
|
|
|
|
if(medge->flag & ME_EDGEDRAW) {
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mdm->verts[ medge->v1].co);
|
|
|
|
glVertex3fv(mdm->verts[ medge->v2].co);
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glBegin(GL_LINES);
|
2005-07-20 06:14:21 +02:00
|
|
|
for(a=0; a<me->totface; a++, mface++) {
|
2005-03-27 22:34:18 +02:00
|
|
|
int test= mface->edcode;
|
|
|
|
|
|
|
|
if(test) {
|
|
|
|
if(test&ME_V1V2){
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mdm->verts[mface->v1].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v2].co);
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(mface->v3) {
|
|
|
|
if(test&ME_V2V3){
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mdm->verts[mface->v2].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v3].co);
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mface->v4) {
|
|
|
|
if(test&ME_V3V4){
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mdm->verts[mface->v3].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v4].co);
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
if(test&ME_V4V1){
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mdm->verts[mface->v4].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v1].co);
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(test&ME_V3V1){
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mdm->verts[mface->v3].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v1].co);
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void meshDM_drawLooseEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 21:58:23 +02:00
|
|
|
Mesh *me = mdm->me;
|
2005-03-27 22:34:18 +02:00
|
|
|
MFace *mface= me->mface;
|
2005-07-20 06:14:21 +02:00
|
|
|
int a;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
2005-07-20 06:14:21 +02:00
|
|
|
for(a=0; a<me->totface; a++, mface++) {
|
2005-03-27 22:34:18 +02:00
|
|
|
if(!mface->v3) {
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mdm->verts[mface->v3].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v4].co);
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
2005-07-13 22:16:35 +02:00
|
|
|
static void meshDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int))
|
2005-03-27 22:34:18 +02:00
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 21:58:23 +02:00
|
|
|
Mesh *me = mdm->me;
|
2005-07-17 22:12:16 +02:00
|
|
|
MVert *mvert= mdm->verts;
|
2005-03-27 22:34:18 +02:00
|
|
|
MFace *mface= me->mface;
|
|
|
|
float *nors = mdm->nors;
|
2005-07-20 06:14:21 +02:00
|
|
|
int a;
|
2005-07-13 22:16:35 +02:00
|
|
|
int glmode=-1, shademodel=-1, matnr=-1, drawCurrentMat=1;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2005-07-23 18:09:08 +02:00
|
|
|
#define PASSVERT(index) { \
|
2005-03-27 22:34:18 +02:00
|
|
|
if (shademodel==GL_SMOOTH) { \
|
2005-07-17 22:12:16 +02:00
|
|
|
short *no = mvert[index].no; \
|
2005-07-23 18:09:08 +02:00
|
|
|
glNormal3sv(no); \
|
2005-03-27 22:34:18 +02:00
|
|
|
} \
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mvert[index].co); \
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
glBegin(glmode=GL_QUADS);
|
2005-07-20 06:14:21 +02:00
|
|
|
for(a=0; a<me->totface; a++, mface++, nors+=3) {
|
2005-03-27 22:34:18 +02:00
|
|
|
if(mface->v3) {
|
|
|
|
int new_glmode, new_matnr, new_shademodel;
|
|
|
|
|
2005-03-29 09:58:56 +02:00
|
|
|
new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES;
|
2005-03-27 22:34:18 +02:00
|
|
|
new_matnr = mface->mat_nr+1;
|
|
|
|
new_shademodel = (!(me->flag&ME_AUTOSMOOTH) && (mface->flag & ME_SMOOTH))?GL_SMOOTH:GL_FLAT;
|
|
|
|
|
|
|
|
if (new_glmode!=glmode || new_matnr!=matnr || new_shademodel!=shademodel) {
|
|
|
|
glEnd();
|
|
|
|
|
2005-07-13 22:16:35 +02:00
|
|
|
drawCurrentMat = setMaterial(matnr=new_matnr);
|
2005-03-27 22:34:18 +02:00
|
|
|
|
|
|
|
glShadeModel(shademodel=new_shademodel);
|
|
|
|
glBegin(glmode=new_glmode);
|
2005-07-13 22:16:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (drawCurrentMat) {
|
|
|
|
if(shademodel==GL_FLAT)
|
|
|
|
glNormal3fv(nors);
|
|
|
|
|
2005-07-23 18:09:08 +02:00
|
|
|
PASSVERT(mface->v1);
|
|
|
|
PASSVERT(mface->v2);
|
|
|
|
PASSVERT(mface->v3);
|
2005-07-13 22:16:35 +02:00
|
|
|
if (mface->v4) {
|
2005-07-23 18:09:08 +02:00
|
|
|
PASSVERT(mface->v4);
|
2005-07-13 22:16:35 +02:00
|
|
|
}
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
#undef PASSVERT
|
|
|
|
}
|
|
|
|
|
|
|
|
static void meshDM_drawFacesColored(DerivedMesh *dm, int useTwoSide, unsigned char *col1, unsigned char *col2)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 21:58:23 +02:00
|
|
|
Mesh *me= mdm->me;
|
2005-03-27 22:34:18 +02:00
|
|
|
MFace *mface= me->mface;
|
2005-07-20 06:14:21 +02:00
|
|
|
int a, glmode;
|
2005-03-27 22:34:18 +02:00
|
|
|
unsigned char *cp1, *cp2;
|
|
|
|
|
|
|
|
cp1= col1;
|
|
|
|
if(col2) {
|
|
|
|
cp2= col2;
|
|
|
|
} else {
|
|
|
|
cp2= NULL;
|
|
|
|
useTwoSide= 0;
|
|
|
|
}
|
|
|
|
|
2005-05-28 14:23:40 +02:00
|
|
|
/* there's a conflict here... twosided colors versus culling...? */
|
|
|
|
/* defined by history, only texture faces have culling option */
|
|
|
|
/* we need that as mesh option builtin, next to double sided lighting */
|
2005-05-29 12:47:36 +02:00
|
|
|
if(col1 && col2)
|
|
|
|
glEnable(GL_CULL_FACE);
|
2005-05-28 14:23:40 +02:00
|
|
|
|
2005-03-27 22:34:18 +02:00
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
glBegin(glmode=GL_QUADS);
|
2005-07-20 06:14:21 +02:00
|
|
|
for(a=0; a<me->totface; a++, mface++, cp1+= 16) {
|
2005-03-27 22:34:18 +02:00
|
|
|
if(mface->v3) {
|
|
|
|
int new_glmode= mface->v4?GL_QUADS:GL_TRIANGLES;
|
|
|
|
|
|
|
|
if (new_glmode!=glmode) {
|
|
|
|
glEnd();
|
|
|
|
glBegin(glmode= new_glmode);
|
|
|
|
}
|
|
|
|
|
|
|
|
glColor3ub(cp1[3], cp1[2], cp1[1]);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv( mdm->verts[mface->v1].co );
|
2005-03-27 22:34:18 +02:00
|
|
|
glColor3ub(cp1[7], cp1[6], cp1[5]);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv( mdm->verts[mface->v2].co );
|
2005-03-27 22:34:18 +02:00
|
|
|
glColor3ub(cp1[11], cp1[10], cp1[9]);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv( mdm->verts[mface->v3].co );
|
2005-03-29 09:58:56 +02:00
|
|
|
if(mface->v4) {
|
2005-03-27 22:34:18 +02:00
|
|
|
glColor3ub(cp1[15], cp1[14], cp1[13]);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv( mdm->verts[mface->v4].co );
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(useTwoSide) {
|
|
|
|
glColor3ub(cp2[11], cp2[10], cp2[9]);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv( mdm->verts[mface->v3].co );
|
2005-03-27 22:34:18 +02:00
|
|
|
glColor3ub(cp2[7], cp2[6], cp2[5]);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv( mdm->verts[mface->v2].co );
|
2005-03-27 22:34:18 +02:00
|
|
|
glColor3ub(cp2[3], cp2[2], cp2[1]);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv( mdm->verts[mface->v1].co );
|
2005-03-27 22:34:18 +02:00
|
|
|
if(mface->v4) {
|
|
|
|
glColor3ub(cp2[15], cp2[14], cp2[13]);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv( mdm->verts[mface->v4].co );
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(col2) cp2+= 16;
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
}
|
|
|
|
|
2005-03-29 09:51:00 +02:00
|
|
|
static void meshDM_drawFacesTex(DerivedMesh *dm, int (*setDrawParams)(TFace *tf, int matnr))
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 21:58:23 +02:00
|
|
|
Mesh *me = mdm->me;
|
2005-07-17 22:12:16 +02:00
|
|
|
MVert *mvert= mdm->verts;
|
2005-03-29 09:51:00 +02:00
|
|
|
MFace *mface= me->mface;
|
|
|
|
TFace *tface = me->tface;
|
|
|
|
float *nors = mdm->nors;
|
2005-07-20 06:14:21 +02:00
|
|
|
int a;
|
2005-03-29 09:51:00 +02:00
|
|
|
|
2005-07-20 06:14:21 +02:00
|
|
|
for (a=0; a<me->totface; a++) {
|
2005-03-29 09:51:00 +02:00
|
|
|
MFace *mf= &mface[a];
|
2005-04-14 15:46:05 +02:00
|
|
|
TFace *tf = tface?&tface[a]:NULL;
|
2005-03-29 09:51:00 +02:00
|
|
|
unsigned char *cp= NULL;
|
|
|
|
|
|
|
|
if(mf->v3==0) continue;
|
2005-04-14 15:46:05 +02:00
|
|
|
if(tf && ((tf->flag&TF_HIDE) || (tf->mode&TF_INVISIBLE))) continue;
|
2005-03-29 09:51:00 +02:00
|
|
|
|
2005-04-14 15:46:05 +02:00
|
|
|
if (setDrawParams(tf, mf->mat_nr)) {
|
|
|
|
if (tf) {
|
|
|
|
cp= (unsigned char *) tf->col;
|
2005-03-29 09:51:00 +02:00
|
|
|
} else if (me->mcol) {
|
|
|
|
cp= (unsigned char *) &me->mcol[a*4];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(mf->flag&ME_SMOOTH)) {
|
|
|
|
glNormal3fv(&nors[a*3]);
|
|
|
|
}
|
|
|
|
|
2005-03-30 08:24:34 +02:00
|
|
|
glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
|
2005-04-14 15:46:05 +02:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[0]);
|
2005-03-29 09:51:00 +02:00
|
|
|
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v1].no);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mvert[mf->v1].co);
|
2005-03-29 09:51:00 +02:00
|
|
|
|
2005-04-14 15:46:05 +02:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[1]);
|
2005-03-29 09:51:00 +02:00
|
|
|
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v2].no);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mvert[mf->v2].co);
|
2005-03-29 09:51:00 +02:00
|
|
|
|
2005-04-14 15:46:05 +02:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[2]);
|
2005-03-29 09:51:00 +02:00
|
|
|
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v3].no);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mvert[mf->v3].co);
|
2005-03-29 09:51:00 +02:00
|
|
|
|
2005-03-30 08:24:34 +02:00
|
|
|
if(mf->v4) {
|
2005-04-14 15:46:05 +02:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[3]);
|
2005-03-29 09:51:00 +02:00
|
|
|
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v4].no);
|
2005-07-17 22:12:16 +02:00
|
|
|
glVertex3fv(mvert[mf->v4].co);
|
2005-03-29 09:51:00 +02:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
2005-03-27 23:27:12 +02:00
|
|
|
static int meshDM_getNumVerts(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 21:58:23 +02:00
|
|
|
Mesh *me = mdm->me;
|
2005-03-27 23:27:12 +02:00
|
|
|
|
|
|
|
return me->totvert;
|
|
|
|
}
|
|
|
|
static int meshDM_getNumFaces(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 21:58:23 +02:00
|
|
|
Mesh *me = mdm->me;
|
2005-03-27 23:27:12 +02:00
|
|
|
|
|
|
|
return me->totface;
|
|
|
|
}
|
|
|
|
|
2005-07-17 19:41:03 +02:00
|
|
|
static void meshDM_release(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
|
|
|
|
2005-07-17 22:12:16 +02:00
|
|
|
if (mdm->freeNors) MEM_freeN(mdm->nors);
|
2005-07-19 04:36:21 +02:00
|
|
|
if (mdm->freeVerts) MEM_freeN(mdm->verts);
|
2005-07-17 19:41:03 +02:00
|
|
|
MEM_freeN(mdm);
|
|
|
|
}
|
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
static DerivedMesh *getMeshDerivedMesh(Mesh *me, Object *ob, float (*vertCos)[3])
|
2005-03-27 22:34:18 +02:00
|
|
|
{
|
2005-07-17 19:41:03 +02:00
|
|
|
MeshDerivedMesh *mdm = MEM_callocN(sizeof(*mdm), "mdm");
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2005-07-17 06:17:33 +02:00
|
|
|
mdm->dm.getMinMax = meshDM_getMinMax;
|
|
|
|
|
2005-07-16 23:03:28 +02:00
|
|
|
mdm->dm.convertToDispListMesh = meshDM_convertToDispListMesh;
|
2005-03-27 23:27:12 +02:00
|
|
|
mdm->dm.getNumVerts = meshDM_getNumVerts;
|
|
|
|
mdm->dm.getNumFaces = meshDM_getNumFaces;
|
|
|
|
|
2005-07-18 21:58:23 +02:00
|
|
|
mdm->dm.getVertCos = meshDM_getVertCos;
|
2005-07-17 03:18:59 +02:00
|
|
|
mdm->dm.getVertCo = meshDM_getVertCo;
|
|
|
|
mdm->dm.getVertNo = meshDM_getVertNo;
|
|
|
|
|
2005-03-27 22:34:18 +02:00
|
|
|
mdm->dm.drawVerts = meshDM_drawVerts;
|
|
|
|
|
|
|
|
mdm->dm.drawEdges = meshDM_drawEdges;
|
|
|
|
mdm->dm.drawMappedEdges = meshDM_drawEdges;
|
|
|
|
mdm->dm.drawLooseEdges = meshDM_drawLooseEdges;
|
|
|
|
|
|
|
|
mdm->dm.drawFacesSolid = meshDM_drawFacesSolid;
|
|
|
|
mdm->dm.drawFacesColored = meshDM_drawFacesColored;
|
2005-03-29 09:51:00 +02:00
|
|
|
mdm->dm.drawFacesTex = meshDM_drawFacesTex;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2005-07-17 19:41:03 +02:00
|
|
|
mdm->dm.release = meshDM_release;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
|
|
|
mdm->ob = ob;
|
2005-07-18 21:58:23 +02:00
|
|
|
mdm->me = me;
|
2005-07-19 02:21:01 +02:00
|
|
|
mdm->verts = me->mvert;
|
|
|
|
mdm->nors = NULL;
|
2005-07-17 22:12:16 +02:00
|
|
|
mdm->freeNors = 0;
|
2005-07-19 04:36:21 +02:00
|
|
|
mdm->freeVerts = 0;
|
2005-07-17 22:12:16 +02:00
|
|
|
|
2005-07-18 21:58:23 +02:00
|
|
|
if (vertCos) {
|
|
|
|
int i;
|
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
mdm->verts = MEM_mallocN(sizeof(*mdm->verts)*me->totvert, "deformedVerts");
|
2005-07-18 21:58:23 +02:00
|
|
|
for (i=0; i<me->totvert; i++) {
|
2005-07-19 02:21:01 +02:00
|
|
|
mdm->verts[i].co[0] = vertCos[i][0];
|
|
|
|
mdm->verts[i].co[1] = vertCos[i][1];
|
|
|
|
mdm->verts[i].co[2] = vertCos[i][2];
|
2005-07-18 21:58:23 +02:00
|
|
|
}
|
2005-07-17 22:12:16 +02:00
|
|
|
mesh_calc_normals(mdm->verts, me->totvert, me->mface, me->totface, &mdm->nors);
|
|
|
|
mdm->freeNors = 1;
|
2005-07-19 04:36:21 +02:00
|
|
|
mdm->freeVerts = 1;
|
2005-07-17 22:12:16 +02:00
|
|
|
} else {
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
// XXX this is kinda hacky because we shouldn't really be editing
|
|
|
|
// the mesh here, however, we can't just call mesh_build_faceNormals(ob)
|
|
|
|
// because in the case when a key is applied to a mesh the vertex normals
|
|
|
|
// would never be correctly computed (and renderer makes this assumption.
|
|
|
|
mesh_calc_normals(mdm->verts, me->totvert, me->mface, me->totface, &mdm->nors);
|
2005-07-19 02:21:01 +02:00
|
|
|
mdm->freeNors = 1;
|
2005-07-17 22:12:16 +02:00
|
|
|
}
|
2005-03-27 22:34:18 +02:00
|
|
|
|
|
|
|
return (DerivedMesh*) mdm;
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DerivedMesh dm;
|
|
|
|
|
|
|
|
EditMesh *em;
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
float (*vertexCos)[3];
|
2005-03-27 22:34:18 +02:00
|
|
|
} EditMeshDerivedMesh;
|
|
|
|
|
2005-03-28 09:10:32 +02:00
|
|
|
static void emDM_getMappedVertCoEM(DerivedMesh *dm, void *vert, float co_r[3])
|
|
|
|
{
|
|
|
|
EditVert *eve = vert;
|
|
|
|
|
|
|
|
co_r[0] = eve->co[0];
|
|
|
|
co_r[1] = eve->co[1];
|
|
|
|
co_r[2] = eve->co[2];
|
|
|
|
}
|
2005-03-30 07:57:40 +02:00
|
|
|
static void emDM_drawMappedVertsEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, EditVert *vert), void *userData)
|
2005-03-27 22:34:18 +02:00
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditVert *eve;
|
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
if (emdm->vertexCos) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
for(i=0,eve= emdm->em->verts.first; eve; i++,eve= eve->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, eve))
|
|
|
|
bglVertex3fv(emdm->vertexCos[i]);
|
|
|
|
}
|
|
|
|
bglEnd();
|
|
|
|
} else {
|
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
for(eve= emdm->em->verts.first; eve; eve= eve->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, eve))
|
|
|
|
bglVertex3fv(eve->co);
|
|
|
|
}
|
|
|
|
bglEnd();
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
2005-03-28 00:14:57 +02:00
|
|
|
static void emDM_drawMappedEdgeEM(DerivedMesh *dm, void *edge)
|
|
|
|
{
|
|
|
|
EditEdge *eed = edge;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex3fv(eed->v1->co);
|
|
|
|
glVertex3fv(eed->v2->co);
|
|
|
|
glEnd();
|
|
|
|
}
|
2005-03-30 07:57:40 +02:00
|
|
|
static void emDM_drawMappedEdgesEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, EditEdge *edge), void *userData)
|
2005-03-27 22:34:18 +02:00
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditEdge *eed;
|
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
if (emdm->vertexCos) {
|
|
|
|
EditVert *eve, *preveve;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
|
|
|
|
eve->prev = (EditVert*) i++;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(eed= emdm->em->edges.first; eed; eed= eed->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, eed)) {
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) eed->v1->prev]);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) eed->v2->prev]);
|
|
|
|
}
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
for (preveve=NULL, eve=emdm->em->verts.first; eve; preveve=eve, eve= eve->next)
|
|
|
|
eve->prev = preveve;
|
|
|
|
} else {
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(eed= emdm->em->edges.first; eed; eed= eed->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, eed)) {
|
|
|
|
glVertex3fv(eed->v1->co);
|
|
|
|
glVertex3fv(eed->v2->co);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
}
|
|
|
|
static void emDM_drawEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
emDM_drawMappedEdgesEM(dm, NULL, NULL);
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
2005-03-30 07:57:40 +02:00
|
|
|
static void emDM_drawMappedEdgesInterpEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, EditEdge *edge), void (*setDrawInterpOptions)(void *userData, EditEdge *edge, float t), void *userData)
|
2005-03-28 08:46:21 +02:00
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditEdge *eed;
|
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
if (emdm->vertexCos) {
|
|
|
|
EditVert *eve, *preveve;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
|
|
|
|
eve->prev = (EditVert*) i++;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(eed= emdm->em->edges.first; eed; eed= eed->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, eed)) {
|
|
|
|
setDrawInterpOptions(userData, eed, 0.0);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) eed->v1->prev]);
|
|
|
|
setDrawInterpOptions(userData, eed, 1.0);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) eed->v2->prev]);
|
|
|
|
}
|
2005-03-28 08:46:21 +02:00
|
|
|
}
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
glEnd();
|
2005-03-27 22:34:18 +02:00
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
for (preveve=NULL, eve=emdm->em->verts.first; eve; preveve=eve, eve= eve->next)
|
|
|
|
eve->prev = preveve;
|
|
|
|
} else {
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(eed= emdm->em->edges.first; eed; eed= eed->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, eed)) {
|
|
|
|
setDrawInterpOptions(userData, eed, 0.0);
|
|
|
|
glVertex3fv(eed->v1->co);
|
|
|
|
setDrawInterpOptions(userData, eed, 1.0);
|
|
|
|
glVertex3fv(eed->v2->co);
|
|
|
|
}
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
glEnd();
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
2005-07-23 09:45:39 +02:00
|
|
|
static void emDM__calcFaceCent(EditFace *efa, float cent[3], float (*vertexCos)[3])
|
|
|
|
{
|
|
|
|
if (vertexCos) {
|
|
|
|
VECCOPY(cent, vertexCos[(int) efa->v1->prev]);
|
|
|
|
VecAddf(cent, cent, vertexCos[(int) efa->v2->prev]);
|
|
|
|
VecAddf(cent, cent, vertexCos[(int) efa->v3->prev]);
|
|
|
|
if (efa->v4) VecAddf(cent, cent, vertexCos[(int) efa->v4->prev]);
|
|
|
|
} else {
|
|
|
|
VECCOPY(cent, efa->v1->co);
|
|
|
|
VecAddf(cent, cent, efa->v2->co);
|
|
|
|
VecAddf(cent, cent, efa->v3->co);
|
|
|
|
if (efa->v4) VecAddf(cent, cent, efa->v4->co);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (efa->v4) {
|
|
|
|
cent[0] *= 0.25f;
|
|
|
|
cent[1] *= 0.25f;
|
|
|
|
cent[2] *= 0.25f;
|
|
|
|
} else {
|
|
|
|
cent[0] *= 0.33333333333f;
|
|
|
|
cent[1] *= 0.33333333333f;
|
|
|
|
cent[2] *= 0.33333333333f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void emDM_drawMappedFaceCentersEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, struct EditFace *efa), void *userData)
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditVert *eve, *preveve;
|
|
|
|
EditFace *efa;
|
|
|
|
float cent[3];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (emdm->vertexCos) {
|
|
|
|
for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
|
|
|
|
eve->prev = (EditVert*) i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
for(efa= emdm->em->faces.first; efa; efa= efa->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, efa)) {
|
|
|
|
emDM__calcFaceCent(efa, cent, emdm->vertexCos);
|
|
|
|
bglVertex3fv(cent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bglEnd();
|
|
|
|
|
|
|
|
if (emdm->vertexCos) {
|
|
|
|
for (preveve=NULL, eve=emdm->em->verts.first; eve; preveve=eve, eve= eve->next)
|
|
|
|
eve->prev = preveve;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void emDM_drawMappedFaceNormalsEM(DerivedMesh *dm, float length, int (*setDrawOptions)(void *userData, struct EditFace *efa), void *userData)
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditVert *eve, *preveve;
|
|
|
|
EditFace *efa;
|
|
|
|
float cent[3];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
if (emdm->vertexCos) {
|
|
|
|
for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
|
|
|
|
eve->prev = (EditVert*) i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (efa= emdm->em->faces.first; efa; efa= efa->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, efa)) {
|
|
|
|
emDM__calcFaceCent(efa, cent, emdm->vertexCos);
|
|
|
|
|
|
|
|
glVertex3fv(efa->cent);
|
|
|
|
glVertex3f( efa->cent[0] + length*efa->n[0],
|
|
|
|
efa->cent[1] + length*efa->n[1],
|
|
|
|
efa->cent[2] + length*efa->n[2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (emdm->vertexCos) {
|
|
|
|
for (preveve=NULL, eve=emdm->em->verts.first; eve; preveve=eve, eve= eve->next)
|
|
|
|
eve->prev = preveve;
|
|
|
|
}
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
static void emDM_drawMappedVertNormalsEM(DerivedMesh *dm, float length, int (*setDrawOptions)(void *userData, struct EditVert *eve), void *userData)
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditVert *eve;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (i=0,eve= emdm->em->verts.first; eve; i++,eve= eve->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, eve)) {
|
|
|
|
if (emdm->vertexCos) {
|
|
|
|
glVertex3fv(emdm->vertexCos[i]);
|
|
|
|
glVertex3f( emdm->vertexCos[i][0] + length*eve->no[0],
|
|
|
|
emdm->vertexCos[i][1] + length*eve->no[1],
|
|
|
|
emdm->vertexCos[i][2] + length*eve->no[2]);
|
|
|
|
} else {
|
|
|
|
glVertex3fv(eve->co);
|
|
|
|
glVertex3f( eve->co[0] + length*eve->no[0],
|
|
|
|
eve->co[1] + length*eve->no[1],
|
|
|
|
eve->co[2] + length*eve->no[2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
static void emDM_drawMappedFacesEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, EditFace *face), void *userData)
|
2005-03-28 07:58:43 +02:00
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
2005-03-28 08:46:21 +02:00
|
|
|
EditFace *efa;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
if (emdm->vertexCos) {
|
|
|
|
EditVert *eve, *preveve;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
|
|
|
|
eve->prev = (EditVert*) i++;
|
|
|
|
|
|
|
|
for (efa= emdm->em->faces.first; efa; efa= efa->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, efa)) {
|
2005-07-13 22:16:35 +02:00
|
|
|
glNormal3fv(efa->n);
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) efa->v1->prev]);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) efa->v2->prev]);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) efa->v3->prev]);
|
|
|
|
if(efa->v4) glVertex3fv(emdm->vertexCos[(int) efa->v4->prev]);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (preveve=NULL, eve=emdm->em->verts.first; eve; preveve=eve, eve= eve->next)
|
|
|
|
eve->prev = preveve;
|
|
|
|
} else {
|
|
|
|
for (efa= emdm->em->faces.first; efa; efa= efa->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, efa)) {
|
2005-07-13 22:16:35 +02:00
|
|
|
glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
|
|
|
|
glVertex3fv(efa->v1->co);
|
|
|
|
glVertex3fv(efa->v2->co);
|
|
|
|
glVertex3fv(efa->v3->co);
|
|
|
|
if(efa->v4) glVertex3fv(efa->v4->co);
|
|
|
|
glEnd();
|
|
|
|
}
|
2005-03-28 07:58:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
static void emDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int))
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditFace *efa;
|
|
|
|
|
|
|
|
if (emdm->vertexCos) {
|
|
|
|
EditVert *eve, *preveve;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
|
|
|
|
eve->prev = (EditVert*) i++;
|
|
|
|
|
|
|
|
for (efa= emdm->em->faces.first; efa; efa= efa->next) {
|
|
|
|
if(efa->h==0) {
|
|
|
|
if (setMaterial(efa->mat_nr+1)) {
|
|
|
|
glNormal3fv(efa->n);
|
|
|
|
glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) efa->v1->prev]);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) efa->v2->prev]);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) efa->v3->prev]);
|
|
|
|
if(efa->v4) glVertex3fv(emdm->vertexCos[(int) efa->v4->prev]);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (preveve=NULL, eve=emdm->em->verts.first; eve; preveve=eve, eve= eve->next)
|
|
|
|
eve->prev = preveve;
|
|
|
|
} else {
|
|
|
|
for (efa= emdm->em->faces.first; efa; efa= efa->next) {
|
|
|
|
if(efa->h==0) {
|
|
|
|
if (setMaterial(efa->mat_nr+1)) {
|
|
|
|
glNormal3fv(efa->n);
|
|
|
|
glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
|
|
|
|
glVertex3fv(efa->v1->co);
|
|
|
|
glVertex3fv(efa->v2->co);
|
|
|
|
glVertex3fv(efa->v3->co);
|
|
|
|
if(efa->v4) glVertex3fv(efa->v4->co);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2005-07-17 06:17:33 +02:00
|
|
|
static void emDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditVert *eve;
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
int i;
|
2005-07-17 06:17:33 +02:00
|
|
|
|
2005-07-18 19:33:51 +02:00
|
|
|
if (emdm->em->verts.first) {
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
for (i=0,eve= emdm->em->verts.first; eve; i++,eve= eve->next) {
|
|
|
|
if (emdm->vertexCos) {
|
|
|
|
DO_MINMAX(emdm->vertexCos[i], min_r, max_r);
|
|
|
|
} else {
|
|
|
|
DO_MINMAX(eve->co, min_r, max_r);
|
|
|
|
}
|
2005-07-18 19:33:51 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
min_r[0] = min_r[1] = min_r[2] = max_r[0] = max_r[1] = max_r[2] = 0.0;
|
2005-07-17 06:17:33 +02:00
|
|
|
}
|
|
|
|
}
|
2005-03-27 23:27:12 +02:00
|
|
|
static int emDM_getNumVerts(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
|
|
|
|
return BLI_countlist(&emdm->em->verts);
|
|
|
|
}
|
|
|
|
static int emDM_getNumFaces(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
|
|
|
|
return BLI_countlist(&emdm->em->faces);
|
|
|
|
}
|
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
static void emDM_release(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
|
|
|
|
if (emdm->vertexCos)
|
|
|
|
MEM_freeN(emdm->vertexCos);
|
|
|
|
|
|
|
|
MEM_freeN(emdm);
|
|
|
|
}
|
|
|
|
|
2005-07-23 09:45:39 +02:00
|
|
|
// XXX face and vertex normals are wrong with vertexcos
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, float (*vertexCos)[3])
|
2005-03-27 22:34:18 +02:00
|
|
|
{
|
2005-07-17 19:41:03 +02:00
|
|
|
EditMeshDerivedMesh *emdm = MEM_callocN(sizeof(*emdm), "emdm");
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2005-07-17 06:17:33 +02:00
|
|
|
emdm->dm.getMinMax = emDM_getMinMax;
|
|
|
|
|
2005-03-27 23:27:12 +02:00
|
|
|
emdm->dm.getNumVerts = emDM_getNumVerts;
|
|
|
|
emdm->dm.getNumFaces = emDM_getNumFaces;
|
2005-03-28 09:10:32 +02:00
|
|
|
emdm->dm.getMappedVertCoEM = emDM_getMappedVertCoEM;
|
2005-03-27 23:27:12 +02:00
|
|
|
|
2005-03-27 22:34:18 +02:00
|
|
|
emdm->dm.drawMappedVertsEM = emDM_drawMappedVertsEM;
|
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
emdm->dm.drawEdges = emDM_drawEdges;
|
2005-03-28 00:14:57 +02:00
|
|
|
emdm->dm.drawMappedEdgeEM = emDM_drawMappedEdgeEM;
|
2005-03-27 22:34:18 +02:00
|
|
|
emdm->dm.drawMappedEdgesEM = emDM_drawMappedEdgesEM;
|
2005-03-30 02:32:10 +02:00
|
|
|
emdm->dm.drawMappedEdgesInterpEM = emDM_drawMappedEdgesInterpEM;
|
|
|
|
|
2005-07-23 09:45:39 +02:00
|
|
|
emdm->dm.drawMappedVertNormalsEM = emDM_drawMappedVertNormalsEM;
|
|
|
|
emdm->dm.drawMappedFaceNormalsEM = emDM_drawMappedFaceNormalsEM;
|
|
|
|
emdm->dm.drawMappedFaceCentersEM = emDM_drawMappedFaceCentersEM;
|
|
|
|
|
2005-03-27 22:34:18 +02:00
|
|
|
emdm->dm.drawFacesSolid = emDM_drawFacesSolid;
|
2005-03-30 02:32:10 +02:00
|
|
|
emdm->dm.drawMappedFacesEM = emDM_drawMappedFacesEM;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
emdm->dm.release = emDM_release;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
|
|
|
emdm->em = em;
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
emdm->vertexCos = vertexCos;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
|
|
|
return (DerivedMesh*) emdm;
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DerivedMesh dm;
|
|
|
|
|
|
|
|
DispListMesh *dlm;
|
|
|
|
} SSDerivedMesh;
|
|
|
|
|
|
|
|
static void ssDM_drawMappedEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
|
|
|
MEdge *medge= dlm->medge;
|
|
|
|
MVert *mvert= dlm->mvert;
|
|
|
|
int a;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (a=0; a<dlm->totedge; a++, medge++) {
|
|
|
|
if (medge->flag&ME_EDGEDRAW) {
|
|
|
|
glVertex3fv(mvert[medge->v1].co);
|
|
|
|
glVertex3fv(mvert[medge->v2].co);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ssDM_drawLooseEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
/* Can't implement currently */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ssDM_drawVerts(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
|
|
|
MVert *mvert= dlm->mvert;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
for (i=0; i<dlm->totvert; i++) {
|
|
|
|
bglVertex3fv(mvert[i].co);
|
|
|
|
}
|
|
|
|
bglEnd();
|
|
|
|
}
|
|
|
|
static void ssDM_drawEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
|
|
|
MVert *mvert= dlm->mvert;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (dlm->medge) {
|
|
|
|
MEdge *medge= dlm->medge;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (i=0; i<dlm->totedge; i++, medge++) {
|
|
|
|
glVertex3fv(mvert[medge->v1].co);
|
|
|
|
glVertex3fv(mvert[medge->v2].co);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
} else {
|
|
|
|
MFace *mface= dlm->mface;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (i=0; i<dlm->totface; i++, mface++) {
|
|
|
|
glVertex3fv(mvert[mface->v1].co);
|
|
|
|
glVertex3fv(mvert[mface->v2].co);
|
|
|
|
|
|
|
|
if (mface->v3) {
|
|
|
|
glVertex3fv(mvert[mface->v2].co);
|
|
|
|
glVertex3fv(mvert[mface->v3].co);
|
|
|
|
|
|
|
|
glVertex3fv(mvert[mface->v3].co);
|
|
|
|
if (mface->v4) {
|
|
|
|
glVertex3fv(mvert[mface->v4].co);
|
|
|
|
|
|
|
|
glVertex3fv(mvert[mface->v4].co);
|
|
|
|
}
|
|
|
|
glVertex3fv(mvert[mface->v1].co);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
2005-07-13 22:16:35 +02:00
|
|
|
static void ssDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int))
|
2005-03-27 22:34:18 +02:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
2005-03-28 10:17:51 +02:00
|
|
|
float *nors = dlm->nors;
|
2005-07-13 22:16:35 +02:00
|
|
|
int glmode=-1, shademodel=-1, matnr=-1, drawCurrentMat=1;
|
2005-03-27 22:34:18 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
#define PASSVERT(ind) { \
|
|
|
|
if (shademodel==GL_SMOOTH) \
|
|
|
|
glNormal3sv(dlm->mvert[(ind)].no); \
|
|
|
|
glVertex3fv(dlm->mvert[(ind)].co); \
|
|
|
|
}
|
|
|
|
|
|
|
|
glBegin(glmode=GL_QUADS);
|
|
|
|
for (i=0; i<dlm->totface; i++) {
|
|
|
|
MFace *mf= &dlm->mface[i];
|
|
|
|
|
|
|
|
if (mf->v3) {
|
|
|
|
int new_glmode = mf->v4?GL_QUADS:GL_TRIANGLES;
|
|
|
|
int new_shademodel = (mf->flag&ME_SMOOTH)?GL_SMOOTH:GL_FLAT;
|
|
|
|
int new_matnr = mf->mat_nr+1;
|
|
|
|
|
|
|
|
if(new_glmode!=glmode || new_shademodel!=shademodel || new_matnr!=matnr) {
|
|
|
|
glEnd();
|
|
|
|
|
2005-07-13 22:16:35 +02:00
|
|
|
drawCurrentMat = setMaterial(matnr=new_matnr);
|
2005-03-27 22:34:18 +02:00
|
|
|
|
|
|
|
glShadeModel(shademodel=new_shademodel);
|
|
|
|
glBegin(glmode=new_glmode);
|
|
|
|
}
|
|
|
|
|
2005-07-13 22:16:35 +02:00
|
|
|
if (drawCurrentMat) {
|
|
|
|
if (shademodel==GL_FLAT)
|
|
|
|
glNormal3fv(&nors[i*3]);
|
|
|
|
|
|
|
|
PASSVERT(mf->v1);
|
|
|
|
PASSVERT(mf->v2);
|
|
|
|
PASSVERT(mf->v3);
|
|
|
|
if (mf->v4)
|
|
|
|
PASSVERT(mf->v4);
|
|
|
|
}
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
#undef PASSVERT
|
|
|
|
}
|
|
|
|
static void ssDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned char *vcols1, unsigned char *vcols2)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
|
|
|
int i, lmode;
|
|
|
|
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
if (vcols2) {
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
} else {
|
|
|
|
useTwoSided = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PASSVERT(vidx, fidx) { \
|
|
|
|
unsigned char *col= &colbase[fidx*4]; \
|
|
|
|
glColor3ub(col[3], col[2], col[1]); \
|
|
|
|
glVertex3fv(dlm->mvert[(vidx)].co); \
|
|
|
|
}
|
|
|
|
|
|
|
|
glBegin(lmode= GL_QUADS);
|
|
|
|
for (i=0; i<dlm->totface; i++) {
|
|
|
|
MFace *mf= &dlm->mface[i];
|
|
|
|
|
|
|
|
if (mf->v3) {
|
|
|
|
int nmode= mf->v4?GL_QUADS:GL_TRIANGLES;
|
|
|
|
unsigned char *colbase= &vcols1[i*16];
|
|
|
|
|
|
|
|
if (nmode!=lmode) {
|
|
|
|
glEnd();
|
|
|
|
glBegin(lmode= nmode);
|
|
|
|
}
|
|
|
|
|
|
|
|
PASSVERT(mf->v1, 0);
|
|
|
|
PASSVERT(mf->v2, 1);
|
|
|
|
PASSVERT(mf->v3, 2);
|
|
|
|
if (mf->v4)
|
|
|
|
PASSVERT(mf->v4, 3);
|
|
|
|
|
|
|
|
if (useTwoSided) {
|
|
|
|
unsigned char *colbase= &vcols2[i*16];
|
|
|
|
|
|
|
|
if (mf->v4)
|
|
|
|
PASSVERT(mf->v4, 3);
|
|
|
|
PASSVERT(mf->v3, 2);
|
|
|
|
PASSVERT(mf->v2, 1);
|
|
|
|
PASSVERT(mf->v1, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
if (vcols2)
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
#undef PASSVERT
|
|
|
|
}
|
2005-03-29 09:51:00 +02:00
|
|
|
static void ssDM_drawFacesTex(DerivedMesh *dm, int (*setDrawParams)(TFace *tf, int matnr))
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
|
|
|
MVert *mvert= dlm->mvert;
|
|
|
|
MFace *mface= dlm->mface;
|
|
|
|
TFace *tface = dlm->tface;
|
|
|
|
float *nors = dlm->nors;
|
|
|
|
int a;
|
|
|
|
|
|
|
|
for (a=0; a<dlm->totface; a++) {
|
|
|
|
MFace *mf= &mface[a];
|
2005-04-14 15:46:05 +02:00
|
|
|
TFace *tf = tface?&tface[a]:NULL;
|
2005-03-29 09:51:00 +02:00
|
|
|
unsigned char *cp= NULL;
|
|
|
|
|
|
|
|
if(mf->v3==0) continue;
|
2005-04-14 15:46:05 +02:00
|
|
|
if(tf && ((tf->flag&TF_HIDE) || (tf->mode&TF_INVISIBLE))) continue;
|
2005-03-29 09:51:00 +02:00
|
|
|
|
2005-04-14 15:46:05 +02:00
|
|
|
if (setDrawParams(tf, mf->mat_nr)) {
|
|
|
|
if (tf) {
|
|
|
|
cp= (unsigned char*) tf->col;
|
2005-03-29 09:51:00 +02:00
|
|
|
} else if (dlm->mcol) {
|
|
|
|
cp= (unsigned char*) &dlm->mcol[a*4];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(mf->flag&ME_SMOOTH)) {
|
|
|
|
glNormal3fv(&nors[a*3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
|
2005-04-14 15:46:05 +02:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[0]);
|
2005-03-29 09:51:00 +02:00
|
|
|
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v1].no);
|
|
|
|
glVertex3fv((mvert+mf->v1)->co);
|
|
|
|
|
2005-04-14 15:46:05 +02:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[1]);
|
2005-03-29 09:51:00 +02:00
|
|
|
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v2].no);
|
|
|
|
glVertex3fv((mvert+mf->v2)->co);
|
|
|
|
|
2005-04-14 15:46:05 +02:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[2]);
|
2005-03-29 09:51:00 +02:00
|
|
|
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v3].no);
|
|
|
|
glVertex3fv((mvert+mf->v3)->co);
|
|
|
|
|
|
|
|
if(mf->v4) {
|
2005-04-14 15:46:05 +02:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[3]);
|
2005-03-29 09:51:00 +02:00
|
|
|
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v4].no);
|
|
|
|
glVertex3fv((mvert+mf->v4)->co);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-17 06:17:33 +02:00
|
|
|
static void ssDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
int i;
|
|
|
|
|
2005-07-18 19:33:51 +02:00
|
|
|
if (ssdm->dlm->totvert) {
|
|
|
|
for (i=0; i<ssdm->dlm->totvert; i++) {
|
|
|
|
DO_MINMAX(ssdm->dlm->mvert[i].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;
|
2005-07-17 06:17:33 +02:00
|
|
|
}
|
|
|
|
}
|
2005-07-17 19:41:03 +02:00
|
|
|
|
2005-07-18 21:58:23 +02:00
|
|
|
static void ssDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3])
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<ssdm->dlm->totvert; i++) {
|
|
|
|
cos_r[i][0] = ssdm->dlm->mvert[i].co[0];
|
|
|
|
cos_r[i][1] = ssdm->dlm->mvert[i].co[1];
|
|
|
|
cos_r[i][2] = ssdm->dlm->mvert[i].co[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-27 23:27:12 +02:00
|
|
|
static int ssDM_getNumVerts(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
|
|
|
|
return ssdm->dlm->totvert;
|
|
|
|
}
|
|
|
|
static int ssDM_getNumFaces(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
|
|
|
|
return ssdm->dlm->totface;
|
|
|
|
}
|
|
|
|
|
2005-03-28 00:42:57 +02:00
|
|
|
static DispListMesh *ssDM_convertToDispListMesh(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
|
|
|
|
return displistmesh_copy(ssdm->dlm);
|
|
|
|
}
|
|
|
|
|
2005-03-28 23:49:49 +02:00
|
|
|
static void ssDM_release(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
|
2005-03-29 18:43:39 +02:00
|
|
|
displistmesh_free(ssdm->dlm);
|
2005-03-28 23:49:49 +02:00
|
|
|
|
|
|
|
MEM_freeN(dm);
|
|
|
|
}
|
|
|
|
|
2005-04-04 06:50:41 +02:00
|
|
|
DerivedMesh *derivedmesh_from_displistmesh(DispListMesh *dlm)
|
2005-03-27 22:34:18 +02:00
|
|
|
{
|
2005-07-17 19:41:03 +02:00
|
|
|
SSDerivedMesh *ssdm = MEM_callocN(sizeof(*ssdm), "ssdm");
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2005-07-17 06:17:33 +02:00
|
|
|
ssdm->dm.getMinMax = ssDM_getMinMax;
|
|
|
|
|
2005-03-27 23:27:12 +02:00
|
|
|
ssdm->dm.getNumVerts = ssDM_getNumVerts;
|
|
|
|
ssdm->dm.getNumFaces = ssDM_getNumFaces;
|
2005-03-28 00:42:57 +02:00
|
|
|
ssdm->dm.convertToDispListMesh = ssDM_convertToDispListMesh;
|
2005-03-27 23:27:12 +02:00
|
|
|
|
2005-07-18 21:58:23 +02:00
|
|
|
ssdm->dm.getVertCos = ssDM_getVertCos;
|
|
|
|
|
2005-03-27 22:34:18 +02:00
|
|
|
ssdm->dm.drawVerts = ssDM_drawVerts;
|
|
|
|
|
|
|
|
ssdm->dm.drawEdges = ssDM_drawEdges;
|
|
|
|
ssdm->dm.drawMappedEdges = ssDM_drawMappedEdges;
|
|
|
|
ssdm->dm.drawLooseEdges = ssDM_drawLooseEdges;
|
|
|
|
|
|
|
|
ssdm->dm.drawFacesSolid = ssDM_drawFacesSolid;
|
|
|
|
ssdm->dm.drawFacesColored = ssDM_drawFacesColored;
|
2005-03-29 09:51:00 +02:00
|
|
|
ssdm->dm.drawFacesTex = ssDM_drawFacesTex;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2005-03-28 23:49:49 +02:00
|
|
|
ssdm->dm.release = ssDM_release;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
|
|
|
ssdm->dlm = dlm;
|
|
|
|
|
|
|
|
return (DerivedMesh*) ssdm;
|
|
|
|
}
|
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
/***/
|
2005-03-27 22:34:18 +02:00
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
typedef float vec3f[3];
|
|
|
|
|
2005-07-26 02:45:19 +02:00
|
|
|
DerivedMesh *mesh_create_derived_for_modifier(Object *ob, ModifierData *md)
|
|
|
|
{
|
|
|
|
Mesh *me = ob->data;
|
|
|
|
ModifierTypeInfo *mti = modifierType_get_info(md->type);
|
|
|
|
DerivedMesh *dm;
|
|
|
|
|
|
|
|
if (!(md->mode&eModifierMode_Realtime)) return NULL;
|
|
|
|
if (mti->isDisabled && mti->isDisabled(md)) return NULL;
|
|
|
|
|
|
|
|
if (mti->type==eModifierTypeType_OnlyDeform) {
|
|
|
|
int numVerts;
|
|
|
|
float (*deformedVerts)[3] = mesh_getVertexCos(me, &numVerts);
|
|
|
|
|
|
|
|
mti->deformVerts(md, ob, NULL, deformedVerts, numVerts);
|
|
|
|
|
|
|
|
dm = getMeshDerivedMesh(me, ob, deformedVerts);
|
|
|
|
MEM_freeN(deformedVerts);
|
|
|
|
} else {
|
|
|
|
dm = mti->applyModifier(md, ob, NULL, NULL, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dm;
|
|
|
|
}
|
|
|
|
|
2005-07-20 06:44:02 +02:00
|
|
|
static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedMesh **deform_r, DerivedMesh **final_r, int useRenderParams, int useDeform)
|
2005-03-27 22:34:18 +02:00
|
|
|
{
|
2005-07-20 06:44:02 +02:00
|
|
|
Mesh *me = ob->data;
|
|
|
|
ModifierData *md= ob->modifiers.first;
|
2005-07-19 02:21:01 +02:00
|
|
|
float (*deformedVerts)[3];
|
2005-07-19 22:14:17 +02:00
|
|
|
DerivedMesh *dm;
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
int numVerts = me->totvert;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
if (deform_r) *deform_r = NULL;
|
|
|
|
*final_r = NULL;
|
|
|
|
|
2005-07-20 20:15:40 +02:00
|
|
|
if (useDeform) {
|
2005-07-19 04:36:21 +02:00
|
|
|
mesh_modifier(ob, &deformedVerts);
|
2005-07-19 02:21:01 +02:00
|
|
|
|
2005-07-19 22:14:17 +02:00
|
|
|
/* Apply all leading deforming modifiers */
|
|
|
|
for (; md; md=md->next) {
|
|
|
|
ModifierTypeInfo *mti = modifierType_get_info(md->type);
|
|
|
|
|
|
|
|
if (!(md->mode&(1<<useRenderParams))) continue;
|
2005-07-20 09:11:26 +02:00
|
|
|
if (mti->isDisabled && mti->isDisabled(md)) continue;
|
2005-07-19 22:14:17 +02:00
|
|
|
|
|
|
|
if (mti->type==eModifierTypeType_OnlyDeform) {
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
if (!deformedVerts) deformedVerts = mesh_getVertexCos(me, &numVerts);
|
|
|
|
mti->deformVerts(md, ob, NULL, deformedVerts, numVerts);
|
2005-07-19 22:14:17 +02:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Result of all leading deforming modifiers is cached for
|
|
|
|
* places that wish to use the original mesh but with deformed
|
|
|
|
* coordinates (vpaint, etc.)
|
|
|
|
*/
|
2005-07-19 02:21:01 +02:00
|
|
|
if (deform_r) *deform_r = getMeshDerivedMesh(me, ob, deformedVerts);
|
|
|
|
} else {
|
|
|
|
deformedVerts = inputVertexCos;
|
|
|
|
}
|
|
|
|
|
2005-07-19 22:14:17 +02:00
|
|
|
/* Now apply all remaining modifiers. If useDeform is off then skip
|
2005-07-20 06:44:02 +02:00
|
|
|
* OnlyDeform ones.
|
2005-07-19 22:14:17 +02:00
|
|
|
*/
|
|
|
|
dm = NULL;
|
|
|
|
for (; md; md=md->next) {
|
|
|
|
ModifierTypeInfo *mti = modifierType_get_info(md->type);
|
|
|
|
|
|
|
|
if (!(md->mode&(1<<useRenderParams))) continue;
|
|
|
|
if (mti->type==eModifierTypeType_OnlyDeform && !useDeform) continue;
|
2005-07-20 09:11:26 +02:00
|
|
|
if (mti->isDisabled && mti->isDisabled(md)) continue;
|
2005-07-19 22:14:17 +02:00
|
|
|
|
|
|
|
/* How to apply modifier depends on (a) what we already have as
|
|
|
|
* a result of previous modifiers (could be a DerivedMesh or just
|
|
|
|
* deformed vertices) and (b) what type the modifier is.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (mti->type==eModifierTypeType_OnlyDeform) {
|
|
|
|
/* No existing verts to deform, need to build them. */
|
|
|
|
if (!deformedVerts) {
|
|
|
|
if (dm) {
|
|
|
|
/* Deforming a derived mesh, read the vertex locations out of the mesh and
|
2005-07-21 23:19:38 +02:00
|
|
|
* deform them. Once done with this run of deformers verts will be written back.
|
2005-07-19 22:14:17 +02:00
|
|
|
*/
|
|
|
|
numVerts = dm->getNumVerts(dm);
|
|
|
|
deformedVerts = MEM_mallocN(sizeof(*deformedVerts)*numVerts, "dfmv");
|
|
|
|
dm->getVertCos(dm, deformedVerts);
|
|
|
|
} else {
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
deformedVerts = mesh_getVertexCos(me, &numVerts);
|
2005-07-19 22:14:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
mti->deformVerts(md, ob, dm, deformedVerts, numVerts);
|
2005-07-19 22:14:17 +02:00
|
|
|
} else {
|
|
|
|
/* There are 4 cases here (have deform? have dm?) but they all are handled
|
|
|
|
* by the modifier apply function, which will also free the DerivedMesh if
|
|
|
|
* it exists.
|
|
|
|
*/
|
2005-07-26 04:44:59 +02:00
|
|
|
DerivedMesh *ndm = mti->applyModifier(md, ob, dm, deformedVerts, useRenderParams, !inputVertexCos);
|
2005-07-19 22:14:17 +02:00
|
|
|
|
2005-07-26 04:44:59 +02:00
|
|
|
if (ndm) {
|
|
|
|
dm = ndm;
|
|
|
|
|
|
|
|
if (deformedVerts) {
|
|
|
|
if (deformedVerts!=inputVertexCos) {
|
|
|
|
MEM_freeN(deformedVerts);
|
|
|
|
}
|
|
|
|
deformedVerts = NULL;
|
2005-07-19 22:14:17 +02:00
|
|
|
}
|
2005-07-26 04:44:59 +02:00
|
|
|
}
|
2005-07-19 22:14:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Yay, we are done. If we have a DerivedMesh and deformed vertices need to apply
|
|
|
|
* these back onto the DerivedMesh. If we have no DerivedMesh then we need to build
|
|
|
|
* one.
|
|
|
|
*/
|
|
|
|
if (dm && deformedVerts) {
|
|
|
|
DispListMesh *dlm = dm->convertToDispListMesh(dm); // XXX what if verts or nors were shared
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* XXX, would like to avoid the conversion to a DLM here if possible.
|
|
|
|
* Requires adding a DerivedMesh.updateVertCos method.
|
|
|
|
*/
|
|
|
|
for (i=0; i<numVerts; i++) {
|
|
|
|
VECCOPY(dlm->mvert[i].co, deformedVerts[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
dm->release(dm);
|
|
|
|
|
|
|
|
if (dlm->nors && !dlm->dontFreeNors) {
|
|
|
|
MEM_freeN(dlm->nors);
|
|
|
|
dlm->nors = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh_calc_normals(dlm->mvert, dlm->totvert, dlm->mface, dlm->totface, &dlm->nors);
|
|
|
|
*final_r = derivedmesh_from_displistmesh(dlm);
|
|
|
|
} else if (dm) {
|
|
|
|
*final_r = dm;
|
2005-07-19 02:21:01 +02:00
|
|
|
} else {
|
|
|
|
*final_r = getMeshDerivedMesh(me, ob, deformedVerts);
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
if (deformedVerts && deformedVerts!=inputVertexCos) {
|
|
|
|
MEM_freeN(deformedVerts);
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
static vec3f *editmesh_getVertexCos(EditMesh *em, int *numVerts_r)
|
|
|
|
{
|
|
|
|
int i, numVerts = *numVerts_r = BLI_countlist(&em->verts);
|
|
|
|
float (*cos)[3];
|
|
|
|
EditVert *eve;
|
|
|
|
|
|
|
|
cos = MEM_mallocN(sizeof(*cos)*numVerts, "vertexcos");
|
|
|
|
for (i=0,eve=em->verts.first; i<numVerts; i++,eve=eve->next) {
|
|
|
|
VECCOPY(cos[i], eve->co);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void editmesh_calc_modifiers(DerivedMesh **cage_r, DerivedMesh **final_r)
|
|
|
|
{
|
|
|
|
Object *ob = G.obedit;
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
ModifierData *md= ob->modifiers.first;
|
|
|
|
float (*deformedVerts)[3] = NULL;
|
|
|
|
DerivedMesh *dm;
|
|
|
|
int numVerts;
|
|
|
|
|
|
|
|
if (cage_r) *cage_r = NULL;
|
|
|
|
*final_r = NULL;
|
|
|
|
|
|
|
|
*cage_r = getEditMeshDerivedMesh(em, NULL);
|
|
|
|
|
|
|
|
// mesh_modifier(ob, &deformedVerts);
|
|
|
|
|
|
|
|
dm = NULL;
|
|
|
|
for (; md; md=md->next) {
|
|
|
|
ModifierTypeInfo *mti = modifierType_get_info(md->type);
|
|
|
|
|
2005-07-27 22:16:41 +02:00
|
|
|
if (!(md->mode&eModifierMode_Realtime)) continue;
|
2005-07-23 21:15:08 +02:00
|
|
|
if (!(md->mode&eModifierMode_Editmode)) continue;
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
if (mti->isDisabled && mti->isDisabled(md)) continue;
|
|
|
|
if (!(mti->flags&eModifierTypeFlag_SupportsEditmode)) continue;
|
|
|
|
|
|
|
|
/* How to apply modifier depends on (a) what we already have as
|
|
|
|
* a result of previous modifiers (could be a DerivedMesh or just
|
|
|
|
* deformed vertices) and (b) what type the modifier is.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (mti->type==eModifierTypeType_OnlyDeform) {
|
|
|
|
/* No existing verts to deform, need to build them. */
|
|
|
|
if (!deformedVerts) {
|
|
|
|
if (dm) {
|
|
|
|
/* Deforming a derived mesh, read the vertex locations out of the mesh and
|
|
|
|
* deform them. Once done with this run of deformers verts will be written back.
|
|
|
|
*/
|
|
|
|
numVerts = dm->getNumVerts(dm);
|
|
|
|
deformedVerts = MEM_mallocN(sizeof(*deformedVerts)*numVerts, "dfmv");
|
|
|
|
dm->getVertCos(dm, deformedVerts);
|
|
|
|
} else {
|
|
|
|
deformedVerts = editmesh_getVertexCos(em, &numVerts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mti->deformVertsEM(md, ob, em, dm, deformedVerts, numVerts);
|
|
|
|
} else {
|
|
|
|
/* There are 4 cases here (have deform? have dm?) but they all are handled
|
|
|
|
* by the modifier apply function, which will also free the DerivedMesh if
|
|
|
|
* it exists.
|
|
|
|
*/
|
|
|
|
dm = mti->applyModifierEM(md, ob, em, dm, deformedVerts);
|
|
|
|
|
|
|
|
if (deformedVerts) {
|
|
|
|
MEM_freeN(deformedVerts);
|
|
|
|
deformedVerts = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Yay, we are done. If we have a DerivedMesh and deformed vertices need to apply
|
|
|
|
* these back onto the DerivedMesh. If we have no DerivedMesh then we need to build
|
|
|
|
* one.
|
|
|
|
*/
|
|
|
|
if (dm && deformedVerts) {
|
|
|
|
DispListMesh *dlm = dm->convertToDispListMesh(dm); // XXX what if verts or nors were shared
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* XXX, would like to avoid the conversion to a DLM here if possible.
|
|
|
|
* Requires adding a DerivedMesh.updateVertCos method.
|
|
|
|
*/
|
|
|
|
for (i=0; i<numVerts; i++) {
|
|
|
|
VECCOPY(dlm->mvert[i].co, deformedVerts[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
dm->release(dm);
|
|
|
|
|
|
|
|
if (dlm->nors && !dlm->dontFreeNors) {
|
|
|
|
MEM_freeN(dlm->nors);
|
|
|
|
dlm->nors = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh_calc_normals(dlm->mvert, dlm->totvert, dlm->mface, dlm->totface, &dlm->nors);
|
|
|
|
*final_r = derivedmesh_from_displistmesh(dlm);
|
|
|
|
MEM_freeN(deformedVerts);
|
|
|
|
} else if (dm) {
|
|
|
|
*final_r = dm;
|
|
|
|
} else {
|
|
|
|
*final_r = getEditMeshDerivedMesh(em, deformedVerts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
/***/
|
|
|
|
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
static void clear_mesh_caches(Object *ob)
|
2005-07-19 04:36:21 +02:00
|
|
|
{
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
|
|
|
|
/* also serves as signal to remake texspace */
|
|
|
|
if (me->bb) {
|
|
|
|
MEM_freeN(me->bb);
|
|
|
|
me->bb = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
freedisplist(&ob->disp);
|
|
|
|
|
|
|
|
if (ob->derivedFinal) {
|
|
|
|
ob->derivedFinal->release(ob->derivedFinal);
|
|
|
|
ob->derivedFinal= NULL;
|
|
|
|
}
|
|
|
|
if (ob->derivedDeform) {
|
|
|
|
ob->derivedDeform->release(ob->derivedDeform);
|
|
|
|
ob->derivedDeform= NULL;
|
|
|
|
}
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
}
|
2005-07-19 04:36:21 +02:00
|
|
|
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
static void mesh_build_data(Object *ob)
|
|
|
|
{
|
|
|
|
float min[3], max[3];
|
|
|
|
|
|
|
|
if(ob->flag&OB_FROMDUPLI) return;
|
|
|
|
|
|
|
|
clear_mesh_caches(ob);
|
|
|
|
|
|
|
|
mesh_calc_modifiers(ob, NULL, &ob->derivedDeform, &ob->derivedFinal, 0, 1);
|
2005-07-23 09:45:39 +02:00
|
|
|
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
INIT_MINMAX(min, max);
|
2005-07-19 04:36:21 +02:00
|
|
|
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
ob->derivedFinal->getMinMax(ob->derivedFinal, min, max);
|
2005-07-19 04:36:21 +02:00
|
|
|
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
boundbox_set_from_min_max(mesh_get_bb(ob->data), min, max);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void editmesh_build_data(void)
|
|
|
|
{
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
float min[3], max[3];
|
|
|
|
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
|
|
|
clear_mesh_caches(G.obedit);
|
|
|
|
|
|
|
|
if (em->derivedFinal) {
|
|
|
|
if (em->derivedFinal!=em->derivedCage) {
|
|
|
|
em->derivedFinal->release(em->derivedFinal);
|
|
|
|
}
|
|
|
|
em->derivedFinal = NULL;
|
|
|
|
}
|
|
|
|
if (em->derivedCage) {
|
|
|
|
em->derivedCage->release(em->derivedCage);
|
|
|
|
em->derivedCage = NULL;
|
|
|
|
}
|
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
editmesh_calc_modifiers(&em->derivedCage, &em->derivedFinal);
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 09:37:15 +02:00
|
|
|
em->derivedFinal->getMinMax(em->derivedFinal, min, max);
|
|
|
|
|
|
|
|
boundbox_set_from_min_max(mesh_get_bb(G.obedit->data), min, max);
|
2005-07-19 04:36:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void makeDispListMesh(Object *ob)
|
|
|
|
{
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
if (ob==G.obedit) {
|
|
|
|
editmesh_build_data();
|
|
|
|
} else {
|
|
|
|
mesh_build_data(ob);
|
2005-07-23 00:01:39 +02:00
|
|
|
|
|
|
|
build_particle_system(ob);
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
}
|
2005-07-19 04:36:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***/
|
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
DerivedMesh *mesh_get_derived_final(Object *ob, int *needsFree_r)
|
2005-03-27 22:34:18 +02:00
|
|
|
{
|
2005-07-19 04:36:21 +02:00
|
|
|
if (!ob->derivedFinal) {
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
mesh_build_data(ob);
|
2005-07-19 02:21:01 +02:00
|
|
|
}
|
2005-07-13 22:16:35 +02:00
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
*needsFree_r = 0;
|
2005-07-19 04:36:21 +02:00
|
|
|
return ob->derivedFinal;
|
2005-07-19 02:21:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DerivedMesh *mesh_get_derived_deform(Object *ob, int *needsFree_r)
|
|
|
|
{
|
|
|
|
if (!ob->derivedDeform) {
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
mesh_build_data(ob);
|
2005-03-28 23:49:49 +02:00
|
|
|
}
|
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
*needsFree_r = 0;
|
|
|
|
return ob->derivedDeform;
|
2005-03-28 23:49:49 +02:00
|
|
|
}
|
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
DerivedMesh *mesh_create_derived_render(Object *ob)
|
2005-07-16 23:03:28 +02:00
|
|
|
{
|
2005-07-19 02:21:01 +02:00
|
|
|
DerivedMesh *final;
|
2005-07-16 23:03:28 +02:00
|
|
|
|
2005-07-20 06:44:02 +02:00
|
|
|
mesh_calc_modifiers(ob, NULL, NULL, &final, 1, 1);
|
2005-07-16 23:03:28 +02:00
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
return final;
|
2005-07-16 23:03:28 +02:00
|
|
|
}
|
|
|
|
|
2005-07-20 06:44:02 +02:00
|
|
|
DerivedMesh *mesh_create_derived_no_deform(Object *ob, float (*vertCos)[3])
|
2005-07-17 03:18:59 +02:00
|
|
|
{
|
2005-07-19 02:21:01 +02:00
|
|
|
DerivedMesh *final;
|
2005-07-17 03:18:59 +02:00
|
|
|
|
2005-07-20 06:44:02 +02:00
|
|
|
mesh_calc_modifiers(ob, vertCos, NULL, &final, 0, 0);
|
2005-07-17 03:18:59 +02:00
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
return final;
|
2005-07-17 03:18:59 +02:00
|
|
|
}
|
|
|
|
|
2005-07-20 06:44:02 +02:00
|
|
|
DerivedMesh *mesh_create_derived_no_deform_render(Object *ob, float (*vertCos)[3])
|
2005-03-28 23:49:49 +02:00
|
|
|
{
|
2005-07-19 02:21:01 +02:00
|
|
|
DerivedMesh *final;
|
2005-03-28 23:49:49 +02:00
|
|
|
|
2005-07-20 06:44:02 +02:00
|
|
|
mesh_calc_modifiers(ob, vertCos, NULL, &final, 1, 0);
|
2005-04-04 14:22:33 +02:00
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
return final;
|
|
|
|
}
|
2005-04-04 05:38:21 +02:00
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
/***/
|
|
|
|
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
DerivedMesh *editmesh_get_derived_cage_and_final(DerivedMesh **final_r, int *cageNeedsFree_r, int *finalNeedsFree_r)
|
2005-07-19 02:21:01 +02:00
|
|
|
{
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
*cageNeedsFree_r = *finalNeedsFree_r = 0;
|
2005-03-27 22:34:18 +02:00
|
|
|
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
if (!G.editMesh->derivedCage)
|
|
|
|
editmesh_build_data();
|
2005-03-27 22:34:18 +02:00
|
|
|
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
*final_r = G.editMesh->derivedFinal;
|
|
|
|
return G.editMesh->derivedCage;
|
2005-03-27 22:34:18 +02:00
|
|
|
}
|
2005-03-28 07:58:43 +02:00
|
|
|
|
2005-07-19 02:21:01 +02:00
|
|
|
DerivedMesh *editmesh_get_derived_cage(int *needsFree_r)
|
2005-03-28 07:58:43 +02:00
|
|
|
{
|
2005-07-17 03:18:59 +02:00
|
|
|
*needsFree_r = 0;
|
2005-03-29 18:43:39 +02:00
|
|
|
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
if (!G.editMesh->derivedCage)
|
|
|
|
editmesh_build_data();
|
2005-03-28 07:58:43 +02:00
|
|
|
|
- shuffled editmesh derived function name/function
- added ModifierTypeInfo.freeData function
- added modifier_{new,free] utility function
- added ccgSubSurf_getUseAgeCounts to query info
- removed subsurf modifier faking (ME_SUBSURF flag is no
longer valid). subsurf modifier gets converted on file load
although there is obscure linked mesh situation where this
can go wrong, will fix shortly. this also means that some
places in the code that test/copy subsurf settings are broken
for the time being.
- shuffled modifier calculation to be simpler. note that
all modifiers are currently disabled in editmode (including
subsurf). don't worry, will return shortly.
- bug fix, build modifier didn't randomize meshes with only verts
- cleaned up subsurf_ccg and adapted for future editmode modifier
work
- added editmesh.derived{Cage,Final}, not used yet
- added SubsurfModifierData.{mCache,emCache}, will be used to cache
subsurf instead of caching in derivedmesh itself
- removed old subsurf buttons
- added do_modifiers_buttons to handle modifier events
- removed count_object counting of modifier (subsurfed) objects...
this would be nice to add back at some point but requires care.
probably requires rewrite of counting system.
New feature: Incremental Subsurf in Object Mode
The previous release introduce incremental subsurf calculation during
editmode but it was not turned on during object mode. In general it
does not make sense to have it always enabled during object mode because
it requires caching a fair amount of information about the mesh which
is a waste of memory unless the mesh is often recalculated.
However, for mesh's that have subsurfed armatures for example, or that
have other modifiers so that the mesh is essentially changing on every
frame, it makes a lot of sense to keep the subsurf'd object around and
that is what the new incremental subsurf modifier toggle is for. The
intent is that the user will enable this option for (a) a mesh that is
currently under active editing or (b) a mesh that is heavily updated
in the scene, such as a character.
I will try to write more about this feature for release, because it
has advantages and disadvantages that are not immediately obvious (the
first user reaction will be to turn it on for ever object, which is
probably not correct).
2005-07-21 22:30:33 +02:00
|
|
|
return G.editMesh->derivedCage;
|
2005-03-28 07:58:43 +02:00
|
|
|
}
|