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:
authorBastien Montagne <montagne29@wanadoo.fr>2014-04-13 14:18:51 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-04-13 14:19:00 +0400
commit18e4224142261cd8a1086c5872efb406b82f8330 (patch)
treea1a9f7680ab45158ec2c2755f76a966532cad8b8 /source/blender/editors/space_view3d/drawobject.c
parenta872d0b414f406a7d53ce77f7b43e7a831a68fa7 (diff)
Split Normals I (1/5): basis for split normals (nearly nothing user-visible here):
* Add a new calcLoopNormals function to DerivedMesh struct, and implement it for CDDM and CCGDM (subsurf). EditDerivedBMesh (edit mode DM) only gets a dummy one in this commit. * Add a tessellated version of CD_LOOPNORMAL layer (CD_TESSLOOPNORMAL), with relevant code to handle it (tessellation, rna access, etc.). * Change auto_smooth options of Mesh (angle now in radian internaly, and toggle is now used to enable/disable split normals in DM creation process). Note BI render code is not touched here, hence its behavior regarding this option is now incoherent, will be addressed in a separate commit. Reviewers: campbellbarton CC: brecht Differential Revision: https://developer.blender.org/D365
Diffstat (limited to 'source/blender/editors/space_view3d/drawobject.c')
-rw-r--r--source/blender/editors/space_view3d/drawobject.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 6b055d34b13..24e00dd49e2 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -2403,6 +2403,48 @@ static int draw_dm_test_freestyle_face_mark(BMesh *bm, BMFace *efa)
#endif
+/* Draw loop normals. */
+static void draw_dm_loop_normals(BMEditMesh *em, Scene *scene, Object *ob, DerivedMesh *dm)
+{
+ /* XXX Would it be worth adding a dm->foreachMappedLoop func just for this? I doubt it... */
+
+ /* We can't use dm->getLoopDataLayout(dm) here, we want to always access dm->loopData, EditDerivedBMesh would
+ * return loop data from bmesh itself. */
+ float (*lnors)[3] = DM_get_loop_data_layer(dm, CD_NORMAL);
+
+ if (lnors) {
+ drawDMNormal_userData data;
+ MLoop *mloops = dm->getLoopArray(dm);
+ MVert *mverts = dm->getVertArray(dm);
+ int i, totloops = dm->getNumLoops(dm);
+
+ data.bm = em->bm;
+ data.normalsize = scene->toolsettings->normalsize;
+
+ calcDrawDMNormalScale(ob, &data);
+
+ glBegin(GL_LINES);
+ for (i = 0; i < totloops; i++, mloops++, lnors++) {
+ float no[3];
+ float *co = mverts[mloops->v].co;
+
+ if (!data.uniform_scale) {
+ mul_v3_m3v3(no, data.tmat, (float *)lnors);
+ normalize_v3(no);
+ mul_m3_v3(data.imat, no);
+ }
+ else {
+ copy_v3_v3(no,(float *)lnors);
+ }
+ mul_v3_fl(no, data.normalsize);
+ add_v3_v3(no, co);
+ glVertex3fv(co);
+ glVertex3fv(no);
+ }
+ glEnd();
+ }
+}
+
/* Draw faces with color set based on selection
* return 2 for the active face so it renders with stipple enabled */
static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index)
@@ -3351,6 +3393,10 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
UI_ThemeColor(TH_VNORMAL);
draw_dm_vert_normals(em, scene, ob, cageDM);
}
+ if (me->drawflag & ME_DRAW_LNORMALS) {
+ UI_ThemeColor(TH_VNORMAL);
+ draw_dm_loop_normals(em, scene, ob, cageDM);
+ }
if ((me->drawflag & (ME_DRAWEXTRA_EDGELEN |
ME_DRAWEXTRA_FACEAREA |