[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57081] trunk/blender/source: code cleanup : lots of calls to BKE_mesh_calc_normals_mapping were not using the mapping functionality .
Campbell Barton
ideasman42 at gmail.com
Tue May 28 16:23:07 CEST 2013
Revision: 57081
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57081
Author: campbellbarton
Date: 2013-05-28 14:23:07 +0000 (Tue, 28 May 2013)
Log Message:
-----------
code cleanup: lots of calls to BKE_mesh_calc_normals_mapping were not using the mapping functionality.
replace ED_mesh_calc_normals with BKE_mesh_calc_normals().
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_mesh.h
trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
trunk/blender/source/blender/blenkernel/intern/mesh.c
trunk/blender/source/blender/blenkernel/intern/multires.c
trunk/blender/source/blender/collada/MeshImporter.cpp
trunk/blender/source/blender/editors/include/ED_mesh.h
trunk/blender/source/blender/editors/mesh/mesh_data.c
trunk/blender/source/blender/editors/mesh/meshtools.c
trunk/blender/source/blender/editors/object/object_transform.c
trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
trunk/blender/source/blender/makesdna/DNA_mesh_types.h
trunk/blender/source/blender/makesrna/intern/rna_mesh_api.c
trunk/blender/source/blenderplayer/bad_level_call_stubs/stubs.c
Modified: trunk/blender/source/blender/blenkernel/BKE_mesh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_mesh.h 2013-05-28 14:05:12 UTC (rev 57080)
+++ trunk/blender/source/blender/blenkernel/BKE_mesh.h 2013-05-28 14:23:07 UTC (rev 57081)
@@ -211,18 +211,20 @@
struct MVert *mverts, int numVerts,
struct MLoop *mloop, struct MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3],
struct MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3]);
-/* extended version of 'BKE_mesh_calc_normals' with option not to calc vertex normals */
+/* extended version of 'BKE_mesh_calc_normals_poly' with option not to calc vertex normals */
void BKE_mesh_calc_normals_mapping_ex(
struct MVert *mverts, int numVerts,
struct MLoop *mloop, struct MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3],
struct MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3],
const bool only_face_normals);
-void BKE_mesh_calc_normals(
+void BKE_mesh_calc_normals_poly(
struct MVert *mverts, int numVerts,
struct MLoop *mloop, struct MPoly *mpolys,
int numLoops, int numPolys, float (*polyNors_r)[3]);
+void BKE_mesh_calc_normals(struct Mesh *me);
+
/* Return a newly MEM_malloc'd array of all the mesh vertex locations
* (_numVerts_r_ may be NULL) */
float (*BKE_mesh_vertexCos_get(struct Mesh *me, int *r_numVerts))[3];
Modified: trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2013-05-28 14:05:12 UTC (rev 57080)
+++ trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2013-05-28 14:23:07 UTC (rev 57081)
@@ -2283,8 +2283,8 @@
poly_nors = CustomData_add_layer(&dm->polyData, CD_NORMAL, CD_CALLOC, NULL, dm->numPolyData);
}
- BKE_mesh_calc_normals(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm),
- dm->numLoopData, dm->numPolyData, poly_nors);
+ BKE_mesh_calc_normals_poly(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm),
+ dm->numLoopData, dm->numPolyData, poly_nors);
}
void CDDM_calc_normals_tessface(DerivedMesh *dm)
Modified: trunk/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mesh.c 2013-05-28 14:05:12 UTC (rev 57080)
+++ trunk/blender/source/blender/blenkernel/intern/mesh.c 2013-05-28 14:23:07 UTC (rev 57081)
@@ -1197,7 +1197,7 @@
BKE_mesh_update_customdata_pointers(me, true);
- BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL);
+ BKE_mesh_calc_normals(me);
BKE_mesh_calc_edges(me, true, false);
}
@@ -1591,7 +1591,7 @@
me->mloopuv = CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_ASSIGN, alluv, me->totloop, uvname);
}
- BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL);
+ BKE_mesh_calc_normals(me);
}
else {
me = BKE_mesh_add(G.main, "Mesh");
@@ -1907,7 +1907,7 @@
if (only_face_normals == FALSE) {
/* vertex normals are optional, they require some extra calculations,
* so make them optional */
- BKE_mesh_calc_normals(mverts, numVerts, mloop, mpolys, numLoops, numPolys, pnors);
+ BKE_mesh_calc_normals_poly(mverts, numVerts, mloop, mpolys, numLoops, numPolys, pnors);
}
else {
/* only calc poly normals */
@@ -1929,7 +1929,7 @@
}
else {
/* eek, we're not corresponding to polys */
- printf("error in BKE_mesh_calc_normals; tessellation face indices are incorrect. normals may look bad.\n");
+ printf("error in %s: tessellation face indices are incorrect. normals may look bad.\n", __func__);
}
}
}
@@ -1993,10 +1993,10 @@
}
-void BKE_mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys,
- int UNUSED(numLoops), int numPolys, float (*polyNors_r)[3])
+void BKE_mesh_calc_normals_poly(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys,
+ int UNUSED(numLoops), int numPolys, float (*r_polynors)[3])
{
- float (*pnors)[3] = polyNors_r;
+ float (*pnors)[3] = r_polynors;
float (*tnorms)[3];
float tpnor[3]; /* temp poly normal */
int i;
@@ -2025,6 +2025,13 @@
MEM_freeN(tnorms);
}
+void BKE_mesh_calc_normals(Mesh *mesh)
+{
+ BKE_mesh_calc_normals_poly(mesh->mvert, mesh->totvert,
+ mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
+ NULL);
+}
+
void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float (*faceNors_r)[3])
{
float (*tnorms)[3] = MEM_callocN(numVerts * sizeof(*tnorms), "tnorms");
Modified: trunk/blender/source/blender/blenkernel/intern/multires.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/multires.c 2013-05-28 14:05:12 UTC (rev 57080)
+++ trunk/blender/source/blender/blenkernel/intern/multires.c 2013-05-28 14:23:07 UTC (rev 57081)
@@ -861,7 +861,7 @@
* Probably this is possible to do in the loop above, but this is rather tricky because
* we don't know all needed vertices' coordinates there yet.
*/
- BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL);
+ BKE_mesh_calc_normals(me);
/* subdivide the mesh to highest level without displacements */
cddm = CDDM_from_mesh(me, NULL);
Modified: trunk/blender/source/blender/collada/MeshImporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/MeshImporter.cpp 2013-05-28 14:05:12 UTC (rev 57080)
+++ trunk/blender/source/blender/collada/MeshImporter.cpp 2013-05-28 14:23:07 UTC (rev 57081)
@@ -710,7 +710,7 @@
if ((*m).second) {
Mesh *me = (*m).second;
BKE_mesh_tessface_clear(me);
- BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL);
+ BKE_mesh_calc_normals(me);
//BKE_mesh_validate(me, 1);
}
}
@@ -1033,10 +1033,7 @@
Mesh *new_mesh = uid_mesh_map[*geom_uid];
BKE_mesh_assign_object(ob, new_mesh);
- BKE_mesh_calc_normals_mapping(new_mesh->mvert, new_mesh->totvert,
- new_mesh->mloop, new_mesh->mpoly,
- new_mesh->totloop, new_mesh->totpoly,
- NULL, NULL, 0, NULL, NULL);
+ BKE_mesh_calc_normals(new_mesh);
if (old_mesh->id.us == 0) BKE_libblock_free(&G.main->mesh, old_mesh);
Modified: trunk/blender/source/blender/editors/include/ED_mesh.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_mesh.h 2013-05-28 14:05:12 UTC (rev 57080)
+++ trunk/blender/source/blender/editors/include/ED_mesh.h 2013-05-28 14:23:07 UTC (rev 57081)
@@ -259,7 +259,6 @@
void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int count);
void ED_mesh_transform(struct Mesh *me, float *mat);
-void ED_mesh_calc_normals(struct Mesh *me);
void ED_mesh_calc_tessface(struct Mesh *mesh);
void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int calc_tessface);
Modified: trunk/blender/source/blender/editors/mesh/mesh_data.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/mesh_data.c 2013-05-28 14:05:12 UTC (rev 57080)
+++ trunk/blender/source/blender/editors/mesh/mesh_data.c 2013-05-28 14:23:07 UTC (rev 57081)
@@ -896,8 +896,6 @@
void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface)
{
- int *polyindex = NULL;
- float (*face_nors)[3];
bool tessface_input = false;
if (mesh->totface > 0 && mesh->totpoly == 0) {
@@ -920,29 +918,8 @@
BKE_mesh_tessface_clear(mesh);
}
- /* note on this if/else - looks like these layers are not needed
- * so rather then add poly-index layer and calculate normals for it
- * calculate normals only for the mvert's. - campbell */
-#ifdef USE_BMESH_MPOLY_NORMALS
- polyindex = CustomData_get_layer(&mesh->fdata, CD_ORIGINDEX);
- /* add a normals layer for tessellated faces, a tessface normal will
- * contain the normal of the poly the face was tessellated from. */
- face_nors = CustomData_add_layer(&mesh->fdata, CD_NORMAL, CD_CALLOC, NULL, mesh->totface);
+ BKE_mesh_calc_normals(mesh);
- BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert,
- mesh->mloop, mesh->mpoly,
- mesh->totloop, mesh->totpoly,
- NULL /* polyNors_r */,
- mesh->mface, mesh->totface,
- polyindex, face_nors, false);
-#else
- BKE_mesh_calc_normals(mesh->mvert, mesh->totvert,
- mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
- NULL);
- (void)polyindex;
- (void)face_nors;
-#endif
-
DAG_id_tag_update(&mesh->id, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mesh);
}
@@ -1257,19 +1234,6 @@
mesh_add_polys(mesh, count);
}
-void ED_mesh_calc_normals(Mesh *mesh)
-{
-#ifdef USE_BMESH_MPOLY_NORMALS
- BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert,
- mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
- NULL, NULL, 0, NULL, NULL, false);
-#else
- BKE_mesh_calc_normals(mesh->mvert, mesh->totvert,
- mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
- NULL);
-#endif
-}
-
void ED_mesh_calc_tessface(Mesh *mesh)
{
if (mesh->edit_btmesh) {
Modified: trunk/blender/source/blender/editors/mesh/meshtools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/meshtools.c 2013-05-28 14:05:12 UTC (rev 57080)
+++ trunk/blender/source/blender/editors/mesh/meshtools.c 2013-05-28 14:23:07 UTC (rev 57081)
@@ -507,7 +507,7 @@
BKE_mesh_update_customdata_pointers(me, false);
/* update normals in case objects with non-uniform scale are joined */
- ED_mesh_calc_normals(me);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list