Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-01-19 21:51:52 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-19 21:51:52 +0400
commitbc745a32d31fd7885dcd3dc0682a8e3150268778 (patch)
tree1572d6159cd1a9da5678485037cf6ffce27a666f /source/blender
parent330da356dab13db7d094064a00d56347b1d53e79 (diff)
argument to mesh_recalcTesselation to skip copying normals from polygons.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_mesh.h7
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c5
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c13
-rw-r--r--source/blender/blenkernel/intern/mesh.c33
-rw-r--r--source/blender/blenloader/intern/readfile.c7
-rw-r--r--source/blender/bmesh/operators/mesh_conv.c8
-rw-r--r--source/blender/editors/mesh/mesh_data.c13
-rw-r--r--source/blender/editors/object/object_add.c4
8 files changed, 53 insertions, 37 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 06e4787c741..b1cb62d4d5a 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -76,9 +76,10 @@ struct BMesh *BKE_mesh_to_bmesh(struct Mesh *me, struct Object *ob);
* if both of the above are 0, it'll use the indices of the mpolys of the MPoly
* data in pdata, and ignore the origindex layer altogether.
*/
-int mesh_recalcTesselation(struct CustomData *fdata, struct CustomData *ldata,
- struct CustomData *pdata, struct MVert *mvert, int totface,
- int totloop, int totpoly);
+int mesh_recalcTesselation(struct CustomData *fdata, struct CustomData *ldata, struct CustomData *pdata,
+ struct MVert *mvert,
+ int totface, int totloop, int totpoly,
+ const int do_face_normals);
/* for forwards compat only quad->tri polys to mface, skip ngons.
*/
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 63605c14f6c..99428ca482f 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -448,7 +448,10 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
/* yes, must be before _and_ after tesselate */
mesh_update_customdata_pointers(&tmp, TRUE);
- tmp.totface = mesh_recalcTesselation(&tmp.fdata, &tmp.ldata, &tmp.pdata, tmp.mvert, tmp.totface, tmp.totloop, tmp.totpoly);
+ tmp.totface = mesh_recalcTesselation(&tmp.fdata, &tmp.ldata, &tmp.pdata,
+ tmp.mvert,
+ tmp.totface, tmp.totloop, tmp.totpoly,
+ TRUE);
mesh_update_customdata_pointers(&tmp, TRUE);
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 3746e089538..aa8227c39ff 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -1582,9 +1582,10 @@ void CDDM_recalc_tesselation(DerivedMesh *dm)
{
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
- dm->numTessFaceData = mesh_recalcTesselation(&dm->faceData, &dm->loopData,
- &dm->polyData, cddm->mvert, dm->numTessFaceData, dm->numLoopData,
- dm->numPolyData);
+ dm->numTessFaceData = mesh_recalcTesselation(&dm->faceData, &dm->loopData, &dm->polyData,
+ cddm->mvert,
+ dm->numTessFaceData, dm->numLoopData, dm->numPolyData,
+ TRUE);
if (!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX)) {
int *polyIndex = CustomData_get_layer(&dm->faceData, CD_POLYINDEX);
@@ -2255,6 +2256,7 @@ void CDDM_calc_normals_mapping(DerivedMesh *dm)
cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
#endif
+
if (dm->numTessFaceData == 0) {
/* No tesselation on this mesh yet, need to calculate one */
CDDM_recalc_tesselation(dm);
@@ -2265,6 +2267,7 @@ void CDDM_calc_normals_mapping(DerivedMesh *dm)
CustomData_free_layers(&dm->faceData, CD_NORMAL, dm->numTessFaceData);
}
+
face_nors = MEM_mallocN(sizeof(float)*3*dm->numTessFaceData, "face_nors");
/* calculate face normals */
@@ -2274,7 +2277,9 @@ void CDDM_calc_normals_mapping(DerivedMesh *dm)
only_face_normals);
CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN,
- face_nors, dm->numTessFaceData);
+ face_nors, dm->numTessFaceData);
+
+
}
/* bmesh note: this matches what we have in trunk */
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 805302027b2..bf727935de3 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -1105,12 +1105,16 @@ void mball_to_mesh(ListBase *lb, Mesh *me)
index+= 4;
}
+ /* BMESH_TODO - why is this converting from MFaces to MPoly's then tesselating?
+ * should just make mpolys */
+
make_edges(me, 0); // all edges
convert_mfaces_to_mpolys(me);
- me->totface = mesh_recalcTesselation(
- &me->fdata, &me->ldata, &me->pdata,
- me->mvert, me->totface, me->totloop, me->totpoly);
+ me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, &me->pdata,
+ me->mvert,
+ me->totface, me->totloop, me->totpoly,
+ TRUE);
mesh_update_customdata_pointers(me, TRUE);
}
@@ -2212,10 +2216,13 @@ void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata,
this function recreates a tesselation.
returns number of tesselation faces.
*/
-int mesh_recalcTesselation(CustomData *fdata,
+int mesh_recalcTesselation(CustomData *fdata,
CustomData *ldata, CustomData *pdata,
MVert *mvert, int totface, int UNUSED(totloop),
- int totpoly)
+ int totpoly,
+ /* when teseelating to recalcilate normals after
+ * we can skip copying here */
+ const int do_face_nor_cpy)
{
/* use this to avoid locking pthread for _every_ polygon
@@ -2350,13 +2357,15 @@ int mesh_recalcTesselation(CustomData *fdata,
CustomData_from_bmeshpoly(fdata, pdata, ldata, totface);
- /* If polys have a normals layer, copying that to faces can help
- * avoid the need to recalculate normals later */
- if (CustomData_has_layer(pdata, CD_NORMAL)) {
- float *pnors = CustomData_get_layer(pdata, CD_NORMAL);
- float *fnors = CustomData_add_layer(fdata, CD_NORMAL, CD_CALLOC, NULL, totface);
- for (i=0; i<totface; i++, fnors++) {
- copy_v3_v3(fnors, &pnors[polyIndex[i]]);
+ if (do_face_nor_cpy) {
+ /* If polys have a normals layer, copying that to faces can help
+ * avoid the need to recalculate normals later */
+ if (CustomData_has_layer(pdata, CD_NORMAL)) {
+ float *pnors = CustomData_get_layer(pdata, CD_NORMAL);
+ float *fnors = CustomData_add_layer(fdata, CD_NORMAL, CD_CALLOC, NULL, totface);
+ for (i=0; i<totface; i++, fnors++) {
+ copy_v3_v3(fnors, &pnors[polyIndex[i]]);
+ }
}
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index b51133d284b..724d6ee2795 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3704,9 +3704,10 @@ static void lib_link_mesh(FileData *fd, Main *main)
* waiting until edit mode has been entered/exited, making it easier
* to recognize problems that would otherwise only show up after edits).
*/
- me->totface = mesh_recalcTesselation(
- &me->fdata, &me->ldata, &me->pdata,
- me->mvert, me->totface, me->totloop, me->totpoly);
+ me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, &me->pdata,
+ me->mvert,
+ me->totface, me->totloop, me->totpoly,
+ TRUE);
mesh_update_customdata_pointers(me, TRUE);
diff --git a/source/blender/bmesh/operators/mesh_conv.c b/source/blender/bmesh/operators/mesh_conv.c
index eda4d5225ba..27b90c9b0c9 100644
--- a/source/blender/bmesh/operators/mesh_conv.c
+++ b/source/blender/bmesh/operators/mesh_conv.c
@@ -614,9 +614,11 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op)
}
if (dotess) {
- me->totface= mesh_recalcTesselation(&me->fdata, &me->ldata, &me->pdata,
- me->mvert,
- me->totface, me->totloop, me->totpoly);
+ me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, &me->pdata,
+ me->mvert,
+ me->totface, me->totloop, me->totpoly,
+ /* possibly can set to FALSE here, but defaults to true */
+ TRUE);
}
mesh_update_customdata_pointers(me, dotess);
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 74e3e189f40..b0512414a7f 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -758,14 +758,11 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges)
if(calc_edges || (mesh->totpoly && mesh->totedge == 0))
BKE_mesh_calc_edges(mesh, calc_edges);
- mesh->totface = mesh_recalcTesselation(
- &mesh->fdata,
- &mesh->ldata,
- &mesh->pdata,
- mesh->mvert,
- mesh->totface,
- mesh->totloop,
- mesh->totpoly);
+ mesh->totface = mesh_recalcTesselation(&mesh->fdata, &mesh->ldata, &mesh->pdata,
+ mesh->mvert,
+ mesh->totface, mesh->totloop, mesh->totpoly,
+ /* calc normals right after, dont copy from polys here */
+ FALSE);
mesh_update_customdata_pointers(mesh, TRUE);
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 70a1aa73fc9..f96da9e5b07 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1371,9 +1371,7 @@ static int convert_exec(bContext *C, wmOperator *op)
DM_to_mesh(dm, newob->data, newob);
- /* re-tesselation doesn't happen automatic, calling like this is */
- me= newob->data;
- me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, &me->pdata, me->mvert, me->totface, me->totloop, me->totpoly);
+ /* re-tesselation is called by DM_to_mesh */
dm->release(dm);
object_free_modifiers(newob); /* after derivedmesh calls! */