Skip to content

Commit

Permalink
Merge pull request zeux#314 from dtrebilco/Fix_Samplers
Browse files Browse the repository at this point in the history
Fix for samplers being written out with default values and writing 0 filter fields if no filter value was read

Fixes zeux#313.
  • Loading branch information
zeux authored Jul 8, 2021
2 parents b2a5d65 + 93b8b7c commit 2866a3f
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions gltf/write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,14 +749,30 @@ static std::string decodeUri(const char* uri)

void writeSampler(std::string& json, const cgltf_sampler& sampler)
{
append(json, "\"magFilter\":");
append(json, size_t(sampler.mag_filter));
append(json, ",\"minFilter\":");
append(json, size_t(sampler.min_filter));
append(json, ",\"wrapS\":");
append(json, size_t(sampler.wrap_s));
append(json, ",\"wrapT\":");
append(json, size_t(sampler.wrap_t));
if (sampler.mag_filter != 0)
{
comma(json);
append(json, "\"magFilter\":");
append(json, size_t(sampler.mag_filter));
}
if (sampler.min_filter != 0)
{
comma(json);
append(json, "\"minFilter\":");
append(json, size_t(sampler.min_filter));
}
if (sampler.wrap_s != 10497)
{
comma(json);
append(json, "\"wrapS\":");
append(json, size_t(sampler.wrap_s));
}
if (sampler.wrap_t != 10497)
{
comma(json);
append(json, "\"wrapT\":");
append(json, size_t(sampler.wrap_t));
}
}

void writeImage(std::string& json, std::vector<BufferView>& views, const cgltf_image& image, const ImageInfo& info, size_t index, const char* input_path, const char* output_path, const Settings& settings)
Expand Down

0 comments on commit 2866a3f

Please sign in to comment.