Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rounding errors breaking buffer sizes of large gltf models #810

Merged
merged 7 commits into from
Aug 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
guh
Strilanc committed Aug 3, 2024
commit 93f305a734097a4a73b17f393971b3a18d4fd496
4 changes: 2 additions & 2 deletions src/stim/diagram/gltf.cc
Original file line number Diff line number Diff line change
@@ -31,14 +31,14 @@ JsonObj GltfScene::_to_json_local() const {
JsonObj GltfScene::to_json() {
// Clear indices.
visit([&](GltfId &item_id, const char *type, const std::function<JsonObj(void)> &to_json, uintptr_t abs_id) {
item_id.index = SIZE_MAX;
item_id.index = UINT64_MAX;
});

// Re-index.
std::map<std::string, size_t> counts;
visit([&](GltfId &item_id, const char *type, const std::function<JsonObj(void)> &to_json, uintptr_t abs_id) {
auto &c = counts[type];
if (item_id.index == SIZE_MAX || item_id.index == c) {
if (item_id.index == UINT64_MAX || item_id.index == c) {
item_id.index = c;
c++;
} else if (item_id.index > c) {
12 changes: 6 additions & 6 deletions src/stim/diagram/gltf.h
Original file line number Diff line number Diff line change
@@ -32,9 +32,9 @@ constexpr size_t GL_NEAREST = 9728;

struct GltfId {
std::string name;
size_t index;
uint64_t index;

GltfId(std::string name) : name(name), index(SIZE_MAX) {
GltfId(std::string name) : name(name), index(UINT64_MAX) {
}
GltfId() = delete;
};
@@ -125,10 +125,10 @@ struct GltfBuffer {

struct GltfSampler {
GltfId id;
size_t magFilter;
size_t minFilter;
size_t wrapS;
size_t wrapT;
uint64_t magFilter;
uint64_t minFilter;
uint64_t wrapS;
uint64_t wrapT;

void visit(const gltf_visit_callback &callback);
JsonObj to_json() const;