Skip to content

Commit

Permalink
Merge pull request #210 from zeux/sdeflz
Browse files Browse the repository at this point in the history
Replace miniz with sdefl
  • Loading branch information
zeux authored Dec 24, 2020
2 parents eafd888 + ead17db commit 2dfcbbd
Show file tree
Hide file tree
Showing 6 changed files with 685 additions and 1,506 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ endif()
set(TARGETS meshoptimizer)

if(MESHOPT_BUILD_DEMO)
add_executable(demo demo/main.cpp demo/miniz.cpp demo/tests.cpp tools/meshloader.cpp)
add_executable(demo demo/main.cpp demo/tests.cpp tools/meshloader.cpp)
target_link_libraries(demo meshoptimizer)
endif()

Expand Down
16 changes: 11 additions & 5 deletions demo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include <vector>

#include "../extern/fast_obj.h"
#include "miniz.h"

#define SDEFL_IMPLEMENTATION
#include "../extern/sdefl.h"

// This file uses assert() to verify algorithm correctness
#undef NDEBUG
Expand Down Expand Up @@ -564,11 +566,11 @@ void optimize(const Mesh& mesh, const char* name, void (*optf)(Mesh& mesh))
}

template <typename T>
size_t compress(const std::vector<T>& data)
size_t compress(const std::vector<T>& data, int level = SDEFL_LVL_DEF)
{
std::vector<unsigned char> cbuf(tdefl_compress_bound(data.size() * sizeof(T)));
unsigned int flags = tdefl_create_comp_flags_from_zip_params(MZ_DEFAULT_LEVEL, 15, MZ_DEFAULT_STRATEGY);
return tdefl_compress_mem_to_mem(&cbuf[0], cbuf.size(), &data[0], data.size() * sizeof(T), flags);
std::vector<unsigned char> cbuf(sdefl_bound(int(data.size() * sizeof(T))));
sdefl s = {};
return sdeflate(&s, &cbuf[0], reinterpret_cast<const unsigned char*>(&data[0]), int(data.size() * sizeof(T)), level);
}

void encodeIndex(const Mesh& mesh, char desc)
Expand Down Expand Up @@ -1082,6 +1084,10 @@ void processDev(const char* path)
strip.resize(meshopt_stripify(&strip[0], &copystrip.indices[0], copystrip.indices.size(), copystrip.vertices.size(), 0));

encodeIndexSequence(strip, copystrip.vertices.size(), 'D');

packVertex<PackedVertex>(copy, "");
encodeVertex<PackedVertex>(copy, "");
encodeVertex<PackedVertexOct>(copy, "O");
}

int main(int argc, char** argv)
Expand Down
Loading

0 comments on commit 2dfcbbd

Please sign in to comment.