a bug fix and a compile fix
This commit is contained in:
@@ -60,10 +60,13 @@ struct BMesh *BKE_mesh_to_bmesh(struct Mesh *me, struct Object *ob);
|
||||
/*
|
||||
this function recreates a tesselation.
|
||||
returns number of tesselation faces.
|
||||
|
||||
use_poly_origindex sets whether or not the tesselation faces' origindex
|
||||
layer should point to original poly indices or real poly indices.
|
||||
*/
|
||||
int mesh_recalcTesselation(struct CustomData *fdata, struct CustomData *ldata,
|
||||
struct CustomData *pdata, struct MVert *mvert, int totface,
|
||||
int totloop, int totpoly);
|
||||
int totloop, int totpoly, int use_poly_origindex);
|
||||
|
||||
/*calculates a face normal.*/
|
||||
void mesh_calc_poly_normal(struct MPoly *mpoly, struct MLoop *loopstart,
|
||||
|
||||
@@ -1310,7 +1310,20 @@ static void cdDM_recalcTesselation(DerivedMesh *dm)
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
|
||||
dm->numFaceData = mesh_recalcTesselation(&dm->faceData, &dm->loopData,
|
||||
&dm->polyData, cddm->mvert, dm->numFaceData, dm->numLoopData, dm->numPolyData);
|
||||
&dm->polyData, cddm->mvert, dm->numFaceData, dm->numLoopData,
|
||||
dm->numPolyData, 1);
|
||||
|
||||
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
|
||||
}
|
||||
|
||||
/*ignores original poly origindex layer*/
|
||||
static void cdDM_recalcTesselation2(DerivedMesh *dm)
|
||||
{
|
||||
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
|
||||
|
||||
dm->numFaceData = mesh_recalcTesselation(&dm->faceData, &dm->loopData,
|
||||
&dm->polyData, cddm->mvert, dm->numFaceData, dm->numLoopData,
|
||||
dm->numPolyData, 0);
|
||||
|
||||
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
|
||||
}
|
||||
@@ -2010,7 +2023,7 @@ void CDDM_calc_normals(DerivedMesh *dm)
|
||||
|
||||
/*recalc tesselation to ensure we have valid origindex values
|
||||
for mface->mpoly lookups.*/
|
||||
cdDM_recalcTesselation(dm);
|
||||
cdDM_recalcTesselation2(dm);
|
||||
|
||||
numFaces = dm->numFaceData;
|
||||
|
||||
@@ -2029,7 +2042,6 @@ void CDDM_calc_normals(DerivedMesh *dm)
|
||||
}
|
||||
|
||||
face_nors = MEM_callocN(sizeof(float)*3*dm->numFaceData, "face_nors cdderivedmesh.c");
|
||||
CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN, face_nors, dm->numFaceData);
|
||||
origIndex = CustomData_get_layer(&dm->faceData, CD_ORIGINDEX);
|
||||
|
||||
mf = cddm->mface;
|
||||
@@ -2057,6 +2069,13 @@ void CDDM_calc_normals(DerivedMesh *dm)
|
||||
|
||||
MEM_freeN(temp_nors);
|
||||
MEM_freeN(vert_nors);
|
||||
|
||||
/*this restores original poly origindex -> tessface origindex mapping,
|
||||
instead of the poly index -> tessface origindex one we generated
|
||||
with cdDM_recalcTesselation2*/
|
||||
cdDM_recalcTesselation(dm);
|
||||
CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN,
|
||||
face_nors, dm->numFaceData);
|
||||
}
|
||||
|
||||
void CDDM_calc_edges(DerivedMesh *dm)
|
||||
|
||||
@@ -1604,7 +1604,7 @@ static void mesh_loops_to_corners(CustomData *fdata, CustomData *ldata,
|
||||
int mesh_recalcTesselation(CustomData *fdata,
|
||||
CustomData *ldata, CustomData *pdata,
|
||||
MVert *mvert, int totface, int totloop,
|
||||
int totpoly)
|
||||
int totpoly, int use_poly_origindex)
|
||||
{
|
||||
MPoly *mp, *mpoly;
|
||||
MLoop *ml, *mloop;
|
||||
@@ -1624,7 +1624,7 @@ int mesh_recalcTesselation(CustomData *fdata,
|
||||
|
||||
k = 0;
|
||||
mp = mpoly;
|
||||
polyorigIndex = CustomData_get_layer(pdata, CD_ORIGINDEX);
|
||||
polyorigIndex = use_poly_origindex? CustomData_get_layer(pdata, CD_ORIGINDEX) : NULL;
|
||||
for (i=0; i<totpoly; i++, mp++) {
|
||||
ml = mloop + mp->loopstart;
|
||||
firstv = NULL;
|
||||
|
||||
@@ -2507,7 +2507,7 @@ DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd)
|
||||
cddm->numFaceData = mesh_recalcTesselation(&cddm->faceData,
|
||||
&cddm->loopData, &cddm->polyData,
|
||||
mvert, cddm->numFaceData,
|
||||
cddm->numLoopData, cddm->numPolyData);
|
||||
cddm->numLoopData, cddm->numPolyData, 1);
|
||||
|
||||
CDDM_set_mface(cddm, DM_get_tessface_data_layer(cddm, CD_MFACE));
|
||||
CDDM_calc_normals(cddm);
|
||||
|
||||
@@ -31,15 +31,6 @@
|
||||
#include "mesh_intern.h"
|
||||
#include "bmesh.h"
|
||||
|
||||
/*
|
||||
HACK: we're using the old keyindex shape key hack for now, where each
|
||||
vertex is assigned an index on entering editmode, which is used to retrieve
|
||||
the original shapekey coordinates on exiting editmode.
|
||||
|
||||
this should be replaced by proper use of customdata layers, but I'm not
|
||||
sure if that's such a good idea before merging with trunk or not.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MESH CONV.C
|
||||
*
|
||||
|
||||
@@ -54,8 +54,8 @@ void ED_OT_redo (struct wmOperatorType *ot);
|
||||
void undo_editmode_push(struct bContext *C, char *name,
|
||||
void * (*getdata)(struct bContext *C),
|
||||
void (*freedata)(void *),
|
||||
void (*to_editmode)(void *, void *),
|
||||
void *(*from_editmode)(void *),
|
||||
void (*to_editmode)(void *, void *, void *),
|
||||
void *(*from_editmode)(void *, void *),
|
||||
int (*validate_undo)(void *, void *));
|
||||
|
||||
|
||||
|
||||
@@ -1287,7 +1287,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *event)
|
||||
/*we can't assume mfaces have a correct origindex layer that indices to mpolys.
|
||||
so instead we have to regenerate the tesselation faces altogether.*/
|
||||
me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, &me->pdata,
|
||||
me->mvert, me->totface, me->totloop, me->totpoly);
|
||||
me->mvert, me->totface, me->totloop, me->totpoly, 1);
|
||||
mesh_update_customdata_pointers(me);
|
||||
makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH);
|
||||
|
||||
@@ -1717,7 +1717,7 @@ static void vpaint_build_poly_facemap(struct VPaintData *vd, Mesh *me,
|
||||
/*we can't assume mfaces have a correct origindex layer that indices to mpolys.
|
||||
so instead we have to regenerate the tesselation faces altogether.*/
|
||||
me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, &me->pdata,
|
||||
me->mvert, me->totface, me->totloop, me->totpoly);
|
||||
me->mvert, me->totface, me->totloop, me->totpoly, 1);
|
||||
mesh_update_customdata_pointers(me);
|
||||
makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user