fix: inline tessellation in io_gltf to avoid circular dep
CI / Build & Test (push) Failing after 32s
CI / Release Build (push) Failing after 31s

This commit is contained in:
茂之钳
2026-07-24 09:13:18 +00:00
parent 0dbbb4ac4f
commit d99c9f1dba
+24 -5
View File
@@ -296,13 +296,32 @@ bool write_brep_gltf(const std::string& filepath, const brep::BrepModel& model,
const auto& surf = model.surface(surf_id);
// Tessellate using the surface evaluator
// Inline tessellation: sample surface uniformly, create quad mesh
int res = std::max(4, tessellation_res);
auto eval = [&surf](double u, double v) -> core::Point3D {
return surf.evaluate(u, v);
};
std::vector<core::Point3D> verts;
std::vector<std::array<int, 3>> tris;
auto [verts, tris] = curves::tessellate(eval, res, res);
auto [u_min, u_max] = surf.domain_u();
auto [v_min, v_max] = surf.domain_v();
for (int j = 0; j <= res; ++j) {
double v = v_min + (v_max - v_min) * static_cast<double>(j) / res;
for (int i = 0; i <= res; ++i) {
double u = u_min + (u_max - u_min) * static_cast<double>(i) / res;
verts.push_back(surf.evaluate(u, v));
}
}
for (int j = 0; j < res; ++j) {
for (int i = 0; i < res; ++i) {
int a = j * (res + 1) + i;
int b = a + 1;
int c = a + (res + 1);
int d = c + 1;
tris.push_back({a, b, d});
tris.push_back({a, d, c});
}
}
// Offset indices
int base = static_cast<int>(all_verts.size());