added a function to ensure derived mesh has tessface's, in preparation for removal of tessface recalculation after each modifier runs.

This commit is contained in:
Campbell Barton
2012-01-05 12:40:09 +00:00
parent 348f116fe5
commit 7fd67392eb
8 changed files with 35 additions and 0 deletions

View File

@@ -517,6 +517,8 @@ void DM_free_poly_data(struct DerivedMesh *dm, int index, int count);
/*sets up mpolys for a DM based on face iterators in source*/
void DM_DupPolys(DerivedMesh *source, DerivedMesh *target);
void DM_ensure_tessface(DerivedMesh *dm);
/* interpolates vertex data from the vertices indexed by src_indices in the
* source mesh using the given weights and stores the result in the vertex
* indexed by dest_index in the dest mesh

View File

@@ -352,6 +352,26 @@ void DM_DupPolys(DerivedMesh *source, DerivedMesh *target)
}
}
/* note: until all modifiers can take MPoly's as input,
* use this at the start of modifiers */
void DM_ensure_tessface(DerivedMesh *dm)
{
const int numTessFaces = dm->getNumTessFaces(dm);
const int numPolys = dm->getNumPolys(dm);
if ( (numTessFaces == 0) && (numPolys != 0)) {
dm->recalcTesselation(dm);
if (dm->getNumTessFaces(dm)) {
printf("warning %s: could not create tessfaces from %d polygons, dm->type=%d\n",
__func__, numPolys, dm->type);
}
else {
printf("info %s: polys -> ngons calculated\n", __func__);
}
}
}
void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
{
/* dm might depend on me, so we need to do everything with a local copy */

View File

@@ -137,6 +137,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
result = get_quick_derivedMesh(derivedData, dm, bmd->operation);
if(result == NULL) {
DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
DM_ensure_tessface(derivedData); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob,
1 + bmd->operation);
}

View File

@@ -81,6 +81,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
int totvert, totface;
int a, numTris;
DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
mvert = dm->getVertArray(dm);
mface = dm->getTessFaceArray(dm);
totvert = dm->getNumVerts(dm);

View File

@@ -983,6 +983,8 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
ExplodeModifierData *emd= (ExplodeModifierData*) md;
ParticleSystemModifierData *psmd=findPrecedingParticlesystem(ob,md);
DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
if(psmd){
ParticleSystem * psys=psmd->psys;

View File

@@ -122,6 +122,8 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
float max_co=0.0, min_co=0.0, temp_co[3], cross[3];
float *size=NULL;
DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
trackneg=((ob->trackflag>2)?1:0);
if(pimd->ob==ob){

View File

@@ -151,6 +151,8 @@ static DerivedMesh *applyModifier(ModifierData *md,
DualConFlags flags = 0;
DualConMode mode = 0;
DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
rmd = (RemeshModifierData*)md;
init_dualcon_mesh(&input, dm);

View File

@@ -725,6 +725,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
/* must recalculate normals with vgroups since they can displace unevenly [#26888] */
if(dvert) {
/* BMESH_TODO, we only need to get vertex normals here, this is way overkill */
CDDM_calc_normals(result);
}
else {