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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-05-17 03:49:28 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-05-17 03:51:00 +0400
commitf8554ed61a427e0407c7e6ad951ef6985a19df95 (patch)
treefb76a765856602f7f38e62c2f39a72a25dc736f9 /source/blender/render
parent2e20c1689798b84fd63d84cd6fc7fb282af05588 (diff)
Fix T39669: Freestyle: Curve with extrude>0 causes warnings in console.
The reported Freestyle warnings were due to wrong normals of filled faces at both ends of a 2D extruded curve. The problem is detailed in the comment #19 of T39669. The cause of the bug was an inconsistency in the use of vertex indices between BKE_mesh_nurbs_displist_to_mdata() and init_render_curve() in the case of DispList::type equal to DL_INDEX3. This commit also fixes a related bug that the normals of filled faces were not inverted when a scale of the curve object is set to a negative value (e.g., the Z scale was -1). Reviewers: campbellbarton Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D532
Diffstat (limited to 'source/blender/render')
-rw-r--r--source/blender/render/intern/source/convertblender.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index cb5f75efd16..3cbbebb069e 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -2635,7 +2635,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
Material **matar;
float *data, *fp, *orco=NULL;
float n[3], mat[4][4], nmat[4][4];
- int nr, startvert, a, b;
+ int nr, startvert, a, b, negative_scale;
bool need_orco = false;
int totmat;
@@ -2649,6 +2649,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
mul_m4_m4m4(mat, re->viewmat, ob->obmat);
invert_m4_m4(ob->imat, mat);
+ negative_scale = is_negative_m4(mat);
/* local object -> world space transform for normals */
copy_m4_m4(nmat, mat);
@@ -2718,7 +2719,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
zero_v3(n);
index= dl->index;
for (a=0; a<dl->parts; a++, index+=3) {
- int v1 = index[0], v2 = index[1], v3 = index[2];
+ int v1 = index[0], v2 = index[2], v3 = index[1];
float *co1 = &dl->verts[v1 * 3],
*co2 = &dl->verts[v2 * 3],
*co3 = &dl->verts[v3 * 3];
@@ -2731,7 +2732,10 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
/* to prevent float accuracy issues, we calculate normal in local object space (not world) */
if (area_tri_v3(co3, co2, co1)>FLT_EPSILON) {
- normal_tri_v3(tmp, co3, co2, co1);
+ if (negative_scale)
+ normal_tri_v3(tmp, co1, co2, co3);
+ else
+ normal_tri_v3(tmp, co3, co2, co1);
add_v3_v3(n, tmp);
}