From 677876e4294708784eceb47bfc73698673a6e910 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 12 Jul 2012 05:55:07 +0000 Subject: Fix normals around root nodes of skin modifier output. The direction for these are flipped from other end caps, so add a root flag to indicate whether the cap polygon's vertex output order should be reversed. Fixes bug [#32079] Skin-modifier calculates root's normals wrong projects.blender.org/tracker/index.php?func=detail&aid=32079&group_id=9&atid=498 --- source/blender/modifiers/intern/MOD_skin.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 46987f30205..f24898ccee2 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -91,6 +91,7 @@ typedef enum { CAP_START = 1, CAP_END = 2, SEAM_FRAME = 4, + ROOT = 8 } SkinNodeFlag; typedef struct Frame { @@ -502,6 +503,9 @@ static void end_node_frames(int v, SkinNode *skin_nodes, const MVert *mvert, /* End frame */ create_frame(&skin_nodes[v].frames[0], mvert[v].co, rad, mat, 0); } + + if (nodes[v].flag & MVERT_SKIN_ROOT) + skin_nodes[v].flag |= ROOT; } /* Returns 1 for seam, 0 otherwise */ @@ -1493,18 +1497,27 @@ static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes, } if (sn->flag & CAP_START) { - add_poly(so, - sn->frames[0].verts[3], - sn->frames[0].verts[2], - sn->frames[0].verts[1], - sn->frames[0].verts[0]); + if (sn->flag & ROOT) { + add_poly(so, + sn->frames[0].verts[0], + sn->frames[0].verts[1], + sn->frames[0].verts[2], + sn->frames[0].verts[3]); + } + else { + add_poly(so, + sn->frames[0].verts[3], + sn->frames[0].verts[2], + sn->frames[0].verts[1], + sn->frames[0].verts[0]); + } } if (sn->flag & CAP_END) { add_poly(so, - sn->frames[1].verts[3], - sn->frames[1].verts[2], + sn->frames[1].verts[0], sn->frames[1].verts[1], - sn->frames[1].verts[0]); + sn->frames[1].verts[2], + sn->frames[1].verts[3]); } } } -- cgit v1.2.3