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.
This commit is contained in:
whitequark 2016-11-18 11:00:55 +00:00
parent 82746b6171
commit ece7630624
3 changed files with 4 additions and 1 deletions

View File

@ -7,6 +7,7 @@ Changelog
Bug fixes: Bug fixes:
* Do not crash when applying a symmetry constraint to two points. * Do not crash when applying a symmetry constraint to two points.
* Fix TTF font metrics again (properly this time). * Fix TTF font metrics again (properly this time).
* Fix the "draw back faces in red" option.
* Various minor crashes. * Various minor crashes.
2.2 2.2

View File

@ -34,7 +34,8 @@ void SMesh::AddTriangle(STriMeta meta, Vector a, Vector b, Vector c) {
AddTriangle(&t); AddTriangle(&t);
} }
void SMesh::AddTriangle(STriangle *st) { void SMesh::AddTriangle(STriangle *st) {
if(st->meta.color.alpha != 255) isTransparent = true; RgbaColor color = st->meta.color;
if(color.ToARGB32() != 0 && color.alpha != 255) isTransparent = true;
l.Add(st); l.Add(st);
} }

View File

@ -426,6 +426,7 @@ void SSurface::TriangulateInto(SShell *shell, SMesh *sm) {
for(i = start; i < sm->l.n; i++) { for(i = start; i < sm->l.n; i++) {
STriangle *st = &(sm->l.elem[i]); STriangle *st = &(sm->l.elem[i]);
st->meta = meta; st->meta = meta;
if(st->meta.color.alpha != 255) sm->isTransparent = true;
st->an = NormalAt(st->a.x, st->a.y); st->an = NormalAt(st->a.x, st->a.y);
st->bn = NormalAt(st->b.x, st->b.y); st->bn = NormalAt(st->b.x, st->b.y);
st->cn = NormalAt(st->c.x, st->c.y); st->cn = NormalAt(st->c.x, st->c.y);