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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-01-06 04:45:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-06 04:45:07 +0400
commit5c59f0d5899d1d8b145e2997b6032a6faaea82f6 (patch)
treea8524717fe962353e57e9ef31de28a3353e2d518 /source
parentded0af482b82cc31ed10c2d03e5f07aedb299c50 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_cdderivedmesh.h2
-rw-r--r--source/blender/blenkernel/BKE_mesh.h9
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c41
3 files changed, 48 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h
index d1926c3f3ef..cd2487022de 100644
--- a/source/blender/blenkernel/BKE_cdderivedmesh.h
+++ b/source/blender/blenkernel/BKE_cdderivedmesh.h
@@ -100,6 +100,8 @@ void CDDM_apply_vert_normals(struct DerivedMesh *cddm, short (*vertNormals)[3]);
/* 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
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 6fcbb6d9f18..22cd822bf93 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -149,14 +149,15 @@ void mesh_calc_normals_mapping(
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) */
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 8a08f8b0218..d913457bfa0 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -2267,6 +2267,47 @@ void CDDM_calc_normals_mapping(DerivedMesh *dm)
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
*