summaryrefslogtreecommitdiff
path: root/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-12-09 14:11:26 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-12-09 14:18:14 -0300
commit65fb961b8b2c81ce33c9e0e4c0add7b13da0193a (patch)
treef6c6c050db94f04874e2fbdc6f2f05c1a51f5b63 /thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp
parentccef401700603fe31692ad67ba5c2026e192bbff (diff)
-Ability to and unwrap lightmap coordinates on import
-Added unwrap functionality to Mesh -Ability to display and debug mesh UVs -Added multiline draw, so it's easier and faster to draw UVs -Many fixes to SurfaceTool -Fixes to Thekla Unwrap, but it's a piece of ass and it keeps crashing. Will have to go away
Diffstat (limited to 'thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp')
-rw-r--r--thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp
index f2156899ae..5ce452cb9e 100644
--- a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp
+++ b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp
@@ -152,7 +152,7 @@ AtlasPacker::~AtlasPacker()
}
// This should compute convex hull and use rotating calipers to find the best box. Currently it uses a brute force method.
-static void computeBoundingBox(Chart * chart, Vector2 * majorAxis, Vector2 * minorAxis, Vector2 * minCorner, Vector2 * maxCorner)
+static bool computeBoundingBox(Chart * chart, Vector2 * majorAxis, Vector2 * minorAxis, Vector2 * minCorner, Vector2 * maxCorner)
{
// Compute list of boundary points.
Array<Vector2> points(16);
@@ -184,6 +184,9 @@ static void computeBoundingBox(Chart * chart, Vector2 * majorAxis, Vector2 * min
#if 1
Array<Vector2> hull;
+ if (points.size()==0) {
+ return false;
+ }
convexHull(points, hull, 0.00001f);
@@ -373,6 +376,8 @@ static void computeBoundingBox(Chart * chart, Vector2 * majorAxis, Vector2 * min
}
}*/
#endif
+
+ return true;
}
@@ -431,7 +436,10 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned
// Compute bounding box of chart.
Vector2 majorAxis, minorAxis, origin, end;
- computeBoundingBox(chart, &majorAxis, &minorAxis, &origin, &end);
+ if (!computeBoundingBox(chart, &majorAxis, &minorAxis, &origin, &end)) {
+ m_atlas->setFailed();
+ return;
+ }
nvCheck(isFinite(majorAxis) && isFinite(minorAxis) && isFinite(origin));