2005-03-27 20:34:18 +00: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 16:43:39 +00:00
|
|
|
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
2005-03-27 20:34:18 +00: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 19:15:08 +00:00
|
|
|
#include "PIL_time.h"
|
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "DNA_effect_types.h"
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meshdata_types.h"
|
2005-07-19 20:14:17 +00:00
|
|
|
#include "DNA_modifier_types.h"
|
2005-03-27 20:34:18 +00:00
|
|
|
#include "DNA_object_types.h"
|
2005-06-06 09:52:44 +00:00
|
|
|
#include "DNA_object_force.h"
|
2005-03-27 20:34:18 +00:00
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
#include "BLI_arithb.h"
|
2005-03-27 21:27:12 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2005-03-27 20:34:18 +00:00
|
|
|
#include "BLI_editVert.h"
|
|
|
|
|
2005-07-17 04:17:33 +00:00
|
|
|
#include "BKE_utildefines.h"
|
2005-03-27 20:34:18 +00:00
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
#include "BKE_displist.h"
|
|
|
|
#include "BKE_effect.h"
|
|
|
|
#include "BKE_global.h"
|
2005-03-29 07:51:00 +00:00
|
|
|
#include "BKE_material.h"
|
2005-03-27 20:34:18 +00:00
|
|
|
#include "BKE_mesh.h"
|
|
|
|
#include "BKE_object.h"
|
2005-03-28 21:49:49 +00:00
|
|
|
#include "BKE_subsurf.h"
|
2005-07-19 00:21:01 +00:00
|
|
|
#include "BKE_deform.h"
|
2005-07-19 20:14:17 +00:00
|
|
|
#include "BKE_modifier.h"
|
2005-08-11 03:31:33 +00:00
|
|
|
#include "BKE_key.h"
|
2005-03-27 20:34:18 +00:00
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
|
|
///////////////////////////////////
|
|
|
|
///////////////////////////////////
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DerivedMesh dm;
|
|
|
|
|
|
|
|
Object *ob;
|
2005-07-18 19:58:23 +00:00
|
|
|
Mesh *me;
|
2005-07-17 20:12:16 +00:00
|
|
|
MVert *verts;
|
|
|
|
float *nors;
|
|
|
|
|
2005-07-19 02:36:21 +00:00
|
|
|
int freeNors, freeVerts;
|
2005-03-27 20:34:18 +00:00
|
|
|
} MeshDerivedMesh;
|
|
|
|
|
2005-08-07 02:30:29 +00:00
|
|
|
static DispListMesh *meshDM_convertToDispListMesh(DerivedMesh *dm, int allowShared)
|
2005-07-16 21:03:28 +00:00
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 19:58:23 +00:00
|
|
|
Mesh *me = mdm->me;
|
2005-07-16 21:03:28 +00:00
|
|
|
DispListMesh *dlm = MEM_callocN(sizeof(*dlm), "dlm");
|
|
|
|
|
|
|
|
dlm->totvert = me->totvert;
|
|
|
|
dlm->totedge = me->totedge;
|
|
|
|
dlm->totface = me->totface;
|
2005-07-17 20:12:16 +00:00
|
|
|
dlm->mvert = mdm->verts;
|
2005-07-16 21:03:28 +00:00
|
|
|
dlm->medge = me->medge;
|
|
|
|
dlm->mface = me->mface;
|
|
|
|
dlm->tface = me->tface;
|
|
|
|
dlm->mcol = me->mcol;
|
|
|
|
dlm->nors = mdm->nors;
|
2005-07-16 21:16:05 +00:00
|
|
|
dlm->dontFreeVerts = dlm->dontFreeOther = dlm->dontFreeNors = 1;
|
2005-07-16 21:03:28 +00:00
|
|
|
|
2005-08-07 02:30:29 +00:00
|
|
|
if (!allowShared) {
|
|
|
|
dlm->mvert = MEM_dupallocN(dlm->mvert);
|
|
|
|
if (dlm->nors) dlm->nors = MEM_dupallocN(dlm->nors);
|
|
|
|
|
2005-08-11 07:11:57 +00:00
|
|
|
dlm->dontFreeVerts = dlm->dontFreeNors = 0;
|
2005-08-07 02:30:29 +00:00
|
|
|
}
|
|
|
|
|
2005-07-16 21:03:28 +00:00
|
|
|
return dlm;
|
|
|
|
}
|
|
|
|
|
2005-07-17 04:17:33 +00:00
|
|
|
static void meshDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 19:58:23 +00:00
|
|
|
Mesh *me = mdm->me;
|
2005-07-17 04:17:33 +00:00
|
|
|
int i;
|
|
|
|
|
2005-07-18 17:33:51 +00: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 04:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-18 19:58:23 +00: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 01:18:59 +00:00
|
|
|
static void meshDM_getVertCo(DerivedMesh *dm, int index, float co_r[3])
|
|
|
|
{
|
2005-07-17 20:12:16 +00:00
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-17 01:18:59 +00:00
|
|
|
|
2005-08-07 05:42:03 +00:00
|
|
|
VECCOPY(co_r, mdm->verts[index].co);
|
2005-07-17 01:18:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void meshDM_getVertNo(DerivedMesh *dm, int index, float no_r[3])
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-17 20:12:16 +00:00
|
|
|
short *no = mdm->verts[index].no;
|
2005-07-17 01:18:59 +00: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 20:34:18 +00:00
|
|
|
static void meshDM_drawVerts(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 19:58:23 +00:00
|
|
|
Mesh *me = mdm->me;
|
2005-07-20 04:14:21 +00:00
|
|
|
int a;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
|
|
|
glBegin(GL_POINTS);
|
2005-07-20 04:14:21 +00:00
|
|
|
for(a=0; a<me->totvert; a++) {
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mdm->verts[ a].co);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
2005-08-18 11:31:20 +00:00
|
|
|
static void meshDM_drawUVEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
|
|
|
Mesh *me = mdm->me;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (me->tface) {
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (i=0; i<me->totface; i++) {
|
|
|
|
if (me->mface[i].v3) {
|
|
|
|
TFace *tf = &me->tface[i];
|
|
|
|
|
|
|
|
if (!(tf->flag&TF_HIDE)) {
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
glVertex2fv(tf->uv[1]);
|
|
|
|
|
|
|
|
glVertex2fv(tf->uv[1]);
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
|
|
|
|
if (!me->mface[i].v4) {
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
} else {
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[3]);
|
|
|
|
|
|
|
|
glVertex2fv(tf->uv[3]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
2005-08-14 10:35:58 +00:00
|
|
|
static void meshDM_drawEdges(DerivedMesh *dm, int drawLooseEdges)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 19:58:23 +00:00
|
|
|
Mesh *me= mdm->me;
|
2005-07-20 04:14:21 +00:00
|
|
|
int a;
|
2005-03-27 20:34:18 +00:00
|
|
|
MFace *mface = me->mface;
|
|
|
|
|
2005-07-20 04:14:21 +00:00
|
|
|
if(me->medge) {
|
2005-03-27 20:34:18 +00:00
|
|
|
MEdge *medge= me->medge;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(a=me->totedge; a>0; a--, medge++) {
|
2005-08-14 10:35:58 +00:00
|
|
|
if ((medge->flag&ME_EDGEDRAW) && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mdm->verts[ medge->v1].co);
|
|
|
|
glVertex3fv(mdm->verts[ medge->v2].co);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glBegin(GL_LINES);
|
2005-07-20 04:14:21 +00:00
|
|
|
for(a=0; a<me->totface; a++, mface++) {
|
2005-03-27 20:34:18 +00:00
|
|
|
int test= mface->edcode;
|
|
|
|
|
|
|
|
if(test) {
|
2005-08-14 10:35:58 +00:00
|
|
|
if((test&ME_V1V2) && (drawLooseEdges || mface->v3)) {
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mdm->verts[mface->v1].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v2].co);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(mface->v3) {
|
|
|
|
if(test&ME_V2V3){
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mdm->verts[mface->v2].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v3].co);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mface->v4) {
|
|
|
|
if(test&ME_V3V4){
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mdm->verts[mface->v3].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v4].co);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
if(test&ME_V4V1){
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mdm->verts[mface->v4].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v1].co);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(test&ME_V3V1){
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mdm->verts[mface->v3].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v1].co);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
2005-08-18 11:31:20 +00:00
|
|
|
static void meshDM_drawEdgesFlag(DerivedMesh *dm, unsigned int mask, unsigned int value)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-08-18 11:31:20 +00:00
|
|
|
Mesh *me= mdm->me;
|
2005-07-20 04:14:21 +00:00
|
|
|
int a;
|
2005-08-18 11:31:20 +00:00
|
|
|
MFace *mface = me->mface;
|
|
|
|
int tfaceFlags = (ME_EDGE_TFSEL|ME_EDGE_TFACT|ME_EDGE_TFVISIBLE|ME_EDGE_TFACTFIRST|ME_EDGE_TFACTLAST);
|
|
|
|
|
|
|
|
if ((mask&tfaceFlags) && me->tface) {
|
|
|
|
TFace *tface = me->tface;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
2005-08-14 10:35:58 +00:00
|
|
|
glBegin(GL_LINES);
|
2005-08-18 11:31:20 +00:00
|
|
|
for(a=0; a<me->totface; a++, mface++, tface++) {
|
|
|
|
if (mface->v3) {
|
|
|
|
unsigned int flags = ME_EDGEDRAW|ME_EDGEMAPPED;
|
|
|
|
unsigned int flag0, flag1, flag2, flag3;
|
|
|
|
|
|
|
|
if (tface->flag&TF_SELECT) flags |= ME_EDGE_TFSEL;
|
|
|
|
if (!(tface->flag&TF_HIDE)) flags |= ME_EDGE_TFVISIBLE;
|
|
|
|
|
|
|
|
if (tface->flag&TF_ACTIVE) {
|
|
|
|
flags |= ME_EDGE_TFACT;
|
|
|
|
flag0 = flag1 = flag2 = flag3 = flags;
|
|
|
|
|
|
|
|
flag0 |= ME_EDGE_TFACTFIRST;
|
|
|
|
flag3 |= ME_EDGE_TFACTLAST;
|
|
|
|
} else {
|
|
|
|
flag0 = flag1 = flag2 = flag3 = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mask&ME_SEAM) {
|
|
|
|
if (tface->unwrap&TF_SEAM1) flag0 |= ME_SEAM;
|
|
|
|
if (tface->unwrap&TF_SEAM2) flag1 |= ME_SEAM;
|
|
|
|
if (tface->unwrap&TF_SEAM3) flag2 |= ME_SEAM;
|
|
|
|
if (tface->unwrap&TF_SEAM4) flag3 |= ME_SEAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((flag0&mask)==value) {
|
|
|
|
glVertex3fv(mdm->verts[mface->v1].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v2].co);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((flag1&mask)==value) {
|
|
|
|
glVertex3fv(mdm->verts[mface->v2].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v3].co);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mface->v4) {
|
|
|
|
if ((flag2&mask)==value) {
|
|
|
|
glVertex3fv(mdm->verts[mface->v3].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v4].co);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((flag3&mask)==value) {
|
|
|
|
glVertex3fv(mdm->verts[mface->v4].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v1].co);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ((flag3&mask)==value) {
|
|
|
|
glVertex3fv(mdm->verts[mface->v3].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v1].co);
|
|
|
|
}
|
|
|
|
}
|
2005-08-14 10:35:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
2005-08-18 11:31:20 +00:00
|
|
|
}
|
|
|
|
else if(me->medge) {
|
|
|
|
MEdge *medge= me->medge;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(a=me->totedge; a>0; a--, medge++) {
|
|
|
|
if (((medge->flag|ME_EDGEMAPPED)&mask)==value) {
|
|
|
|
glVertex3fv(mdm->verts[ medge->v1].co);
|
|
|
|
glVertex3fv(mdm->verts[ medge->v2].co);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else {
|
2005-08-14 10:35:58 +00:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(a=0; a<me->totface; a++, mface++) {
|
2005-08-18 11:31:20 +00:00
|
|
|
if (!mface->v3) {
|
|
|
|
if (((ME_EDGEDRAW|ME_LOOSEEDGE|ME_EDGEMAPPED)&mask)==value) {
|
|
|
|
glVertex3fv(mdm->verts[mface->v1].co);
|
|
|
|
glVertex3fv(mdm->verts[mface->v2].co);
|
|
|
|
}
|
|
|
|
}
|
2005-08-14 10:35:58 +00:00
|
|
|
}
|
|
|
|
glEnd();
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-13 20:16:35 +00:00
|
|
|
static void meshDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int))
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 19:58:23 +00:00
|
|
|
Mesh *me = mdm->me;
|
2005-07-17 20:12:16 +00:00
|
|
|
MVert *mvert= mdm->verts;
|
2005-03-27 20:34:18 +00:00
|
|
|
MFace *mface= me->mface;
|
|
|
|
float *nors = mdm->nors;
|
2005-07-20 04:14:21 +00:00
|
|
|
int a;
|
2005-07-13 20:16:35 +00:00
|
|
|
int glmode=-1, shademodel=-1, matnr=-1, drawCurrentMat=1;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
2005-07-23 16:09:08 +00:00
|
|
|
#define PASSVERT(index) { \
|
2005-03-27 20:34:18 +00:00
|
|
|
if (shademodel==GL_SMOOTH) { \
|
2005-07-17 20:12:16 +00:00
|
|
|
short *no = mvert[index].no; \
|
2005-07-23 16:09:08 +00:00
|
|
|
glNormal3sv(no); \
|
2005-03-27 20:34:18 +00:00
|
|
|
} \
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mvert[index].co); \
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
glBegin(glmode=GL_QUADS);
|
2005-07-20 04:14:21 +00:00
|
|
|
for(a=0; a<me->totface; a++, mface++, nors+=3) {
|
2005-03-27 20:34:18 +00:00
|
|
|
if(mface->v3) {
|
|
|
|
int new_glmode, new_matnr, new_shademodel;
|
|
|
|
|
2005-03-29 07:58:56 +00:00
|
|
|
new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES;
|
2005-03-27 20:34:18 +00: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 20:16:35 +00:00
|
|
|
drawCurrentMat = setMaterial(matnr=new_matnr);
|
2005-03-27 20:34:18 +00:00
|
|
|
|
|
|
|
glShadeModel(shademodel=new_shademodel);
|
|
|
|
glBegin(glmode=new_glmode);
|
2005-07-13 20:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (drawCurrentMat) {
|
|
|
|
if(shademodel==GL_FLAT)
|
|
|
|
glNormal3fv(nors);
|
|
|
|
|
2005-07-23 16:09:08 +00:00
|
|
|
PASSVERT(mface->v1);
|
|
|
|
PASSVERT(mface->v2);
|
|
|
|
PASSVERT(mface->v3);
|
2005-07-13 20:16:35 +00:00
|
|
|
if (mface->v4) {
|
2005-07-23 16:09:08 +00:00
|
|
|
PASSVERT(mface->v4);
|
2005-07-13 20:16:35 +00:00
|
|
|
}
|
2005-03-27 20:34:18 +00: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 19:58:23 +00:00
|
|
|
Mesh *me= mdm->me;
|
2005-03-27 20:34:18 +00:00
|
|
|
MFace *mface= me->mface;
|
2005-07-20 04:14:21 +00:00
|
|
|
int a, glmode;
|
2005-03-27 20:34:18 +00:00
|
|
|
unsigned char *cp1, *cp2;
|
|
|
|
|
|
|
|
cp1= col1;
|
|
|
|
if(col2) {
|
|
|
|
cp2= col2;
|
|
|
|
} else {
|
|
|
|
cp2= NULL;
|
|
|
|
useTwoSide= 0;
|
|
|
|
}
|
|
|
|
|
2005-05-28 12:23:40 +00: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 10:47:36 +00:00
|
|
|
if(col1 && col2)
|
|
|
|
glEnable(GL_CULL_FACE);
|
2005-05-28 12:23:40 +00:00
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
glBegin(glmode=GL_QUADS);
|
2005-07-20 04:14:21 +00:00
|
|
|
for(a=0; a<me->totface; a++, mface++, cp1+= 16) {
|
2005-03-27 20:34:18 +00: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 20:12:16 +00:00
|
|
|
glVertex3fv( mdm->verts[mface->v1].co );
|
2005-03-27 20:34:18 +00:00
|
|
|
glColor3ub(cp1[7], cp1[6], cp1[5]);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv( mdm->verts[mface->v2].co );
|
2005-03-27 20:34:18 +00:00
|
|
|
glColor3ub(cp1[11], cp1[10], cp1[9]);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv( mdm->verts[mface->v3].co );
|
2005-03-29 07:58:56 +00:00
|
|
|
if(mface->v4) {
|
2005-03-27 20:34:18 +00:00
|
|
|
glColor3ub(cp1[15], cp1[14], cp1[13]);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv( mdm->verts[mface->v4].co );
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(useTwoSide) {
|
|
|
|
glColor3ub(cp2[11], cp2[10], cp2[9]);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv( mdm->verts[mface->v3].co );
|
2005-03-27 20:34:18 +00:00
|
|
|
glColor3ub(cp2[7], cp2[6], cp2[5]);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv( mdm->verts[mface->v2].co );
|
2005-03-27 20:34:18 +00:00
|
|
|
glColor3ub(cp2[3], cp2[2], cp2[1]);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv( mdm->verts[mface->v1].co );
|
2005-03-27 20:34:18 +00:00
|
|
|
if(mface->v4) {
|
|
|
|
glColor3ub(cp2[15], cp2[14], cp2[13]);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv( mdm->verts[mface->v4].co );
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(col2) cp2+= 16;
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
}
|
|
|
|
|
2005-03-29 07:51:00 +00:00
|
|
|
static void meshDM_drawFacesTex(DerivedMesh *dm, int (*setDrawParams)(TFace *tf, int matnr))
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 19:58:23 +00:00
|
|
|
Mesh *me = mdm->me;
|
2005-07-17 20:12:16 +00:00
|
|
|
MVert *mvert= mdm->verts;
|
2005-03-29 07:51:00 +00:00
|
|
|
MFace *mface= me->mface;
|
|
|
|
TFace *tface = me->tface;
|
|
|
|
float *nors = mdm->nors;
|
2005-07-20 04:14:21 +00:00
|
|
|
int a;
|
2005-03-29 07:51:00 +00:00
|
|
|
|
2005-07-20 04:14:21 +00:00
|
|
|
for (a=0; a<me->totface; a++) {
|
2005-03-29 07:51:00 +00:00
|
|
|
MFace *mf= &mface[a];
|
2005-04-14 13:46:05 +00:00
|
|
|
TFace *tf = tface?&tface[a]:NULL;
|
2005-08-18 11:31:20 +00:00
|
|
|
int flag;
|
2005-03-29 07:51:00 +00:00
|
|
|
unsigned char *cp= NULL;
|
|
|
|
|
2005-08-18 11:31:20 +00:00
|
|
|
if (mf->v3==0) continue;
|
2005-03-29 07:51:00 +00:00
|
|
|
|
2005-08-18 11:31:20 +00:00
|
|
|
flag = setDrawParams(tf, mf->mat_nr);
|
|
|
|
|
|
|
|
if (flag==0) {
|
|
|
|
continue;
|
|
|
|
} else if (flag==1) {
|
2005-04-14 13:46:05 +00:00
|
|
|
if (tf) {
|
2005-08-18 11:31:20 +00:00
|
|
|
cp= (unsigned char*) tf->col;
|
2005-03-29 07:51:00 +00:00
|
|
|
} else if (me->mcol) {
|
2005-08-18 11:31:20 +00:00
|
|
|
cp= (unsigned char*) &me->mcol[a*4];
|
2005-03-29 07:51:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(mf->flag&ME_SMOOTH)) {
|
|
|
|
glNormal3fv(&nors[a*3]);
|
|
|
|
}
|
|
|
|
|
2005-03-30 06:24:34 +00:00
|
|
|
glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
|
2005-04-14 13:46:05 +00:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[0]);
|
2005-03-29 07:51:00 +00:00
|
|
|
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v1].no);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mvert[mf->v1].co);
|
2005-03-29 07:51:00 +00:00
|
|
|
|
2005-04-14 13:46:05 +00:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[1]);
|
2005-03-29 07:51:00 +00:00
|
|
|
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v2].no);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mvert[mf->v2].co);
|
2005-03-29 07:51:00 +00:00
|
|
|
|
2005-04-14 13:46:05 +00:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[2]);
|
2005-03-29 07:51:00 +00:00
|
|
|
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v3].no);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mvert[mf->v3].co);
|
2005-03-29 07:51:00 +00:00
|
|
|
|
2005-03-30 06:24:34 +00:00
|
|
|
if(mf->v4) {
|
2005-04-14 13:46:05 +00:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[3]);
|
2005-03-29 07:51:00 +00:00
|
|
|
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
|
|
|
|
if (mf->flag&ME_SMOOTH) glNormal3sv(mvert[mf->v4].no);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv(mvert[mf->v4].co);
|
2005-03-29 07:51:00 +00:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
2005-03-27 21:27:12 +00:00
|
|
|
static int meshDM_getNumVerts(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 19:58:23 +00:00
|
|
|
Mesh *me = mdm->me;
|
2005-03-27 21:27:12 +00:00
|
|
|
|
|
|
|
return me->totvert;
|
|
|
|
}
|
|
|
|
static int meshDM_getNumFaces(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-07-18 19:58:23 +00:00
|
|
|
Mesh *me = mdm->me;
|
2005-03-27 21:27:12 +00:00
|
|
|
|
|
|
|
return me->totface;
|
|
|
|
}
|
|
|
|
|
2005-07-17 17:41:03 +00:00
|
|
|
static void meshDM_release(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
|
|
|
|
2005-07-17 20:12:16 +00:00
|
|
|
if (mdm->freeNors) MEM_freeN(mdm->nors);
|
2005-07-19 02:36:21 +00:00
|
|
|
if (mdm->freeVerts) MEM_freeN(mdm->verts);
|
2005-07-17 17:41:03 +00:00
|
|
|
MEM_freeN(mdm);
|
|
|
|
}
|
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
static DerivedMesh *getMeshDerivedMesh(Mesh *me, Object *ob, float (*vertCos)[3])
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
2005-07-17 17:41:03 +00:00
|
|
|
MeshDerivedMesh *mdm = MEM_callocN(sizeof(*mdm), "mdm");
|
2005-03-27 20:34:18 +00:00
|
|
|
|
2005-07-17 04:17:33 +00:00
|
|
|
mdm->dm.getMinMax = meshDM_getMinMax;
|
|
|
|
|
2005-07-16 21:03:28 +00:00
|
|
|
mdm->dm.convertToDispListMesh = meshDM_convertToDispListMesh;
|
2005-03-27 21:27:12 +00:00
|
|
|
mdm->dm.getNumVerts = meshDM_getNumVerts;
|
|
|
|
mdm->dm.getNumFaces = meshDM_getNumFaces;
|
|
|
|
|
2005-07-18 19:58:23 +00:00
|
|
|
mdm->dm.getVertCos = meshDM_getVertCos;
|
2005-07-17 01:18:59 +00:00
|
|
|
mdm->dm.getVertCo = meshDM_getVertCo;
|
|
|
|
mdm->dm.getVertNo = meshDM_getVertNo;
|
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
mdm->dm.drawVerts = meshDM_drawVerts;
|
|
|
|
|
2005-08-18 11:31:20 +00:00
|
|
|
mdm->dm.drawUVEdges = meshDM_drawUVEdges;
|
2005-03-27 20:34:18 +00:00
|
|
|
mdm->dm.drawEdges = meshDM_drawEdges;
|
2005-08-18 11:31:20 +00:00
|
|
|
mdm->dm.drawEdgesFlag = meshDM_drawEdgesFlag;
|
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
mdm->dm.drawFacesSolid = meshDM_drawFacesSolid;
|
|
|
|
mdm->dm.drawFacesColored = meshDM_drawFacesColored;
|
2005-03-29 07:51:00 +00:00
|
|
|
mdm->dm.drawFacesTex = meshDM_drawFacesTex;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
2005-07-17 17:41:03 +00:00
|
|
|
mdm->dm.release = meshDM_release;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
|
|
|
mdm->ob = ob;
|
2005-07-18 19:58:23 +00:00
|
|
|
mdm->me = me;
|
2005-07-19 00:21:01 +00:00
|
|
|
mdm->verts = me->mvert;
|
|
|
|
mdm->nors = NULL;
|
2005-07-17 20:12:16 +00:00
|
|
|
mdm->freeNors = 0;
|
2005-07-19 02:36:21 +00:00
|
|
|
mdm->freeVerts = 0;
|
2005-07-17 20:12:16 +00:00
|
|
|
|
2005-07-18 19:58:23 +00:00
|
|
|
if (vertCos) {
|
|
|
|
int i;
|
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
mdm->verts = MEM_mallocN(sizeof(*mdm->verts)*me->totvert, "deformedVerts");
|
2005-07-18 19:58:23 +00:00
|
|
|
for (i=0; i<me->totvert; i++) {
|
2005-08-07 05:42:03 +00:00
|
|
|
VECCOPY(mdm->verts[i].co, vertCos[i]);
|
2005-07-18 19:58:23 +00:00
|
|
|
}
|
2005-07-17 20:12:16 +00:00
|
|
|
mesh_calc_normals(mdm->verts, me->totvert, me->mface, me->totface, &mdm->nors);
|
|
|
|
mdm->freeNors = 1;
|
2005-07-19 02:36:21 +00:00
|
|
|
mdm->freeVerts = 1;
|
2005-07-17 20:12:16 +00: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 07:37:15 +00: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
|
2005-08-07 02:30:29 +00:00
|
|
|
// would never be correctly computed.
|
- 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 07:37:15 +00:00
|
|
|
mesh_calc_normals(mdm->verts, me->totvert, me->mface, me->totface, &mdm->nors);
|
2005-07-19 00:21:01 +00:00
|
|
|
mdm->freeNors = 1;
|
2005-07-17 20:12:16 +00:00
|
|
|
}
|
2005-03-27 20:34:18 +00: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 07:37:15 +00:00
|
|
|
float (*vertexCos)[3];
|
2005-08-03 04:04:05 +00:00
|
|
|
float (*vertexNos)[3];
|
|
|
|
float (*faceNos)[3];
|
2005-03-27 20:34:18 +00:00
|
|
|
} EditMeshDerivedMesh;
|
|
|
|
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
static void emDM_foreachMappedVertEM(DerivedMesh *dm, void (*func)(void *userData, EditVert *vert, float *co, float *no_f, short *no_s), void *userData)
|
2005-03-28 07:10:32 +00:00
|
|
|
{
|
2005-08-03 04:04:05 +00:00
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
EditVert *eve;
|
2005-08-03 04:04:05 +00:00
|
|
|
|
|
|
|
if (emdm->vertexCos) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0,eve= emdm->em->verts.first; eve; i++,eve=eve->next) {
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
func(userData, eve, emdm->vertexCos[i], emdm->vertexNos[i], NULL);
|
2005-08-03 04:04:05 +00:00
|
|
|
}
|
|
|
|
} else {
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
for (eve= emdm->em->verts.first; eve; eve=eve->next) {
|
|
|
|
func(userData, eve, eve->co, eve->no, NULL);
|
|
|
|
}
|
2005-08-03 04:04:05 +00:00
|
|
|
}
|
2005-03-28 07:10:32 +00:00
|
|
|
}
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
static void emDM_foreachMappedEdgeEM(DerivedMesh *dm, void (*func)(void *userData, EditEdge *eed, float *v0co, float *v1co), void *userData)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
EditEdge *eed;
|
2005-03-27 20:34:18 +00: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 07:37:15 +00:00
|
|
|
if (emdm->vertexCos) {
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
EditVert *eve, *preveve;
|
- 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 07:37:15 +00:00
|
|
|
int i;
|
|
|
|
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
|
|
|
|
eve->prev = (EditVert*) i++;
|
|
|
|
for(eed= emdm->em->edges.first; eed; eed= eed->next)
|
|
|
|
func(userData, eed, emdm->vertexCos[(int) eed->v1->prev], emdm->vertexCos[(int) eed->v2->prev]);
|
|
|
|
for (preveve=NULL, eve=emdm->em->verts.first; eve; preveve=eve, eve= eve->next)
|
|
|
|
eve->prev = preveve;
|
- 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 07:37:15 +00:00
|
|
|
} else {
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
for(eed= emdm->em->edges.first; eed; eed= eed->next)
|
|
|
|
func(userData, eed, eed->v1->co, eed->v2->co);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
2005-03-30 05:57:40 +00:00
|
|
|
static void emDM_drawMappedEdgesEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, EditEdge *edge), void *userData)
|
2005-03-27 20:34:18 +00: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 07:37:15 +00: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 20:34:18 +00: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 07:37:15 +00: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 20:34:18 +00: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 07:37:15 +00:00
|
|
|
}
|
2005-08-14 10:35:58 +00:00
|
|
|
static void emDM_drawEdges(DerivedMesh *dm, int drawLooseEdges)
|
- 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 07:37:15 +00:00
|
|
|
{
|
|
|
|
emDM_drawMappedEdgesEM(dm, NULL, NULL);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
2005-03-30 05:57:40 +00: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 06:46:21 +00: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 07:37:15 +00: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 06:46:21 +00: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 07:37:15 +00:00
|
|
|
glEnd();
|
2005-03-27 20:34:18 +00: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 07:37:15 +00: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 20:34:18 +00: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 07:37:15 +00:00
|
|
|
glEnd();
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-23 07:45:39 +00: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) {
|
2005-08-07 05:42:03 +00:00
|
|
|
VecMulf(cent, 0.25f);
|
2005-07-23 07:45:39 +00:00
|
|
|
} else {
|
2005-08-07 05:42:03 +00:00
|
|
|
VecMulf(cent, 0.33333333333f);
|
2005-07-23 07:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
static void emDM_foreachMappedFaceCenterEM(DerivedMesh *dm, void (*func)(void *userData, EditFace *efa, float *co, float *no), void *userData)
|
2005-07-23 07:45:39 +00:00
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditVert *eve, *preveve;
|
|
|
|
EditFace *efa;
|
|
|
|
float cent[3];
|
2005-08-15 14:02:03 +00:00
|
|
|
int i=0; // gcc!
|
2005-07-23 07:45:39 +00:00
|
|
|
|
|
|
|
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) {
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
emDM__calcFaceCent(efa, cent, emdm->vertexCos);
|
|
|
|
func(userData, efa, cent, emdm->vertexCos?emdm->faceNos[i]:efa->n);
|
2005-07-23 07:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (emdm->vertexCos) {
|
|
|
|
for (preveve=NULL, eve=emdm->em->verts.first; eve; preveve=eve, eve= eve->next)
|
|
|
|
eve->prev = preveve;
|
|
|
|
}
|
|
|
|
}
|
- 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 07:37:15 +00:00
|
|
|
static void emDM_drawMappedFacesEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, EditFace *face), void *userData)
|
2005-03-28 05:58:43 +00:00
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
2005-03-28 06:46:21 +00:00
|
|
|
EditFace *efa;
|
2005-03-27 20:34:18 +00: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 07:37:15 +00: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++;
|
|
|
|
|
2005-08-03 04:04:05 +00:00
|
|
|
for (i=0,efa= emdm->em->faces.first; efa; i++,efa= efa->next) {
|
- 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 07:37:15 +00:00
|
|
|
if(!setDrawOptions || setDrawOptions(userData, efa)) {
|
2005-08-03 04:04:05 +00:00
|
|
|
glNormal3fv(emdm->faceNos[i]);
|
- 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 07:37:15 +00: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 20:16:35 +00: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 05:58:43 +00: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 07:37:15 +00: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++;
|
|
|
|
|
2005-08-03 04:04:05 +00:00
|
|
|
for (i=0,efa= emdm->em->faces.first; efa; i++,efa= efa->next) {
|
- 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 07:37:15 +00:00
|
|
|
if(efa->h==0) {
|
|
|
|
if (setMaterial(efa->mat_nr+1)) {
|
2005-08-03 04:04:05 +00:00
|
|
|
glNormal3fv(emdm->faceNos[i]);
|
- 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 07:37:15 +00: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(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 20:34:18 +00:00
|
|
|
|
2005-07-17 04:17:33 +00: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 07:37:15 +00:00
|
|
|
int i;
|
2005-07-17 04:17:33 +00:00
|
|
|
|
2005-07-18 17:33:51 +00: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 07:37:15 +00: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 17:33:51 +00: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 04:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
2005-03-27 21:27:12 +00: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 07:37:15 +00:00
|
|
|
static void emDM_release(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
|
2005-08-03 04:04:05 +00:00
|
|
|
if (emdm->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 07:37:15 +00:00
|
|
|
MEM_freeN(emdm->vertexCos);
|
2005-08-03 04:04:05 +00:00
|
|
|
MEM_freeN(emdm->vertexNos);
|
|
|
|
MEM_freeN(emdm->faceNos);
|
|
|
|
}
|
- 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 07:37:15 +00:00
|
|
|
|
|
|
|
MEM_freeN(emdm);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, float (*vertexCos)[3])
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
2005-07-17 17:41:03 +00:00
|
|
|
EditMeshDerivedMesh *emdm = MEM_callocN(sizeof(*emdm), "emdm");
|
2005-03-27 20:34:18 +00:00
|
|
|
|
2005-07-17 04:17:33 +00:00
|
|
|
emdm->dm.getMinMax = emDM_getMinMax;
|
|
|
|
|
2005-03-27 21:27:12 +00:00
|
|
|
emdm->dm.getNumVerts = emDM_getNumVerts;
|
|
|
|
emdm->dm.getNumFaces = emDM_getNumFaces;
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
emdm->dm.foreachMappedVertEM = emDM_foreachMappedVertEM;
|
|
|
|
emdm->dm.foreachMappedEdgeEM = emDM_foreachMappedEdgeEM;
|
|
|
|
emdm->dm.foreachMappedFaceCenterEM = emDM_foreachMappedFaceCenterEM;
|
2005-03-27 20:34:18 +00: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 07:37:15 +00:00
|
|
|
emdm->dm.drawEdges = emDM_drawEdges;
|
2005-03-27 20:34:18 +00:00
|
|
|
emdm->dm.drawMappedEdgesEM = emDM_drawMappedEdgesEM;
|
2005-03-30 00:32:10 +00:00
|
|
|
emdm->dm.drawMappedEdgesInterpEM = emDM_drawMappedEdgesInterpEM;
|
2005-07-23 07:45:39 +00:00
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
emdm->dm.drawFacesSolid = emDM_drawFacesSolid;
|
2005-03-30 00:32:10 +00:00
|
|
|
emdm->dm.drawMappedFacesEM = emDM_drawMappedFacesEM;
|
2005-03-27 20:34:18 +00: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 07:37:15 +00:00
|
|
|
emdm->dm.release = emDM_release;
|
2005-03-27 20:34:18 +00: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 07:37:15 +00:00
|
|
|
emdm->vertexCos = vertexCos;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
2005-08-03 04:04:05 +00:00
|
|
|
if (vertexCos) {
|
|
|
|
EditVert *eve, *preveve;
|
|
|
|
EditFace *efa;
|
|
|
|
int totface = BLI_countlist(&em->faces);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0,eve=em->verts.first; eve; eve= eve->next)
|
|
|
|
eve->prev = (EditVert*) i++;
|
|
|
|
|
|
|
|
emdm->vertexNos = MEM_callocN(sizeof(*emdm->vertexNos)*i, "emdm_vno");
|
|
|
|
emdm->faceNos = MEM_mallocN(sizeof(*emdm->faceNos)*totface, "emdm_vno");
|
|
|
|
|
|
|
|
for(i=0, efa= em->faces.first; efa; i++, efa=efa->next) {
|
|
|
|
float *v1 = vertexCos[(int) efa->v1->prev];
|
|
|
|
float *v2 = vertexCos[(int) efa->v2->prev];
|
|
|
|
float *v3 = vertexCos[(int) efa->v3->prev];
|
|
|
|
float *no = emdm->faceNos[i];
|
|
|
|
|
|
|
|
if(efa->v4) {
|
|
|
|
float *v4 = vertexCos[(int) efa->v3->prev];
|
|
|
|
|
|
|
|
CalcNormFloat4(v1, v2, v3, v4, no);
|
|
|
|
VecAddf(emdm->vertexNos[(int) efa->v4->prev], emdm->vertexNos[(int) efa->v4->prev], no);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
CalcNormFloat(v1, v2, v3, no);
|
|
|
|
}
|
|
|
|
|
|
|
|
VecAddf(emdm->vertexNos[(int) efa->v1->prev], emdm->vertexNos[(int) efa->v1->prev], no);
|
|
|
|
VecAddf(emdm->vertexNos[(int) efa->v2->prev], emdm->vertexNos[(int) efa->v2->prev], no);
|
|
|
|
VecAddf(emdm->vertexNos[(int) efa->v3->prev], emdm->vertexNos[(int) efa->v3->prev], no);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0, eve= em->verts.first; eve; i++, eve=eve->next) {
|
|
|
|
float *no = emdm->vertexNos[i];
|
|
|
|
|
|
|
|
if (Normalise(no)==0.0) {
|
|
|
|
VECCOPY(no, vertexCos[i]);
|
|
|
|
Normalise(no);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (preveve=NULL, eve=emdm->em->verts.first; eve; preveve=eve, eve= eve->next)
|
|
|
|
eve->prev = preveve;
|
|
|
|
}
|
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
return (DerivedMesh*) emdm;
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DerivedMesh dm;
|
|
|
|
|
|
|
|
DispListMesh *dlm;
|
2005-08-07 05:42:03 +00:00
|
|
|
|
|
|
|
EditVert **vertMap;
|
|
|
|
EditEdge **edgeMap;
|
|
|
|
EditFace **faceMap;
|
2005-03-27 20:34:18 +00:00
|
|
|
} SSDerivedMesh;
|
|
|
|
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
static void ssDM_foreachMappedVertEM(DerivedMesh *dm, void (*func)(void *userData, EditVert *vert, float *co, float *no_f, short *no_s), void *userData)
|
2005-08-07 05:42:03 +00:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
int i;
|
2005-08-07 05:42:03 +00:00
|
|
|
|
|
|
|
if (ssdm->vertMap) {
|
|
|
|
for (i=0; i<dlm->totvert; i++) {
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
if (ssdm->vertMap[i]) {
|
|
|
|
func(userData, ssdm->vertMap[i], dlm->mvert[i].co, NULL, dlm->mvert[i].no);
|
2005-08-07 05:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
static void ssDM_foreachMappedEdgeEM(DerivedMesh *dm, void (*func)(void *userData, EditEdge *eed, float *v0co, float *v1co), void *userData)
|
2005-08-07 05:42:03 +00:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
int i;
|
2005-08-07 05:42:03 +00:00
|
|
|
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
if (ssdm->edgeMap) {
|
|
|
|
for (i=0; i<dlm->totedge; i++) {
|
|
|
|
if (ssdm->edgeMap[i]) {
|
|
|
|
MEdge *med = &dlm->medge[i];
|
2005-08-07 05:42:03 +00:00
|
|
|
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
func(userData, ssdm->edgeMap[i], dlm->mvert[med->v1].co, dlm->mvert[med->v2].co);
|
2005-08-07 05:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void ssDM_drawMappedEdgesEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, EditEdge *edge), void *userData)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (ssdm->edgeMap) {
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(i=0; i<dlm->totedge; i++) {
|
|
|
|
if(ssdm->edgeMap[i] && (!setDrawOptions || setDrawOptions(userData, ssdm->edgeMap[i]))) {
|
|
|
|
MEdge *med = &dlm->medge[i];
|
|
|
|
|
|
|
|
glVertex3fv(dlm->mvert[med->v1].co);
|
|
|
|
glVertex3fv(dlm->mvert[med->v2].co);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
static void ssDM_foreachMappedFaceCenterEM(DerivedMesh *dm, void (*func)(void *userData, EditFace *efa, float *co, float *no), void *userData)
|
2005-08-07 05:42:03 +00:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (ssdm->faceMap) {
|
|
|
|
for (i=0; i<dlm->totface; i++) {
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
if(ssdm->faceMap[i]) {
|
2005-08-07 05:42:03 +00:00
|
|
|
MFace *mf = &dlm->mface[i];
|
|
|
|
|
|
|
|
if (mf->v3) {
|
|
|
|
float cent[3];
|
|
|
|
float no[3];
|
|
|
|
|
|
|
|
VECCOPY(cent, dlm->mvert[mf->v1].co);
|
|
|
|
VecAddf(cent, cent, dlm->mvert[mf->v2].co);
|
|
|
|
VecAddf(cent, cent, dlm->mvert[mf->v3].co);
|
|
|
|
|
|
|
|
if (mf->v4) {
|
|
|
|
CalcNormFloat4(dlm->mvert[mf->v1].co, dlm->mvert[mf->v2].co, dlm->mvert[mf->v3].co, dlm->mvert[mf->v4].co, no);
|
|
|
|
VecAddf(cent, cent, dlm->mvert[mf->v4].co);
|
|
|
|
VecMulf(cent, 0.25f);
|
|
|
|
} else {
|
|
|
|
CalcNormFloat(dlm->mvert[mf->v1].co, dlm->mvert[mf->v2].co, dlm->mvert[mf->v3].co, no);
|
|
|
|
VecMulf(cent, 0.33333333333f);
|
|
|
|
}
|
|
|
|
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
func(userData, ssdm->faceMap[i], cent, no);
|
2005-08-07 05:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void ssDM_drawMappedFacesEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, EditFace *face), void *userData)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (ssdm->faceMap) {
|
|
|
|
for (i=0; i<dlm->totface; i++) {
|
|
|
|
if(ssdm->faceMap[i] && (!setDrawOptions || setDrawOptions(userData, ssdm->faceMap[i]))) {
|
|
|
|
MFace *mf = &dlm->mface[i];
|
|
|
|
|
|
|
|
if (mf->v3) {
|
|
|
|
glBegin(mf->v3?GL_QUADS:GL_TRIANGLES);
|
|
|
|
glVertex3fv(dlm->mvert[mf->v1].co);
|
|
|
|
glVertex3fv(dlm->mvert[mf->v2].co);
|
|
|
|
glVertex3fv(dlm->mvert[mf->v3].co);
|
|
|
|
if(mf->v4) glVertex3fv(dlm->mvert[mf->v4].co);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-18 11:31:20 +00:00
|
|
|
static void ssDM_drawVerts(DerivedMesh *dm)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
2005-08-14 10:35:58 +00:00
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
2005-08-18 11:31:20 +00:00
|
|
|
MVert *mvert= dlm->mvert;
|
2005-08-14 10:35:58 +00:00
|
|
|
int i;
|
|
|
|
|
2005-08-18 11:31:20 +00:00
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
for (i=0; i<dlm->totvert; i++) {
|
|
|
|
bglVertex3fv(mvert[i].co);
|
|
|
|
}
|
|
|
|
bglEnd();
|
|
|
|
}
|
|
|
|
static void ssDM_drawUVEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (dlm->tface) {
|
2005-08-14 10:35:58 +00:00
|
|
|
glBegin(GL_LINES);
|
2005-08-18 11:31:20 +00:00
|
|
|
for (i=0; i<dlm->totface; i++) {
|
|
|
|
if (dlm->mface[i].v3) {
|
|
|
|
TFace *tf = &dlm->tface[i];
|
|
|
|
|
|
|
|
if (!(tf->flag&TF_HIDE)) {
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
glVertex2fv(tf->uv[1]);
|
|
|
|
|
|
|
|
glVertex2fv(tf->uv[1]);
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
|
|
|
|
if (!dlm->mface[i].v4) {
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
} else {
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[3]);
|
|
|
|
|
|
|
|
glVertex2fv(tf->uv[3]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
}
|
|
|
|
}
|
2005-08-14 10:35:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
2005-08-18 11:31:20 +00:00
|
|
|
static void ssDM_drawEdgesFlag(DerivedMesh *dm, unsigned int mask, unsigned int value)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
2005-08-18 11:31:20 +00:00
|
|
|
MVert *mvert = dlm->mvert;
|
2005-03-27 20:34:18 +00:00
|
|
|
int i;
|
|
|
|
|
2005-08-18 11:31:20 +00:00
|
|
|
if (dlm->medge) {
|
|
|
|
MEdge *medge= dlm->medge;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (i=0; i<dlm->totedge; i++, medge++) {
|
|
|
|
if ((medge->flag&mask)==value) {
|
|
|
|
glVertex3fv(mvert[medge->v1].co);
|
|
|
|
glVertex3fv(mvert[medge->v2].co);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
2005-08-14 10:35:58 +00:00
|
|
|
static void ssDM_drawEdges(DerivedMesh *dm, int drawLooseEdges)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
|
|
|
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++) {
|
2005-08-14 10:35:58 +00:00
|
|
|
if ((medge->flag&ME_EDGEDRAW) && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
|
2005-08-12 21:55:50 +00:00
|
|
|
glVertex3fv(mvert[medge->v1].co);
|
|
|
|
glVertex3fv(mvert[medge->v2].co);
|
|
|
|
}
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
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 20:16:35 +00:00
|
|
|
static void ssDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int))
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
2005-03-28 08:17:51 +00:00
|
|
|
float *nors = dlm->nors;
|
2005-07-13 20:16:35 +00:00
|
|
|
int glmode=-1, shademodel=-1, matnr=-1, drawCurrentMat=1;
|
2005-03-27 20:34:18 +00: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 20:16:35 +00:00
|
|
|
drawCurrentMat = setMaterial(matnr=new_matnr);
|
2005-03-27 20:34:18 +00:00
|
|
|
|
|
|
|
glShadeModel(shademodel=new_shademodel);
|
|
|
|
glBegin(glmode=new_glmode);
|
|
|
|
}
|
|
|
|
|
2005-07-13 20:16:35 +00: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 20:34:18 +00: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 07:51:00 +00: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 13:46:05 +00:00
|
|
|
TFace *tf = tface?&tface[a]:NULL;
|
2005-08-18 11:31:20 +00:00
|
|
|
int flag;
|
2005-03-29 07:51:00 +00:00
|
|
|
unsigned char *cp= NULL;
|
|
|
|
|
2005-08-18 11:31:20 +00:00
|
|
|
if (mf->v3==0) continue;
|
2005-03-29 07:51:00 +00:00
|
|
|
|
2005-08-18 11:31:20 +00:00
|
|
|
flag = setDrawParams(tf, mf->mat_nr);
|
|
|
|
|
|
|
|
if (flag==0) {
|
|
|
|
continue;
|
|
|
|
} else if (flag==1) {
|
2005-04-14 13:46:05 +00:00
|
|
|
if (tf) {
|
|
|
|
cp= (unsigned char*) tf->col;
|
2005-03-29 07:51:00 +00: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 13:46:05 +00:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[0]);
|
2005-03-29 07:51:00 +00: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 13:46:05 +00:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[1]);
|
2005-03-29 07:51:00 +00: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 13:46:05 +00:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[2]);
|
2005-03-29 07:51:00 +00: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 13:46:05 +00:00
|
|
|
if (tf) glTexCoord2fv(tf->uv[3]);
|
2005-03-29 07:51:00 +00: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 04:17:33 +00:00
|
|
|
static void ssDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
int i;
|
|
|
|
|
2005-07-18 17:33:51 +00: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 04:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-17 17:41:03 +00:00
|
|
|
|
2005-07-18 19:58:23 +00: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 21:27:12 +00: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-08-07 02:30:29 +00:00
|
|
|
static DispListMesh *ssDM_convertToDispListMesh(DerivedMesh *dm, int allowShared)
|
2005-03-27 22:42:57 +00:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
|
2005-08-07 02:30:29 +00:00
|
|
|
if (allowShared) {
|
|
|
|
return displistmesh_copyShared(ssdm->dlm);
|
|
|
|
} else {
|
|
|
|
return displistmesh_copy(ssdm->dlm);
|
|
|
|
}
|
2005-03-27 22:42:57 +00:00
|
|
|
}
|
|
|
|
|
2005-08-07 05:42:03 +00:00
|
|
|
static DispListMesh *ssDM_convertToDispListMeshMapped(DerivedMesh *dm, int allowShared, EditVert ***vertMap_r, EditEdge ***edgeMap_r, EditFace ***faceMap_r)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
|
|
|
|
// We should never get here if the appropriate ssdm fields weren't given.
|
|
|
|
|
|
|
|
*vertMap_r = MEM_dupallocN(ssdm->vertMap);
|
|
|
|
*edgeMap_r = MEM_dupallocN(ssdm->edgeMap);
|
|
|
|
*faceMap_r = MEM_dupallocN(ssdm->faceMap);
|
|
|
|
|
|
|
|
if (allowShared) {
|
|
|
|
return displistmesh_copyShared(ssdm->dlm);
|
|
|
|
} else {
|
|
|
|
return displistmesh_copy(ssdm->dlm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-28 21:49:49 +00:00
|
|
|
static void ssDM_release(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
|
2005-03-29 16:43:39 +00:00
|
|
|
displistmesh_free(ssdm->dlm);
|
2005-08-07 05:42:03 +00:00
|
|
|
if (ssdm->vertMap) {
|
|
|
|
MEM_freeN(ssdm->vertMap);
|
|
|
|
MEM_freeN(ssdm->edgeMap);
|
|
|
|
MEM_freeN(ssdm->faceMap);
|
|
|
|
}
|
2005-03-28 21:49:49 +00:00
|
|
|
|
|
|
|
MEM_freeN(dm);
|
|
|
|
}
|
|
|
|
|
2005-08-07 05:42:03 +00:00
|
|
|
DerivedMesh *derivedmesh_from_displistmesh(DispListMesh *dlm, float (*vertexCos)[3], EditVert **vertMap, EditEdge **edgeMap, EditFace **faceMap)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
2005-07-17 17:41:03 +00:00
|
|
|
SSDerivedMesh *ssdm = MEM_callocN(sizeof(*ssdm), "ssdm");
|
2005-03-27 20:34:18 +00:00
|
|
|
|
2005-07-17 04:17:33 +00:00
|
|
|
ssdm->dm.getMinMax = ssDM_getMinMax;
|
|
|
|
|
2005-03-27 21:27:12 +00:00
|
|
|
ssdm->dm.getNumVerts = ssDM_getNumVerts;
|
|
|
|
ssdm->dm.getNumFaces = ssDM_getNumFaces;
|
2005-03-27 22:42:57 +00:00
|
|
|
ssdm->dm.convertToDispListMesh = ssDM_convertToDispListMesh;
|
2005-08-07 05:42:03 +00:00
|
|
|
ssdm->dm.convertToDispListMeshMapped = ssDM_convertToDispListMeshMapped;
|
2005-03-27 21:27:12 +00:00
|
|
|
|
2005-07-18 19:58:23 +00:00
|
|
|
ssdm->dm.getVertCos = ssDM_getVertCos;
|
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
ssdm->dm.drawVerts = ssDM_drawVerts;
|
|
|
|
|
2005-08-18 11:31:20 +00:00
|
|
|
ssdm->dm.drawUVEdges = ssDM_drawUVEdges;
|
2005-03-27 20:34:18 +00:00
|
|
|
ssdm->dm.drawEdges = ssDM_drawEdges;
|
2005-08-18 11:31:20 +00:00
|
|
|
ssdm->dm.drawEdgesFlag = ssDM_drawEdgesFlag;
|
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
ssdm->dm.drawFacesSolid = ssDM_drawFacesSolid;
|
|
|
|
ssdm->dm.drawFacesColored = ssDM_drawFacesColored;
|
2005-03-29 07:51:00 +00:00
|
|
|
ssdm->dm.drawFacesTex = ssDM_drawFacesTex;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
2005-08-07 05:42:03 +00:00
|
|
|
/* EM functions */
|
|
|
|
|
Big commit, had to rework lots of selection stuff so that things
worked properly with modifiers. Needs more testing I am sure.
No, honestly, I wasn't just cleaning for the hell of it, it
was *necessary* (I would never do such a thing). Selection should
work completely with cage options of modifiers now.
- added DerivedMesh foreach functions to iterate over mapped
verts/edges/face centers. These replaced some of the drawing
functions and are more general anyway. Special edge drawing
functions remain for performance reasons.
- removed EditFace xs, ys fields
- added general functions to iterate over screen coordinates of
mesh/curve/lattice objects
- removed all calc_*verts* functions that were used for storing
screen coordinates in objects. they were recalc'd on the fly
for most situations anyway, so now we just always do that.
calc_*verts_ext was one of those calls that did dirty things
deep down in the callstack (changing curarea and poking at
matrices)
- rewrote all vertex level selection routines (circle, lasso, bbox)
and closest vertex routines (rightmouse select) to use the new
system. This cleaned up the selection code a lot and the structure
of selection is much easier to see now. This is good for future
work on allowing modifiers to completely override the selection
system. It also points out some discrepancies in the way selection
is handled that might be nice to resolve (mesh vertex selection has
fancy stuff to try to help with selecting overlapping, but it only
works w/o bbuf select, and curves/lattices don't have at all).
- had to remove ton's code to move Manipulator to cage location, this
is not reliable (can come up with a different method if requested)
- as it happens BezTriple.s and BPoint.s are basically available to
be removed, just need to rewrite editipo code that still does
background calc of screen coordinates
- MVert.{xs,ys} are still around because they are abused in some places
for other info (not sure if this is safe actually, since they are
short's and the mvert limit went up).
And did I mention this commit is comes out to -305 lines? Well it does.
2005-08-09 08:12:36 +00:00
|
|
|
ssdm->dm.foreachMappedVertEM = ssDM_foreachMappedVertEM;
|
|
|
|
ssdm->dm.foreachMappedEdgeEM = ssDM_foreachMappedEdgeEM;
|
|
|
|
ssdm->dm.foreachMappedFaceCenterEM = ssDM_foreachMappedFaceCenterEM;
|
|
|
|
|
2005-08-07 05:42:03 +00:00
|
|
|
ssdm->dm.drawMappedEdgesEM = ssDM_drawMappedEdgesEM;
|
|
|
|
ssdm->dm.drawMappedEdgesInterpEM = NULL; // no way to implement this one
|
|
|
|
|
|
|
|
ssdm->dm.drawMappedFacesEM = ssDM_drawMappedFacesEM;
|
|
|
|
|
2005-03-28 21:49:49 +00:00
|
|
|
ssdm->dm.release = ssDM_release;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
|
|
|
ssdm->dlm = dlm;
|
2005-08-07 05:42:03 +00:00
|
|
|
ssdm->vertMap = vertMap;
|
|
|
|
ssdm->edgeMap = edgeMap;
|
|
|
|
ssdm->faceMap = faceMap;
|
|
|
|
|
|
|
|
if (vertexCos) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<dlm->totvert; i++) {
|
|
|
|
VECCOPY(dlm->mvert[i].co, vertexCos[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2005-03-27 20:34:18 +00:00
|
|
|
|
|
|
|
return (DerivedMesh*) ssdm;
|
|
|
|
}
|
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
/***/
|
2005-03-27 20:34:18 +00: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 07:37:15 +00:00
|
|
|
typedef float vec3f[3];
|
|
|
|
|
2005-07-26 00:45:19 +00:00
|
|
|
DerivedMesh *mesh_create_derived_for_modifier(Object *ob, ModifierData *md)
|
|
|
|
{
|
|
|
|
Mesh *me = ob->data;
|
2005-08-03 04:04:05 +00:00
|
|
|
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
2005-07-26 00:45:19 +00:00
|
|
|
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 04:44:02 +00:00
|
|
|
static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedMesh **deform_r, DerivedMesh **final_r, int useRenderParams, int useDeform)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
2005-07-20 04:44:02 +00:00
|
|
|
Mesh *me = ob->data;
|
2005-08-11 03:31:33 +00:00
|
|
|
ModifierData *md= modifiers_getVirtualModifierList(ob);
|
|
|
|
float (*deformedVerts)[3] = NULL;
|
2005-07-19 20:14:17 +00: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 07:37:15 +00:00
|
|
|
int numVerts = me->totvert;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
- added eModifierTypeFlag_RequiresOriginalData for modifiers that
can only follow deform (for example, they store mesh vertex
indices)
- added ModifierType.foreachObjectLink for iterating over Object
links inside modifier data (used for file load, relinking, etc)
- switched various modifiers_ functions to take object argument
instead of ListBase
- added user editable name field to modifiers
- bug fix, duplicate and make single user didn't relink object
pointers in modifier data
- added modifiers to outliner, needs icon
- added armature, hook, and softbody modifiers (softbody doesn't
do anything atm). added conversion of old hooks to modifiers.
NOTE-THE-FIRST: User name field is not initialized on loading 2.38 files
so if you have saved stuff with a cvs blender you will see blank names.
NOTE-THE-SECOND: Since modifiers aren't evaluated yet for non-Mesh
objects, hooks for lattices and curves are broken. Don't updated if
you actually, say, *use* Blender.
NOTE-THE-THIRD: Old hooks used a quirky weighting system during
deformation which can't be extended to modifiers. On the upside,
I doubt anyone relied on the old quirky system and the new system
makes much more sense. (Although the way falloff works is still
quite stupid I think).
2005-08-10 22:05:52 +00:00
|
|
|
modifiers_clearErrors(ob);
|
2005-08-04 07:25:43 +00:00
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
if (deform_r) *deform_r = NULL;
|
|
|
|
*final_r = NULL;
|
|
|
|
|
2005-07-20 18:15:40 +00:00
|
|
|
if (useDeform) {
|
2005-08-11 03:31:33 +00:00
|
|
|
do_mesh_key(me);
|
2005-07-19 00:21:01 +00:00
|
|
|
|
2005-07-19 20:14:17 +00:00
|
|
|
/* Apply all leading deforming modifiers */
|
|
|
|
for (; md; md=md->next) {
|
2005-08-03 04:04:05 +00:00
|
|
|
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
2005-07-19 20:14:17 +00:00
|
|
|
|
|
|
|
if (!(md->mode&(1<<useRenderParams))) continue;
|
2005-07-20 07:11:26 +00:00
|
|
|
if (mti->isDisabled && mti->isDisabled(md)) continue;
|
2005-07-19 20:14:17 +00: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 07:37:15 +00:00
|
|
|
if (!deformedVerts) deformedVerts = mesh_getVertexCos(me, &numVerts);
|
|
|
|
mti->deformVerts(md, ob, NULL, deformedVerts, numVerts);
|
2005-07-19 20:14:17 +00: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 00:21:01 +00:00
|
|
|
if (deform_r) *deform_r = getMeshDerivedMesh(me, ob, deformedVerts);
|
|
|
|
} else {
|
|
|
|
deformedVerts = inputVertexCos;
|
|
|
|
}
|
|
|
|
|
2005-07-19 20:14:17 +00:00
|
|
|
/* Now apply all remaining modifiers. If useDeform is off then skip
|
2005-07-20 04:44:02 +00:00
|
|
|
* OnlyDeform ones.
|
2005-07-19 20:14:17 +00:00
|
|
|
*/
|
|
|
|
dm = NULL;
|
|
|
|
for (; md; md=md->next) {
|
2005-08-03 04:04:05 +00:00
|
|
|
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
2005-07-19 20:14:17 +00:00
|
|
|
|
|
|
|
if (!(md->mode&(1<<useRenderParams))) continue;
|
|
|
|
if (mti->type==eModifierTypeType_OnlyDeform && !useDeform) continue;
|
- added eModifierTypeFlag_RequiresOriginalData for modifiers that
can only follow deform (for example, they store mesh vertex
indices)
- added ModifierType.foreachObjectLink for iterating over Object
links inside modifier data (used for file load, relinking, etc)
- switched various modifiers_ functions to take object argument
instead of ListBase
- added user editable name field to modifiers
- bug fix, duplicate and make single user didn't relink object
pointers in modifier data
- added modifiers to outliner, needs icon
- added armature, hook, and softbody modifiers (softbody doesn't
do anything atm). added conversion of old hooks to modifiers.
NOTE-THE-FIRST: User name field is not initialized on loading 2.38 files
so if you have saved stuff with a cvs blender you will see blank names.
NOTE-THE-SECOND: Since modifiers aren't evaluated yet for non-Mesh
objects, hooks for lattices and curves are broken. Don't updated if
you actually, say, *use* Blender.
NOTE-THE-THIRD: Old hooks used a quirky weighting system during
deformation which can't be extended to modifiers. On the upside,
I doubt anyone relied on the old quirky system and the new system
makes much more sense. (Although the way falloff works is still
quite stupid I think).
2005-08-10 22:05:52 +00:00
|
|
|
if ((mti->flags&eModifierTypeFlag_RequiresOriginalData) && dm) {
|
|
|
|
modifier_setError(md, "Internal error, modifier requires original data (bad stack position).");
|
|
|
|
continue;
|
|
|
|
}
|
2005-07-20 07:11:26 +00:00
|
|
|
if (mti->isDisabled && mti->isDisabled(md)) continue;
|
2005-07-19 20:14:17 +00: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 21:19:38 +00:00
|
|
|
* deform them. Once done with this run of deformers verts will be written back.
|
2005-07-19 20:14:17 +00: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 07:37:15 +00:00
|
|
|
deformedVerts = mesh_getVertexCos(me, &numVerts);
|
2005-07-19 20:14:17 +00: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 07:37:15 +00:00
|
|
|
mti->deformVerts(md, ob, dm, deformedVerts, numVerts);
|
2005-07-19 20:14:17 +00: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 02:44:59 +00:00
|
|
|
DerivedMesh *ndm = mti->applyModifier(md, ob, dm, deformedVerts, useRenderParams, !inputVertexCos);
|
2005-07-19 20:14:17 +00:00
|
|
|
|
2005-07-26 02:44:59 +00:00
|
|
|
if (ndm) {
|
2005-08-03 04:04:05 +00:00
|
|
|
if (dm) dm->release(dm);
|
|
|
|
|
2005-07-26 02:44:59 +00:00
|
|
|
dm = ndm;
|
|
|
|
|
|
|
|
if (deformedVerts) {
|
|
|
|
if (deformedVerts!=inputVertexCos) {
|
|
|
|
MEM_freeN(deformedVerts);
|
|
|
|
}
|
|
|
|
deformedVerts = NULL;
|
2005-07-19 20:14:17 +00:00
|
|
|
}
|
2005-07-26 02:44:59 +00:00
|
|
|
}
|
2005-07-19 20:14:17 +00: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) {
|
2005-08-07 02:30:29 +00:00
|
|
|
DispListMesh *dlm = dm->convertToDispListMesh(dm, 0);
|
2005-07-19 20:14:17 +00:00
|
|
|
|
|
|
|
dm->release(dm);
|
|
|
|
|
2005-08-07 05:42:03 +00:00
|
|
|
*final_r = derivedmesh_from_displistmesh(dlm, deformedVerts, NULL, NULL, NULL);
|
2005-07-19 20:14:17 +00:00
|
|
|
} else if (dm) {
|
|
|
|
*final_r = dm;
|
2005-07-19 00:21:01 +00:00
|
|
|
} else {
|
|
|
|
*final_r = getMeshDerivedMesh(me, ob, deformedVerts);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
if (deformedVerts && deformedVerts!=inputVertexCos) {
|
|
|
|
MEM_freeN(deformedVerts);
|
2005-03-27 20:34:18 +00: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 07:37:15 +00: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;
|
2005-08-04 07:25:43 +00:00
|
|
|
ModifierData *md;
|
- 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 07:37:15 +00:00
|
|
|
float (*deformedVerts)[3] = NULL;
|
|
|
|
DerivedMesh *dm;
|
- added eModifierTypeFlag_RequiresOriginalData for modifiers that
can only follow deform (for example, they store mesh vertex
indices)
- added ModifierType.foreachObjectLink for iterating over Object
links inside modifier data (used for file load, relinking, etc)
- switched various modifiers_ functions to take object argument
instead of ListBase
- added user editable name field to modifiers
- bug fix, duplicate and make single user didn't relink object
pointers in modifier data
- added modifiers to outliner, needs icon
- added armature, hook, and softbody modifiers (softbody doesn't
do anything atm). added conversion of old hooks to modifiers.
NOTE-THE-FIRST: User name field is not initialized on loading 2.38 files
so if you have saved stuff with a cvs blender you will see blank names.
NOTE-THE-SECOND: Since modifiers aren't evaluated yet for non-Mesh
objects, hooks for lattices and curves are broken. Don't updated if
you actually, say, *use* Blender.
NOTE-THE-THIRD: Old hooks used a quirky weighting system during
deformation which can't be extended to modifiers. On the upside,
I doubt anyone relied on the old quirky system and the new system
makes much more sense. (Although the way falloff works is still
quite stupid I think).
2005-08-10 22:05:52 +00:00
|
|
|
int i, numVerts, cageIndex = modifiers_getCageIndex(ob, 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 07:37:15 +00:00
|
|
|
|
- added eModifierTypeFlag_RequiresOriginalData for modifiers that
can only follow deform (for example, they store mesh vertex
indices)
- added ModifierType.foreachObjectLink for iterating over Object
links inside modifier data (used for file load, relinking, etc)
- switched various modifiers_ functions to take object argument
instead of ListBase
- added user editable name field to modifiers
- bug fix, duplicate and make single user didn't relink object
pointers in modifier data
- added modifiers to outliner, needs icon
- added armature, hook, and softbody modifiers (softbody doesn't
do anything atm). added conversion of old hooks to modifiers.
NOTE-THE-FIRST: User name field is not initialized on loading 2.38 files
so if you have saved stuff with a cvs blender you will see blank names.
NOTE-THE-SECOND: Since modifiers aren't evaluated yet for non-Mesh
objects, hooks for lattices and curves are broken. Don't updated if
you actually, say, *use* Blender.
NOTE-THE-THIRD: Old hooks used a quirky weighting system during
deformation which can't be extended to modifiers. On the upside,
I doubt anyone relied on the old quirky system and the new system
makes much more sense. (Although the way falloff works is still
quite stupid I think).
2005-08-10 22:05:52 +00:00
|
|
|
modifiers_clearErrors(ob);
|
- 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 07:37:15 +00:00
|
|
|
|
2005-08-04 07:25:43 +00:00
|
|
|
if (cage_r && cageIndex==-1) {
|
2005-08-03 04:04:05 +00:00
|
|
|
*cage_r = getEditMeshDerivedMesh(em, 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 07:37:15 +00:00
|
|
|
|
|
|
|
dm = NULL;
|
2005-08-04 07:25:43 +00:00
|
|
|
for (i=0,md= ob->modifiers.first; md; i++,md=md->next) {
|
2005-08-03 04:04:05 +00:00
|
|
|
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
- 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 07:37:15 +00:00
|
|
|
|
2005-07-27 20:16:41 +00:00
|
|
|
if (!(md->mode&eModifierMode_Realtime)) continue;
|
2005-07-23 19:15:08 +00:00
|
|
|
if (!(md->mode&eModifierMode_Editmode)) continue;
|
- added eModifierTypeFlag_RequiresOriginalData for modifiers that
can only follow deform (for example, they store mesh vertex
indices)
- added ModifierType.foreachObjectLink for iterating over Object
links inside modifier data (used for file load, relinking, etc)
- switched various modifiers_ functions to take object argument
instead of ListBase
- added user editable name field to modifiers
- bug fix, duplicate and make single user didn't relink object
pointers in modifier data
- added modifiers to outliner, needs icon
- added armature, hook, and softbody modifiers (softbody doesn't
do anything atm). added conversion of old hooks to modifiers.
NOTE-THE-FIRST: User name field is not initialized on loading 2.38 files
so if you have saved stuff with a cvs blender you will see blank names.
NOTE-THE-SECOND: Since modifiers aren't evaluated yet for non-Mesh
objects, hooks for lattices and curves are broken. Don't updated if
you actually, say, *use* Blender.
NOTE-THE-THIRD: Old hooks used a quirky weighting system during
deformation which can't be extended to modifiers. On the upside,
I doubt anyone relied on the old quirky system and the new system
makes much more sense. (Although the way falloff works is still
quite stupid I think).
2005-08-10 22:05:52 +00:00
|
|
|
if ((mti->flags&eModifierTypeFlag_RequiresOriginalData) && dm) {
|
|
|
|
modifier_setError(md, "Internal error, modifier requires original data (bad stack position).");
|
|
|
|
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 07:37:15 +00: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.
|
|
|
|
*/
|
2005-08-03 04:04:05 +00:00
|
|
|
DerivedMesh *ndm = mti->applyModifierEM(md, ob, em, dm, deformedVerts);
|
|
|
|
|
|
|
|
if (ndm) {
|
|
|
|
if (dm && (!cage_r || dm!=*cage_r)) dm->release(dm);
|
|
|
|
|
|
|
|
dm = ndm;
|
|
|
|
|
|
|
|
if (deformedVerts) {
|
|
|
|
MEM_freeN(deformedVerts);
|
|
|
|
deformedVerts = 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 07:37:15 +00:00
|
|
|
|
2005-08-04 07:25:43 +00:00
|
|
|
if (cage_r && i==cageIndex) {
|
2005-08-03 04:04:05 +00:00
|
|
|
if (dm && deformedVerts) {
|
2005-08-07 05:42:03 +00:00
|
|
|
DispListMesh *dlm;
|
|
|
|
EditVert **vertMap;
|
|
|
|
EditEdge **edgeMap;
|
|
|
|
EditFace **faceMap;
|
|
|
|
|
|
|
|
dlm = dm->convertToDispListMeshMapped(dm, 0, &vertMap, &edgeMap, &faceMap);
|
|
|
|
|
|
|
|
*cage_r = derivedmesh_from_displistmesh(dlm, deformedVerts, vertMap, edgeMap, faceMap);
|
2005-08-03 04:04:05 +00:00
|
|
|
} else if (dm) {
|
|
|
|
*cage_r = dm;
|
|
|
|
} else {
|
|
|
|
*cage_r = getEditMeshDerivedMesh(em, deformedVerts?MEM_dupallocN(deformedVerts):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 07:37:15 +00: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) {
|
2005-08-07 02:30:29 +00:00
|
|
|
DispListMesh *dlm = dm->convertToDispListMesh(dm, 0);
|
- 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 07:37:15 +00:00
|
|
|
|
2005-08-03 04:04:05 +00:00
|
|
|
if (!cage_r || dm!=*cage_r) dm->release(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 07:37:15 +00:00
|
|
|
|
2005-08-07 05:42:03 +00:00
|
|
|
*final_r = derivedmesh_from_displistmesh(dlm, deformedVerts, NULL, NULL, 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 07:37:15 +00:00
|
|
|
MEM_freeN(deformedVerts);
|
|
|
|
} else if (dm) {
|
|
|
|
*final_r = dm;
|
|
|
|
} else {
|
|
|
|
*final_r = getEditMeshDerivedMesh(em, deformedVerts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-19 00:21:01 +00: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 20:30:33 +00:00
|
|
|
static void clear_mesh_caches(Object *ob)
|
2005-07-19 02:36:21 +00: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 20:30:33 +00:00
|
|
|
}
|
2005-07-19 02:36:21 +00: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 20:30:33 +00: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 07:45:39 +00: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 20:30:33 +00:00
|
|
|
INIT_MINMAX(min, max);
|
2005-07-19 02:36:21 +00: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 20:30:33 +00:00
|
|
|
ob->derivedFinal->getMinMax(ob->derivedFinal, min, max);
|
2005-07-19 02:36:21 +00: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 20:30:33 +00: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 07:37:15 +00: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 20:30:33 +00: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 07:37:15 +00: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 20:30:33 +00:00
|
|
|
|
2005-08-03 04:04:05 +00:00
|
|
|
INIT_MINMAX(min, max);
|
|
|
|
|
- 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 07:37:15 +00:00
|
|
|
em->derivedFinal->getMinMax(em->derivedFinal, min, max);
|
|
|
|
|
|
|
|
boundbox_set_from_min_max(mesh_get_bb(G.obedit->data), min, max);
|
2005-07-19 02:36:21 +00: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 20:30:33 +00:00
|
|
|
if (ob==G.obedit) {
|
|
|
|
editmesh_build_data();
|
|
|
|
} else {
|
|
|
|
mesh_build_data(ob);
|
2005-07-22 22:01:39 +00: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 20:30:33 +00:00
|
|
|
}
|
2005-07-19 02:36:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***/
|
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
DerivedMesh *mesh_get_derived_final(Object *ob, int *needsFree_r)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
2005-07-19 02:36:21 +00: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 20:30:33 +00:00
|
|
|
mesh_build_data(ob);
|
2005-07-19 00:21:01 +00:00
|
|
|
}
|
2005-07-13 20:16:35 +00:00
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
*needsFree_r = 0;
|
2005-07-19 02:36:21 +00:00
|
|
|
return ob->derivedFinal;
|
2005-07-19 00:21:01 +00: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 20:30:33 +00:00
|
|
|
mesh_build_data(ob);
|
2005-03-28 21:49:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
*needsFree_r = 0;
|
|
|
|
return ob->derivedDeform;
|
2005-03-28 21:49:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
DerivedMesh *mesh_create_derived_render(Object *ob)
|
2005-07-16 21:03:28 +00:00
|
|
|
{
|
2005-07-19 00:21:01 +00:00
|
|
|
DerivedMesh *final;
|
2005-07-16 21:03:28 +00:00
|
|
|
|
2005-07-20 04:44:02 +00:00
|
|
|
mesh_calc_modifiers(ob, NULL, NULL, &final, 1, 1);
|
2005-07-16 21:03:28 +00:00
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
return final;
|
2005-07-16 21:03:28 +00:00
|
|
|
}
|
|
|
|
|
2005-07-20 04:44:02 +00:00
|
|
|
DerivedMesh *mesh_create_derived_no_deform(Object *ob, float (*vertCos)[3])
|
2005-07-17 01:18:59 +00:00
|
|
|
{
|
2005-07-19 00:21:01 +00:00
|
|
|
DerivedMesh *final;
|
2005-07-17 01:18:59 +00:00
|
|
|
|
2005-07-20 04:44:02 +00:00
|
|
|
mesh_calc_modifiers(ob, vertCos, NULL, &final, 0, 0);
|
2005-07-17 01:18:59 +00:00
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
return final;
|
2005-07-17 01:18:59 +00:00
|
|
|
}
|
|
|
|
|
2005-07-20 04:44:02 +00:00
|
|
|
DerivedMesh *mesh_create_derived_no_deform_render(Object *ob, float (*vertCos)[3])
|
2005-03-28 21:49:49 +00:00
|
|
|
{
|
2005-07-19 00:21:01 +00:00
|
|
|
DerivedMesh *final;
|
2005-03-28 21:49:49 +00:00
|
|
|
|
2005-07-20 04:44:02 +00:00
|
|
|
mesh_calc_modifiers(ob, vertCos, NULL, &final, 1, 0);
|
2005-04-04 12:22:33 +00:00
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
return final;
|
|
|
|
}
|
2005-04-04 03:38:21 +00:00
|
|
|
|
2005-07-19 00:21:01 +00: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 20:30:33 +00:00
|
|
|
DerivedMesh *editmesh_get_derived_cage_and_final(DerivedMesh **final_r, int *cageNeedsFree_r, int *finalNeedsFree_r)
|
2005-07-19 00:21:01 +00: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 20:30:33 +00:00
|
|
|
*cageNeedsFree_r = *finalNeedsFree_r = 0;
|
2005-03-27 20:34:18 +00: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 20:30:33 +00:00
|
|
|
if (!G.editMesh->derivedCage)
|
|
|
|
editmesh_build_data();
|
2005-03-27 20:34:18 +00: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 20:30:33 +00:00
|
|
|
*final_r = G.editMesh->derivedFinal;
|
|
|
|
return G.editMesh->derivedCage;
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
2005-03-28 05:58:43 +00:00
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
DerivedMesh *editmesh_get_derived_cage(int *needsFree_r)
|
2005-03-28 05:58:43 +00:00
|
|
|
{
|
2005-07-17 01:18:59 +00:00
|
|
|
*needsFree_r = 0;
|
2005-03-29 16:43:39 +00: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 20:30:33 +00:00
|
|
|
if (!G.editMesh->derivedCage)
|
|
|
|
editmesh_build_data();
|
2005-03-28 05:58:43 +00: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 20:30:33 +00:00
|
|
|
return G.editMesh->derivedCage;
|
2005-03-28 05:58:43 +00:00
|
|
|
}
|
2005-08-06 20:44:59 +00:00
|
|
|
|
|
|
|
DerivedMesh *editmesh_get_derived_base(void)
|
|
|
|
{
|
|
|
|
return getEditMeshDerivedMesh(G.editMesh, NULL);
|
|
|
|
}
|