Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:munix9
meshoptimizer
0002-Remove-debug-code.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0002-Remove-debug-code.patch of Package meshoptimizer
From: =?utf-8?q?Timo_R=C3=B6hling?= <timo@gaussglocke.de> Date: Wed, 2 Dec 2020 00:20:52 +0100 Subject: Remove debug code --- gltf/gltfpack.cpp | 39 --------- gltf/mesh.cpp | 227 ----------------------------------------------------- src/simplifier.cpp | 16 ---- 3 files changed, 282 deletions(-) diff --git a/gltf/gltfpack.cpp b/gltf/gltfpack.cpp index fabc586..7c960f7 100644 --- a/gltf/gltfpack.cpp +++ b/gltf/gltfpack.cpp @@ -366,41 +366,12 @@ static void process(cgltf_data* data, const char* input_path, const char* output markNeededNodes(data, nodes, meshes, animations, settings); markNeededMaterials(data, materials, meshes, settings); -#ifndef NDEBUG - std::vector<Mesh> debug_meshes; - - for (size_t i = 0; i < meshes.size(); ++i) - { - const Mesh& mesh = meshes[i]; - - if (settings.simplify_debug > 0) - { - Mesh kinds = {}; - Mesh loops = {}; - debugSimplify(mesh, kinds, loops, settings.simplify_debug); - debug_meshes.push_back(kinds); - debug_meshes.push_back(loops); - } - - if (settings.meshlet_debug > 0) - { - Mesh meshlets = {}; - Mesh bounds = {}; - debugMeshlets(mesh, meshlets, bounds, settings.meshlet_debug, /* scan= */ false); - debug_meshes.push_back(meshlets); - debug_meshes.push_back(bounds); - } - } -#endif for (size_t i = 0; i < meshes.size(); ++i) { processMesh(meshes[i], settings); } -#ifndef NDEBUG - meshes.insert(meshes.end(), debug_meshes.begin(), debug_meshes.end()); -#endif filterEmptyMeshes(meshes); // some meshes may become empty after processing @@ -1308,16 +1279,6 @@ int main(int argc, char** argv) { settings.simplify_lock_borders = true; } -#ifndef NDEBUG - else if (strcmp(arg, "-sd") == 0 && i + 1 < argc && isdigit(argv[i + 1][0])) - { - settings.simplify_debug = clamp(float(atof(argv[++i])), 0.f, 1.f); - } - else if (strcmp(arg, "-md") == 0 && i + 1 < argc && isdigit(argv[i + 1][0])) - { - settings.meshlet_debug = clamp(atoi(argv[++i]), 3, 255); - } -#endif else if (strcmp(arg, "-tu") == 0) { settings.texture_ktx2 = true; diff --git a/gltf/mesh.cpp b/gltf/mesh.cpp index 2f4b29f..f619e70 100644 --- a/gltf/mesh.cpp +++ b/gltf/mesh.cpp @@ -777,230 +777,3 @@ void processMesh(Mesh& mesh, const Settings& settings) } } -#ifndef NDEBUG -extern MESHOPTIMIZER_API unsigned char* meshopt_simplifyDebugKind; -extern MESHOPTIMIZER_API unsigned int* meshopt_simplifyDebugLoop; -extern MESHOPTIMIZER_API unsigned int* meshopt_simplifyDebugLoopBack; - -void debugSimplify(const Mesh& source, Mesh& kinds, Mesh& loops, float ratio) -{ - Mesh mesh = source; - assert(mesh.type == cgltf_primitive_type_triangles); - - // note: it's important to follow the same pipeline as processMesh - // otherwise the result won't match - filterBones(mesh); - reindexMesh(mesh); - filterTriangles(mesh); - - // before simplification we need to setup target kind/loop arrays - size_t vertex_count = mesh.streams[0].data.size(); - - std::vector<unsigned char> kind(vertex_count); - std::vector<unsigned int> loop(vertex_count); - std::vector<unsigned int> loopback(vertex_count); - std::vector<unsigned char> live(vertex_count); - - meshopt_simplifyDebugKind = &kind[0]; - meshopt_simplifyDebugLoop = &loop[0]; - meshopt_simplifyDebugLoopBack = &loopback[0]; - - simplifyMesh(mesh, ratio, /* aggressive= */ false, /* lock_borders= */ false); - - meshopt_simplifyDebugKind = NULL; - meshopt_simplifyDebugLoop = NULL; - meshopt_simplifyDebugLoopBack = NULL; - - // fill out live info - for (size_t i = 0; i < mesh.indices.size(); ++i) - live[mesh.indices[i]] = true; - - // color palette for display - static const Attr kPalette[] = { - {0.5f, 0.5f, 0.5f, 1.f}, // manifold - {0.f, 0.f, 1.f, 1.f}, // border - {0.f, 1.f, 0.f, 1.f}, // seam - {0.f, 1.f, 1.f, 1.f}, // complex - {1.f, 0.f, 0.f, 1.f}, // locked - }; - - // prepare meshes - kinds.nodes = mesh.nodes; - kinds.skin = mesh.skin; - - loops.nodes = mesh.nodes; - loops.skin = mesh.skin; - - for (size_t i = 0; i < mesh.streams.size(); ++i) - { - const Stream& stream = mesh.streams[i]; - - if (stream.target == 0 && (stream.type == cgltf_attribute_type_position || stream.type == cgltf_attribute_type_joints || stream.type == cgltf_attribute_type_weights)) - { - kinds.streams.push_back(stream); - loops.streams.push_back(stream); - } - } - - // transform kind/loop data into lines & points - Stream colors = {cgltf_attribute_type_color}; - colors.data.resize(vertex_count); - - for (size_t i = 0; i < vertex_count; ++i) - colors.data[i] = kPalette[kind[i]]; - - kinds.type = cgltf_primitive_type_points; - - kinds.streams.push_back(colors); - - for (size_t i = 0; i < vertex_count; ++i) - if (live[i] && kind[i] != 0) - kinds.indices.push_back(unsigned(i)); - - loops.type = cgltf_primitive_type_lines; - - loops.streams.push_back(colors); - - for (size_t i = 0; i < vertex_count; ++i) - if (live[i] && (kind[i] == 1 || kind[i] == 2)) - { - if (loop[i] != ~0u && live[loop[i]]) - { - loops.indices.push_back(unsigned(i)); - loops.indices.push_back(loop[i]); - } - - if (loopback[i] != ~0u && live[loopback[i]]) - { - loops.indices.push_back(loopback[i]); - loops.indices.push_back(unsigned(i)); - } - } -} - -void debugMeshlets(const Mesh& source, Mesh& meshlets, Mesh& bounds, int max_vertices, bool scan) -{ - Mesh mesh = source; - assert(mesh.type == cgltf_primitive_type_triangles); - - reindexMesh(mesh); - - if (scan) - optimizeMesh(mesh, false); - - const Stream* positions = getStream(mesh, cgltf_attribute_type_position); - assert(positions); - - const float cone_weight = 0.f; - - size_t max_triangles = (max_vertices * 2 + 3) & ~3; - size_t max_meshlets = meshopt_buildMeshletsBound(mesh.indices.size(), max_vertices, max_triangles); - - std::vector<meshopt_Meshlet> ml(max_meshlets); - std::vector<unsigned int> mlv(max_meshlets * max_vertices); - std::vector<unsigned char> mlt(max_meshlets * max_triangles * 3); - - if (scan) - ml.resize(meshopt_buildMeshletsScan(&ml[0], &mlv[0], &mlt[0], &mesh.indices[0], mesh.indices.size(), positions->data.size(), max_vertices, max_triangles)); - else - ml.resize(meshopt_buildMeshlets(&ml[0], &mlv[0], &mlt[0], &mesh.indices[0], mesh.indices.size(), positions->data[0].f, positions->data.size(), sizeof(Attr), max_vertices, max_triangles, cone_weight)); - - // generate meshlet meshes, using unique colors - meshlets.nodes = mesh.nodes; - - Stream mv = {cgltf_attribute_type_position}; - Stream mc = {cgltf_attribute_type_color}; - - for (size_t i = 0; i < ml.size(); ++i) - { - const meshopt_Meshlet& m = ml[i]; - - unsigned int h = unsigned(i); - h ^= h >> 13; - h *= 0x5bd1e995; - h ^= h >> 15; - - Attr c = {{float(h & 0xff) / 255.f, float((h >> 8) & 0xff) / 255.f, float((h >> 16) & 0xff) / 255.f, 1.f}}; - - unsigned int offset = unsigned(mv.data.size()); - - for (size_t j = 0; j < m.vertex_count; ++j) - { - mv.data.push_back(positions->data[mlv[m.vertex_offset + j]]); - mc.data.push_back(c); - } - - for (size_t j = 0; j < m.triangle_count; ++j) - { - meshlets.indices.push_back(offset + mlt[m.triangle_offset + j * 3 + 0]); - meshlets.indices.push_back(offset + mlt[m.triangle_offset + j * 3 + 1]); - meshlets.indices.push_back(offset + mlt[m.triangle_offset + j * 3 + 2]); - } - } - - meshlets.type = cgltf_primitive_type_triangles; - meshlets.streams.push_back(mv); - meshlets.streams.push_back(mc); - - // generate bounds meshes, using a sphere per meshlet - bounds.nodes = mesh.nodes; - - Stream bv = {cgltf_attribute_type_position}; - Stream bc = {cgltf_attribute_type_color}; - - for (size_t i = 0; i < ml.size(); ++i) - { - const meshopt_Meshlet& m = ml[i]; - - meshopt_Bounds mb = meshopt_computeMeshletBounds(&mlv[m.vertex_offset], &mlt[m.triangle_offset], m.triangle_count, positions->data[0].f, positions->data.size(), sizeof(Attr)); - - unsigned int h = unsigned(i); - h ^= h >> 13; - h *= 0x5bd1e995; - h ^= h >> 15; - - Attr c = {{float(h & 0xff) / 255.f, float((h >> 8) & 0xff) / 255.f, float((h >> 16) & 0xff) / 255.f, 0.1f}}; - - unsigned int offset = unsigned(bv.data.size()); - - const int N = 10; - - for (int y = 0; y <= N; ++y) - { - float u = (y == N) ? 0 : float(y) / N * 2 * 3.1415926f; - float sinu = sinf(u), cosu = cosf(u); - - for (int x = 0; x <= N; ++x) - { - float v = float(x) / N * 3.1415926f; - float sinv = sinf(v), cosv = cosf(v); - - float fx = sinv * cosu; - float fy = sinv * sinu; - float fz = cosv; - - Attr p = {{mb.center[0] + mb.radius * fx, mb.center[1] + mb.radius * fy, mb.center[2] + mb.radius * fz, 1.f}}; - - bv.data.push_back(p); - bc.data.push_back(c); - } - } - - for (int y = 0; y < N; ++y) - for (int x = 0; x < N; ++x) - { - bounds.indices.push_back(offset + (N + 1) * (y + 0) + (x + 0)); - bounds.indices.push_back(offset + (N + 1) * (y + 0) + (x + 1)); - bounds.indices.push_back(offset + (N + 1) * (y + 1) + (x + 0)); - - bounds.indices.push_back(offset + (N + 1) * (y + 1) + (x + 0)); - bounds.indices.push_back(offset + (N + 1) * (y + 0) + (x + 1)); - bounds.indices.push_back(offset + (N + 1) * (y + 1) + (x + 1)); - } - } - - bounds.type = cgltf_primitive_type_triangles; - bounds.streams.push_back(bv); - bounds.streams.push_back(bc); -} -#endif diff --git a/src/simplifier.cpp b/src/simplifier.cpp index 5ba8570..04efc89 100644 --- a/src/simplifier.cpp +++ b/src/simplifier.cpp @@ -1461,12 +1461,6 @@ static float interpolate(float y, float x0, float y0, float x1, float y1, float } // namespace meshopt -#ifndef NDEBUG -// Note: this is only exposed for debug visualization purposes; do *not* use these in debug builds -MESHOPTIMIZER_API unsigned char* meshopt_simplifyDebugKind = NULL; -MESHOPTIMIZER_API unsigned int* meshopt_simplifyDebugLoop = NULL; -MESHOPTIMIZER_API unsigned int* meshopt_simplifyDebugLoopBack = NULL; -#endif size_t meshopt_simplifyEdge(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions_data, size_t vertex_count, size_t vertex_positions_stride, const float* vertex_attributes_data, size_t vertex_attributes_stride, const float* attribute_weights, size_t attribute_count, size_t target_index_count, float target_error, unsigned int options, float* out_result_error) { @@ -1614,16 +1608,6 @@ size_t meshopt_simplifyEdge(unsigned int* destination, const unsigned int* indic printf("result: %d triangles, error: %e; total %d passes\n", int(result_count), sqrtf(result_error), int(pass_count)); #endif -#ifndef NDEBUG - if (meshopt_simplifyDebugKind) - memcpy(meshopt_simplifyDebugKind, vertex_kind, vertex_count); - - if (meshopt_simplifyDebugLoop) - memcpy(meshopt_simplifyDebugLoop, loop, vertex_count * sizeof(unsigned int)); - - if (meshopt_simplifyDebugLoopBack) - memcpy(meshopt_simplifyDebugLoopBack, loopback, vertex_count * sizeof(unsigned int)); -#endif // result_error is quadratic; we need to remap it back to linear if (out_result_error)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor