ensure defoem DM has tessface data for the few places that need it.

also add a workaround for CDDM_recalc_tesselation_ex() which would add a CD_NORMAL to dm->fdata and then overwrite immediate
This commit is contained in:
Campbell Barton
2012-01-19 19:23:25 +00:00
parent 7c82dbe68b
commit 1f84876e89
4 changed files with 24 additions and 5 deletions

View File

@@ -115,6 +115,7 @@ void CDDM_calc_edges(struct DerivedMesh *dm);
/* reconstitute face triangulation */
void CDDM_recalc_tesselation(struct DerivedMesh *dm);
void CDDM_recalc_tesselation_ex(struct DerivedMesh *dm, const int do_face_nor_cpy);
/* lowers the number of vertices/edges/faces in a CDDerivedMesh
* the layer data stays the same size

View File

@@ -1578,14 +1578,14 @@ static void cdDM_foreachMappedFaceCenter(
}
void CDDM_recalc_tesselation(DerivedMesh *dm)
void CDDM_recalc_tesselation_ex(DerivedMesh *dm, const int do_face_nor_cpy)
{
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
dm->numTessFaceData = mesh_recalcTesselation(&dm->faceData, &dm->loopData, &dm->polyData,
cddm->mvert,
dm->numTessFaceData, dm->numLoopData, dm->numPolyData,
TRUE);
do_face_nor_cpy);
if (!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX)) {
int *polyIndex = CustomData_get_layer(&dm->faceData, CD_POLYINDEX);
@@ -1599,6 +1599,11 @@ void CDDM_recalc_tesselation(DerivedMesh *dm)
CustomData_bmesh_update_active_layers(&dm->faceData, &dm->polyData, &dm->loopData);
}
void CDDM_recalc_tesselation(DerivedMesh *dm)
{
CDDM_recalc_tesselation_ex(dm, TRUE);
}
static void cdDM_free_internal(CDDerivedMesh *cddm)
{
if(cddm->fmap) MEM_freeN(cddm->fmap);
@@ -2160,10 +2165,13 @@ DerivedMesh *CDDM_copy(DerivedMesh *source, int faces_from_tessfaces)
cddm->mloop = CustomData_get_layer(&dm->loopData, CD_MLOOP);
cddm->mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY);
/* any callers that need tessface data can calculate it - campbell */
#if 0
/* BMESH_TODO: Find out why this is necessary (or else find a way to remove
it). If it is necessary, add a comment explaining why. */
CDDM_recalc_tesselation((DerivedMesh *)cddm);
#endif
return dm;
}
@@ -2258,8 +2266,12 @@ void CDDM_calc_normals_mapping(DerivedMesh *dm)
if (dm->numTessFaceData == 0) {
/* No tesselation on this mesh yet, need to calculate one */
CDDM_recalc_tesselation(dm);
/* No tesselation on this mesh yet, need to calculate one.
*
* Important not to update face normals from polys since it
* interfears with assigning the new normal layer in the following code.
*/
CDDM_recalc_tesselation_ex(dm, FALSE);
}
else {
/* A tesselation already exists, it should always have a CD_POLYINDEX */

View File

@@ -3067,6 +3067,8 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm,
return 0;
}
/* BMESH_ONLY, deform dm may not have tessface */
DM_ensure_tessface(dm);
if(pa_minmax==0){

View File

@@ -649,6 +649,10 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
else
dm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
/* BMESH_ONLY, deform dm may not have tessface */
DM_ensure_tessface(dm);
numverts = dm->getNumVerts (dm);
/* convert to global coordinates */