mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
Three callers were each open-coding the same quantize-and-
bucket pass over vertex positions: --info-mesh-stats,
--info-wob-stats, and --bake-wom-collision. Move the
implementation to cli_weld.{hpp,cpp} as buildWeldMap() and
have each caller pass a flat positions array.
Identical std::map-based exact-equality keying preserved
(unbalanced-hash collisions remain absent). All three call
sites verified to produce byte-identical output:
• info-mesh-stats firepit: 240→80 verts, 0 boundary
• info-wob-stats cube: 8→8 verts, watertight YES
• bake-wom-collision tent: 18→6 verts, 8-tri WOC
About 75 lines of duplication removed; future weld-using
commands now opt in by including one header.
30 lines
1,002 B
C++
30 lines
1,002 B
C++
#pragma once
|
|
|
|
#include <glm/glm.hpp>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
namespace wowee {
|
|
namespace editor {
|
|
namespace cli {
|
|
|
|
// Vertex weld pass shared by --info-mesh-stats / --info-wob-stats /
|
|
// --bake-wom-collision. Positions are quantized onto a 1/eps grid;
|
|
// every vertex sharing a cell with a previously-seen vertex is
|
|
// remapped to that vertex's index. Returns canon[v] giving the
|
|
// canonical (lowest-index) representative of v's equivalence class
|
|
// and writes the count of distinct cells to `uniqueOut`.
|
|
//
|
|
// Implementation uses std::map<tuple<int64,int64,int64>, uint32_t>
|
|
// for exact equality on the quantized key — a hash-based key would
|
|
// risk false-positive collisions that incorrectly merge distinct
|
|
// corners (e.g. a unit cube's 8 corners all hashing to 2 buckets).
|
|
std::vector<uint32_t> buildWeldMap(
|
|
const std::vector<glm::vec3>& positions,
|
|
float eps,
|
|
std::size_t& uniqueOut);
|
|
|
|
} // namespace cli
|
|
} // namespace editor
|
|
} // namespace wowee
|