[Bf-blender-cvs] [6cbde1d] temp_custom_loop_normals: Merge branch 'master' into temp_custom_loop_normals
Bastien Montagne
noreply at git.blender.org
Mon Jan 19 17:14:43 CET 2015
Commit: 6cbde1df19f215c6c5404ef152b314ba6175e553
Author: Bastien Montagne
Date: Mon Jan 19 16:36:21 2015 +0100
Branches: temp_custom_loop_normals
https://developer.blender.org/rB6cbde1df19f215c6c5404ef152b314ba6175e553
Merge branch 'master' into temp_custom_loop_normals
Conflicts:
source/blender/blenkernel/BKE_cdderivedmesh.h
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/mesh_evaluate.c
source/blender/blenkernel/intern/mesh_remap.c
source/blender/bmesh/intern/bmesh_mesh.c
source/blender/bmesh/intern/bmesh_mesh.h
source/blender/makesrna/intern/rna_mesh_api.c
Note: commented out part of 'copynors' modifier code, we will get rid of this one soon anyway.
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_DerivedMesh.h
index 2bea203,96c519f..e573a1d
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@@ -198,11 -197,8 +198,12 @@@ struct DerivedMesh
void (*calcNormals)(DerivedMesh *dm);
/** Calculate loop (split) normals */
- void (*calcLoopNormals)(DerivedMesh *dm, const float split_angle);
+ void (*calcLoopNormals)(DerivedMesh *dm, const bool use_split_normals, const float split_angle);
+ /** Calculate loop (split) normals, and returns split loop normal spaces. */
- void (*calcLoopNormalsSpaces)(DerivedMesh *dm, const float split_angle, struct MLoopsNorSpaces *r_lnors_spaces);
++ void (*calcLoopNormalsSpaces)(DerivedMesh *dm, const bool use_split_normals, const float split_angle,
++ struct MLoopsNorSpaces *r_lnors_spaces);
+
/** Recalculates mesh tessellation */
void (*recalcTessellation)(DerivedMesh *dm);
diff --cc source/blender/blenkernel/BKE_cdderivedmesh.h
index 1b790f83,448617f..977207c
--- a/source/blender/blenkernel/BKE_cdderivedmesh.h
+++ b/source/blender/blenkernel/BKE_cdderivedmesh.h
@@@ -107,9 -106,7 +107,9 @@@ void CDDM_calc_normals_mapping(struct D
void CDDM_calc_normals(struct DerivedMesh *dm);
void CDDM_calc_normals_tessface(struct DerivedMesh *dm);
- void CDDM_calc_loop_normals(struct DerivedMesh *dm, const float split_angle);
- void CDDM_calc_loop_normals_spaces(struct DerivedMesh *dm, const float split_angle,
+ void CDDM_calc_loop_normals(struct DerivedMesh *dm, const bool use_split_normals, const float split_angle);
++void CDDM_calc_loop_normals_spaces(struct DerivedMesh *dm, const bool use_split_normals, const float split_angle,
+ struct MLoopsNorSpaces *r_lnors_spaces);
/* calculates edges for a CDDerivedMesh (from face data)
* this completely replaces the current edge data in the DerivedMesh
diff --cc source/blender/blenkernel/BKE_mesh.h
index 0732fa9,c9f61ca..09ccd3b
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@@ -184,49 -186,6 +184,49 @@@ void BKE_mesh_loop_tangents_ex
void BKE_mesh_loop_tangents(
struct Mesh *mesh, const char *uvmap, float (*r_looptangents)[4], struct ReportList *reports);
+typedef struct MLoopNorSpace {
+ float vec_lnor[3]; /* Automatically computed loop normal. */
+ float vec_ref[3]; /* Reference vector, orthogonal to vec_lnor. */
+ float vec_ortho[3]; /* Third vector, orthogonal to vec_lnor and vec_ref. */
+ float ref_alpha; /* Reference angle, around vec_ortho, in ]0, pi] range (0.0 marks that space as invalid). */
+ float ref_beta; /* Reference angle, around vec_lnor, in ]0, 2pi] range (0.0 marks that space as invalid). */
+ struct LinkNode *loops; /* All indices (uint_in_ptr) of loops using this lnor space (i.e. smooth fan of loops). */
+} MLoopNorSpace;
+typedef struct MLoopsNorSpaces {
+ MLoopNorSpace **lspaces;
+ struct LinkNode *loops_pool; /* Allocated once, avoids to call BLI_linklist_prepend_arena() for each loop! */
+ struct MemArena *mem;
+} MLoopsNorSpaces;
+void BKE_lnor_spaces_init(MLoopsNorSpaces *lnors_spaces, const int numLoops);
+void BKE_lnor_spaces_free(MLoopsNorSpaces *lnors_spaces);
+MLoopNorSpace *BKE_lnor_space_create(MLoopsNorSpaces *lnors_spaces);
+void BKE_lnor_space_define(
+ MLoopNorSpace *lnor_space, const float lnor[3], float vec_ref[3], float vec_other[3],
+ struct BLI_Stack *edge_vectors);
+void BKE_lnor_space_add_loop(
+ MLoopsNorSpaces *lnors_spaces, MLoopNorSpace *lnor_space, const int ml_index, const bool add_to_list);
+void BKE_lnor_space_custom_data_to_normal(MLoopNorSpace *lnor_space, const short clnor_data[2], float r_custom_lnor[3]);
+void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space, const float custom_lnor[3], short r_clnor_data[2]);
+
+bool BKE_mesh_has_custom_loop_normals(struct Mesh *me);
+
- void BKE_mesh_normals_loop_split(
- struct MVert *mverts, const int numVerts, struct MEdge *medges, const int numEdges,
++void BKE_mesh_normals_loop_split(struct MVert *mverts, const int numVerts, struct MEdge *medges, const int numEdges,
+ struct MLoop *mloops, float (*r_loopnors)[3], const int numLoops,
- struct MPoly *mpolys, const float (*polynors)[3], const int numPolys, float split_angle,
++ struct MPoly *mpolys, const float (*polynors)[3], const int numPolys,
++ const bool use_split_normals, float split_angle,
+ MLoopsNorSpaces *r_lnors_spaces, short (*clnors_data)[2], int *r_loop_to_poly);
+
+void BKE_mesh_normals_loop_custom_set(
+ struct MVert *mverts, const int numVerts, struct MEdge *medges, const int numEdges,
+ struct MLoop *mloops, float (*custom_loopnors)[3], const float *custom_loopnors_facs, const int numLoops,
+ struct MPoly *mpolys, const float (*polynors)[3], const int numPolys,
+ short (*r_clnors_data)[2], const bool use_clnors_data);
+void BKE_mesh_normals_loop_custom_from_vertices_set(
+ struct MVert *mverts, float (*custom_vertnors)[3], const float *custom_vertnors_facs, const int numVerts,
+ struct MEdge *medges, const int numEdges, struct MLoop *mloops, const int numLoops,
+ struct MPoly *mpolys, const float (*polynors)[3], const int numPolys,
+ short (*r_clnors_data)[2], const bool use_clnors_data);
+
void BKE_mesh_calc_poly_normal(
struct MPoly *mpoly, struct MLoop *loopstart,
struct MVert *mvarray, float no[3]);
diff --cc source/blender/blenkernel/intern/cdderivedmesh.c
index bd59431,48fcaf6..6f3c946
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@@ -2209,15 -2208,8 +2209,16 @@@ void CDDM_calc_normals(DerivedMesh *dm
#endif
- void CDDM_calc_loop_normals(DerivedMesh *dm, const float split_angle)
+ void CDDM_calc_loop_normals(DerivedMesh *dm, const bool use_split_normals, const float split_angle)
{
- CDDM_calc_loop_normals_spaces(dm, split_angle, NULL);
++ CDDM_calc_loop_normals_spaces(dm, use_split_normals, split_angle, NULL);
+}
+
+//#define DEBUG_CLNORS
+
- void CDDM_calc_loop_normals_spaces(DerivedMesh *dm, const float split_angle, MLoopsNorSpaces *r_lnors_spaces)
++void CDDM_calc_loop_normals_spaces(
++ DerivedMesh *dm, const bool use_split_normals, const float split_angle, MLoopsNorSpaces *r_lnors_spaces)
+{
MVert *mverts = dm->getVertArray(dm);
MEdge *medges = dm->getEdgeArray(dm);
MLoop *mloops = dm->getLoopArray(dm);
@@@ -2253,40 -2245,11 +2254,41 @@@
dm->dirty &= ~DM_DIRTY_NORMALS;
- BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
- mpolys, pnors, numPolys, use_split_normals, split_angle);
+ {
+ short (*clnor_data)[2] = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
+
+ BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
- mpolys, (const float (*)[3])pnors, numPolys, split_angle,
++ mpolys, (const float (*)[3])pnors, numPolys,
++ use_split_normals, split_angle,
+ r_lnors_spaces, clnor_data, NULL);
+#ifdef DEBUG_CLNORS
+ if (r_lnors_spaces) {
+ int i;
+ for (i = 0; i < numLoops; i++) {
+ if (r_lnors_spaces->lspaces[i]->ref_alpha != 0.0f) {
+ LinkNode *loops = r_lnors_spaces->lspaces[i]->loops;
+ printf("Loop %d uses lnor space %p:\n", i, r_lnors_spaces->lspaces[i]);
+ print_v3("\tfinal lnor", lnors[i]);
+ print_v3("\tauto lnor", r_lnors_spaces->lspaces[i]->vec_lnor);
+ print_v3("\tref_vec", r_lnors_spaces->lspaces[i]->vec_ref);
+ printf("\talpha: %f\n\tbeta: %f\n\tloops: %p\n", r_lnors_spaces->lspaces[i]->ref_alpha,
+ r_lnors_spaces->lspaces[i]->ref_beta, r_lnors_spaces->lspaces[i]->loops);
+ printf("\t\t(shared with loops");
+ while(loops) {
+ printf(" %d", GET_INT_FROM_POINTER(loops->link));
+ loops = loops->next;
+ }
+ printf(")\n");
+ }
+ else {
+ printf("Loop %d has no lnor space\n", i);
+ }
+ }
+ }
+#endif
+ }
}
-
void CDDM_calc_normals_tessface(DerivedMesh *dm)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
diff --cc source/blender/blenkernel/intern/data_transfer.c
index 64271cf,8c42aa7..ca69b75
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@@ -251,110 -242,6 +251,107 @@@ int BKE_object_data_transfer_dttype_to_
/* ********** */
+/* Generic pre/post processing, only used by custom loop normals currently. */
+
+static void data_transfer_dtdata_type_preprocess(
- Object *ob_src, Object *UNUSED(ob_dst), DerivedMesh *dm_src, DerivedMesh *dm_dst, Mesh *me_dst,
- const int dtdata_type, const bool dirty_nors_dst, void **r_prepost_data)
++ Object *UNUSED(ob_src), Object *UNUSED(ob_dst), DerivedMesh *dm_src, DerivedMesh *dm_dst, Mesh *me_dst,
++ const int dtdata_type, const bool dirty_nors_dst, const bool use_split_nors_src, const float split_angle_src,
++ void **r_prepost_data)
+{
+ *r_prepost_data = NULL;
+
+ if (dtdata_type == DT_TYPE_LNOR) {
+ /* Compute custom normals into regular loop normals, which will be used for the transfer. */
- Mesh *me_src = ob_src->data;
-
+ MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert;
+ const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert;
+ MEdge *edges_dst = dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge;
+ const int num_edges_dst = dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge;
+ MPoly *polys_dst = dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly;
+ const int num_polys_dst = dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly;
+ MLoop *loops_dst = dm_dst ? dm_dst->getLoopArray(dm_dst) : me_dst->mloop;
+ const int num_loops_dst = dm_dst ? dm_dst->getNumLoops(dm_dst) : me_dst->totloop;
+ CustomData *pdata_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_ds
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list