From 9a0f2c36013f13a212fcdb4149e86eea49558575 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 18 Nov 2016 11:00:55 +0000 Subject: [PATCH] Fix detection of transparent meshes. SSurface::TriangulateInto first populates the mesh with triangles that have no color, and then paints them, which confused the code that detects if a mesh is transparent into thinking that all of them are; and that broke the "draw back faces in red" feature, since it is disabled for transparent meshes. --- CHANGELOG.md | 1 + src/mesh.cpp | 3 ++- src/srf/surface.cpp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b315eb4..466ad25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ Other new features: Bug fixes: * Do not crash when applying a symmetry constraint to two points. * Fix TTF font metrics again (properly this time). + * Fix the "draw back faces in red" option. * Various minor crashes. 2.2 diff --git a/src/mesh.cpp b/src/mesh.cpp index fe84248..c909f8b 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -34,7 +34,8 @@ void SMesh::AddTriangle(STriMeta meta, Vector a, Vector b, Vector c) { AddTriangle(&t); } void SMesh::AddTriangle(const STriangle *st) { - if(st->meta.color.alpha != 255) isTransparent = true; + RgbaColor color = st->meta.color; + if(!color.IsEmpty() && color.alpha != 255) isTransparent = true; l.Add(st); } diff --git a/src/srf/surface.cpp b/src/srf/surface.cpp index 62e2088..1645c1c 100644 --- a/src/srf/surface.cpp +++ b/src/srf/surface.cpp @@ -424,6 +424,7 @@ void SSurface::TriangulateInto(SShell *shell, SMesh *sm) { for(i = start; i < sm->l.n; i++) { STriangle *st = &(sm->l.elem[i]); st->meta = meta; + if(st->meta.color.alpha != 255) sm->isTransparent = true; st->an = NormalAt(st->a.x, st->a.y); st->bn = NormalAt(st->b.x, st->b.y); st->cn = NormalAt(st->c.x, st->c.y);