[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43192] branches/bmesh/blender/source/ blender/blenkernel: added
Campbell Barton
ideasman42 at gmail.com
Fri Jan 6 01:45:16 CET 2012
Revision: 43192
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43192
Author: campbellbarton
Date: 2012-01-06 00:45:07 +0000 (Fri, 06 Jan 2012)
Log Message:
-----------
added
* CDDM_calc_normals
* CDDM_calc_normals_tessface
these match what we have in trunk - CDDM_calc_normals_mapping() is kept for more comprehensive operatons.
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h
branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h
branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h 2012-01-06 00:12:24 UTC (rev 43191)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h 2012-01-06 00:45:07 UTC (rev 43192)
@@ -100,6 +100,8 @@
/* recalculates vertex and face normals for a CDDerivedMesh
*/
void CDDM_calc_normals_mapping(struct DerivedMesh *dm);
+void CDDM_calc_normals(struct DerivedMesh *dm);
+void CDDM_calc_normals_tessface(struct DerivedMesh *dm);
/* calculates edges for a CDDerivedMesh (from face data)
* this completely replaces the current edge data in the DerivedMesh
Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h 2012-01-06 00:12:24 UTC (rev 43191)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h 2012-01-06 00:45:07 UTC (rev 43192)
@@ -149,14 +149,15 @@
struct MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3]);
/* extended version of 'mesh_calc_normals' with option not to calc vertex normals */
void 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 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 short only_face_normals);
void mesh_calc_normals(
- struct MVert *mverts, int numVerts, struct MLoop *mloop,
- struct MPoly *mpolys, int UNUSED(numLoops), int numPolys, float (*polyNors_r)[3]);
+ struct MVert *mverts, int numVerts,
+ struct MLoop *mloop, struct MPoly *mpolys,
+ int numLoops, int numPolys, float (*polyNors_r)[3]);
/* Return a newly MEM_malloc'd array of all the mesh vertex locations
* (_numVerts_r_ may be NULL) */
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2012-01-06 00:12:24 UTC (rev 43191)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2012-01-06 00:45:07 UTC (rev 43192)
@@ -2267,6 +2267,47 @@
face_nors, dm->numTessFaceData);
}
+/* bmesh note: this matches what we have in trunk */
+void CDDM_calc_normals(DerivedMesh *dm)
+{
+ CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
+ float (*poly_nors)[3];
+
+ if(dm->numVertData == 0) return;
+
+ /* we don't want to overwrite any referenced layers */
+ cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
+
+ /* fill in if it exists */
+ poly_nors = CustomData_get_layer(&dm->polyData, CD_NORMAL);
+ if (!poly_nors) {
+ poly_nors = CustomData_add_layer(&dm->polyData, CD_NORMAL, CD_CALLOC, NULL, dm->numPolyData);
+ }
+
+ mesh_calc_normals(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)
+{
+ CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
+ float (*face_nors)[3];
+
+ if(dm->numVertData == 0) return;
+
+ /* we don't want to overwrite any referenced layers */
+ cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
+
+ /* fill in if it exists */
+ face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
+ if (!face_nors) {
+ face_nors = CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_CALLOC, NULL, dm->numTessFaceData);
+ }
+
+ mesh_calc_normals_tessface(cddm->mvert, dm->numVertData,
+ cddm->mface, dm->numTessFaceData, face_nors);
+}
+
#if 1
/* merge verts
*
More information about the Bf-blender-cvs
mailing list