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 *****
|
|
|
|
*/
|
|
|
|
|
2005-08-23 20:04:10 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-09-18 13:27:12 +00:00
|
|
|
#include <zlib.h>
|
|
|
|
|
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"
|
2006-08-28 01:12:36 +00:00
|
|
|
#include "DNA_key_types.h"
|
2005-03-27 20:34:18 +00:00
|
|
|
#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-09-18 13:27:12 +00:00
|
|
|
#include "DNA_object_fluidsim.h" // N_T
|
|
|
|
#include "DNA_scene_types.h" // N_T
|
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"
|
2006-08-30 10:55:46 +00:00
|
|
|
#include "BLI_edgehash.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"
|
2006-08-28 01:12:36 +00:00
|
|
|
#include "BKE_cdderivedmesh.h"
|
2006-11-11 16:38:37 +00:00
|
|
|
#include "BKE_customdata.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
|
|
|
|
2006-08-20 15:22:56 +00:00
|
|
|
#ifdef WITH_VERSE
|
|
|
|
#include "BKE_verse.h"
|
|
|
|
#endif
|
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
2006-11-06 01:08:26 +00:00
|
|
|
#include "multires.h"
|
|
|
|
|
2006-03-29 14:57:14 +00:00
|
|
|
// headers for fluidsim bobj meshes
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "LBM_fluidsim.h"
|
|
|
|
#include "elbeem.h"
|
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
///////////////////////////////////
|
|
|
|
///////////////////////////////////
|
2006-08-28 01:12:36 +00:00
|
|
|
#define DERIVEDMESH_INITIAL_LAYERS 5
|
|
|
|
|
|
|
|
MVert *dm_dupVertArray(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MVert *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumVerts(dm),
|
|
|
|
"dm_dupVertArray tmp");
|
|
|
|
|
|
|
|
if(tmp) dm->getVertArray(dm, tmp);
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
MEdge *dm_dupEdgeArray(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MEdge *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumEdges(dm),
|
|
|
|
"dm_dupEdgeArray tmp");
|
|
|
|
|
|
|
|
if(tmp) dm->getEdgeArray(dm, tmp);
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
MFace *dm_dupFaceArray(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MFace *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumFaces(dm),
|
|
|
|
"dm_dupFaceArray tmp");
|
|
|
|
|
|
|
|
if(tmp) dm->getFaceArray(dm, tmp);
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_init_funcs(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
/* default function implementations */
|
|
|
|
dm->dupVertArray = dm_dupVertArray;
|
|
|
|
dm->dupEdgeArray = dm_dupEdgeArray;
|
|
|
|
dm->dupFaceArray = dm_dupFaceArray;
|
|
|
|
|
|
|
|
dm->getVertData = DM_get_vert_data;
|
|
|
|
dm->getEdgeData = DM_get_edge_data;
|
|
|
|
dm->getFaceData = DM_get_face_data;
|
|
|
|
dm->getVertDataArray = DM_get_vert_data_layer;
|
|
|
|
dm->getEdgeDataArray = DM_get_edge_data_layer;
|
|
|
|
dm->getFaceDataArray = DM_get_face_data_layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_init(DerivedMesh *dm,
|
|
|
|
int numVerts, int numEdges, int numFaces)
|
|
|
|
{
|
2006-09-07 06:44:25 +00:00
|
|
|
CustomData_init(&dm->vertData, DERIVEDMESH_INITIAL_LAYERS, numVerts,
|
|
|
|
SUB_ELEMS_VERT);
|
|
|
|
CustomData_init(&dm->edgeData, DERIVEDMESH_INITIAL_LAYERS, numEdges,
|
|
|
|
SUB_ELEMS_EDGE);
|
|
|
|
CustomData_init(&dm->faceData, DERIVEDMESH_INITIAL_LAYERS, numFaces,
|
|
|
|
SUB_ELEMS_FACE);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2006-09-07 06:44:25 +00:00
|
|
|
CustomData_add_layer(&dm->vertData, LAYERTYPE_ORIGINDEX, 0, NULL);
|
|
|
|
CustomData_add_layer(&dm->edgeData, LAYERTYPE_ORIGINDEX, 0, NULL);
|
|
|
|
CustomData_add_layer(&dm->faceData, LAYERTYPE_ORIGINDEX, 0, NULL);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
DM_init_funcs(dm);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_from_template(DerivedMesh *dm, DerivedMesh *source,
|
|
|
|
int numVerts, int numEdges, int numFaces)
|
|
|
|
{
|
2006-11-11 16:38:37 +00:00
|
|
|
CustomData_from_template(&source->vertData, &dm->vertData, 0, numVerts);
|
|
|
|
CustomData_from_template(&source->edgeData, &dm->edgeData, 0, numEdges);
|
|
|
|
CustomData_from_template(&source->faceData, &dm->faceData, 0, numFaces);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
DM_init_funcs(dm);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_release(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
CustomData_free(&dm->vertData);
|
|
|
|
CustomData_free(&dm->edgeData);
|
|
|
|
CustomData_free(&dm->faceData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_to_mesh(DerivedMesh *dm, Mesh *me)
|
|
|
|
{
|
|
|
|
/* dm might depend on me, so we need to do everything with a local copy */
|
|
|
|
Mesh tmp_me = *me;
|
|
|
|
int numVerts = dm->getNumVerts(dm);
|
|
|
|
|
|
|
|
tmp_me.dvert = NULL;
|
|
|
|
tmp_me.tface = NULL;
|
|
|
|
tmp_me.mcol = NULL;
|
|
|
|
|
|
|
|
tmp_me.totvert = numVerts;
|
|
|
|
tmp_me.totedge = dm->getNumEdges(dm);
|
|
|
|
tmp_me.totface = dm->getNumFaces(dm);
|
|
|
|
|
|
|
|
tmp_me.mvert = dm->dupVertArray(dm);
|
|
|
|
tmp_me.medge = dm->dupEdgeArray(dm);
|
|
|
|
tmp_me.mface = dm->dupFaceArray(dm);
|
|
|
|
|
|
|
|
if(dm->getFaceDataArray(dm, LAYERTYPE_TFACE))
|
|
|
|
tmp_me.tface = MEM_dupallocN(dm->getFaceDataArray(dm,
|
|
|
|
LAYERTYPE_TFACE));
|
|
|
|
if(dm->getFaceDataArray(dm, LAYERTYPE_MCOL))
|
|
|
|
tmp_me.mcol = MEM_dupallocN(dm->getFaceDataArray(dm,
|
|
|
|
LAYERTYPE_MCOL));
|
|
|
|
if(dm->getVertDataArray(dm, LAYERTYPE_MDEFORMVERT)) {
|
|
|
|
int i;
|
|
|
|
MDeformVert *dv;
|
|
|
|
|
|
|
|
tmp_me.dvert = MEM_dupallocN(
|
|
|
|
dm->getVertDataArray(dm, LAYERTYPE_MDEFORMVERT));
|
|
|
|
|
|
|
|
for(i = 0, dv = tmp_me.dvert; i < numVerts; ++i, ++dv)
|
|
|
|
dv->dw = MEM_dupallocN(dv->dw);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(me->mvert) MEM_freeN(me->mvert);
|
|
|
|
if(me->dvert) free_dverts(me->dvert, me->totvert);
|
|
|
|
if(me->mface) MEM_freeN(me->mface);
|
|
|
|
if(me->tface) MEM_freeN(me->tface);
|
|
|
|
if(me->mcol) MEM_freeN(me->mcol);
|
|
|
|
if(me->medge) MEM_freeN(me->medge);
|
|
|
|
|
|
|
|
/* if the number of verts has changed, remove invalid data */
|
|
|
|
if(numVerts != me->totvert) {
|
|
|
|
if(me->msticky) MEM_freeN(me->msticky);
|
|
|
|
me->msticky = NULL;
|
|
|
|
|
|
|
|
if(me->key) me->key->id.us--;
|
|
|
|
me->key = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*me = tmp_me;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_add_vert_layer(DerivedMesh *dm, int type, int flag, void *layer)
|
|
|
|
{
|
|
|
|
CustomData_add_layer(&dm->vertData, type, flag, layer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_add_edge_layer(DerivedMesh *dm, int type, int flag, void *layer)
|
|
|
|
{
|
|
|
|
CustomData_add_layer(&dm->edgeData, type, flag, layer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_add_face_layer(DerivedMesh *dm, int type, int flag, void *layer)
|
|
|
|
{
|
|
|
|
CustomData_add_layer(&dm->faceData, type, flag, layer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *DM_get_vert_data(DerivedMesh *dm, int index, int type)
|
|
|
|
{
|
|
|
|
return CustomData_get(&dm->vertData, index, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *DM_get_edge_data(DerivedMesh *dm, int index, int type)
|
|
|
|
{
|
|
|
|
return CustomData_get(&dm->edgeData, index, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *DM_get_face_data(DerivedMesh *dm, int index, int type)
|
|
|
|
{
|
|
|
|
return CustomData_get(&dm->faceData, index, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *DM_get_vert_data_layer(DerivedMesh *dm, int type)
|
|
|
|
{
|
|
|
|
return CustomData_get_layer(&dm->vertData, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *DM_get_edge_data_layer(DerivedMesh *dm, int type)
|
|
|
|
{
|
|
|
|
return CustomData_get_layer(&dm->edgeData, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *DM_get_face_data_layer(DerivedMesh *dm, int type)
|
|
|
|
{
|
|
|
|
return CustomData_get_layer(&dm->faceData, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_set_vert_data(DerivedMesh *dm, int index, int type, void *data)
|
|
|
|
{
|
|
|
|
CustomData_set(&dm->vertData, index, type, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_set_edge_data(DerivedMesh *dm, int index, int type, void *data)
|
|
|
|
{
|
|
|
|
CustomData_set(&dm->edgeData, index, type, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_set_face_data(DerivedMesh *dm, int index, int type, void *data)
|
|
|
|
{
|
|
|
|
CustomData_set(&dm->faceData, index, type, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_copy_vert_data(DerivedMesh *source, DerivedMesh *dest,
|
|
|
|
int source_index, int dest_index, int count)
|
|
|
|
{
|
|
|
|
CustomData_copy_data(&source->vertData, &dest->vertData,
|
|
|
|
source_index, dest_index,
|
|
|
|
count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_copy_edge_data(DerivedMesh *source, DerivedMesh *dest,
|
|
|
|
int source_index, int dest_index, int count)
|
|
|
|
{
|
|
|
|
CustomData_copy_data(&source->edgeData, &dest->edgeData,
|
|
|
|
source_index, dest_index,
|
|
|
|
count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_copy_face_data(DerivedMesh *source, DerivedMesh *dest,
|
|
|
|
int source_index, int dest_index, int count)
|
|
|
|
{
|
|
|
|
CustomData_copy_data(&source->faceData, &dest->faceData,
|
|
|
|
source_index, dest_index,
|
|
|
|
count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_free_vert_data(struct DerivedMesh *dm, int index, int count)
|
|
|
|
{
|
|
|
|
CustomData_free_elem(&dm->vertData, index, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_free_edge_data(struct DerivedMesh *dm, int index, int count)
|
|
|
|
{
|
|
|
|
CustomData_free_elem(&dm->edgeData, index, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_free_face_data(struct DerivedMesh *dm, int index, int count)
|
|
|
|
{
|
|
|
|
CustomData_free_elem(&dm->faceData, index, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_interp_vert_data(DerivedMesh *source, DerivedMesh *dest,
|
|
|
|
int *src_indices, float *weights,
|
|
|
|
int count, int dest_index)
|
|
|
|
{
|
|
|
|
CustomData_interp(&source->vertData, &dest->vertData, src_indices,
|
|
|
|
weights, NULL, count, dest_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DM_interp_edge_data(DerivedMesh *source, DerivedMesh *dest,
|
|
|
|
int *src_indices,
|
|
|
|
float *weights, EdgeVertWeight *vert_weights,
|
|
|
|
int count, int dest_index)
|
|
|
|
{
|
|
|
|
CustomData_interp(&source->edgeData, &dest->edgeData, src_indices,
|
2006-11-11 16:38:37 +00:00
|
|
|
weights, (float*)vert_weights, count, dest_index);
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DM_interp_face_data(DerivedMesh *source, DerivedMesh *dest,
|
|
|
|
int *src_indices,
|
|
|
|
float *weights, FaceVertWeight *vert_weights,
|
|
|
|
int count, int dest_index)
|
|
|
|
{
|
|
|
|
CustomData_interp(&source->faceData, &dest->faceData, src_indices,
|
2006-11-11 16:38:37 +00:00
|
|
|
weights, (float*)vert_weights, count, dest_index);
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
2005-03-27 20:34:18 +00:00
|
|
|
|
|
|
|
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-08-23 21:04:17 +00:00
|
|
|
MCol *wpaintMCol;
|
2005-07-17 20:12:16 +00:00
|
|
|
|
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-08-23 20:04:10 +00:00
|
|
|
int i;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
|
|
|
glBegin(GL_POINTS);
|
2005-08-23 20:04:10 +00:00
|
|
|
for(i=0; i<me->totvert; i++) {
|
|
|
|
glVertex3fv(mdm->verts[i].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++) {
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
TFace *tf = &me->tface[i];
|
2005-08-18 11:31:20 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
if (!(tf->flag&TF_HIDE)) {
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
glVertex2fv(tf->uv[1]);
|
2005-08-18 11:31:20 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glVertex2fv(tf->uv[1]);
|
|
|
|
glVertex2fv(tf->uv[2]);
|
2005-08-18 11:31:20 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
if (!me->mface[i].v4) {
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
} else {
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[3]);
|
2005-08-18 11:31:20 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glVertex2fv(tf->uv[3]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
2005-08-18 11:31:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
MEdge *medge= me->medge;
|
2005-08-23 20:04:10 +00:00
|
|
|
int i;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glBegin(GL_LINES);
|
2005-08-23 20:04:10 +00:00
|
|
|
for(i=0; i<me->totedge; i++, medge++) {
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
if ((medge->flag&ME_EDGEDRAW) && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
|
2005-08-23 20:04:10 +00:00
|
|
|
glVertex3fv(mdm->verts[medge->v1].co);
|
|
|
|
glVertex3fv(mdm->verts[medge->v2].co);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glEnd();
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
2005-08-21 20:48:45 +00:00
|
|
|
static void meshDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
|
|
|
Mesh *me= mdm->me;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (i=0; i<me->totedge; i++) {
|
|
|
|
if (!setDrawOptions || setDrawOptions(userData, i)) {
|
|
|
|
glVertex3fv(mdm->verts[me->medge[i].v1].co);
|
|
|
|
glVertex3fv(mdm->verts[me->medge[i].v2].co);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
static void meshDM_drawLooseEdges(DerivedMesh *dm)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
2005-08-18 11:31:20 +00:00
|
|
|
Mesh *me= mdm->me;
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
MEdge *medge= me->medge;
|
2005-08-23 20:04:10 +00:00
|
|
|
int i;
|
2005-08-18 11:31:20 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glBegin(GL_LINES);
|
2005-08-23 20:04:10 +00:00
|
|
|
for (i=0; i<me->totedge; i++, medge++) {
|
2005-08-21 20:48:45 +00:00
|
|
|
if (medge->flag&ME_LOOSEEDGE) {
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glVertex3fv(mdm->verts[medge->v1].co);
|
|
|
|
glVertex3fv(mdm->verts[medge->v2].co);
|
2005-08-14 10:35:58 +00:00
|
|
|
}
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +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) {
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
int new_glmode, new_matnr, new_shademodel;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES;
|
|
|
|
new_matnr = mface->mat_nr+1;
|
2005-11-03 18:58:35 +00:00
|
|
|
new_shademodel = (mface->flag & ME_SMOOTH)?GL_SMOOTH:GL_FLAT;
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
|
|
|
|
if (new_glmode!=glmode || new_matnr!=matnr || new_shademodel!=shademodel) {
|
|
|
|
glEnd();
|
2005-03-27 20:34:18 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
drawCurrentMat = setMaterial(matnr=new_matnr);
|
2005-03-27 20:34:18 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glShadeModel(shademodel=new_shademodel);
|
|
|
|
glBegin(glmode=new_glmode);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drawCurrentMat) {
|
|
|
|
if(shademodel==GL_FLAT)
|
|
|
|
glNormal3fv(nors);
|
|
|
|
|
|
|
|
PASSVERT(mface->v1);
|
|
|
|
PASSVERT(mface->v2);
|
|
|
|
PASSVERT(mface->v3);
|
|
|
|
if (mface->v4) {
|
|
|
|
PASSVERT(mface->v4);
|
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) {
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
int new_glmode= mface->v4?GL_QUADS:GL_TRIANGLES;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
if (new_glmode!=glmode) {
|
|
|
|
glEnd();
|
|
|
|
glBegin(glmode= new_glmode);
|
|
|
|
}
|
|
|
|
|
|
|
|
glColor3ub(cp1[3], cp1[2], cp1[1]);
|
|
|
|
glVertex3fv( mdm->verts[mface->v1].co );
|
|
|
|
glColor3ub(cp1[7], cp1[6], cp1[5]);
|
|
|
|
glVertex3fv( mdm->verts[mface->v2].co );
|
|
|
|
glColor3ub(cp1[11], cp1[10], cp1[9]);
|
|
|
|
glVertex3fv( mdm->verts[mface->v3].co );
|
|
|
|
if(mface->v4) {
|
|
|
|
glColor3ub(cp1[15], cp1[14], cp1[13]);
|
|
|
|
glVertex3fv( mdm->verts[mface->v4].co );
|
|
|
|
}
|
|
|
|
|
|
|
|
if(useTwoSide) {
|
|
|
|
glColor3ub(cp2[11], cp2[10], cp2[9]);
|
2005-07-17 20:12:16 +00:00
|
|
|
glVertex3fv( mdm->verts[mface->v3].co );
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glColor3ub(cp2[7], cp2[6], cp2[5]);
|
|
|
|
glVertex3fv( mdm->verts[mface->v2].co );
|
|
|
|
glColor3ub(cp2[3], cp2[2], cp2[1]);
|
|
|
|
glVertex3fv( mdm->verts[mface->v1].co );
|
2005-03-29 07:58:56 +00:00
|
|
|
if(mface->v4) {
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
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);
|
|
|
|
}
|
2006-03-11 16:13:10 +00:00
|
|
|
|
|
|
|
static void meshDM_drawFacesTex_common(DerivedMesh *dm, int (*drawParams)(TFace *tface, int matnr), int (*drawParamsMapped)(void *userData, int index), void *userData)
|
2005-03-29 07:51:00 +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-29 07:51:00 +00:00
|
|
|
MFace *mface= me->mface;
|
|
|
|
TFace *tface = me->tface;
|
|
|
|
float *nors = mdm->nors;
|
2005-08-23 20:04:10 +00:00
|
|
|
int i;
|
2005-03-29 07:51:00 +00:00
|
|
|
|
2005-08-23 20:04:10 +00:00
|
|
|
for (i=0; i<me->totface; i++) {
|
|
|
|
MFace *mf= &mface[i];
|
|
|
|
TFace *tf = tface?&tface[i]:NULL;
|
2005-08-18 11:31:20 +00:00
|
|
|
int flag;
|
2005-03-29 07:51:00 +00:00
|
|
|
unsigned char *cp= NULL;
|
|
|
|
|
2006-03-11 16:13:10 +00:00
|
|
|
if (drawParams)
|
|
|
|
flag = drawParams(tf, mf->mat_nr);
|
|
|
|
else
|
|
|
|
flag = drawParamsMapped(userData, i);
|
2005-08-18 11:31:20 +00:00
|
|
|
|
|
|
|
if (flag==0) {
|
|
|
|
continue;
|
|
|
|
} else if (flag==1) {
|
2005-08-23 21:04:17 +00:00
|
|
|
if (mdm->wpaintMCol) {
|
|
|
|
cp= (unsigned char*) &mdm->wpaintMCol[i*4];
|
|
|
|
} else 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-23 20:04:10 +00:00
|
|
|
cp= (unsigned char*) &me->mcol[i*4];
|
2005-03-29 07:51:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(mf->flag&ME_SMOOTH)) {
|
2005-08-23 20:04:10 +00:00
|
|
|
glNormal3fv(&nors[i*3]);
|
2005-03-29 07:51:00 +00:00
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2006-03-11 16:13:10 +00:00
|
|
|
static void meshDM_drawFacesTex(DerivedMesh *dm, int (*setDrawParams)(TFace *tface, int matnr))
|
|
|
|
{
|
|
|
|
meshDM_drawFacesTex_common(dm, setDrawParams, NULL, NULL);
|
|
|
|
}
|
|
|
|
static void meshDM_drawMappedFacesTex(DerivedMesh *dm, int (*setDrawParams)(void *userData, int index), void *userData)
|
|
|
|
{
|
|
|
|
meshDM_drawFacesTex_common(dm, NULL, setDrawParams, userData);
|
|
|
|
}
|
|
|
|
|
2005-08-23 20:04:10 +00:00
|
|
|
static void meshDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors)
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
|
|
|
Mesh *me = mdm->me;
|
|
|
|
MVert *mvert= mdm->verts;
|
|
|
|
MFace *mface= me->mface;
|
|
|
|
float *nors= mdm->nors;
|
2005-08-23 20:04:10 +00:00
|
|
|
int i;
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
|
2005-08-23 20:04:10 +00:00
|
|
|
for (i=0; i<me->totface; i++) {
|
|
|
|
MFace *mf= &mface[i];
|
2006-08-28 01:12:36 +00:00
|
|
|
int drawSmooth = (mf->flag & ME_SMOOTH);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
|
2005-08-23 20:04:10 +00:00
|
|
|
if (!setDrawOptions || setDrawOptions(userData, i, &drawSmooth)) {
|
|
|
|
unsigned char *cp = NULL;
|
|
|
|
|
|
|
|
if (useColors) {
|
2005-08-23 21:04:17 +00:00
|
|
|
if (mdm->wpaintMCol) {
|
|
|
|
cp= (unsigned char*) &mdm->wpaintMCol[i*4];
|
|
|
|
} else if (me->tface) {
|
2005-08-23 20:04:10 +00:00
|
|
|
cp= (unsigned char*) me->tface[i].col;
|
|
|
|
} else if (me->mcol) {
|
|
|
|
cp= (unsigned char*) &me->mcol[i*4];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-20 18:14:04 +00:00
|
|
|
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
|
|
|
|
glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
|
2005-08-20 18:14:04 +00:00
|
|
|
if (!drawSmooth) {
|
2005-08-23 20:04:10 +00:00
|
|
|
glNormal3fv(&nors[i*3]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glVertex3fv(mvert[mf->v1].co);
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glVertex3fv(mvert[mf->v2].co);
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glVertex3fv(mvert[mf->v3].co);
|
2005-08-23 20:04:10 +00:00
|
|
|
if(mf->v4) {
|
|
|
|
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
|
|
|
|
glVertex3fv(mvert[mf->v4].co);
|
|
|
|
}
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
} else {
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glNormal3sv(mvert[mf->v1].no);
|
|
|
|
glVertex3fv(mvert[mf->v1].co);
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glNormal3sv(mvert[mf->v2].no);
|
|
|
|
glVertex3fv(mvert[mf->v2].co);
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glNormal3sv(mvert[mf->v3].no);
|
|
|
|
glVertex3fv(mvert[mf->v3].co);
|
|
|
|
if(mf->v4) {
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glNormal3sv(mvert[mf->v4].no);
|
|
|
|
glVertex3fv(mvert[mf->v4].co);
|
|
|
|
}
|
|
|
|
}
|
2005-08-20 18:14:04 +00:00
|
|
|
|
|
|
|
glEnd();
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
static int meshDM_getNumEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
|
|
|
Mesh *me = mdm->me;
|
|
|
|
|
|
|
|
return me->totedge;
|
|
|
|
}
|
|
|
|
|
2005-03-27 21:27:12 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
void meshDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
|
|
|
|
{
|
|
|
|
MVert *verts = ((MeshDerivedMesh *)dm)->verts;
|
|
|
|
|
|
|
|
*vert_r = verts[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void meshDM_getEdge(DerivedMesh *dm, int index, MEdge *edge_r)
|
|
|
|
{
|
|
|
|
Mesh *me = ((MeshDerivedMesh *)dm)->me;
|
|
|
|
|
|
|
|
*edge_r = me->medge[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void meshDM_getFace(DerivedMesh *dm, int index, MFace *face_r)
|
|
|
|
{
|
|
|
|
Mesh *me = ((MeshDerivedMesh *)dm)->me;
|
|
|
|
|
|
|
|
*face_r = me->mface[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void meshDM_getVertArray(DerivedMesh *dm, MVert *vert_r)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh *)dm;
|
|
|
|
memcpy(vert_r, mdm->verts, sizeof(*vert_r) * mdm->me->totvert);
|
|
|
|
}
|
|
|
|
|
|
|
|
void meshDM_getEdgeArray(DerivedMesh *dm, MEdge *edge_r)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh *)dm;
|
|
|
|
memcpy(edge_r, mdm->me->medge, sizeof(*edge_r) * mdm->me->totedge);
|
|
|
|
}
|
|
|
|
|
|
|
|
void meshDM_getFaceArray(DerivedMesh *dm, MFace *face_r)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh *)dm;
|
|
|
|
memcpy(face_r, mdm->me->mface, sizeof(*face_r) * mdm->me->totface);
|
|
|
|
}
|
|
|
|
|
2005-07-17 17:41:03 +00:00
|
|
|
static void meshDM_release(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
DM_release(dm);
|
|
|
|
|
2005-08-23 21:04:17 +00:00
|
|
|
if (mdm->wpaintMCol) MEM_freeN(mdm->wpaintMCol);
|
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
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
DM_init(&mdm->dm, me->totvert, me->totedge, me->totface);
|
|
|
|
|
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;
|
2006-08-28 01:12:36 +00:00
|
|
|
mdm->dm.getNumEdges = meshDM_getNumEdges;
|
2005-03-27 21:27:12 +00:00
|
|
|
mdm->dm.getNumFaces = meshDM_getNumFaces;
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
mdm->dm.getVert = meshDM_getVert;
|
|
|
|
mdm->dm.getEdge = meshDM_getEdge;
|
|
|
|
mdm->dm.getFace = meshDM_getFace;
|
|
|
|
mdm->dm.getVertArray = meshDM_getVertArray;
|
|
|
|
mdm->dm.getEdgeArray = meshDM_getEdgeArray;
|
|
|
|
mdm->dm.getFaceArray = meshDM_getFaceArray;
|
|
|
|
|
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-21 20:48:45 +00:00
|
|
|
mdm->dm.drawLooseEdges = meshDM_drawLooseEdges;
|
2005-08-18 11:31:20 +00:00
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
mdm->dm.drawFacesSolid = meshDM_drawFacesSolid;
|
|
|
|
mdm->dm.drawFacesColored = meshDM_drawFacesColored;
|
2006-03-11 16:13:10 +00:00
|
|
|
mdm->dm.drawFacesTex = meshDM_drawFacesTex;
|
2005-09-18 13:27:12 +00:00
|
|
|
mdm->dm.drawMappedFaces = meshDM_drawMappedFaces;
|
2006-03-11 16:13:10 +00:00
|
|
|
mdm->dm.drawMappedFacesTex = meshDM_drawMappedFacesTex;
|
2005-08-21 20:48:45 +00:00
|
|
|
|
|
|
|
mdm->dm.drawMappedEdges = meshDM_drawMappedEdges;
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
mdm->dm.drawMappedFaces = meshDM_drawMappedFaces;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
2005-07-17 17:41:03 +00:00
|
|
|
mdm->dm.release = meshDM_release;
|
2005-08-23 21:04:17 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
/* add appropriate data layers (don't copy, just reference) */
|
|
|
|
if(me->msticky)
|
|
|
|
DM_add_vert_layer(&mdm->dm, LAYERTYPE_MSTICKY,
|
|
|
|
LAYERFLAG_NOFREE, me->msticky);
|
|
|
|
if(me->dvert)
|
|
|
|
DM_add_vert_layer(&mdm->dm, LAYERTYPE_MDEFORMVERT,
|
|
|
|
LAYERFLAG_NOFREE, me->dvert);
|
|
|
|
|
|
|
|
if(me->tface)
|
|
|
|
DM_add_face_layer(&mdm->dm, LAYERTYPE_TFACE,
|
|
|
|
LAYERFLAG_NOFREE, me->tface);
|
|
|
|
if(me->mcol)
|
|
|
|
DM_add_face_layer(&mdm->dm, LAYERTYPE_MCOL,
|
|
|
|
LAYERFLAG_NOFREE, me->mcol);
|
|
|
|
|
2005-08-23 21:04:17 +00:00
|
|
|
/* Works in conjunction with hack during modifier calc */
|
2005-09-24 13:55:39 +00:00
|
|
|
if ((G.f & G_WEIGHTPAINT) && ob==(G.scene->basact?G.scene->basact->object:NULL)) {
|
2005-08-23 21:04:17 +00:00
|
|
|
mdm->wpaintMCol = MEM_dupallocN(me->mcol);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
if((ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) &&
|
|
|
|
(ob->fluidsimSettings->type & OB_FLUIDSIM_DOMAIN)&&
|
|
|
|
(ob->fluidsimSettings->meshSurface) &&
|
- bugfixes
#4742 exported normals are now correct
#4821 & 4956 for complex movements in/outflows can now also
use the animated mesh option
- new features
* isosurface subdivision: directly
creates a finer surface mesh from the simulation data.
this increases simulation time and harddisk usage, though, so
be careful - usually values of 2-4 should be enough.
* fluidsim particles: extended model for particle
simulation and generation. When isosurface subdivision is enabled,
the particles are now included in the surface generation,
giving a better impression of a single connected surface.
Note - the particles are only included in the final surface
mesh, so the preview surface shows none of the particle
effects.
* particle loading: different types of particles can now be selected for
display: drops, floats and tracers. This is a bit obsolete
due to the extensions mentioned above, but might still be useful.
Floats are just particles floating on the fluid surface, could
be used for e.g. foam.
* moving objects impact factor: this is another tweaking option,
as the handling of moving objects is still not conserving
mass. setting this to zero simply deletes the fluid, 1 is
the default, while larger values cause a stronger
impact. For tweaking the simulation: if fluid disappears, try
increasing this value, and if too much is appearing reduce it.
You can even use negative values for some strange results :)
- more code cleanup, e.g. removed config file writing in fluidsim.c,
added additional safety checks for particles & fluidsim domains (these
currently dont work together). I also removed the "build particles"
debug message in effects.c (seemed to be unnecessary?).
Some more info on the new features:
Here are two test animations showing the difference between
using the particle generation with isosurface subdivision.
This is how it would look with the old solver version:
http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_fl6manc4_1noparts.mpg
and this with the new one:
http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_fl6manc4_2wparts.mpg
Both simulations use a resolution of 64, however, the version with particles
takes significantly longer (almost twice as long).
The .blend file for a similar setup can be found here:
http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_testmanc4.blend
(Minor Tips for this file: dont enable subdivions of characters until rendering,
thus leave off for simulation, as it uses the rendering settings! For making
nice pictures switch on subdivion, and OSA.)
And here's a picture of old vs. new (for webpage or so):
http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_manc4compare.png
2006-11-05 16:30:29 +00:00
|
|
|
(1) && (!give_parteff(ob)) && // doesnt work together with particle systems!
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
(me->totvert == ((Mesh *)(ob->fluidsimSettings->meshSurface))->totvert) ) {
|
|
|
|
// dont recompute for fluidsim mesh, use from readBobjgz
|
|
|
|
// TODO? check for modifiers!?
|
2005-07-18 19:58:23 +00:00
|
|
|
int i;
|
2005-07-17 20:12:16 +00:00
|
|
|
mesh_calc_normals(mdm->verts, me->totvert, me->mface, me->totface, &mdm->nors);
|
|
|
|
mdm->freeNors = 1;
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
for (i=0; i<me->totvert; i++) {
|
|
|
|
MVert *mv= &mdm->verts[i];
|
|
|
|
MVert *fsv;
|
|
|
|
fsv = &ob->fluidsimSettings->meshSurfNormals[i];
|
|
|
|
VECCOPY(mv->no, fsv->no);
|
|
|
|
//mv->no[0]= 30000; mv->no[1]= mv->no[2]= 0; // DEBUG fixed test normals
|
|
|
|
}
|
2005-07-17 20:12:16 +00:00
|
|
|
} else {
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
// recompute normally
|
|
|
|
|
|
|
|
if (vertCos) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* copy the original verts to preserve flag settings; if this is too
|
|
|
|
* costly, must at least use MEM_callocN to clear flags */
|
|
|
|
mdm->verts = MEM_dupallocN( me->mvert );
|
|
|
|
for (i=0; i<me->totvert; i++) {
|
|
|
|
VECCOPY(mdm->verts[i].co, vertCos[i]);
|
|
|
|
}
|
|
|
|
mesh_calc_normals(mdm->verts, me->totvert, me->mface, me->totface, &mdm->nors);
|
|
|
|
mdm->freeNors = 1;
|
|
|
|
mdm->freeVerts = 1;
|
|
|
|
} 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.
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
mesh_calc_normals(mdm->verts, me->totvert, me->mface, me->totface, &mdm->nors);
|
|
|
|
mdm->freeNors = 1;
|
|
|
|
}
|
|
|
|
} // fs TEST
|
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;
|
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
static void emDM_foreachMappedVert(DerivedMesh *dm, void (*func)(void *userData, int index, 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;
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
int i;
|
2005-08-03 04:04:05 +00:00
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
for (i=0,eve= emdm->em->verts.first; eve; i++,eve=eve->next) {
|
|
|
|
if (emdm->vertexCos) {
|
|
|
|
func(userData, i, emdm->vertexCos[i], emdm->vertexNos[i], NULL);
|
|
|
|
} else {
|
|
|
|
func(userData, i, eve->co, eve->no, NULL);
|
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
|
|
|
}
|
2005-08-03 04:04:05 +00:00
|
|
|
}
|
2005-03-28 07:10:32 +00:00
|
|
|
}
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
static void emDM_foreachMappedEdge(DerivedMesh *dm, void (*func)(void *userData, int index, 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;
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
int i;
|
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
|
|
|
|
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++;
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
for(i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next)
|
|
|
|
func(userData, i, emdm->vertexCos[(int) eed->v1->prev], emdm->vertexCos[(int) eed->v2->prev]);
|
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 (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 {
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
for(i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next)
|
|
|
|
func(userData, i, eed->v1->co, eed->v2->co);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
static void emDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditEdge *eed;
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
int i;
|
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;
|
|
|
|
|
|
|
|
for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
|
|
|
|
eve->prev = (EditVert*) i++;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
for(i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, 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
|
|
|
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);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
for(i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, 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
|
|
|
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
|
|
|
{
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
emDM_drawMappedEdges(dm, NULL, NULL);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
static void emDM_drawMappedEdgesInterp(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void (*setDrawInterpOptions)(void *userData, int index, float t), void *userData)
|
2005-03-28 06:46:21 +00:00
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditEdge *eed;
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
int i;
|
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
|
|
|
if (emdm->vertexCos) {
|
|
|
|
EditVert *eve, *preveve;
|
|
|
|
|
|
|
|
for (i=0,eve=emdm->em->verts.first; eve; eve= eve->next)
|
|
|
|
eve->prev = (EditVert*) i++;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
for (i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, i)) {
|
|
|
|
setDrawInterpOptions(userData, i, 0.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
|
|
|
glVertex3fv(emdm->vertexCos[(int) eed->v1->prev]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
setDrawInterpOptions(userData, i, 1.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
|
|
|
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);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
for (i=0,eed= emdm->em->edges.first; eed; i++,eed= eed->next) {
|
|
|
|
if(!setDrawOptions || setDrawOptions(userData, i)) {
|
|
|
|
setDrawInterpOptions(userData, i, 0.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
|
|
|
glVertex3fv(eed->v1->co);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
setDrawInterpOptions(userData, i, 1.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
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2006-10-26 23:34:44 +00:00
|
|
|
|
|
|
|
static void emDM_drawUVEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
EditFace *efa;
|
2006-11-11 16:38:37 +00:00
|
|
|
TFace *tf;
|
2006-10-26 23:34:44 +00:00
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for(efa= emdm->em->faces.first; efa; efa= efa->next) {
|
2006-11-11 16:38:37 +00:00
|
|
|
tf = CustomData_em_get(&emdm->em->fdata, efa->data, LAYERTYPE_TFACE);
|
2006-10-26 23:34:44 +00:00
|
|
|
|
2006-11-11 16:38:37 +00:00
|
|
|
if(tf && !(tf->flag&TF_HIDE)) {
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
glVertex2fv(tf->uv[1]);
|
|
|
|
|
|
|
|
glVertex2fv(tf->uv[1]);
|
|
|
|
glVertex2fv(tf->uv[2]);
|
2006-10-26 23:34:44 +00:00
|
|
|
|
|
|
|
if (!efa->v4) {
|
2006-11-11 16:38:37 +00:00
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
2006-10-26 23:34:44 +00:00
|
|
|
} else {
|
2006-11-11 16:38:37 +00:00
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[3]);
|
|
|
|
glVertex2fv(tf->uv[3]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
2006-10-26 23:34:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
static void emDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *userData, int index, 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];
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
int i;
|
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++;
|
|
|
|
}
|
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
for(i=0,efa= emdm->em->faces.first; efa; i++,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);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
func(userData, i, 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;
|
|
|
|
}
|
|
|
|
}
|
2005-08-23 20:04:10 +00:00
|
|
|
static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors)
|
2005-03-28 05:58:43 +00:00
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
2005-03-28 06:46:21 +00:00
|
|
|
EditFace *efa;
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
int i;
|
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;
|
|
|
|
|
|
|
|
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) {
|
2006-08-28 01:12:36 +00:00
|
|
|
int drawSmooth = (efa->flag & ME_SMOOTH);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
if(!setDrawOptions || setDrawOptions(userData, i, &drawSmooth)) {
|
|
|
|
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
|
- 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-13 20:16:35 +00:00
|
|
|
glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
|
2005-08-20 18:49:08 +00:00
|
|
|
if (!drawSmooth) {
|
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
|
|
|
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]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
} else {
|
|
|
|
glNormal3fv(emdm->vertexNos[(int) efa->v1->prev]);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) efa->v1->prev]);
|
|
|
|
glNormal3fv(emdm->vertexNos[(int) efa->v2->prev]);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) efa->v2->prev]);
|
|
|
|
glNormal3fv(emdm->vertexNos[(int) efa->v3->prev]);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) efa->v3->prev]);
|
|
|
|
if(efa->v4) {
|
|
|
|
glNormal3fv(emdm->vertexNos[(int) efa->v4->prev]);
|
|
|
|
glVertex3fv(emdm->vertexCos[(int) efa->v4->prev]);
|
|
|
|
}
|
- 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
|
|
|
}
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glEnd();
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 07:37:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (preveve=NULL, eve=emdm->em->verts.first; eve; preveve=eve, eve= eve->next)
|
|
|
|
eve->prev = preveve;
|
|
|
|
} else {
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
for (i=0,efa= emdm->em->faces.first; efa; i++,efa= efa->next) {
|
2006-08-28 01:12:36 +00:00
|
|
|
int drawSmooth = (efa->flag & ME_SMOOTH);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
if(!setDrawOptions || setDrawOptions(userData, i, &drawSmooth)) {
|
|
|
|
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
|
|
|
|
|
|
|
|
glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
|
2005-08-20 18:49:08 +00:00
|
|
|
if (!drawSmooth) {
|
- 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
|
|
|
glNormal3fv(efa->n);
|
|
|
|
glVertex3fv(efa->v1->co);
|
|
|
|
glVertex3fv(efa->v2->co);
|
|
|
|
glVertex3fv(efa->v3->co);
|
|
|
|
if(efa->v4) glVertex3fv(efa->v4->co);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
} else {
|
|
|
|
glNormal3fv(efa->v1->no);
|
|
|
|
glVertex3fv(efa->v1->co);
|
|
|
|
glNormal3fv(efa->v2->no);
|
|
|
|
glVertex3fv(efa->v2->co);
|
|
|
|
glNormal3fv(efa->v3->no);
|
|
|
|
glVertex3fv(efa->v3->co);
|
|
|
|
if(efa->v4) {
|
|
|
|
glNormal3fv(efa->v4->no);
|
|
|
|
glVertex3fv(efa->v4->co);
|
|
|
|
}
|
- 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
|
|
|
}
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glEnd();
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 07:37:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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);
|
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
static int emDM_getNumEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
|
|
|
|
return BLI_countlist(&emdm->em->edges);
|
|
|
|
}
|
|
|
|
|
2005-03-27 21:27:12 +00:00
|
|
|
static int emDM_getNumFaces(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
|
|
|
|
|
|
|
|
return BLI_countlist(&emdm->em->faces);
|
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
void emDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
|
|
|
|
{
|
|
|
|
EditVert *ev = ((EditMeshDerivedMesh *)dm)->em->verts.first;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < index; ++i) ev = ev->next;
|
|
|
|
|
|
|
|
VECCOPY(vert_r->co, ev->co);
|
|
|
|
|
|
|
|
vert_r->no[0] = ev->no[0] * 32767.0;
|
|
|
|
vert_r->no[1] = ev->no[1] * 32767.0;
|
|
|
|
vert_r->no[2] = ev->no[2] * 32767.0;
|
|
|
|
|
|
|
|
/* TODO what to do with vert_r->flag and vert_r->mat_nr? */
|
|
|
|
vert_r->mat_nr = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void emDM_getEdge(DerivedMesh *dm, int index, MEdge *edge_r)
|
|
|
|
{
|
|
|
|
EditMesh *em = ((EditMeshDerivedMesh *)dm)->em;
|
|
|
|
EditEdge *ee = em->edges.first;
|
|
|
|
EditVert *ev, *v1, *v2;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < index; ++i) ee = ee->next;
|
|
|
|
|
|
|
|
edge_r->crease = (unsigned char) (ee->crease*255.0f);
|
|
|
|
/* TODO what to do with edge_r->flag? */
|
|
|
|
edge_r->flag = ME_EDGEDRAW|ME_EDGERENDER;
|
|
|
|
if (ee->seam) edge_r->flag |= ME_SEAM;
|
|
|
|
if (ee->sharp) edge_r->flag |= ME_SHARP;
|
|
|
|
#if 0
|
|
|
|
/* this needs setup of f2 field */
|
|
|
|
if (!ee->f2) edge_r->flag |= ME_LOOSEEDGE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* goddamn, we have to search all verts to find indices */
|
|
|
|
v1 = ee->v1;
|
|
|
|
v2 = ee->v2;
|
|
|
|
for(i = 0, ev = em->verts.first; v1 || v2; i++, ev = ev->next) {
|
|
|
|
if(ev == v1) {
|
|
|
|
edge_r->v1 = i;
|
|
|
|
v1 = NULL;
|
|
|
|
}
|
|
|
|
if(ev == v2) {
|
|
|
|
edge_r->v2 = i;
|
|
|
|
v2 = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void emDM_getFace(DerivedMesh *dm, int index, MFace *face_r)
|
|
|
|
{
|
|
|
|
EditMesh *em = ((EditMeshDerivedMesh *)dm)->em;
|
|
|
|
EditFace *ef = em->faces.first;
|
|
|
|
EditVert *ev, *v1, *v2, *v3, *v4;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < index; ++i) ef = ef->next;
|
|
|
|
|
|
|
|
face_r->mat_nr = ef->mat_nr;
|
|
|
|
face_r->flag = ef->flag;
|
|
|
|
|
|
|
|
/* goddamn, we have to search all verts to find indices */
|
|
|
|
v1 = ef->v1;
|
|
|
|
v2 = ef->v2;
|
|
|
|
v3 = ef->v3;
|
|
|
|
v4 = ef->v4;
|
|
|
|
if(!v4) face_r->v4 = 0;
|
|
|
|
|
|
|
|
for(i = 0, ev = em->verts.first; v1 || v2 || v3 || v4;
|
|
|
|
i++, ev = ev->next) {
|
|
|
|
if(ev == v1) {
|
|
|
|
face_r->v1 = i;
|
|
|
|
v1 = NULL;
|
|
|
|
}
|
|
|
|
if(ev == v2) {
|
|
|
|
face_r->v2 = i;
|
|
|
|
v2 = NULL;
|
|
|
|
}
|
|
|
|
if(ev == v3) {
|
|
|
|
face_r->v3 = i;
|
|
|
|
v3 = NULL;
|
|
|
|
}
|
|
|
|
if(ev == v4) {
|
|
|
|
face_r->v4 = i;
|
|
|
|
v4 = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test_index_face(face_r, NULL, NULL, ef->v4?4:3);
|
|
|
|
}
|
|
|
|
|
|
|
|
void emDM_getVertArray(DerivedMesh *dm, MVert *vert_r)
|
|
|
|
{
|
|
|
|
EditVert *ev = ((EditMeshDerivedMesh *)dm)->em->verts.first;
|
|
|
|
|
|
|
|
for( ; ev; ev = ev->next, ++vert_r) {
|
|
|
|
VECCOPY(vert_r->co, ev->co);
|
|
|
|
|
|
|
|
vert_r->no[0] = ev->no[0] * 32767.0;
|
|
|
|
vert_r->no[1] = ev->no[1] * 32767.0;
|
|
|
|
vert_r->no[2] = ev->no[2] * 32767.0;
|
|
|
|
|
|
|
|
/* TODO what to do with vert_r->flag and vert_r->mat_nr? */
|
|
|
|
vert_r->mat_nr = 0;
|
|
|
|
vert_r->flag = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void emDM_getEdgeArray(DerivedMesh *dm, MEdge *edge_r)
|
|
|
|
{
|
|
|
|
EditMesh *em = ((EditMeshDerivedMesh *)dm)->em;
|
|
|
|
EditEdge *ee = em->edges.first;
|
|
|
|
EditVert *ev, *prevev;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* store vert indices in the prev pointer (kind of hacky) */
|
|
|
|
for(ev = em->verts.first, i = 0; ev; ev = ev->next, ++i)
|
|
|
|
ev->prev = (EditVert*) i++;
|
|
|
|
|
|
|
|
for( ; ee; ee = ee->next, ++edge_r) {
|
|
|
|
edge_r->crease = (unsigned char) (ee->crease*255.0f);
|
|
|
|
/* TODO what to do with edge_r->flag? */
|
|
|
|
edge_r->flag = ME_EDGEDRAW|ME_EDGERENDER;
|
|
|
|
if (ee->seam) edge_r->flag |= ME_SEAM;
|
|
|
|
if (ee->sharp) edge_r->flag |= ME_SHARP;
|
|
|
|
#if 0
|
|
|
|
/* this needs setup of f2 field */
|
|
|
|
if (!ee->f2) edge_r->flag |= ME_LOOSEEDGE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
edge_r->v1 = (int)ee->v1->prev;
|
|
|
|
edge_r->v2 = (int)ee->v2->prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* restore prev pointers */
|
|
|
|
for(prevev = NULL, ev = em->verts.first; ev; prevev = ev, ev = ev->next)
|
|
|
|
ev->prev = prevev;
|
|
|
|
}
|
|
|
|
|
|
|
|
void emDM_getFaceArray(DerivedMesh *dm, MFace *face_r)
|
|
|
|
{
|
|
|
|
EditMesh *em = ((EditMeshDerivedMesh *)dm)->em;
|
|
|
|
EditFace *ef = em->faces.first;
|
|
|
|
EditVert *ev, *prevev;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* store vert indices in the prev pointer (kind of hacky) */
|
|
|
|
for(ev = em->verts.first, i = 0; ev; ev = ev->next, ++i)
|
|
|
|
ev->prev = (EditVert*) i++;
|
|
|
|
|
|
|
|
for( ; ef; ef = ef->next, ++face_r) {
|
|
|
|
face_r->mat_nr = ef->mat_nr;
|
|
|
|
face_r->flag = ef->flag;
|
|
|
|
|
|
|
|
face_r->v1 = (int)ef->v1->prev;
|
|
|
|
face_r->v2 = (int)ef->v2->prev;
|
|
|
|
face_r->v3 = (int)ef->v3->prev;
|
|
|
|
if(ef->v4) face_r->v4 = (int)ef->v4->prev;
|
|
|
|
else face_r->v4 = 0;
|
|
|
|
|
|
|
|
test_index_face(face_r, NULL, NULL, ef->v4?4:3);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* restore prev pointers */
|
|
|
|
for(prevev = NULL, ev = em->verts.first; ev; prevev = ev, ev = ev->next)
|
|
|
|
ev->prev = prevev;
|
|
|
|
}
|
|
|
|
|
- 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;
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
DM_release(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);
|
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob,
|
|
|
|
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");
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
DM_init(&emdm->dm, BLI_countlist(&em->verts),
|
|
|
|
BLI_countlist(&em->edges), BLI_countlist(&em->faces));
|
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;
|
2006-08-28 01:12:36 +00:00
|
|
|
emdm->dm.getNumEdges = emDM_getNumEdges;
|
2005-03-27 21:27:12 +00:00
|
|
|
emdm->dm.getNumFaces = emDM_getNumFaces;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
emdm->dm.getVert = emDM_getVert;
|
|
|
|
emdm->dm.getEdge = emDM_getEdge;
|
|
|
|
emdm->dm.getFace = emDM_getFace;
|
|
|
|
emdm->dm.getVertArray = emDM_getVertArray;
|
|
|
|
emdm->dm.getEdgeArray = emDM_getEdgeArray;
|
|
|
|
emdm->dm.getFaceArray = emDM_getFaceArray;
|
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
emdm->dm.foreachMappedVert = emDM_foreachMappedVert;
|
|
|
|
emdm->dm.foreachMappedEdge = emDM_foreachMappedEdge;
|
|
|
|
emdm->dm.foreachMappedFaceCenter = emDM_foreachMappedFaceCenter;
|
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;
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
emdm->dm.drawMappedEdges = emDM_drawMappedEdges;
|
|
|
|
emdm->dm.drawMappedEdgesInterp = emDM_drawMappedEdgesInterp;
|
|
|
|
emdm->dm.drawMappedFaces = emDM_drawMappedFaces;
|
2006-10-26 23:34:44 +00:00
|
|
|
emdm->dm.drawUVEdges = emDM_drawUVEdges;
|
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
|
|
|
|
2006-11-11 23:23:15 +00:00
|
|
|
if(CustomData_has_layer(&em->vdata, LAYERTYPE_MDEFORMVERT)) {
|
2006-08-28 01:12:36 +00:00
|
|
|
EditVert *eve;
|
|
|
|
int i;
|
2006-11-11 23:23:15 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
DM_add_vert_layer(&emdm->dm, LAYERTYPE_MDEFORMVERT, 0, NULL);
|
|
|
|
|
2006-11-11 23:23:15 +00:00
|
|
|
for(eve = em->verts.first, i = 0; eve; eve = eve->next, ++i)
|
|
|
|
DM_set_vert_data(&emdm->dm, i, LAYERTYPE_MDEFORMVERT,
|
|
|
|
CustomData_em_get(&em->vdata, eve->data, LAYERTYPE_MDEFORMVERT));
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(vertexCos) {
|
2005-08-03 04:04:05 +00:00
|
|
|
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];
|
2006-08-28 01:12:36 +00:00
|
|
|
/* following Mesh convention; we use vertex coordinate itself
|
|
|
|
* for normal in this case */
|
2005-08-03 04:04:05 +00:00
|
|
|
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;
|
|
|
|
} SSDerivedMesh;
|
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
static void ssDM_foreachMappedVert(DerivedMesh *dm, void (*func)(void *userData, int index, 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;
|
2006-08-28 01:12:36 +00:00
|
|
|
int i;
|
|
|
|
int *index = dm->getVertDataArray(dm, LAYERTYPE_ORIGINDEX);
|
2005-08-07 05:42:03 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
for (i=0; i<dlm->totvert; i++, index++) {
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
MVert *mv = &dlm->mvert[i];
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(*index != ORIGINDEX_NONE)
|
|
|
|
func(userData, *index, mv->co, NULL, mv->no);
|
2005-08-07 05:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
static void ssDM_foreachMappedEdge(DerivedMesh *dm, void (*func)(void *userData, int index, float *v0co, float *v1co), void *userData)
|
2005-08-07 05:42:03 +00:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
2006-08-28 01:12:36 +00:00
|
|
|
int i;
|
|
|
|
int *index = dm->getEdgeDataArray(dm, LAYERTYPE_ORIGINDEX);
|
2005-08-07 05:42:03 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
for (i=0; i<dlm->totedge; i++, index++) {
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
MEdge *med = &dlm->medge[i];
|
2005-08-07 05:42:03 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(*index != ORIGINDEX_NONE)
|
|
|
|
func(userData, *index, dlm->mvert[med->v1].co,
|
|
|
|
dlm->mvert[med->v2].co);
|
2005-08-07 05:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
static void ssDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index), void *userData)
|
2005-08-07 05:42:03 +00:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
2006-08-28 01:12:36 +00:00
|
|
|
int i;
|
|
|
|
int *index = dm->getEdgeDataArray(dm, LAYERTYPE_ORIGINDEX);
|
2005-08-07 05:42:03 +00:00
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glBegin(GL_LINES);
|
2006-08-28 01:12:36 +00:00
|
|
|
for(i=0; i<dlm->totedge; i++, index++) {
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
MEdge *med = &dlm->medge[i];
|
2005-08-07 05:42:03 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(*index != ORIGINDEX_NONE
|
|
|
|
&& (!setDrawOptions || setDrawOptions(userData, *index))) {
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glVertex3fv(dlm->mvert[med->v1].co);
|
|
|
|
glVertex3fv(dlm->mvert[med->v2].co);
|
2005-08-07 05:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glEnd();
|
2005-08-07 05:42:03 +00:00
|
|
|
}
|
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
static void ssDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *userData, int index, float *co, float *no), void *userData)
|
2005-08-07 05:42:03 +00:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
2006-08-28 01:12:36 +00:00
|
|
|
int i;
|
|
|
|
int *index = dm->getFaceDataArray(dm, LAYERTYPE_ORIGINDEX);
|
2005-08-07 05:42:03 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
for (i=0; i<dlm->totface; i++, index++) {
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
MFace *mf = &dlm->mface[i];
|
2005-08-07 05:42:03 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(*index != ORIGINDEX_NONE) {
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
float cent[3];
|
|
|
|
float no[3];
|
2005-08-07 05:42:03 +00:00
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
VECCOPY(cent, dlm->mvert[mf->v1].co);
|
|
|
|
VecAddf(cent, cent, dlm->mvert[mf->v2].co);
|
|
|
|
VecAddf(cent, cent, dlm->mvert[mf->v3].co);
|
2005-08-07 05:42:03 +00:00
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
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);
|
2005-08-07 05:42:03 +00:00
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
func(userData, *index, cent, no);
|
2005-08-07 05:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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++) {
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
TFace *tf = &dlm->tface[i];
|
2005-08-18 11:31:20 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
if (!(tf->flag&TF_HIDE)) {
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
glVertex2fv(tf->uv[1]);
|
2005-08-18 11:31:20 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glVertex2fv(tf->uv[1]);
|
|
|
|
glVertex2fv(tf->uv[2]);
|
2005-08-18 11:31:20 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
if (!dlm->mface[i].v4) {
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
|
|
|
} else {
|
|
|
|
glVertex2fv(tf->uv[2]);
|
|
|
|
glVertex2fv(tf->uv[3]);
|
2005-08-18 11:31:20 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glVertex2fv(tf->uv[3]);
|
|
|
|
glVertex2fv(tf->uv[0]);
|
2005-08-18 11:31:20 +00:00
|
|
|
}
|
2005-08-14 10:35:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
2005-08-21 20:48:45 +00:00
|
|
|
static void ssDM_drawLooseEdges(DerivedMesh *dm)
|
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;
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
MEdge *medge= dlm->medge;
|
2005-03-27 20:34:18 +00:00
|
|
|
int i;
|
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (i=0; i<dlm->totedge; i++, medge++) {
|
2005-08-21 20:48:45 +00:00
|
|
|
if (medge->flag&ME_LOOSEEDGE) {
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glVertex3fv(mvert[medge->v1].co);
|
|
|
|
glVertex3fv(mvert[medge->v2].co);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
}
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
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;
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
MEdge *medge= dlm->medge;
|
2005-03-27 20:34:18 +00:00
|
|
|
int i;
|
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (i=0; i<dlm->totedge; i++, medge++) {
|
|
|
|
if ((medge->flag&ME_EDGEDRAW) && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
|
|
|
|
glVertex3fv(mvert[medge->v1].co);
|
|
|
|
glVertex3fv(mvert[medge->v2].co);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glEnd();
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
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];
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
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;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
if(new_glmode!=glmode || new_shademodel!=shademodel || new_matnr!=matnr) {
|
|
|
|
glEnd();
|
2005-03-27 20:34:18 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
drawCurrentMat = setMaterial(matnr=new_matnr);
|
2005-03-27 20:34:18 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
glShadeModel(shademodel=new_shademodel);
|
|
|
|
glBegin(glmode=new_glmode);
|
|
|
|
}
|
|
|
|
|
|
|
|
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];
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
int nmode= mf->v4?GL_QUADS:GL_TRIANGLES;
|
|
|
|
unsigned char *colbase= &vcols1[i*16];
|
2005-03-27 20:34:18 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
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];
|
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
if (mf->v4)
|
|
|
|
PASSVERT(mf->v4, 3);
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
PASSVERT(mf->v3, 2);
|
|
|
|
PASSVERT(mf->v2, 1);
|
|
|
|
PASSVERT(mf->v1, 0);
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
if (vcols2)
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
#undef PASSVERT
|
|
|
|
}
|
2006-02-08 21:01:00 +00:00
|
|
|
|
2006-03-11 16:13:10 +00:00
|
|
|
static void ssDM_drawFacesTex_common(DerivedMesh *dm, int (*drawParams)(TFace *tface, int matnr), int (*drawParamsMapped)(void *userData, int index), void *userData)
|
2005-03-29 07:51:00 +00:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
|
|
|
MVert *mvert= dlm->mvert;
|
|
|
|
MFace *mface= dlm->mface;
|
|
|
|
TFace *tface = dlm->tface;
|
|
|
|
float *nors = dlm->nors;
|
2006-08-28 01:12:36 +00:00
|
|
|
int a;
|
|
|
|
int *index = dm->getFaceDataArray(dm, LAYERTYPE_ORIGINDEX);
|
2005-03-29 07:51:00 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
for (a=0; a<dlm->totface; a++, index++) {
|
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;
|
2006-10-26 23:34:44 +00:00
|
|
|
int flag = 0;
|
2005-03-29 07:51:00 +00:00
|
|
|
unsigned char *cp= NULL;
|
|
|
|
|
2006-03-11 16:13:10 +00:00
|
|
|
if (drawParams) {
|
|
|
|
flag = drawParams(tf, mf->mat_nr);
|
|
|
|
}
|
|
|
|
else {
|
2006-08-28 01:12:36 +00:00
|
|
|
if(*index != ORIGINDEX_NONE)
|
|
|
|
flag = drawParamsMapped(userData, *index);
|
2006-03-11 16:13:10 +00:00
|
|
|
}
|
2005-08-18 11:31:20 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2006-03-11 16:13:10 +00:00
|
|
|
static void ssDM_drawFacesTex(DerivedMesh *dm, int (*setDrawParams)(TFace *tface, int matnr))
|
|
|
|
{
|
|
|
|
ssDM_drawFacesTex_common(dm, setDrawParams, NULL, NULL);
|
|
|
|
}
|
|
|
|
static void ssDM_drawMappedFacesTex(DerivedMesh *dm, int (*setDrawParams)(void *userData, int index), void *userData)
|
|
|
|
{
|
|
|
|
ssDM_drawFacesTex_common(dm, NULL, setDrawParams, userData);
|
|
|
|
}
|
|
|
|
|
2005-08-23 20:04:10 +00:00
|
|
|
static void ssDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors)
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
DispListMesh *dlm = ssdm->dlm;
|
|
|
|
MVert *mvert= dlm->mvert;
|
|
|
|
MFace *mface= dlm->mface;
|
|
|
|
float *nors = dlm->nors;
|
2006-08-28 01:12:36 +00:00
|
|
|
int i;
|
|
|
|
int *index = dm->getFaceDataArray(dm, LAYERTYPE_ORIGINDEX);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
for (i=0; i<dlm->totface; i++, index++) {
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
MFace *mf = &mface[i];
|
2006-08-28 01:12:36 +00:00
|
|
|
int drawSmooth = (mf->flag & ME_SMOOTH);
|
2005-03-29 07:51:00 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(*index != ORIGINDEX_NONE
|
|
|
|
&& (!setDrawOptions
|
|
|
|
|| setDrawOptions(userData, *index, &drawSmooth))) {
|
2005-08-23 20:04:10 +00:00
|
|
|
unsigned char *cp = NULL;
|
|
|
|
|
|
|
|
if (useColors) {
|
|
|
|
if (dlm->tface) {
|
|
|
|
cp= (unsigned char*) dlm->tface[i].col;
|
|
|
|
} else if (dlm->mcol) {
|
|
|
|
cp= (unsigned char*) &dlm->mcol[i*4];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-20 18:14:04 +00:00
|
|
|
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
|
|
|
|
glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
|
2005-08-23 20:04:10 +00:00
|
|
|
|
2005-08-20 18:14:04 +00:00
|
|
|
if (!drawSmooth) {
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glNormal3fv(&nors[i*3]);
|
|
|
|
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glVertex3fv(mvert[mf->v1].co);
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glVertex3fv(mvert[mf->v2].co);
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glVertex3fv(mvert[mf->v3].co);
|
2005-08-23 20:04:10 +00:00
|
|
|
if(mf->v4) {
|
|
|
|
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
|
|
|
|
glVertex3fv(mvert[mf->v4].co);
|
|
|
|
}
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
} else {
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[3], cp[2], cp[1]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glNormal3sv(mvert[mf->v1].no);
|
|
|
|
glVertex3fv(mvert[mf->v1].co);
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[7], cp[6], cp[5]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glNormal3sv(mvert[mf->v2].no);
|
|
|
|
glVertex3fv(mvert[mf->v2].co);
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[11], cp[10], cp[9]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glNormal3sv(mvert[mf->v3].no);
|
|
|
|
glVertex3fv(mvert[mf->v3].co);
|
|
|
|
if(mf->v4) {
|
2005-08-23 20:04:10 +00:00
|
|
|
if (cp) glColor3ub(cp[15], cp[14], cp[13]);
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
glNormal3sv(mvert[mf->v4].no);
|
|
|
|
glVertex3fv(mvert[mf->v4].co);
|
|
|
|
}
|
|
|
|
}
|
2005-08-23 20:04:10 +00:00
|
|
|
|
2005-08-20 18:14:04 +00:00
|
|
|
glEnd();
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
static int ssDM_getNumEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
|
|
|
|
return ssdm->dlm->totedge;
|
|
|
|
}
|
|
|
|
|
2005-03-27 21:27:12 +00:00
|
|
|
static int ssDM_getNumFaces(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
|
|
|
|
return ssdm->dlm->totface;
|
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
void ssDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
|
|
|
|
{
|
|
|
|
*vert_r = ((SSDerivedMesh *)dm)->dlm->mvert[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void ssDM_getEdge(DerivedMesh *dm, int index, MEdge *edge_r)
|
|
|
|
{
|
|
|
|
*edge_r = ((SSDerivedMesh *)dm)->dlm->medge[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void ssDM_getFace(DerivedMesh *dm, int index, MFace *face_r)
|
|
|
|
{
|
|
|
|
*face_r = ((SSDerivedMesh *)dm)->dlm->mface[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void ssDM_getVertArray(DerivedMesh *dm, MVert *vert_r)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh *)dm;
|
|
|
|
memcpy(vert_r, ssdm->dlm->mvert, sizeof(*vert_r) * ssdm->dlm->totvert);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ssDM_getEdgeArray(DerivedMesh *dm, MEdge *edge_r)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh *)dm;
|
|
|
|
memcpy(edge_r, ssdm->dlm->medge, sizeof(*edge_r) * ssdm->dlm->totedge);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ssDM_getFaceArray(DerivedMesh *dm, MFace *face_r)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh *)dm;
|
|
|
|
memcpy(face_r, ssdm->dlm->mface, sizeof(*face_r) * 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-03-28 21:49:49 +00:00
|
|
|
static void ssDM_release(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
DM_release(dm);
|
|
|
|
|
2005-03-29 16:43:39 +00:00
|
|
|
displistmesh_free(ssdm->dlm);
|
2005-03-28 21:49:49 +00:00
|
|
|
|
|
|
|
MEM_freeN(dm);
|
|
|
|
}
|
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
DerivedMesh *derivedmesh_from_displistmesh(DispListMesh *dlm, float (*vertexCos)[3])
|
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
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
DM_init(&ssdm->dm, dlm->totvert, dlm->totedge, dlm->totface);
|
|
|
|
|
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;
|
2006-08-28 01:12:36 +00:00
|
|
|
ssdm->dm.getNumEdges = ssDM_getNumEdges;
|
2005-03-27 21:27:12 +00:00
|
|
|
ssdm->dm.getNumFaces = ssDM_getNumFaces;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
ssdm->dm.getVert = ssDM_getVert;
|
|
|
|
ssdm->dm.getEdge = ssDM_getEdge;
|
|
|
|
ssdm->dm.getFace = ssDM_getFace;
|
|
|
|
ssdm->dm.getVertArray = ssDM_getVertArray;
|
|
|
|
ssdm->dm.getEdgeArray = ssDM_getEdgeArray;
|
|
|
|
ssdm->dm.getFaceArray = ssDM_getFaceArray;
|
|
|
|
|
2005-03-27 22:42:57 +00:00
|
|
|
ssdm->dm.convertToDispListMesh = ssDM_convertToDispListMesh;
|
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-21 20:48:45 +00:00
|
|
|
ssdm->dm.drawLooseEdges = ssDM_drawLooseEdges;
|
2005-08-18 11:31:20 +00:00
|
|
|
|
2005-03-27 20:34:18 +00:00
|
|
|
ssdm->dm.drawFacesSolid = ssDM_drawFacesSolid;
|
|
|
|
ssdm->dm.drawFacesColored = ssDM_drawFacesColored;
|
2006-03-11 16:13:10 +00:00
|
|
|
ssdm->dm.drawFacesTex = ssDM_drawFacesTex;
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
ssdm->dm.drawMappedFaces = ssDM_drawMappedFaces;
|
2006-03-11 16:13:10 +00:00
|
|
|
ssdm->dm.drawMappedFacesTex = ssDM_drawMappedFacesTex;
|
2005-03-27 20:34:18 +00:00
|
|
|
|
2005-08-07 05:42:03 +00:00
|
|
|
/* EM functions */
|
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
ssdm->dm.foreachMappedVert = ssDM_foreachMappedVert;
|
|
|
|
ssdm->dm.foreachMappedEdge = ssDM_foreachMappedEdge;
|
|
|
|
ssdm->dm.foreachMappedFaceCenter = ssDM_foreachMappedFaceCenter;
|
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
|
|
|
|
- convert all DerivedMesh map functions to use index based
mapping (instead of Edit{Vert,Edge,Face} pointers)
- dropped convertToDispListMeshMapped (whew, glad of it too)
- added DerivedMesh drawMappedFaces function
- dropped EM suffix for DerivedMesh functions, it was neither
particularly correct nor descriptive
- converted test_index_mface to test_index_face that also corrects
MCol and TFace. Good thing we had three versions of this routine,
you never know when one might burn down.
- removed flipnorm_mesh, not used anymore (and was incorrect to
boot)
- Getting face select to work with modifiers turned out to be much
more complicated than expected. Reworked mapping architecture for
modifiers - basically elements in a DispListMesh are now required
to be stored in an order that corresponds exactly to original
ordering. MVert/MEdge/MFace all have a new flag ME_XXX_STEPINDEX
that is set on each element that is set on the first derived element
of each original element. I can't say the code to follow these
requirements for subsurf is particularly transparent, but on the
upside it is a reasonably consistent and simple system that is memory
efficient and allows keeping the DispListMesh structure.
- rewrote mirror modifier to be simpler/conform to new requirements
for mapped DispListMesh structure. This also means that mirror interacts
much better with incremental subsurf calculation (it used to recalc
one entire side on any topology change, now it generally avoids that).
- added EM_{init,free}_index_arrays and EM_get_{vert,edge,face}_for_index
functions to handle mapping indices back into appropriate EditMesh
structures.
- bug fix, make edges didn't recalc object data
- bug fix, initial image assignment to TFace's didn't recalc object data
- new feature, added circle select support for FACESELECT
- bug fix, creating new faces in editmode duplicated the TFACE active
flag - but there should only be one active tface
- bug fix, possible crash when deleting all faces in faceselect mode
on mesh with tfaces...
Still todo: TFace edge drawing is still not always correct in face
mode, in particular with a mirror modifier when mesh has edges (and
no preceeding subsurf). Have not yet decided how to deal with this.
Best solution is probably to do switch to meshes all having MEdge's,
in which case I can get rid of TFace edge flags (and need to recalc
modifiers on tface selection change).
2005-08-20 03:08:23 +00:00
|
|
|
ssdm->dm.drawMappedEdges = ssDM_drawMappedEdges;
|
|
|
|
ssdm->dm.drawMappedEdgesInterp = NULL; // no way to implement this one
|
2005-08-07 05:42:03 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-08-20 15:22:56 +00:00
|
|
|
#ifdef WITH_VERSE
|
|
|
|
|
|
|
|
/* verse derived mesh */
|
|
|
|
typedef struct {
|
|
|
|
struct DerivedMesh dm;
|
|
|
|
struct VNode *vnode;
|
|
|
|
struct VLayer *vertex_layer;
|
|
|
|
struct VLayer *polygon_layer;
|
|
|
|
float (*verts)[3];
|
|
|
|
} VDerivedMesh;
|
|
|
|
|
|
|
|
/* this function set up border points of verse mesh bounding box */
|
|
|
|
static void vDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3])
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
struct VerseVert *vvert;
|
|
|
|
|
|
|
|
if(!vdm->vertex_layer) return;
|
|
|
|
|
|
|
|
vvert = (VerseVert*)vdm->vertex_layer->dl.lb.first;
|
|
|
|
|
|
|
|
if(vdm->vertex_layer->dl.da.count > 0) {
|
|
|
|
while(vvert) {
|
|
|
|
DO_MINMAX(vdm->verts ? vvert->cos : vvert->co, min_r, max_r);
|
|
|
|
vvert = vvert->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
min_r[0] = min_r[1] = min_r[2] = max_r[0] = max_r[1] = max_r[2] = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this function return number of vertexes in vertex layer */
|
|
|
|
static int vDM_getNumVerts(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
|
|
|
|
if(!vdm->vertex_layer) return 0;
|
|
|
|
else return vdm->vertex_layer->dl.da.count;
|
|
|
|
}
|
|
|
|
|
2006-08-30 10:55:46 +00:00
|
|
|
/* this function return number of 'fake' edges */
|
|
|
|
static int vDM_getNumEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-08-20 15:22:56 +00:00
|
|
|
/* this function returns number of polygons in polygon layer */
|
|
|
|
static int vDM_getNumFaces(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
|
|
|
|
if(!vdm->polygon_layer) return 0;
|
|
|
|
else return vdm->polygon_layer->dl.da.count;
|
|
|
|
}
|
|
|
|
|
2006-08-30 10:55:46 +00:00
|
|
|
/* this function doesn't return vertex with index of access array,
|
|
|
|
* but it return 'indexth' vertex of dynamic list */
|
|
|
|
void vDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
|
|
|
|
{
|
|
|
|
VerseVert *vvert = ((VDerivedMesh*)dm)->vertex_layer->dl.lb.first;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0 ; i<index; i++) vvert = vvert->next;
|
|
|
|
|
|
|
|
if(vvert) {
|
|
|
|
VECCOPY(vert_r->co, vvert->co);
|
|
|
|
|
|
|
|
vert_r->no[0] = vvert->no[0] * 32767.0;
|
|
|
|
vert_r->no[1] = vvert->no[1] * 32767.0;
|
|
|
|
vert_r->no[2] = vvert->no[2] * 32767.0;
|
|
|
|
|
|
|
|
/* TODO what to do with vert_r->flag and vert_r->mat_nr? */
|
|
|
|
vert_r->mat_nr = 0;
|
|
|
|
vert_r->flag = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dummy function, because verse mesh doesn't store edges */
|
|
|
|
void vDM_getEdge(DerivedMesh *dm, int index, MEdge *edge_r)
|
|
|
|
{
|
|
|
|
edge_r->flag = 0;
|
|
|
|
edge_r->crease = 0;
|
|
|
|
edge_r->v1 = 0;
|
|
|
|
edge_r->v2 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this function doesn't return face with index of access array,
|
|
|
|
* but it returns 'indexth' vertex of dynamic list */
|
|
|
|
void vDM_getFace(DerivedMesh *dm, int index, MFace *face_r)
|
|
|
|
{
|
|
|
|
struct VerseFace *vface = ((VDerivedMesh*)dm)->polygon_layer->dl.lb.first;
|
|
|
|
struct VerseVert *vvert = ((VDerivedMesh*)dm)->vertex_layer->dl.lb.first;
|
|
|
|
struct VerseVert *vvert0, *vvert1, *vvert2, *vvert3;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < index; ++i) vface = vface->next;
|
|
|
|
|
|
|
|
face_r->mat_nr = 0;
|
|
|
|
face_r->flag = 0;
|
|
|
|
|
|
|
|
/* goddamn, we have to search all verts to find indices */
|
|
|
|
vvert0 = vface->vvert0;
|
|
|
|
vvert1 = vface->vvert1;
|
|
|
|
vvert2 = vface->vvert2;
|
|
|
|
vvert3 = vface->vvert3;
|
|
|
|
if(!vvert3) face_r->v4 = 0;
|
|
|
|
|
|
|
|
for(i = 0; vvert0 || vvert1 || vvert2 || vvert3; i++, vvert = vvert->next) {
|
|
|
|
if(vvert == vvert0) {
|
|
|
|
face_r->v1 = i;
|
|
|
|
vvert0 = NULL;
|
|
|
|
}
|
|
|
|
if(vvert == vvert1) {
|
|
|
|
face_r->v2 = i;
|
|
|
|
vvert1 = NULL;
|
|
|
|
}
|
|
|
|
if(vvert == vvert2) {
|
|
|
|
face_r->v3 = i;
|
|
|
|
vvert2 = NULL;
|
|
|
|
}
|
|
|
|
if(vvert == vvert3) {
|
|
|
|
face_r->v4 = i;
|
|
|
|
vvert3 = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test_index_face(face_r, NULL, NULL, vface->vvert3?4:3);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fill array of mvert */
|
|
|
|
void vDM_getVertArray(DerivedMesh *dm, MVert *vert_r)
|
|
|
|
{
|
|
|
|
VerseVert *vvert = ((VDerivedMesh *)dm)->vertex_layer->dl.lb.first;
|
|
|
|
|
|
|
|
for( ; vvert; vvert = vvert->next, ++vert_r) {
|
|
|
|
VECCOPY(vert_r->co, vvert->co);
|
|
|
|
|
|
|
|
vert_r->no[0] = vvert->no[0] * 32767.0;
|
|
|
|
vert_r->no[1] = vvert->no[1] * 32767.0;
|
|
|
|
vert_r->no[2] = vvert->no[2] * 32767.0;
|
|
|
|
|
|
|
|
vert_r->mat_nr = 0;
|
|
|
|
vert_r->flag = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dummy function, edges arent supported in verse mesh */
|
|
|
|
void vDM_getEdgeArray(DerivedMesh *dm, MEdge *edge_r)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fill array of mfaces */
|
|
|
|
void vDM_getFaceArray(DerivedMesh *dm, MFace *face_r)
|
|
|
|
{
|
|
|
|
VerseFace *vface = ((VDerivedMesh*)dm)->polygon_layer->dl.lb.first;
|
|
|
|
VerseVert *vvert = ((VDerivedMesh*)dm)->vertex_layer->dl.lb.first;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* store vert indices in the prev pointer (kind of hacky) */
|
|
|
|
for(i = 0; vvert; vvert = vvert->next, ++i)
|
|
|
|
vvert->tmp.index = i;
|
|
|
|
|
|
|
|
for( ; vface; vface = vface->next, ++face_r) {
|
|
|
|
face_r->mat_nr = 0;
|
|
|
|
face_r->flag = 0;
|
|
|
|
|
|
|
|
face_r->v1 = vface->vvert0->tmp.index;
|
|
|
|
face_r->v2 = vface->vvert1->tmp.index;
|
|
|
|
face_r->v3 = vface->vvert2->tmp.index;
|
|
|
|
if(vface->vvert3) face_r->v4 = vface->vvert3->tmp.index;
|
|
|
|
else face_r->v4 = 0;
|
|
|
|
|
|
|
|
test_index_face(face_r, NULL, NULL, vface->vvert3?4:3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-20 15:22:56 +00:00
|
|
|
/* create diplist mesh from verse mesh */
|
|
|
|
static DispListMesh* vDM_convertToDispListMesh(DerivedMesh *dm, int allowShared)
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
DispListMesh *dlm = MEM_callocN(sizeof(*dlm), "dlm");
|
|
|
|
struct VerseVert *vvert;
|
|
|
|
struct VerseFace *vface;
|
|
|
|
struct MVert *mvert=NULL;
|
|
|
|
struct MFace *mface=NULL;
|
|
|
|
float *norms;
|
|
|
|
unsigned int i;
|
2006-08-30 10:55:46 +00:00
|
|
|
EdgeHash *edges;
|
2006-08-20 15:22:56 +00:00
|
|
|
|
|
|
|
if(!vdm->vertex_layer || !vdm->polygon_layer) {
|
|
|
|
dlm->totvert = 0;
|
|
|
|
dlm->totedge = 0;
|
|
|
|
dlm->totface = 0;
|
|
|
|
dlm->dontFreeVerts = dlm->dontFreeOther = dlm->dontFreeNors = 0;
|
|
|
|
|
|
|
|
return dlm;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* number of vertexes, edges and faces */
|
|
|
|
dlm->totvert = vdm->vertex_layer->dl.da.count;
|
|
|
|
dlm->totface = vdm->polygon_layer->dl.da.count;
|
|
|
|
|
|
|
|
/* create dynamic array of mverts */
|
|
|
|
mvert = (MVert*)MEM_mallocN(sizeof(MVert)*dlm->totvert, "dlm verts");
|
|
|
|
dlm->mvert = mvert;
|
|
|
|
vvert = (VerseVert*)vdm->vertex_layer->dl.lb.first;
|
|
|
|
i = 0;
|
|
|
|
while(vvert) {
|
|
|
|
VECCOPY(mvert->co, vdm->verts ? vvert->cos : vvert->co);
|
|
|
|
VECCOPY(mvert->no, vvert->no);
|
|
|
|
mvert->mat_nr = 0;
|
|
|
|
mvert->flag = 0;
|
|
|
|
|
|
|
|
vvert->tmp.index = i++;
|
|
|
|
mvert++;
|
|
|
|
vvert = vvert->next;
|
|
|
|
}
|
|
|
|
|
2006-08-30 10:55:46 +00:00
|
|
|
edges = BLI_edgehash_new();
|
2006-08-20 15:22:56 +00:00
|
|
|
|
|
|
|
/* create dynamic array of faces */
|
|
|
|
mface = (MFace*)MEM_mallocN(sizeof(MFace)*dlm->totface, "dlm faces");
|
|
|
|
dlm->mface = mface;
|
|
|
|
vface = (VerseFace*)vdm->polygon_layer->dl.lb.first;
|
|
|
|
i = 0;
|
|
|
|
while(vface) {
|
|
|
|
mface->v1 = vface->vvert0->tmp.index;
|
|
|
|
mface->v2 = vface->vvert1->tmp.index;
|
|
|
|
mface->v3 = vface->vvert2->tmp.index;
|
2006-08-30 10:55:46 +00:00
|
|
|
if(!BLI_edgehash_haskey(edges, mface->v1, mface->v2))
|
|
|
|
BLI_edgehash_insert(edges, mface->v1, mface->v2, NULL);
|
|
|
|
if(!BLI_edgehash_haskey(edges, mface->v2, mface->v3))
|
|
|
|
BLI_edgehash_insert(edges, mface->v2, mface->v3, NULL);
|
|
|
|
if(vface->vvert3) {
|
|
|
|
mface->v4 = vface->vvert3->tmp.index;
|
|
|
|
if(!BLI_edgehash_haskey(edges, mface->v3, mface->v4))
|
|
|
|
BLI_edgehash_insert(edges, mface->v3, mface->v4, NULL);
|
|
|
|
if(!BLI_edgehash_haskey(edges, mface->v4, mface->v1))
|
|
|
|
BLI_edgehash_insert(edges, mface->v4, mface->v1, NULL);
|
|
|
|
} else {
|
|
|
|
mface->v4 = 0;
|
|
|
|
if(!BLI_edgehash_haskey(edges, mface->v3, mface->v1))
|
|
|
|
BLI_edgehash_insert(edges, mface->v3, mface->v1, NULL);
|
|
|
|
}
|
2006-08-20 15:22:56 +00:00
|
|
|
|
|
|
|
mface->pad = 0;
|
|
|
|
mface->mat_nr = 0;
|
|
|
|
mface->flag = 0;
|
|
|
|
mface->edcode = 0;
|
|
|
|
|
|
|
|
test_index_face(mface, NULL, NULL, vface->vvert3?4:3);
|
|
|
|
|
|
|
|
mface++;
|
|
|
|
vface = vface->next;
|
|
|
|
}
|
|
|
|
|
2006-08-30 10:55:46 +00:00
|
|
|
dlm->totedge = BLI_edgehash_size(edges);
|
|
|
|
|
|
|
|
if(dlm->totedge) {
|
|
|
|
EdgeHashIterator *i;
|
|
|
|
MEdge *medge = dlm->medge = (MEdge *)MEM_mallocN(sizeof(MEdge)*dlm->totedge, "mesh_from_verse edge");
|
|
|
|
|
|
|
|
for(i = BLI_edgehashIterator_new(edges); !BLI_edgehashIterator_isDone(i); BLI_edgehashIterator_step(i), ++medge) {
|
|
|
|
BLI_edgehashIterator_getKey(i, (int*)&medge->v1, (int*)&medge->v2);
|
|
|
|
medge->crease = medge->pad = medge->flag = 0;
|
|
|
|
}
|
|
|
|
BLI_edgehashIterator_free(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_edgehash_free(edges, NULL);
|
|
|
|
|
2006-08-20 15:22:56 +00:00
|
|
|
/* textures and verex colors aren't supported yet */
|
|
|
|
dlm->tface = NULL;
|
|
|
|
dlm->mcol = NULL;
|
|
|
|
|
|
|
|
/* faces normals */
|
|
|
|
norms = (float*)MEM_mallocN(sizeof(float)*3*dlm->totface, "dlm norms");
|
|
|
|
dlm->nors = norms;
|
|
|
|
|
|
|
|
vface = (VerseFace*)vdm->polygon_layer->dl.lb.first;
|
|
|
|
while(vface){
|
|
|
|
VECCOPY(norms, vface->no);
|
|
|
|
norms += 3;
|
|
|
|
vface = vface->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free everything, nothing is shared */
|
|
|
|
dlm->dontFreeVerts = dlm->dontFreeOther = dlm->dontFreeNors = 0;
|
|
|
|
|
|
|
|
return dlm;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return coordination of vertex with index ... I suppose, that it will
|
|
|
|
* be very hard to do, becuase there can be holes in access array */
|
|
|
|
static void vDM_getVertCo(DerivedMesh *dm, int index, float co_r[3])
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
struct VerseVert *vvert = NULL;
|
|
|
|
|
|
|
|
if(!vdm->vertex_layer) return;
|
|
|
|
|
|
|
|
vvert = BLI_dlist_find_link(&(vdm->vertex_layer->dl), index);
|
|
|
|
if(vvert) {
|
|
|
|
VECCOPY(co_r, vdm->verts ? vvert->cos : vvert->co);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
co_r[0] = co_r[1] = co_r[2] = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return array of vertex coordiantions */
|
|
|
|
static void vDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3])
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
struct VerseVert *vvert;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if(!vdm->vertex_layer) return;
|
|
|
|
|
|
|
|
vvert = vdm->vertex_layer->dl.lb.first;
|
|
|
|
while(vvert) {
|
|
|
|
VECCOPY(cos_r[i], vdm->verts ? vvert->cos : vvert->co);
|
|
|
|
i++;
|
|
|
|
vvert = vvert->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return normal of vertex with index ... again, it will be hard to
|
|
|
|
* implemente, because access array */
|
|
|
|
static void vDM_getVertNo(DerivedMesh *dm, int index, float no_r[3])
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
struct VerseVert *vvert = NULL;
|
|
|
|
|
|
|
|
if(!vdm->vertex_layer) return;
|
|
|
|
|
|
|
|
vvert = BLI_dlist_find_link(&(vdm->vertex_layer->dl), index);
|
|
|
|
if(vvert) {
|
|
|
|
VECCOPY(no_r, vvert->no);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
no_r[0] = no_r[1] = no_r[2] = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw all VerseVertexes */
|
|
|
|
static void vDM_drawVerts(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
struct VerseVert *vvert;
|
|
|
|
|
|
|
|
if(!vdm->vertex_layer) return;
|
|
|
|
|
|
|
|
vvert = vdm->vertex_layer->dl.lb.first;
|
|
|
|
|
|
|
|
bglBegin(GL_POINTS);
|
|
|
|
while(vvert) {
|
|
|
|
bglVertex3fv(vdm->verts ? vvert->cos : vvert->co);
|
|
|
|
vvert = vvert->next;
|
|
|
|
}
|
|
|
|
bglEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw all edges of VerseFaces ... it isn't optimal, because verse
|
|
|
|
* specification doesn't support edges :-( ... bother eskil ;-)
|
|
|
|
* ... some edges (most of edges) are drawn twice */
|
|
|
|
static void vDM_drawEdges(DerivedMesh *dm, int drawLooseEdges)
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
struct VerseFace *vface;
|
|
|
|
|
|
|
|
if(!vdm->polygon_layer) return;
|
|
|
|
|
|
|
|
vface = vdm->polygon_layer->dl.lb.first;
|
|
|
|
|
|
|
|
while(vface) {
|
|
|
|
glBegin(GL_LINE_LOOP);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert0->cos : vface->vvert0->co);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert1->cos : vface->vvert1->co);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert2->cos : vface->vvert2->co);
|
|
|
|
if(vface->vvert3) glVertex3fv(vdm->verts ? vface->vvert3->cos : vface->vvert3->co);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
vface = vface->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* verse spec doesn't support edges ... loose edges can't exist */
|
|
|
|
void vDM_drawLooseEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw uv edges, not supported yet */
|
|
|
|
static void vDM_drawUVEdges(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw all VerseFaces */
|
|
|
|
static void vDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int))
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
struct VerseFace *vface;
|
|
|
|
|
|
|
|
if(!vdm->polygon_layer) return;
|
|
|
|
|
|
|
|
vface = vdm->polygon_layer->dl.lb.first;
|
|
|
|
|
|
|
|
while(vface) {
|
|
|
|
/* if((vface->smooth) && (vface->smooth->value)){
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
glBegin(vface->vvert3?GL_QUADS:GL_TRIANGLES);
|
|
|
|
glNormal3fv(vface->vvert0->no);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert0->cos : vface->vvert0->co);
|
|
|
|
glNormal3fv(vface->vvert1->no);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert1->cos : vface->vvert1->co);
|
|
|
|
glNormal3fv(vface->vvert2->no);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert2->cos : vface->vvert2->co);
|
|
|
|
if(vface->vvert3){
|
|
|
|
glNormal3fv(vface->vvert3->no);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert3->cos : vface->vvert3->co);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else { */
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
glBegin(vface->vvert3?GL_QUADS:GL_TRIANGLES);
|
|
|
|
glNormal3fv(vface->no);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert0->cos : vface->vvert0->co);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert1->cos : vface->vvert1->co);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert2->cos : vface->vvert2->co);
|
|
|
|
if(vface->vvert3)
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert3->cos : vface->vvert3->co);
|
|
|
|
glEnd();
|
|
|
|
/* } */
|
|
|
|
|
|
|
|
vface = vface->next;
|
|
|
|
}
|
|
|
|
glShadeModel(GL_FLAT);
|
|
|
|
}
|
|
|
|
|
2006-08-21 13:19:18 +00:00
|
|
|
/* thsi function should draw mesh with mapped texture, but it isn't supported yet */
|
|
|
|
static void vDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(struct TFace *tface, int matnr))
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
struct VerseFace *vface;
|
|
|
|
|
|
|
|
if(!vdm->polygon_layer) return;
|
|
|
|
|
|
|
|
vface = vdm->polygon_layer->dl.lb.first;
|
|
|
|
|
|
|
|
while(vface) {
|
|
|
|
glBegin(vface->vvert3?GL_QUADS:GL_TRIANGLES);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert0->cos : vface->vvert0->co);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert1->cos : vface->vvert1->co);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert2->cos : vface->vvert2->co);
|
|
|
|
if(vface->vvert3)
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert3->cos : vface->vvert3->co);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
vface = vface->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-20 15:22:56 +00:00
|
|
|
/* this function should draw mesh with colored faces (weight paint, vertex
|
|
|
|
* colors, etc.), but it isn't supported yet */
|
|
|
|
static void vDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned char *col1, unsigned char *col2)
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
struct VerseFace *vface;
|
|
|
|
|
|
|
|
if(!vdm->polygon_layer) return;
|
|
|
|
|
|
|
|
vface = vdm->polygon_layer->dl.lb.first;
|
|
|
|
|
|
|
|
while(vface) {
|
|
|
|
glBegin(vface->vvert3?GL_QUADS:GL_TRIANGLES);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert0->cos : vface->vvert0->co);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert1->cos : vface->vvert1->co);
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert2->cos : vface->vvert2->co);
|
|
|
|
if(vface->vvert3)
|
|
|
|
glVertex3fv(vdm->verts ? vface->vvert3->cos : vface->vvert3->co);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
vface = vface->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**/
|
|
|
|
static void vDM_foreachMappedVert(
|
|
|
|
DerivedMesh *dm,
|
|
|
|
void (*func)(void *userData, int index, float *co, float *no_f, short *no_s),
|
|
|
|
void *userData)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**/
|
|
|
|
static void vDM_foreachMappedEdge(
|
|
|
|
DerivedMesh *dm,
|
|
|
|
void (*func)(void *userData, int index, float *v0co, float *v1co),
|
|
|
|
void *userData)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**/
|
|
|
|
static void vDM_foreachMappedFaceCenter(
|
|
|
|
DerivedMesh *dm,
|
|
|
|
void (*func)(void *userData, int index, float *cent, float *no),
|
|
|
|
void *userData)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**/
|
|
|
|
static void vDM_drawMappedFacesTex(
|
|
|
|
DerivedMesh *dm,
|
2006-08-30 10:55:46 +00:00
|
|
|
int (*setDrawParams)(void *userData, int index),
|
2006-08-20 15:22:56 +00:00
|
|
|
void *userData)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**/
|
|
|
|
static void vDM_drawMappedFaces(
|
|
|
|
DerivedMesh *dm,
|
|
|
|
int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r),
|
|
|
|
void *userData,
|
|
|
|
int useColors)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**/
|
|
|
|
static void vDM_drawMappedEdges(
|
|
|
|
DerivedMesh *dm,
|
|
|
|
int (*setDrawOptions)(void *userData, int index),
|
|
|
|
void *userData)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**/
|
|
|
|
static void vDM_drawMappedEdgesInterp(
|
|
|
|
DerivedMesh *dm,
|
|
|
|
int (*setDrawOptions)(void *userData, int index),
|
|
|
|
void (*setDrawInterpOptions)(void *userData, int index, float t),
|
|
|
|
void *userData)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free all DerivedMesh data */
|
|
|
|
static void vDM_release(DerivedMesh *dm)
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = (VDerivedMesh*)dm;
|
|
|
|
|
2006-08-30 10:55:46 +00:00
|
|
|
DM_release(dm);
|
|
|
|
|
2006-08-20 15:22:56 +00:00
|
|
|
if(vdm->verts) MEM_freeN(vdm->verts);
|
|
|
|
MEM_freeN(vdm);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create derived mesh from verse mesh ... it is used in object mode, when some other client can
|
|
|
|
* change shared data and want to see this changes in real time too */
|
|
|
|
DerivedMesh *derivedmesh_from_versemesh(VNode *vnode, float (*vertexCos)[3])
|
|
|
|
{
|
|
|
|
VDerivedMesh *vdm = MEM_callocN(sizeof(*vdm), "vdm");
|
|
|
|
struct VerseVert *vvert;
|
|
|
|
|
|
|
|
vdm->vnode = vnode;
|
|
|
|
vdm->vertex_layer = find_verse_layer_type((VGeomData*)vnode->data, VERTEX_LAYER);
|
|
|
|
vdm->polygon_layer = find_verse_layer_type((VGeomData*)vnode->data, POLYGON_LAYER);
|
|
|
|
|
2006-09-05 09:28:46 +00:00
|
|
|
if(vdm->vertex_layer && vdm->polygon_layer)
|
|
|
|
DM_init(&vdm->dm, vdm->vertex_layer->dl.da.count, 0, vdm->polygon_layer->dl.da.count);
|
|
|
|
else
|
|
|
|
DM_init(&vdm->dm, 0, 0, 0);
|
2006-08-30 10:55:46 +00:00
|
|
|
|
2006-08-20 15:22:56 +00:00
|
|
|
vdm->dm.getMinMax = vDM_getMinMax;
|
|
|
|
|
|
|
|
vdm->dm.getNumVerts = vDM_getNumVerts;
|
2006-08-30 10:55:46 +00:00
|
|
|
vdm->dm.getNumEdges = vDM_getNumEdges;
|
2006-08-20 15:22:56 +00:00
|
|
|
vdm->dm.getNumFaces = vDM_getNumFaces;
|
|
|
|
|
2006-08-30 10:55:46 +00:00
|
|
|
vdm->dm.getVert = vDM_getVert;
|
|
|
|
vdm->dm.getEdge = vDM_getEdge;
|
|
|
|
vdm->dm.getFace = vDM_getFace;
|
|
|
|
vdm->dm.getVertArray = vDM_getVertArray;
|
|
|
|
vdm->dm.getEdgeArray = vDM_getEdgeArray;
|
|
|
|
vdm->dm.getFaceArray = vDM_getFaceArray;
|
|
|
|
|
2006-08-20 15:22:56 +00:00
|
|
|
vdm->dm.foreachMappedVert = vDM_foreachMappedVert;
|
|
|
|
vdm->dm.foreachMappedEdge = vDM_foreachMappedEdge;
|
|
|
|
vdm->dm.foreachMappedFaceCenter = vDM_foreachMappedFaceCenter;
|
|
|
|
|
|
|
|
vdm->dm.convertToDispListMesh = vDM_convertToDispListMesh;
|
|
|
|
|
|
|
|
vdm->dm.getVertCos = vDM_getVertCos;
|
|
|
|
vdm->dm.getVertCo = vDM_getVertCo;
|
|
|
|
vdm->dm.getVertNo = vDM_getVertNo;
|
|
|
|
|
|
|
|
vdm->dm.drawVerts = vDM_drawVerts;
|
|
|
|
|
|
|
|
vdm->dm.drawEdges = vDM_drawEdges;
|
|
|
|
vdm->dm.drawLooseEdges = vDM_drawLooseEdges;
|
|
|
|
vdm->dm.drawUVEdges = vDM_drawUVEdges;
|
|
|
|
|
|
|
|
vdm->dm.drawFacesSolid = vDM_drawFacesSolid;
|
2006-08-21 13:19:18 +00:00
|
|
|
vdm->dm.drawFacesTex = vDM_drawFacesTex;
|
2006-08-20 15:22:56 +00:00
|
|
|
vdm->dm.drawFacesColored = vDM_drawFacesColored;
|
|
|
|
|
|
|
|
vdm->dm.drawMappedFacesTex = vDM_drawMappedFacesTex;
|
|
|
|
vdm->dm.drawMappedFaces = vDM_drawMappedFaces;
|
|
|
|
vdm->dm.drawMappedEdges = vDM_drawMappedEdges;
|
|
|
|
vdm->dm.drawMappedEdgesInterp = vDM_drawMappedEdgesInterp;
|
|
|
|
|
|
|
|
vdm->dm.release = vDM_release;
|
|
|
|
|
|
|
|
if(vdm->vertex_layer) {
|
|
|
|
if(vertexCos) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
vdm->verts = MEM_mallocN(sizeof(float)*3*vdm->vertex_layer->dl.da.count, "verse mod vertexes");
|
|
|
|
vvert = vdm->vertex_layer->dl.lb.first;
|
|
|
|
|
|
|
|
for(i=0; i<vdm->vertex_layer->dl.da.count && vvert; i++, vvert = vvert->next) {
|
|
|
|
VECCOPY(vdm->verts[i], vertexCos[i]);
|
|
|
|
vvert->cos = vdm->verts[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
vdm->verts = NULL;
|
|
|
|
vvert = vdm->vertex_layer->dl.lb.first;
|
|
|
|
|
|
|
|
while(vvert) {
|
|
|
|
vvert->cos = NULL;
|
|
|
|
vvert = vvert->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (DerivedMesh*) vdm;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
/***/
|
2005-03-27 20:34:18 +00:00
|
|
|
|
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);
|
2006-08-20 15:22:56 +00:00
|
|
|
#ifdef WITH_VERSE
|
|
|
|
if(me->vnode) dm = derivedmesh_from_versemesh(me->vnode, deformedVerts);
|
|
|
|
else dm = getMeshDerivedMesh(me, ob, deformedVerts);
|
|
|
|
#else
|
2005-07-26 00:45:19 +00:00
|
|
|
dm = getMeshDerivedMesh(me, ob, deformedVerts);
|
2006-08-20 15:22:56 +00:00
|
|
|
#endif
|
|
|
|
|
2005-07-26 00:45:19 +00:00
|
|
|
MEM_freeN(deformedVerts);
|
|
|
|
} else {
|
2006-08-28 01:12:36 +00:00
|
|
|
DerivedMesh *tdm = getMeshDerivedMesh(me, ob, NULL);
|
|
|
|
dm = mti->applyModifier(md, ob, tdm, 0, 0);
|
|
|
|
|
|
|
|
if(tdm != dm) tdm->release(tdm);
|
2005-07-26 00:45:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return dm;
|
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3],
|
|
|
|
DerivedMesh **deform_r, DerivedMesh **final_r,
|
|
|
|
int useRenderParams, int useDeform,
|
|
|
|
int needMapping)
|
2005-03-27 20:34:18 +00:00
|
|
|
{
|
2005-07-20 04:44:02 +00:00
|
|
|
Mesh *me = ob->data;
|
2006-08-28 01:12:36 +00:00
|
|
|
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
2005-08-11 03:31:33 +00:00
|
|
|
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-11-23 12:49:22 +00:00
|
|
|
int fluidsimMeshUsed = 0;
|
2006-08-28 01:12:36 +00:00
|
|
|
int required_mode;
|
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
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(deform_r) *deform_r = NULL;
|
2005-07-19 00:21:01 +00:00
|
|
|
*final_r = NULL;
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
/* replace original mesh by fluidsim surface mesh for fluidsim
|
|
|
|
* domain objects
|
|
|
|
*/
|
2006-04-07 02:46:20 +00:00
|
|
|
if((G.obedit!=ob) && !needMapping) {
|
- bugfixes
#4742 exported normals are now correct
#4821 & 4956 for complex movements in/outflows can now also
use the animated mesh option
- new features
* isosurface subdivision: directly
creates a finer surface mesh from the simulation data.
this increases simulation time and harddisk usage, though, so
be careful - usually values of 2-4 should be enough.
* fluidsim particles: extended model for particle
simulation and generation. When isosurface subdivision is enabled,
the particles are now included in the surface generation,
giving a better impression of a single connected surface.
Note - the particles are only included in the final surface
mesh, so the preview surface shows none of the particle
effects.
* particle loading: different types of particles can now be selected for
display: drops, floats and tracers. This is a bit obsolete
due to the extensions mentioned above, but might still be useful.
Floats are just particles floating on the fluid surface, could
be used for e.g. foam.
* moving objects impact factor: this is another tweaking option,
as the handling of moving objects is still not conserving
mass. setting this to zero simply deletes the fluid, 1 is
the default, while larger values cause a stronger
impact. For tweaking the simulation: if fluid disappears, try
increasing this value, and if too much is appearing reduce it.
You can even use negative values for some strange results :)
- more code cleanup, e.g. removed config file writing in fluidsim.c,
added additional safety checks for particles & fluidsim domains (these
currently dont work together). I also removed the "build particles"
debug message in effects.c (seemed to be unnecessary?).
Some more info on the new features:
Here are two test animations showing the difference between
using the particle generation with isosurface subdivision.
This is how it would look with the old solver version:
http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_fl6manc4_1noparts.mpg
and this with the new one:
http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_fl6manc4_2wparts.mpg
Both simulations use a resolution of 64, however, the version with particles
takes significantly longer (almost twice as long).
The .blend file for a similar setup can be found here:
http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_testmanc4.blend
(Minor Tips for this file: dont enable subdivions of characters until rendering,
thus leave off for simulation, as it uses the rendering settings! For making
nice pictures switch on subdivion, and OSA.)
And here's a picture of old vs. new (for webpage or so):
http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_manc4compare.png
2006-11-05 16:30:29 +00:00
|
|
|
if((ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) &&
|
|
|
|
(1) && (!give_parteff(ob)) ) { // doesnt work together with particle systems!
|
2006-04-07 02:46:20 +00:00
|
|
|
if(ob->fluidsimSettings->type & OB_FLUIDSIM_DOMAIN) {
|
|
|
|
loadFluidsimMesh(ob,useRenderParams);
|
|
|
|
fluidsimMeshUsed = 1;
|
|
|
|
/* might have changed... */
|
|
|
|
me = ob->data;
|
|
|
|
numVerts = me->totvert;
|
|
|
|
}
|
2005-11-23 12:49:22 +00:00
|
|
|
}
|
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
if(useRenderParams) required_mode = eModifierMode_Render;
|
|
|
|
else required_mode = eModifierMode_Realtime;
|
|
|
|
|
|
|
|
if(useDeform) {
|
|
|
|
if(do_ob_key(ob)) /* shape key makes deform verts */
|
2005-09-26 15:34:21 +00:00
|
|
|
deformedVerts = mesh_getVertexCos(me, &numVerts);
|
|
|
|
|
2006-08-28 01:12:36 +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
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if((md->mode & required_mode) != required_mode) continue;
|
|
|
|
if(mti->isDisabled && mti->isDisabled(md)) continue;
|
|
|
|
|
|
|
|
if(mti->type == eModifierTypeType_OnlyDeform) {
|
|
|
|
if(!deformedVerts)
|
|
|
|
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, NULL, deformedVerts, numVerts);
|
2005-07-19 20:14:17 +00:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
/* Result of all leading deforming modifiers is cached for
|
|
|
|
* places that wish to use the original mesh but with deformed
|
|
|
|
* coordinates (vpaint, etc.)
|
|
|
|
*/
|
2006-08-30 03:05:30 +00:00
|
|
|
if (deform_r) {
|
2006-08-20 15:22:56 +00:00
|
|
|
#ifdef WITH_VERSE
|
|
|
|
if(me->vnode) *deform_r = derivedmesh_from_versemesh(me->vnode, deformedVerts);
|
2006-08-30 03:05:30 +00:00
|
|
|
else {
|
|
|
|
*deform_r = CDDM_from_mesh(me);
|
2006-09-07 06:44:25 +00:00
|
|
|
if(deformedVerts) {
|
2006-08-30 03:05:30 +00:00
|
|
|
CDDM_apply_vert_coords(*deform_r, deformedVerts);
|
2006-09-07 06:44:25 +00:00
|
|
|
CDDM_calc_normals(*deform_r);
|
|
|
|
}
|
2006-08-30 03:05:30 +00:00
|
|
|
}
|
2006-08-20 15:22:56 +00:00
|
|
|
#else
|
2006-08-30 03:05:30 +00:00
|
|
|
*deform_r = CDDM_from_mesh(me);
|
2006-09-07 06:44:25 +00:00
|
|
|
if(deformedVerts) {
|
2006-08-30 03:05:30 +00:00
|
|
|
CDDM_apply_vert_coords(*deform_r, deformedVerts);
|
2006-09-07 06:44:25 +00:00
|
|
|
CDDM_calc_normals(*deform_r);
|
|
|
|
}
|
2006-08-20 15:22:56 +00:00
|
|
|
#endif
|
2006-08-30 03:05:30 +00:00
|
|
|
}
|
2005-07-19 00:21:01 +00:00
|
|
|
} else {
|
2005-12-03 17:45:35 +00:00
|
|
|
if(!fluidsimMeshUsed) {
|
2006-08-28 01:12:36 +00:00
|
|
|
/* default behaviour for meshes */
|
2005-12-03 17:45:35 +00:00
|
|
|
deformedVerts = inputVertexCos;
|
|
|
|
} else {
|
2006-08-28 01:12:36 +00:00
|
|
|
/* the fluid sim mesh might have more vertices than the original
|
|
|
|
* one, so inputVertexCos shouldnt be used
|
|
|
|
*/
|
2005-12-03 17:45:35 +00:00
|
|
|
deformedVerts = mesh_getVertexCos(me, &numVerts);
|
|
|
|
}
|
2005-07-19 00:21:01 +00:00
|
|
|
}
|
|
|
|
|
2005-09-23 14:42:14 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
/* Now apply all remaining modifiers. If useDeform is off then skip
|
|
|
|
* OnlyDeform ones.
|
|
|
|
*/
|
2005-07-19 20:14:17 +00:00
|
|
|
dm = NULL;
|
2006-08-30 10:55:46 +00:00
|
|
|
|
|
|
|
#ifdef WITH_VERSE
|
|
|
|
/* hack to make sure modifiers don't try to use mesh data from a verse
|
|
|
|
* node
|
|
|
|
*/
|
|
|
|
if(me->vnode) dm = derivedmesh_from_versemesh(me->vnode, deformedVerts);
|
|
|
|
#endif
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
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
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if((md->mode & required_mode) != required_mode) continue;
|
|
|
|
if(mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue;
|
|
|
|
if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
|
|
|
|
modifier_setError(md, "Internal error, modifier requires "
|
|
|
|
"original data (bad stack position).");
|
- 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
|
|
|
continue;
|
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
if(mti->isDisabled && mti->isDisabled(md)) continue;
|
|
|
|
if(needMapping && !modifier_supportsMapping(md)) continue;
|
2005-07-19 20:14:17 +00:00
|
|
|
|
2006-08-28 01:12:36 +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.
|
|
|
|
*/
|
2005-07-19 20:14:17 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
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.
|
|
|
|
*/
|
2005-07-19 20:14:17 +00:00
|
|
|
numVerts = dm->getNumVerts(dm);
|
2006-08-28 01:12:36 +00:00
|
|
|
deformedVerts =
|
|
|
|
MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv");
|
2005-07-19 20:14:17 +00:00
|
|
|
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 {
|
2006-08-28 01:12:36 +00:00
|
|
|
DerivedMesh *ndm;
|
2005-07-19 20:14:17 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
/* apply vertex coordinates or build a DerivedMesh as necessary */
|
|
|
|
if(dm) {
|
|
|
|
if(deformedVerts) {
|
|
|
|
DerivedMesh *tdm = CDDM_copy(dm);
|
|
|
|
dm->release(dm);
|
|
|
|
dm = tdm;
|
|
|
|
|
|
|
|
CDDM_apply_vert_coords(dm, deformedVerts);
|
|
|
|
CDDM_calc_normals(dm);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dm = CDDM_from_mesh(me);
|
|
|
|
|
|
|
|
if(deformedVerts) {
|
|
|
|
CDDM_apply_vert_coords(dm, deformedVerts);
|
|
|
|
CDDM_calc_normals(dm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ndm = mti->applyModifier(md, ob, dm, useRenderParams,
|
|
|
|
!inputVertexCos);
|
|
|
|
|
|
|
|
if(ndm) {
|
|
|
|
/* if the modifier returned a new dm, release the old one */
|
|
|
|
if(dm && dm != ndm) dm->release(dm);
|
2005-08-03 04:04:05 +00:00
|
|
|
|
2005-07-26 02:44:59 +00:00
|
|
|
dm = ndm;
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(deformedVerts) {
|
|
|
|
if(deformedVerts != inputVertexCos)
|
2005-07-26 02:44:59 +00:00
|
|
|
MEM_freeN(deformedVerts);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2005-07-26 02:44:59 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +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) {
|
|
|
|
*final_r = CDDM_copy(dm);
|
2005-07-19 20:14:17 +00:00
|
|
|
|
|
|
|
dm->release(dm);
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
CDDM_apply_vert_coords(*final_r, deformedVerts);
|
|
|
|
CDDM_calc_normals(*final_r);
|
|
|
|
} else if(dm) {
|
2005-07-19 20:14:17 +00:00
|
|
|
*final_r = dm;
|
2005-07-19 00:21:01 +00:00
|
|
|
} else {
|
2006-08-20 15:22:56 +00:00
|
|
|
#ifdef WITH_VERSE
|
2006-09-07 06:44:25 +00:00
|
|
|
if(me->vnode)
|
|
|
|
*final_r = derivedmesh_from_versemesh(me->vnode, deformedVerts);
|
2006-08-30 03:05:30 +00:00
|
|
|
else {
|
|
|
|
*final_r = CDDM_from_mesh(me);
|
2006-09-07 06:44:25 +00:00
|
|
|
if(deformedVerts) {
|
2006-08-30 03:05:30 +00:00
|
|
|
CDDM_apply_vert_coords(*final_r, deformedVerts);
|
2006-09-07 06:44:25 +00:00
|
|
|
CDDM_calc_normals(*final_r);
|
|
|
|
}
|
2006-08-30 03:05:30 +00:00
|
|
|
}
|
2006-08-20 15:22:56 +00:00
|
|
|
#else
|
2006-08-30 03:05:30 +00:00
|
|
|
*final_r = CDDM_from_mesh(me);
|
2006-09-07 06:44:25 +00:00
|
|
|
if(deformedVerts) {
|
2006-08-30 03:05:30 +00:00
|
|
|
CDDM_apply_vert_coords(*final_r, deformedVerts);
|
2006-09-07 06:44:25 +00:00
|
|
|
CDDM_calc_normals(*final_r);
|
|
|
|
}
|
2006-08-20 15:22:56 +00:00
|
|
|
#endif
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(deformedVerts && deformedVerts != inputVertexCos)
|
2005-07-19 00:21:01 +00:00
|
|
|
MEM_freeN(deformedVerts);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
/* restore mesh in any case */
|
2005-11-23 12:49:22 +00:00
|
|
|
if(fluidsimMeshUsed) ob->data = ob->fluidsimSettings->orgMesh;
|
2005-03-27 20:34:18 +00:00
|
|
|
}
|
|
|
|
|
2005-10-09 16:57:49 +00:00
|
|
|
static float (*editmesh_getVertexCos(EditMesh *em, int *numVerts_r))[3]
|
- 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, 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);
|
|
|
|
}
|
|
|
|
|
2005-10-09 16:59:10 +00:00
|
|
|
return cos;
|
- 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 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;
|
2006-02-08 21:01:00 +00:00
|
|
|
int i, numVerts = 0, cageIndex = modifiers_getCageIndex(ob, NULL);
|
2006-08-28 01:12:36 +00:00
|
|
|
int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
|
- 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
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(cage_r && cageIndex == -1) {
|
|
|
|
*cage_r = getEditMeshDerivedMesh(em, ob, NULL);
|
2005-08-03 04:04:05 +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
|
|
|
|
|
|
|
dm = NULL;
|
2006-08-28 01:12:36 +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
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if((md->mode & required_mode) != required_mode) continue;
|
|
|
|
if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
|
|
|
|
modifier_setError(md, "Internal error, modifier requires"
|
|
|
|
"original data (bad stack position).");
|
- 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
|
|
|
continue;
|
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
if(mti->isDisabled && mti->isDisabled(md)) continue;
|
|
|
|
if(!(mti->flags & eModifierTypeFlag_SupportsEditmode)) 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
|
|
|
|
2006-08-28 01:12:36 +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.
|
|
|
|
*/
|
- 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
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
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.
|
|
|
|
*/
|
- 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
|
|
|
numVerts = dm->getNumVerts(dm);
|
2006-08-28 01:12:36 +00:00
|
|
|
deformedVerts =
|
|
|
|
MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv");
|
- 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->getVertCos(dm, deformedVerts);
|
|
|
|
} else {
|
|
|
|
deformedVerts = editmesh_getVertexCos(em, &numVerts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mti->deformVertsEM(md, ob, em, dm, deformedVerts, numVerts);
|
|
|
|
} else {
|
2006-08-28 01:12:36 +00:00
|
|
|
DerivedMesh *ndm;
|
|
|
|
|
|
|
|
/* apply vertex coordinates or build a DerivedMesh as necessary */
|
|
|
|
if(dm) {
|
|
|
|
if(deformedVerts) {
|
|
|
|
DerivedMesh *tdm = CDDM_copy(dm);
|
|
|
|
if(!(cage_r && dm == *cage_r)) dm->release(dm);
|
|
|
|
dm = tdm;
|
|
|
|
|
|
|
|
CDDM_apply_vert_coords(dm, deformedVerts);
|
|
|
|
CDDM_calc_normals(dm);
|
|
|
|
} else if(cage_r && dm == *cage_r) {
|
|
|
|
/* dm may be changed by this modifier, so we need to copy it
|
|
|
|
*/
|
|
|
|
dm = CDDM_copy(dm);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
dm = CDDM_from_editmesh(em, ob->data);
|
|
|
|
|
|
|
|
if(deformedVerts) {
|
|
|
|
CDDM_apply_vert_coords(dm, deformedVerts);
|
|
|
|
CDDM_calc_normals(dm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ndm = mti->applyModifierEM(md, ob, em, dm);
|
2005-08-03 04:04:05 +00:00
|
|
|
|
|
|
|
if (ndm) {
|
2006-08-28 01:12:36 +00:00
|
|
|
if(dm && dm != ndm)
|
|
|
|
dm->release(dm);
|
2005-08-03 04:04:05 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(cage_r && i == cageIndex) {
|
|
|
|
if(dm && deformedVerts) {
|
|
|
|
*cage_r = CDDM_copy(dm);
|
|
|
|
CDDM_apply_vert_coords(*cage_r, deformedVerts);
|
|
|
|
} else if(dm) {
|
2005-08-03 04:04:05 +00:00
|
|
|
*cage_r = dm;
|
|
|
|
} else {
|
2006-08-28 01:12:36 +00:00
|
|
|
*cage_r =
|
|
|
|
getEditMeshDerivedMesh(em, ob,
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-28 01:12:36 +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) {
|
|
|
|
*final_r = CDDM_copy(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
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(!(cage_r && dm == *cage_r)) dm->release(dm);
|
|
|
|
|
|
|
|
CDDM_apply_vert_coords(*final_r, deformedVerts);
|
|
|
|
CDDM_calc_normals(*final_r);
|
- 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 {
|
2006-08-28 01:12:36 +00:00
|
|
|
*final_r = getEditMeshDerivedMesh(em, ob, deformedVerts);
|
- 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-19 00:21:01 +00:00
|
|
|
/***/
|
|
|
|
|
2005-08-23 20:04:10 +00:00
|
|
|
|
|
|
|
/* Something of a hack, at the moment deal with weightpaint
|
|
|
|
* by tucking into colors during modifier eval, only in
|
|
|
|
* wpaint mode. Works ok but need to make sure recalc
|
|
|
|
* happens on enter/exit wpaint.
|
|
|
|
*/
|
|
|
|
|
2006-09-03 12:16:14 +00:00
|
|
|
void weight_to_rgb(float input, float *fr, float *fg, float *fb)
|
2005-08-23 20:04:10 +00:00
|
|
|
{
|
|
|
|
float blend;
|
|
|
|
|
|
|
|
blend= ((input/2.0f)+0.5f);
|
|
|
|
|
|
|
|
if (input<=0.25f){ // blue->cyan
|
|
|
|
*fr= 0.0f;
|
|
|
|
*fg= blend*input*4.0f;
|
|
|
|
*fb= blend;
|
|
|
|
}
|
|
|
|
else if (input<=0.50f){ // cyan->green
|
|
|
|
*fr= 0.0f;
|
|
|
|
*fg= blend;
|
|
|
|
*fb= blend*(1.0f-((input-0.25f)*4.0f));
|
|
|
|
}
|
|
|
|
else if (input<=0.75){ // green->yellow
|
|
|
|
*fr= blend * ((input-0.50f)*4.0f);
|
|
|
|
*fg= blend;
|
|
|
|
*fb= 0.0f;
|
|
|
|
}
|
|
|
|
else if (input<=1.0){ // yellow->red
|
|
|
|
*fr= blend;
|
|
|
|
*fg= blend * (1.0f-((input-0.75f)*4.0f));
|
|
|
|
*fb= 0.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void calc_weightpaint_vert_color(Object *ob, int vert, unsigned char *col)
|
|
|
|
{
|
|
|
|
Mesh *me = ob->data;
|
|
|
|
float fr, fg, fb, input = 0.0f;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (me->dvert) {
|
|
|
|
for (i=0; i<me->dvert[vert].totweight; i++)
|
|
|
|
if (me->dvert[vert].dw[i].def_nr==ob->actdef-1)
|
|
|
|
input+=me->dvert[vert].dw[i].weight;
|
|
|
|
}
|
|
|
|
|
|
|
|
CLAMP(input, 0.0f, 1.0f);
|
|
|
|
|
|
|
|
weight_to_rgb(input, &fr, &fg, &fb);
|
|
|
|
|
|
|
|
col[3] = (unsigned char)(fr * 255.0f);
|
|
|
|
col[2] = (unsigned char)(fg * 255.0f);
|
|
|
|
col[1] = (unsigned char)(fb * 255.0f);
|
|
|
|
col[0] = 255;
|
|
|
|
}
|
|
|
|
static unsigned char *calc_weightpaint_colors(Object *ob)
|
|
|
|
{
|
|
|
|
Mesh *me = ob->data;
|
|
|
|
MFace *mf = me->mface;
|
|
|
|
unsigned char *wtcol;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
wtcol = MEM_callocN (sizeof (unsigned char) * me->totface*4*4, "weightmap");
|
|
|
|
|
|
|
|
memset(wtcol, 0x55, sizeof (unsigned char) * me->totface*4*4);
|
|
|
|
for (i=0; i<me->totface; i++, mf++){
|
|
|
|
calc_weightpaint_vert_color(ob, mf->v1, &wtcol[(i*4 + 0)*4]);
|
|
|
|
calc_weightpaint_vert_color(ob, mf->v2, &wtcol[(i*4 + 1)*4]);
|
|
|
|
calc_weightpaint_vert_color(ob, mf->v3, &wtcol[(i*4 + 2)*4]);
|
|
|
|
if (mf->v4)
|
|
|
|
calc_weightpaint_vert_color(ob, mf->v4, &wtcol[(i*4 + 3)*4]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return wtcol;
|
|
|
|
}
|
|
|
|
|
- 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)
|
|
|
|
{
|
2005-08-23 20:04:10 +00:00
|
|
|
Mesh *me = ob->data;
|
- 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
|
|
|
float min[3], max[3];
|
|
|
|
|
|
|
|
clear_mesh_caches(ob);
|
|
|
|
|
2005-10-09 18:38:40 +00:00
|
|
|
if(ob!=G.obedit) {
|
2006-03-11 16:13:10 +00:00
|
|
|
Object *obact = G.scene->basact?G.scene->basact->object:NULL;
|
|
|
|
int editing = (G.f & (G_FACESELECT|G_WEIGHTPAINT|G_VERTEXPAINT|G_TEXTUREPAINT));
|
|
|
|
int needMapping = editing && (ob==obact);
|
|
|
|
|
|
|
|
if( (G.f & G_WEIGHTPAINT) && ob==obact ) {
|
2005-10-09 18:38:40 +00:00
|
|
|
MCol *mcol = me->mcol;
|
|
|
|
TFace *tface = me->tface;
|
2005-08-23 20:04:10 +00:00
|
|
|
|
2005-10-09 18:38:40 +00:00
|
|
|
me->mcol = (MCol*) calc_weightpaint_colors(ob);
|
2006-08-28 01:12:36 +00:00
|
|
|
if(me->tface) {
|
|
|
|
me->tface = MEM_dupallocN(me->tface);
|
|
|
|
mcol_to_tface(me, 1);
|
|
|
|
}
|
2005-08-23 20:04:10 +00:00
|
|
|
|
2006-03-11 16:13:10 +00:00
|
|
|
mesh_calc_modifiers(ob, NULL, &ob->derivedDeform, &ob->derivedFinal, 0, 1,
|
|
|
|
needMapping);
|
2005-08-23 20:04:10 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if(me->mcol) MEM_freeN(me->mcol);
|
|
|
|
if(me->tface) MEM_freeN(me->tface);
|
2005-10-09 18:38:40 +00:00
|
|
|
me->mcol = mcol;
|
|
|
|
me->tface = tface;
|
|
|
|
} else {
|
2006-08-28 01:12:36 +00:00
|
|
|
mesh_calc_modifiers(ob, NULL, &ob->derivedDeform,
|
|
|
|
&ob->derivedFinal, 0, 1, needMapping);
|
2005-10-09 18:38:40 +00:00
|
|
|
}
|
2005-07-23 07:45:39 +00:00
|
|
|
|
2005-10-09 18:38:40 +00:00
|
|
|
INIT_MINMAX(min, max);
|
2005-07-19 02:36:21 +00:00
|
|
|
|
2005-10-09 18:38:40 +00:00
|
|
|
ob->derivedFinal->getMinMax(ob->derivedFinal, min, max);
|
2005-07-19 02:36:21 +00:00
|
|
|
|
2005-10-09 18:38:40 +00:00
|
|
|
boundbox_set_from_min_max(mesh_get_bb(ob->data), min, max);
|
|
|
|
}
|
- 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 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 {
|
2006-06-20 19:02:24 +00:00
|
|
|
PartEff *paf= give_parteff(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
|
|
|
mesh_build_data(ob);
|
2006-06-20 19:02:24 +00:00
|
|
|
|
2006-08-14 13:41:22 +00:00
|
|
|
if(paf) {
|
2006-06-20 19:02:24 +00:00
|
|
|
if((paf->flag & PAF_STATIC) || (ob->recalc & OB_RECALC_TIME)==0)
|
|
|
|
build_particle_system(ob);
|
2006-08-14 13:41:22 +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
|
|
|
}
|
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;
|
2006-11-06 01:08:26 +00:00
|
|
|
Mesh *m= get_mesh(ob);
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
/* Goto the pin level for multires */
|
|
|
|
if(m->mr) {
|
|
|
|
m->mr->newlvl= m->mr->pinlvl;
|
|
|
|
multires_set_level(ob,m);
|
|
|
|
}
|
2005-07-16 21:03:28 +00:00
|
|
|
|
2006-03-11 16:13:10 +00:00
|
|
|
mesh_calc_modifiers(ob, NULL, NULL, &final, 1, 1, 0);
|
2005-07-16 21:03:28 +00:00
|
|
|
|
2006-11-06 01:08:26 +00:00
|
|
|
/* Propagate the changes to render level - fails if mesh topology changed */
|
|
|
|
if(m->mr) {
|
|
|
|
if(final->getNumVerts(final) == m->totvert &&
|
|
|
|
final->getNumFaces(final) == m->totface) {
|
|
|
|
for(i=0; i<m->totvert; ++i)
|
|
|
|
memcpy(&m->mvert[i], CustomData_get(&final->vertData, i, LAYERTYPE_MVERT), sizeof(MVert));
|
|
|
|
|
|
|
|
final->release(final);
|
|
|
|
|
|
|
|
m->mr->newlvl= m->mr->renderlvl;
|
|
|
|
multires_set_level(ob,m);
|
|
|
|
final= getMeshDerivedMesh(m,ob,NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-19 00:21:01 +00:00
|
|
|
return final;
|
2005-07-16 21:03:28 +00:00
|
|
|
}
|
|
|
|
|
2006-09-17 05:15:56 +00:00
|
|
|
DerivedMesh *mesh_create_derived_view(Object *ob)
|
|
|
|
{
|
|
|
|
DerivedMesh *final;
|
|
|
|
|
|
|
|
mesh_calc_modifiers(ob, NULL, NULL, &final, 0, 1, 0);
|
|
|
|
|
|
|
|
return final;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2006-03-11 16:13:10 +00:00
|
|
|
mesh_calc_modifiers(ob, vertCos, NULL, &final, 0, 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
|
|
|
|
2006-03-11 16:13:10 +00:00
|
|
|
mesh_calc_modifiers(ob, vertCos, NULL, &final, 1, 0, 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)
|
|
|
|
{
|
2006-08-28 01:12:36 +00:00
|
|
|
return getEditMeshDerivedMesh(G.editMesh, G.obedit, NULL);
|
2005-08-06 20:44:59 +00:00
|
|
|
}
|
2005-09-18 13:27:12 +00:00
|
|
|
|
2005-09-23 14:42:14 +00:00
|
|
|
|
2005-11-12 10:35:14 +00:00
|
|
|
/* ********* For those who don't grasp derived stuff! (ton) :) *************** */
|
|
|
|
|
|
|
|
static void make_vertexcosnos__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
|
|
|
|
{
|
|
|
|
float *vec = userData;
|
|
|
|
|
|
|
|
vec+= 6*index;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
/* check if we've been here before (normal should not be 0) */
|
|
|
|
if(vec[3] || vec[4] || vec[5]) return;
|
|
|
|
|
2005-11-12 10:35:14 +00:00
|
|
|
VECCOPY(vec, co);
|
|
|
|
vec+= 3;
|
|
|
|
if(no_f) {
|
|
|
|
VECCOPY(vec, no_f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
VECCOPY(vec, no_s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* always returns original amount me->totvert of vertices and normals, but fully deformed and subsurfered */
|
|
|
|
/* this is needed for all code using vertexgroups (no subsurf support) */
|
|
|
|
/* it stores the normals as floats, but they can still be scaled as shorts (32767 = unit) */
|
|
|
|
/* in use now by vertex/weight paint and particle generating */
|
|
|
|
|
|
|
|
float *mesh_get_mapped_verts_nors(Object *ob)
|
|
|
|
{
|
|
|
|
Mesh *me= ob->data;
|
2005-11-12 14:39:14 +00:00
|
|
|
DerivedMesh *dm;
|
2005-11-12 10:35:14 +00:00
|
|
|
float *vertexcosnos;
|
|
|
|
int needsFree;
|
|
|
|
|
|
|
|
/* lets prevent crashing... */
|
|
|
|
if(ob->type!=OB_MESH || me->totvert==0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
dm= mesh_get_derived_final(ob, &needsFree);
|
2006-08-28 01:12:36 +00:00
|
|
|
vertexcosnos= MEM_callocN(6*sizeof(float)*me->totvert, "vertexcosnos map");
|
2005-11-12 10:35:14 +00:00
|
|
|
|
2005-11-23 19:19:44 +00:00
|
|
|
if(dm->foreachMappedVert) {
|
2005-11-12 10:35:14 +00:00
|
|
|
dm->foreachMappedVert(dm, make_vertexcosnos__mapFunc, vertexcosnos);
|
2005-11-23 19:19:44 +00:00
|
|
|
}
|
2005-11-12 10:35:14 +00:00
|
|
|
else {
|
|
|
|
float *fp= vertexcosnos;
|
|
|
|
int a;
|
|
|
|
|
|
|
|
for(a=0; a< me->totvert; a++, fp+=6) {
|
|
|
|
dm->getVertCo(dm, a, fp);
|
|
|
|
dm->getVertNo(dm, a, fp+3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needsFree) dm->release(dm);
|
|
|
|
return vertexcosnos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-09 07:56:26 +00:00
|
|
|
/* ************************* fluidsim bobj file handling **************************** */
|
2005-09-18 13:27:12 +00:00
|
|
|
|
2006-08-22 11:18:00 +00:00
|
|
|
#ifndef DISABLE_ELBEEM
|
|
|
|
|
2005-11-09 11:10:15 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#ifndef snprintf
|
|
|
|
#define snprintf _snprintf
|
|
|
|
#endif
|
|
|
|
#endif
|
2005-09-18 13:27:12 +00:00
|
|
|
|
2005-11-09 11:10:15 +00:00
|
|
|
/* write .bobj.gz file for a mesh object */
|
2006-05-11 08:09:02 +00:00
|
|
|
void writeBobjgz(char *filename, struct Object *ob, int useGlobalCoords, int append, float time)
|
2005-09-18 13:27:12 +00:00
|
|
|
{
|
2005-09-28 16:20:57 +00:00
|
|
|
char debugStrBuffer[256];
|
2005-09-18 13:27:12 +00:00
|
|
|
int wri,i,j;
|
|
|
|
float wrf;
|
|
|
|
gzFile gzf;
|
|
|
|
DispListMesh *dlm = NULL;
|
|
|
|
DerivedMesh *dm;
|
|
|
|
float vec[3];
|
|
|
|
float rotmat[3][3];
|
|
|
|
MFace *mface = NULL;
|
2006-05-11 08:09:02 +00:00
|
|
|
//if(append)return; // DEBUG
|
2005-09-18 13:27:12 +00:00
|
|
|
|
|
|
|
if(!ob->data || (ob->type!=OB_MESH)) {
|
2005-09-28 16:20:57 +00:00
|
|
|
snprintf(debugStrBuffer,256,"Writing GZ_BOBJ Invalid object %s ...\n", ob->id.name);
|
|
|
|
elbeemDebugOut(debugStrBuffer);
|
2005-09-18 13:27:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if((ob->size[0]<0.0) || (ob->size[0]<0.0) || (ob->size[0]<0.0) ) {
|
2005-09-28 16:20:57 +00:00
|
|
|
snprintf(debugStrBuffer,256,"\nfluidSim::writeBobjgz:: Warning object %s has negative scaling - check triangle ordering...?\n\n", ob->id.name);
|
|
|
|
elbeemDebugOut(debugStrBuffer);
|
2005-09-18 13:27:12 +00:00
|
|
|
}
|
|
|
|
|
2005-09-28 16:20:57 +00:00
|
|
|
snprintf(debugStrBuffer,256,"Writing GZ_BOBJ '%s' ... ",filename); elbeemDebugOut(debugStrBuffer);
|
2006-05-11 08:09:02 +00:00
|
|
|
if(append) gzf = gzopen(filename, "a+b9");
|
|
|
|
else gzf = gzopen(filename, "wb9");
|
2005-09-18 13:27:12 +00:00
|
|
|
if (!gzf) {
|
2005-09-28 16:20:57 +00:00
|
|
|
snprintf(debugStrBuffer,256,"writeBobjgz::error - Unable to open file for writing '%s'\n", filename);
|
|
|
|
elbeemDebugOut(debugStrBuffer);
|
2005-09-18 13:27:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dm = mesh_create_derived_render(ob);
|
2006-05-11 08:09:02 +00:00
|
|
|
//dm = mesh_create_derived_no_deform(ob,NULL);
|
2005-09-18 13:27:12 +00:00
|
|
|
dlm = dm->convertToDispListMesh(dm, 1);
|
|
|
|
mface = dlm->mface;
|
|
|
|
|
2006-05-11 08:09:02 +00:00
|
|
|
// write time value for appended anim mesh
|
|
|
|
if(append) {
|
|
|
|
gzwrite(gzf, &time, sizeof(time));
|
|
|
|
}
|
|
|
|
|
|
|
|
// continue with verts/norms
|
2005-09-28 16:20:57 +00:00
|
|
|
if(sizeof(wri)!=4) { snprintf(debugStrBuffer,256,"Writing GZ_BOBJ, Invalid int size %d...\n", wri); elbeemDebugOut(debugStrBuffer); return; } // paranoia check
|
2005-09-18 13:27:12 +00:00
|
|
|
wri = dlm->totvert;
|
|
|
|
gzwrite(gzf, &wri, sizeof(wri));
|
|
|
|
for(i=0; i<wri;i++) {
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
VECCOPY(vec, dlm->mvert[i].co);
|
2006-05-11 08:09:02 +00:00
|
|
|
if(useGlobalCoords) { Mat4MulVecfl(ob->obmat, vec); }
|
2005-09-18 13:27:12 +00:00
|
|
|
for(j=0; j<3; j++) {
|
|
|
|
wrf = vec[j];
|
|
|
|
gzwrite(gzf, &wrf, sizeof( wrf ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// should be the same as Vertices.size
|
|
|
|
wri = dlm->totvert;
|
|
|
|
gzwrite(gzf, &wri, sizeof(wri));
|
|
|
|
EulToMat3(ob->rot, rotmat);
|
|
|
|
for(i=0; i<wri;i++) {
|
|
|
|
VECCOPY(vec, dlm->mvert[i].no);
|
|
|
|
Normalise(vec);
|
2006-05-11 08:09:02 +00:00
|
|
|
if(useGlobalCoords) { Mat3MulVecfl(rotmat, vec); }
|
2005-09-18 13:27:12 +00:00
|
|
|
for(j=0; j<3; j++) {
|
2005-09-23 14:42:14 +00:00
|
|
|
wrf = vec[j];
|
2005-09-18 13:27:12 +00:00
|
|
|
gzwrite(gzf, &wrf, sizeof( wrf ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-11 08:09:02 +00:00
|
|
|
// append only writes verts&norms
|
|
|
|
if(!append) {
|
|
|
|
//float side1[3],side2[3],norm1[3],norm2[3];
|
|
|
|
//float inpf;
|
2005-09-18 13:27:12 +00:00
|
|
|
|
2006-05-11 08:09:02 +00:00
|
|
|
// compute no. of triangles
|
|
|
|
wri = 0;
|
|
|
|
for(i=0; i<dlm->totface; i++) {
|
|
|
|
wri++;
|
|
|
|
if(mface[i].v4) { wri++; }
|
|
|
|
}
|
|
|
|
gzwrite(gzf, &wri, sizeof(wri));
|
|
|
|
for(i=0; i<dlm->totface; i++) {
|
|
|
|
|
|
|
|
int face[4];
|
|
|
|
face[0] = mface[i].v1;
|
|
|
|
face[1] = mface[i].v2;
|
|
|
|
face[2] = mface[i].v3;
|
|
|
|
face[3] = mface[i].v4;
|
|
|
|
//snprintf(debugStrBuffer,256,"F %s %d = %d,%d,%d,%d \n",ob->id.name, i, face[0],face[1],face[2],face[3] ); elbeemDebugOut(debugStrBuffer);
|
|
|
|
//VecSubf(side1, dlm->mvert[face[1]].co,dlm->mvert[face[0]].co);
|
|
|
|
//VecSubf(side2, dlm->mvert[face[2]].co,dlm->mvert[face[0]].co);
|
|
|
|
//Crossf(norm1,side1,side2);
|
2005-09-18 13:27:12 +00:00
|
|
|
gzwrite(gzf, &(face[0]), sizeof( face[0] ));
|
2006-05-11 08:09:02 +00:00
|
|
|
gzwrite(gzf, &(face[1]), sizeof( face[1] ));
|
2005-09-18 13:27:12 +00:00
|
|
|
gzwrite(gzf, &(face[2]), sizeof( face[2] ));
|
2006-05-11 08:09:02 +00:00
|
|
|
if(face[3]) {
|
|
|
|
//VecSubf(side1, dlm->mvert[face[2]].co,dlm->mvert[face[0]].co);
|
|
|
|
//VecSubf(side2, dlm->mvert[face[3]].co,dlm->mvert[face[0]].co);
|
|
|
|
//Crossf(norm2,side1,side2);
|
|
|
|
//inpf = Inpf(norm1,norm2);
|
|
|
|
//if(inpf>0.) {
|
|
|
|
gzwrite(gzf, &(face[0]), sizeof( face[0] ));
|
|
|
|
gzwrite(gzf, &(face[2]), sizeof( face[2] ));
|
|
|
|
gzwrite(gzf, &(face[3]), sizeof( face[3] ));
|
|
|
|
//} else {
|
|
|
|
//gzwrite(gzf, &(face[0]), sizeof( face[0] ));
|
|
|
|
//gzwrite(gzf, &(face[3]), sizeof( face[3] ));
|
|
|
|
//gzwrite(gzf, &(face[2]), sizeof( face[2] ));
|
|
|
|
//}
|
|
|
|
} // quad
|
2005-09-18 13:27:12 +00:00
|
|
|
}
|
|
|
|
}
|
2005-11-09 07:56:26 +00:00
|
|
|
|
|
|
|
snprintf(debugStrBuffer,256,"Done. #Vertices: %d, #Triangles: %d\n", dlm->totvert, dlm->totface );
|
|
|
|
elbeemDebugOut(debugStrBuffer);
|
2005-09-18 13:27:12 +00:00
|
|
|
|
|
|
|
gzclose( gzf );
|
|
|
|
if(dlm) displistmesh_free(dlm);
|
|
|
|
dm->release(dm);
|
|
|
|
}
|
|
|
|
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
void initElbeemMesh(struct Object *ob,
|
|
|
|
int *numVertices, float **vertices,
|
2006-05-11 08:09:02 +00:00
|
|
|
int *numTriangles, int **triangles,
|
|
|
|
int useGlobalCoords)
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
{
|
|
|
|
DispListMesh *dlm = NULL;
|
|
|
|
DerivedMesh *dm = NULL;
|
|
|
|
MFace *mface = NULL;
|
|
|
|
int countTris=0, i;
|
|
|
|
float *verts;
|
|
|
|
int *tris;
|
|
|
|
|
|
|
|
dm = mesh_create_derived_render(ob);
|
2006-05-11 08:09:02 +00:00
|
|
|
//dm = mesh_create_derived_no_deform(ob,NULL);
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
if(!dm) { *numVertices = *numTriangles = 0; *triangles=NULL; *vertices=NULL; }
|
|
|
|
dlm = dm->convertToDispListMesh(dm, 1);
|
|
|
|
if(!dlm) { dm->release(dm); *numVertices = *numTriangles = 0; *triangles=NULL; *vertices=NULL; }
|
|
|
|
mface = dlm->mface;
|
|
|
|
|
|
|
|
*numVertices = dlm->totvert;
|
|
|
|
verts = MEM_callocN( dlm->totvert*3*sizeof(float), "elbeemmesh_vertices");
|
|
|
|
for(i=0; i<dlm->totvert; i++) {
|
|
|
|
VECCOPY( &verts[i*3], dlm->mvert[i].co);
|
2006-05-11 08:09:02 +00:00
|
|
|
if(useGlobalCoords) { Mat4MulVecfl(ob->obmat, &verts[i*3]); }
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
}
|
|
|
|
*vertices = verts;
|
|
|
|
|
|
|
|
for(i=0; i<dlm->totface; i++) {
|
|
|
|
countTris++;
|
|
|
|
if(mface[i].v4) { countTris++; }
|
|
|
|
}
|
|
|
|
*numTriangles = countTris;
|
|
|
|
tris = MEM_callocN( countTris*3*sizeof(int), "elbeemmesh_triangles");
|
|
|
|
countTris = 0;
|
|
|
|
for(i=0; i<dlm->totface; i++) {
|
|
|
|
int face[4];
|
|
|
|
face[0] = mface[i].v1;
|
|
|
|
face[1] = mface[i].v2;
|
|
|
|
face[2] = mface[i].v3;
|
|
|
|
face[3] = mface[i].v4;
|
|
|
|
|
|
|
|
tris[countTris*3+0] = face[0];
|
|
|
|
tris[countTris*3+1] = face[1];
|
|
|
|
tris[countTris*3+2] = face[2];
|
|
|
|
countTris++;
|
|
|
|
if(face[3]) {
|
|
|
|
tris[countTris*3+0] = face[0];
|
|
|
|
tris[countTris*3+1] = face[2];
|
|
|
|
tris[countTris*3+2] = face[3];
|
|
|
|
countTris++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*triangles = tris;
|
|
|
|
|
|
|
|
if(dlm) displistmesh_free(dlm);
|
|
|
|
dm->release(dm);
|
|
|
|
}
|
|
|
|
|
2005-09-18 13:27:12 +00:00
|
|
|
/* read .bobj.gz file into a fluidsimDerivedMesh struct */
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
Mesh* readBobjgz(char *filename, Mesh *orgmesh, float* bbstart, float *bbsize) //, fluidsimDerivedMesh *fsdm)
|
2005-09-18 13:27:12 +00:00
|
|
|
{
|
|
|
|
int wri,i,j;
|
2005-09-28 16:20:57 +00:00
|
|
|
char debugStrBuffer[256];
|
2005-09-18 13:27:12 +00:00
|
|
|
float wrf;
|
|
|
|
Mesh *newmesh;
|
2005-11-09 07:56:26 +00:00
|
|
|
const int debugBobjRead = 1;
|
2005-09-18 13:27:12 +00:00
|
|
|
// init data from old mesh (materials,flags)
|
|
|
|
MFace *origMFace = &((MFace*) orgmesh->mface)[0];
|
2005-11-09 07:56:26 +00:00
|
|
|
int mat_nr = -1;
|
|
|
|
int flag = -1;
|
2005-09-18 13:27:12 +00:00
|
|
|
MFace *fsface = NULL;
|
|
|
|
int gotBytes;
|
2005-09-23 14:42:14 +00:00
|
|
|
gzFile gzf;
|
2005-09-18 13:27:12 +00:00
|
|
|
|
|
|
|
if(!orgmesh) return NULL;
|
2005-11-09 07:56:26 +00:00
|
|
|
if(!origMFace) return NULL;
|
|
|
|
mat_nr = origMFace->mat_nr;
|
|
|
|
flag = origMFace->flag;
|
2005-09-18 13:27:12 +00:00
|
|
|
|
|
|
|
// similar to copy_mesh
|
|
|
|
newmesh = MEM_dupallocN(orgmesh);
|
2005-09-23 14:42:14 +00:00
|
|
|
newmesh->mat= orgmesh->mat;
|
2005-09-18 13:27:12 +00:00
|
|
|
|
|
|
|
newmesh->mvert= NULL;
|
|
|
|
newmesh->medge= NULL;
|
|
|
|
newmesh->mface= NULL;
|
|
|
|
newmesh->tface= NULL;
|
|
|
|
newmesh->dface= NULL;
|
|
|
|
|
2005-09-23 14:42:14 +00:00
|
|
|
newmesh->dvert = NULL;
|
2005-09-18 13:27:12 +00:00
|
|
|
|
2005-09-23 14:42:14 +00:00
|
|
|
newmesh->mcol= NULL;
|
|
|
|
newmesh->msticky= NULL;
|
2005-09-18 13:27:12 +00:00
|
|
|
newmesh->texcomesh= NULL;
|
|
|
|
|
2005-09-23 14:42:14 +00:00
|
|
|
newmesh->key= NULL;
|
2005-09-18 13:27:12 +00:00
|
|
|
newmesh->totface = 0;
|
|
|
|
newmesh->totvert = 0;
|
|
|
|
newmesh->totedge = 0;
|
2005-09-23 14:42:14 +00:00
|
|
|
newmesh->medge = NULL;
|
2005-09-18 13:27:12 +00:00
|
|
|
|
|
|
|
|
2005-09-28 16:20:57 +00:00
|
|
|
snprintf(debugStrBuffer,256,"Reading '%s' GZ_BOBJ... ",filename); elbeemDebugOut(debugStrBuffer);
|
2005-09-18 13:27:12 +00:00
|
|
|
gzf = gzopen(filename, "rb");
|
2005-09-23 14:42:14 +00:00
|
|
|
// gzf = fopen(filename, "rb");
|
|
|
|
// debug: fread(b,c,1,a) = gzread(a,b,c)
|
2005-09-18 13:27:12 +00:00
|
|
|
if (!gzf) {
|
2005-09-28 16:20:57 +00:00
|
|
|
//snprintf(debugStrBuffer,256,"readBobjgz::error - Unable to open file for reading '%s'\n", filename); // DEBUG
|
2005-09-18 13:27:12 +00:00
|
|
|
MEM_freeN(newmesh);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-09-28 16:20:57 +00:00
|
|
|
//if(sizeof(wri)!=4) { snprintf(debugStrBuffer,256,"Reading GZ_BOBJ, Invalid int size %d...\n", wri); return NULL; } // paranoia check
|
2005-09-18 13:27:12 +00:00
|
|
|
gotBytes = gzread(gzf, &wri, sizeof(wri));
|
|
|
|
newmesh->totvert = wri;
|
2005-09-23 14:42:14 +00:00
|
|
|
newmesh->mvert = MEM_callocN(sizeof(MVert)*newmesh->totvert, "fluidsimDerivedMesh_bobjvertices");
|
2005-09-28 16:20:57 +00:00
|
|
|
if(debugBobjRead){ snprintf(debugStrBuffer,256,"#vertices %d ", newmesh->totvert); elbeemDebugOut(debugStrBuffer); } //DEBUG
|
2005-09-18 13:27:12 +00:00
|
|
|
for(i=0; i<newmesh->totvert;i++) {
|
2005-09-28 16:20:57 +00:00
|
|
|
//if(debugBobjRead) snprintf(debugStrBuffer,256,"V %d = ",i);
|
2005-09-18 13:27:12 +00:00
|
|
|
for(j=0; j<3; j++) {
|
|
|
|
gotBytes = gzread(gzf, &wrf, sizeof( wrf ));
|
|
|
|
newmesh->mvert[i].co[j] = wrf;
|
2005-09-28 16:20:57 +00:00
|
|
|
//if(debugBobjRead) snprintf(debugStrBuffer,256,"%25.20f ", wrf);
|
2005-09-18 13:27:12 +00:00
|
|
|
}
|
2005-09-28 16:20:57 +00:00
|
|
|
//if(debugBobjRead) snprintf(debugStrBuffer,256,"\n");
|
2005-09-18 13:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// should be the same as Vertices.size
|
|
|
|
gotBytes = gzread(gzf, &wri, sizeof(wri));
|
|
|
|
if(wri != newmesh->totvert) {
|
|
|
|
// complain #vertices has to be equal to #normals, reset&abort
|
|
|
|
MEM_freeN(newmesh->mvert);
|
|
|
|
MEM_freeN(newmesh);
|
2005-09-28 16:20:57 +00:00
|
|
|
snprintf(debugStrBuffer,256,"Reading GZ_BOBJ, #normals=%d, #vertices=%d, aborting...\n", wri,newmesh->totvert );
|
2005-09-18 13:27:12 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
for(i=0; i<newmesh->totvert;i++) {
|
|
|
|
for(j=0; j<3; j++) {
|
|
|
|
gotBytes = gzread(gzf, &wrf, sizeof( wrf ));
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
newmesh->mvert[i].no[j] = (short)(wrf*32767.0f);
|
|
|
|
//newmesh->mvert[i].no[j] = 0.5; // DEBUG tst
|
2005-09-18 13:27:12 +00:00
|
|
|
}
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
//fprintf(stderr," DEBDPCN nm%d, %d = %d,%d,%d \n",
|
|
|
|
//(int)(newmesh->mvert), i, newmesh->mvert[i].no[0], newmesh->mvert[i].no[1], newmesh->mvert[i].no[2]);
|
2005-09-18 13:27:12 +00:00
|
|
|
}
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
//fprintf(stderr," DPCN 0 = %d,%d,%d \n", newmesh->mvert[0].no[0], newmesh->mvert[0].no[1], newmesh->mvert[0].no[2]);
|
2005-09-18 13:27:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* compute no. of triangles */
|
|
|
|
gotBytes = gzread(gzf, &wri, sizeof(wri));
|
|
|
|
newmesh->totface = wri;
|
2005-09-23 14:42:14 +00:00
|
|
|
newmesh->mface = MEM_callocN(sizeof(MFace)*newmesh->totface, "fluidsimDerivedMesh_bobjfaces");
|
2005-09-28 16:20:57 +00:00
|
|
|
if(debugBobjRead){ snprintf(debugStrBuffer,256,"#faces %d ", newmesh->totface); elbeemDebugOut(debugStrBuffer); } //DEBUG
|
2005-09-18 13:27:12 +00:00
|
|
|
fsface = newmesh->mface;
|
|
|
|
for(i=0; i<newmesh->totface; i++) {
|
|
|
|
int face[4];
|
|
|
|
|
|
|
|
gotBytes = gzread(gzf, &(face[0]), sizeof( face[0] ));
|
|
|
|
gotBytes = gzread(gzf, &(face[1]), sizeof( face[1] ));
|
|
|
|
gotBytes = gzread(gzf, &(face[2]), sizeof( face[2] ));
|
|
|
|
face[3] = 0;
|
|
|
|
|
|
|
|
fsface[i].v1 = face[0];
|
|
|
|
fsface[i].v2 = face[1];
|
|
|
|
fsface[i].v3 = face[2];
|
|
|
|
fsface[i].v4 = face[3];
|
2005-09-23 14:42:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// correct triangles with v3==0 for blender, cycle verts
|
|
|
|
for(i=0; i<newmesh->totface; i++) {
|
|
|
|
if(!fsface[i].v3) {
|
|
|
|
int temp = fsface[i].v1;
|
|
|
|
fsface[i].v1 = fsface[i].v2;
|
|
|
|
fsface[i].v2 = fsface[i].v3;
|
|
|
|
fsface[i].v3 = temp;
|
|
|
|
}
|
2005-09-18 13:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gzclose( gzf );
|
|
|
|
for(i=0;i<newmesh->totface;i++) {
|
|
|
|
fsface[i].mat_nr = mat_nr;
|
|
|
|
fsface[i].flag = flag;
|
2005-09-23 14:42:14 +00:00
|
|
|
fsface[i].edcode = ME_V1V2 | ME_V2V3 | ME_V3V1;
|
2005-09-28 16:20:57 +00:00
|
|
|
//snprintf(debugStrBuffer,256,"%d : %d,%d,%d\n", i,fsface[i].mat_nr, fsface[i].flag, fsface[i].edcode );
|
2005-09-18 13:27:12 +00:00
|
|
|
}
|
|
|
|
|
2005-09-28 16:20:57 +00:00
|
|
|
snprintf(debugStrBuffer,256," (%d,%d) done\n", newmesh->totvert,newmesh->totface); elbeemDebugOut(debugStrBuffer); //DEBUG
|
2005-09-18 13:27:12 +00:00
|
|
|
return newmesh;
|
|
|
|
}
|
|
|
|
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
/* read zipped fluidsim velocities into the co's of the fluidsimsettings normals struct */
|
|
|
|
void readVelgz(char *filename, Object *srcob)
|
|
|
|
{
|
|
|
|
char debugStrBuffer[256];
|
|
|
|
int wri, i, j;
|
|
|
|
float wrf;
|
|
|
|
gzFile gzf;
|
|
|
|
MVert *vverts = srcob->fluidsimSettings->meshSurfNormals;
|
|
|
|
int len = strlen(filename);
|
|
|
|
Mesh *mesh = srcob->data;
|
|
|
|
// mesh and vverts have to be valid from loading...
|
|
|
|
|
|
|
|
// clean up in any case
|
|
|
|
for(i=0; i<mesh->totvert;i++) {
|
|
|
|
for(j=0; j<3; j++) {
|
|
|
|
vverts[i].co[j] = 0.;
|
|
|
|
}
|
|
|
|
}
|
2006-03-29 07:35:54 +00:00
|
|
|
if(srcob->fluidsimSettings->domainNovecgen>0) return;
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
|
|
|
|
if(len<7) {
|
|
|
|
//printf("readVelgz Eror: invalid filename '%s'\n",filename); // DEBUG
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// .bobj.gz , correct filename
|
|
|
|
// 87654321
|
|
|
|
filename[len-6] = 'v';
|
|
|
|
filename[len-5] = 'e';
|
|
|
|
filename[len-4] = 'l';
|
|
|
|
|
|
|
|
snprintf(debugStrBuffer,256,"Reading '%s' GZ_VEL... ",filename); elbeemDebugOut(debugStrBuffer);
|
|
|
|
gzf = gzopen(filename, "rb");
|
|
|
|
if (!gzf) {
|
|
|
|
//printf("readVelgz Eror: unable to open file '%s'\n",filename); // DEBUG
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gzread(gzf, &wri, sizeof( wri ));
|
|
|
|
if(wri != mesh->totvert) {
|
|
|
|
//printf("readVelgz Eror: invalid no. of velocities %d vs. %d aborting.\n" ,wri ,mesh->totvert ); // DEBUG
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0; i<mesh->totvert;i++) {
|
|
|
|
for(j=0; j<3; j++) {
|
|
|
|
gzread(gzf, &wrf, sizeof( wrf ));
|
|
|
|
vverts[i].co[j] = wrf;
|
|
|
|
}
|
|
|
|
//if(i<20) fprintf(stderr, "GZ_VELload %d = %f,%f,%f \n",i,vverts[i].co[0],vverts[i].co[1],vverts[i].co[2]); // DEBUG
|
|
|
|
}
|
|
|
|
|
|
|
|
gzclose(gzf);
|
|
|
|
}
|
|
|
|
|
2005-11-09 07:56:26 +00:00
|
|
|
|
|
|
|
/* ***************************** fluidsim derived mesh ***************************** */
|
|
|
|
|
2005-11-23 12:49:22 +00:00
|
|
|
/* check which file to load, and replace old mesh of the object with it */
|
|
|
|
/* this replacement is undone at the end of mesh_calc_modifiers */
|
|
|
|
void loadFluidsimMesh(Object *srcob, int useRenderParams)
|
2005-11-12 10:35:14 +00:00
|
|
|
{
|
2005-11-09 07:56:26 +00:00
|
|
|
Mesh *mesh = NULL;
|
2005-11-23 19:19:44 +00:00
|
|
|
float *bbStart = NULL, *bbSize = NULL;
|
|
|
|
float lastBB[3];
|
2005-11-09 07:56:26 +00:00
|
|
|
int displaymode = 0;
|
2006-01-05 15:49:27 +00:00
|
|
|
int curFrame = G.scene->r.cfra - 1 /*G.scene->r.sfra*/; /* start with 0 at start frame */
|
2005-11-09 07:56:26 +00:00
|
|
|
char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR];
|
|
|
|
char debugStrBuffer[256];
|
2005-11-23 12:49:22 +00:00
|
|
|
//snprintf(debugStrBuffer,256,"loadFluidsimMesh call (obid '%s', rp %d)\n", srcob->id.name, useRenderParams); // debug
|
2005-11-09 07:56:26 +00:00
|
|
|
|
|
|
|
if((!srcob)||(!srcob->fluidsimSettings)) {
|
2005-11-23 12:49:22 +00:00
|
|
|
snprintf(debugStrBuffer,256,"DEBUG - Invalid loadFluidsimMesh call, rp %d, dm %d)\n", useRenderParams, displaymode); // debug
|
|
|
|
elbeemDebugOut(debugStrBuffer); // debug
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// make sure the original mesh data pointer is stored
|
|
|
|
if(!srcob->fluidsimSettings->orgMesh) {
|
|
|
|
srcob->fluidsimSettings->orgMesh = srcob->data;
|
2005-11-09 07:56:26 +00:00
|
|
|
}
|
2005-11-23 12:49:22 +00:00
|
|
|
|
|
|
|
// free old mesh, if there is one (todo, check if it's still valid?)
|
|
|
|
if(srcob->fluidsimSettings->meshSurface) {
|
|
|
|
Mesh *freeFsMesh = srcob->fluidsimSettings->meshSurface;
|
|
|
|
|
|
|
|
// similar to free_mesh(...) , but no things like unlink...
|
2006-07-20 15:27:55 +00:00
|
|
|
if(freeFsMesh->mvert){ MEM_freeN(freeFsMesh->mvert); freeFsMesh->mvert=NULL; }
|
|
|
|
if(freeFsMesh->medge){ MEM_freeN(freeFsMesh->medge); freeFsMesh->medge=NULL; }
|
|
|
|
if(freeFsMesh->mface){ MEM_freeN(freeFsMesh->mface); freeFsMesh->mface=NULL; }
|
2005-11-23 12:49:22 +00:00
|
|
|
MEM_freeN(freeFsMesh);
|
|
|
|
|
|
|
|
if(srcob->data == srcob->fluidsimSettings->meshSurface)
|
|
|
|
srcob->data = srcob->fluidsimSettings->orgMesh;
|
|
|
|
srcob->fluidsimSettings->meshSurface = NULL;
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
|
|
|
|
if(srcob->fluidsimSettings->meshSurfNormals) MEM_freeN(srcob->fluidsimSettings->meshSurfNormals);
|
|
|
|
srcob->fluidsimSettings->meshSurfNormals = NULL;
|
2005-11-23 12:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// init bounding box
|
|
|
|
bbStart = srcob->fluidsimSettings->bbStart;
|
|
|
|
bbSize = srcob->fluidsimSettings->bbSize;
|
|
|
|
lastBB[0] = bbSize[0]; // TEST
|
|
|
|
lastBB[1] = bbSize[1];
|
|
|
|
lastBB[2] = bbSize[2];
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
fluidsimGetAxisAlignedBB(srcob->fluidsimSettings->orgMesh, srcob->obmat, bbStart, bbSize, &srcob->fluidsimSettings->meshBB);
|
2005-11-23 12:49:22 +00:00
|
|
|
// check free fsmesh... TODO
|
2005-11-09 07:56:26 +00:00
|
|
|
|
|
|
|
if(!useRenderParams) {
|
|
|
|
displaymode = srcob->fluidsimSettings->guiDisplayMode;
|
|
|
|
} else {
|
|
|
|
displaymode = srcob->fluidsimSettings->renderDisplayMode;
|
|
|
|
}
|
|
|
|
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
snprintf(debugStrBuffer,256,"loadFluidsimMesh call (obid '%s', rp %d, dm %d), curFra=%d, sFra=%d #=%d \n",
|
|
|
|
srcob->id.name, useRenderParams, displaymode, G.scene->r.cfra, G.scene->r.sfra, curFrame ); // debug
|
2005-11-09 07:56:26 +00:00
|
|
|
elbeemDebugOut(debugStrBuffer); // debug
|
|
|
|
|
|
|
|
strncpy(targetDir, srcob->fluidsimSettings->surfdataPath, FILE_MAXDIR);
|
|
|
|
// use preview or final mesh?
|
2005-11-23 12:49:22 +00:00
|
|
|
if(displaymode==1) {
|
|
|
|
// just display original object
|
|
|
|
srcob->data = srcob->fluidsimSettings->orgMesh;
|
|
|
|
return;
|
|
|
|
} else if(displaymode==2) {
|
2005-11-09 07:56:26 +00:00
|
|
|
strcat(targetDir,"fluidsurface_preview_#");
|
2005-11-23 12:49:22 +00:00
|
|
|
} else { // 3
|
2005-11-09 07:56:26 +00:00
|
|
|
strcat(targetDir,"fluidsurface_final_#");
|
|
|
|
}
|
|
|
|
BLI_convertstringcode(targetDir, G.sce, curFrame); // fixed #frame-no
|
|
|
|
strcpy(targetFile,targetDir);
|
|
|
|
strcat(targetFile, ".bobj.gz");
|
|
|
|
|
2005-11-23 12:49:22 +00:00
|
|
|
snprintf(debugStrBuffer,256,"loadFluidsimMesh call (obid '%s', rp %d, dm %d) '%s' \n", srcob->id.name, useRenderParams, displaymode, targetFile); // debug
|
2005-11-09 07:56:26 +00:00
|
|
|
elbeemDebugOut(debugStrBuffer); // debug
|
|
|
|
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
if(displaymode!=2) { // dont add bounding box for final
|
|
|
|
mesh = readBobjgz(targetFile, srcob->fluidsimSettings->orgMesh ,NULL,NULL);
|
|
|
|
} else {
|
|
|
|
mesh = readBobjgz(targetFile, srcob->fluidsimSettings->orgMesh, bbSize,bbSize );
|
|
|
|
}
|
2005-11-09 07:56:26 +00:00
|
|
|
if(!mesh) {
|
2006-03-29 07:35:54 +00:00
|
|
|
// switch, abort background rendering when fluidsim mesh is missing
|
|
|
|
const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp
|
|
|
|
if(G.background==1) {
|
|
|
|
if(getenv(strEnvName2)) {
|
|
|
|
int elevel = atoi(getenv(strEnvName2));
|
|
|
|
if(elevel>0) {
|
2006-05-11 08:09:02 +00:00
|
|
|
printf("Env. var %s set, fluid sim mesh '%s' not found, aborting render...\n",strEnvName2, targetFile);
|
2006-03-29 07:35:54 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-09 07:56:26 +00:00
|
|
|
// display org. object upon failure
|
2005-11-23 12:49:22 +00:00
|
|
|
srcob->data = srcob->fluidsimSettings->orgMesh;
|
|
|
|
return;
|
2005-11-09 07:56:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((mesh)&&(mesh->totvert>0)) {
|
|
|
|
make_edges(mesh, 0); // 0 = make all edges draw
|
|
|
|
}
|
2005-11-23 12:49:22 +00:00
|
|
|
srcob->fluidsimSettings->meshSurface = mesh;
|
|
|
|
srcob->data = mesh;
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
srcob->fluidsimSettings->meshSurfNormals = MEM_dupallocN(mesh->mvert);
|
|
|
|
|
|
|
|
// load vertex velocities, if they exist...
|
|
|
|
// TODO? use generate flag as loading flag as well?
|
|
|
|
// warning, needs original .bobj.gz mesh loading filename
|
|
|
|
if(displaymode==3) {
|
|
|
|
readVelgz(targetFile, srcob);
|
|
|
|
} else {
|
|
|
|
// no data for preview, only clear...
|
|
|
|
int i,j;
|
|
|
|
for(i=0; i<mesh->totvert;i++) { for(j=0; j<3; j++) { srcob->fluidsimSettings->meshSurfNormals[i].co[j] = 0.; }}
|
|
|
|
}
|
|
|
|
|
|
|
|
//fprintf(stderr,"LOADFLM DEBXHCH fs=%d 3:%d,%d,%d \n", (int)mesh, ((Mesh *)(srcob->fluidsimSettings->meshSurface))->mvert[3].no[0], ((Mesh *)(srcob->fluidsimSettings->meshSurface))->mvert[3].no[1], ((Mesh *)(srcob->fluidsimSettings->meshSurface))->mvert[3].no[2]);
|
2005-11-23 12:49:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* helper function */
|
|
|
|
/* init axis aligned BB for mesh object */
|
|
|
|
void fluidsimGetAxisAlignedBB(struct Mesh *mesh, float obmat[][4],
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
/*RET*/ float start[3], /*RET*/ float size[3], /*RET*/ struct Mesh **bbmesh )
|
2005-11-23 12:49:22 +00:00
|
|
|
{
|
|
|
|
float bbsx=0.0, bbsy=0.0, bbsz=0.0;
|
|
|
|
float bbex=1.0, bbey=1.0, bbez=1.0;
|
|
|
|
int i;
|
|
|
|
float vec[3];
|
2005-11-09 07:56:26 +00:00
|
|
|
|
2005-11-23 12:49:22 +00:00
|
|
|
VECCOPY(vec, mesh->mvert[0].co);
|
|
|
|
Mat4MulVecfl(obmat, vec);
|
|
|
|
bbsx = vec[0]; bbsy = vec[1]; bbsz = vec[2];
|
|
|
|
bbex = vec[0]; bbey = vec[1]; bbez = vec[2];
|
2005-11-09 07:56:26 +00:00
|
|
|
|
2005-11-23 12:49:22 +00:00
|
|
|
for(i=1; i<mesh->totvert;i++) {
|
|
|
|
VECCOPY(vec, mesh->mvert[i].co);
|
|
|
|
Mat4MulVecfl(obmat, vec);
|
2005-11-09 07:56:26 +00:00
|
|
|
|
2005-11-23 12:49:22 +00:00
|
|
|
if(vec[0] < bbsx){ bbsx= vec[0]; }
|
|
|
|
if(vec[1] < bbsy){ bbsy= vec[1]; }
|
|
|
|
if(vec[2] < bbsz){ bbsz= vec[2]; }
|
|
|
|
if(vec[0] > bbex){ bbex= vec[0]; }
|
|
|
|
if(vec[1] > bbey){ bbey= vec[1]; }
|
|
|
|
if(vec[2] > bbez){ bbez= vec[2]; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// return values...
|
|
|
|
if(start) {
|
|
|
|
start[0] = bbsx;
|
|
|
|
start[1] = bbsy;
|
|
|
|
start[2] = bbsz;
|
|
|
|
}
|
|
|
|
if(size) {
|
|
|
|
size[0] = bbex-bbsx;
|
|
|
|
size[1] = bbey-bbsy;
|
|
|
|
size[2] = bbez-bbsz;
|
|
|
|
}
|
Sorry for the big commit, but I've been fixing many of these
issues in parallel... So this commit contains: an update of
the solver (e.g. moving objects), integration of blender IPOs,
improved rendering (motion blur, smoothed normals) and a first particle
test. In more detail:
Solver update:
- Moving objects using a relatively simple model, and not yet fully optimized - ok
for box falling into water, water in a moving glass might cause trouble. Simulation
times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot
might also cause slowdowns.
- Additional obstacle settings: noslip (as before), free slip (move along wall freely)
and part slip (mix of both).
- Obstacle settings also added for domain boundaries now, the six walls of the domain are
obstacles after all as well
- Got rid of templates, should make compiling for e.g. macs more convenient,
for linux there's not much difference. Finally got rid of parser (and some other code
parts), the simulation now uses the internal API to transfer data.
- Some unnecessary file were removed, the GUI now needs 3 settings buttons...
This should still be changed (maybe by adding a new panel for domain objects).
IPOs:
- Animated params: viscosity, time and gravity for domains. In contrast
to normal time IPO for Blender objects, the fluidsim one scales the time
step size - so a constant 1 has no effect, values towards 0 slow it down,
larger ones speed the simulation up (-> longer time steps, more compuations).
The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect).
- For objects that are enabled for fluidsim, a new IPO type shows up. Inflow
objects can use the velocity channels to animate the inflow. Obstacles, in/outflow
objects can be switched on (Active IPO>0) and off (<0) during the simulation.
- Movement, rotation and scaling of those 3 types is exported from the normal
Blender channels (Loc,dLoc,etc.).
Particles:
- This is still experimental, so it might be deactivated for a
release... It should at some point be used to model smaller splashes,
depending on the the realworld size and the particle generation
settings particles are generated during simulation (stored in _particles_X.gz
files).
- These are loaded by enabling the particle field for an arbitrary object,
which should be given a halo material. For each frame, similar to the mesh
loading, the particle system them loads the simulated particle positions.
- For rendering, I "abused" the part->rt field - I couldnt find any use
for it in the code and it seems to work fine. The fluidsim particles
store their size there.
Rendering:
- The fluidims particles use scaled sizes and alpha values to give a more varied
appearance. In convertblender.c fluidsim particle systems use the p->rt field
to scale up the size and down the alpha of "smaller particles". Setting the
influence fields in the fluidims settings to 0 gives equally sized particles
with same alpha everywhere. Higher values cause larger differences.
- Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals
computed by the solver are used. This is basically done by switching off the
normal recalculation in convertblender.c (the function calc_fluidsimnormals
handles other mesh inits instead of calc_vertexnormals).
This could also be used to e.g. modify mesh normals in a modifier...
- Another change is that fluidsim meshes load the velocities computed
during the simulation for image based motion blur. This is inited in
load_fluidsimspeedvectors for the vector pass (they're loaded during the
normal load in DerivedMesh readBobjgz). Generation and loading can be switched
off in the settings. Vector pass currently loads the fluidism meshes 3 times,
so this should still be optimized.
Examples:
- smoothed normals versus normals from subdividing once:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png
- fluidsim particles, size/alpha influence 0:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png
size influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png
size & alpha influence 1:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png
- the standard drop with motion blur and particles:
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg
(here's how it looks without
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg)
- another inflow animation (moving, switched on/off) with a moving obstacle
(and strong mblur :)
http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg
Things still to fix:
- rotating & scaling domains causes wrong speed vectors
- get rid of SDL code for threading, use pthreads as well?
- update wiki documentation
- cool effects for rendering would be photon maps for caustics,
and motion blur for particles :)
2006-02-27 11:45:42 +00:00
|
|
|
|
|
|
|
// init bounding box mesh?
|
|
|
|
if(bbmesh) {
|
|
|
|
int i,j;
|
|
|
|
Mesh *newmesh = NULL;
|
|
|
|
if(!(*bbmesh)) { newmesh = MEM_callocN(sizeof(Mesh), "fluidsimGetAxisAlignedBB_meshbb"); }
|
|
|
|
else { newmesh = *bbmesh; }
|
|
|
|
|
|
|
|
newmesh->totvert = 8;
|
|
|
|
if(!newmesh->mvert) newmesh->mvert = MEM_callocN(sizeof(MVert)*newmesh->totvert, "fluidsimBBMesh_bobjvertices");
|
|
|
|
for(i=0; i<8; i++) {
|
|
|
|
for(j=0; j<3; j++) newmesh->mvert[i].co[j] = start[j];
|
|
|
|
}
|
|
|
|
|
|
|
|
newmesh->totface = 6;
|
|
|
|
if(!newmesh->mface) newmesh->mface = MEM_callocN(sizeof(MFace)*newmesh->totface, "fluidsimBBMesh_bobjfaces");
|
|
|
|
|
|
|
|
*bbmesh = newmesh;
|
|
|
|
}
|
2005-11-09 07:56:26 +00:00
|
|
|
}
|
|
|
|
|
2006-08-22 11:18:00 +00:00
|
|
|
#else // DISABLE_ELBEEM
|
|
|
|
|
|
|
|
/* dummy for mesh_calc_modifiers */
|
|
|
|
void loadFluidsimMesh(Object *srcob, int useRenderParams) {
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // DISABLE_ELBEEM
|
2005-11-09 07:56:26 +00:00
|
|
|
|