Skip to content

Commit

Permalink
Merge branch 'master' into simplify-attr
Browse files Browse the repository at this point in the history
  • Loading branch information
zeux committed May 30, 2023
2 parents 01b6d85 + 24c8c4e commit e54bbf6
Show file tree
Hide file tree
Showing 32 changed files with 673 additions and 188 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: '16'
- name: test decoder
Expand All @@ -72,7 +72,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: KhronosGroup/glTF-Sample-Models
path: glTF-Sample-Models
Expand All @@ -81,7 +81,7 @@ jobs:
- name: test
run: find glTF-Sample-Models/2.0/ -name *.gltf -or -name *.glb | xargs -d '\n' ./gltfpack -cc -test
- name: pack
run: find glTF-Sample-Models/2.0/ -name *.gltf | grep -v glTF-Draco | grep -v glTF-KTX-BasisU | xargs -d '\n' -I '{}' ./gltfpack -i '{}' -o '{}pack.gltf'
run: find glTF-Sample-Models/2.0/ -name *.gltf | grep -v 'glTF-Draco\|glTF-KTX-BasisU\|glTF-Meshopt' | xargs -d '\n' -I '{}' ./gltfpack -i '{}' -o '{}pack.gltf'
- name: validate
run: |
curl -sL $VALIDATOR | tar xJ
Expand All @@ -93,7 +93,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: '14.x'
- name: install wasi
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: zeux/basis_universal
ref: gltfpack
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ${{matrix.os}}-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: zeux/basis_universal
ref: gltfpack
Expand All @@ -25,12 +25,12 @@ jobs:
run: cmake . -DMESHOPT_BUILD_GLTFPACK=ON -DMESHOPT_BASISU_PATH=basis_universal -DMESHOPT_WERROR=ON -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" -DCMAKE_BUILD_TYPE=Release
- name: cmake build
run: cmake --build . --target gltfpack --config Release -j 2
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v3
with:
name: gltfpack-windows
path: Release/gltfpack.exe
if: matrix.os == 'windows'
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v3
with:
name: gltfpack-${{matrix.os}}
path: gltfpack
Expand All @@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: '14.x'
- name: install wasi
Expand All @@ -61,11 +61,11 @@ jobs:
cp LICENSE.md js/
cd gltf && npm pack && cd ..
cd js && npm pack && cd ..
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: gltfpack-npm
path: gltf/gltfpack-*.tgz
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: meshoptimizer-npm
path: js/meshoptimizer-*.tgz
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW) # Enables clean /W4 override for MSVC
endif()

project(meshoptimizer VERSION 0.18 LANGUAGES CXX)
project(meshoptimizer VERSION 0.19 LANGUAGES CXX)

option(MESHOPT_BUILD_DEMO "Build demo" OFF)
option(MESHOPT_BUILD_GLTFPACK "Build gltfpack" OFF)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016-2022 Arseny Kapoulkine
Copyright (c) 2016-2023 Arseny Kapoulkine

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,18 @@ build/simplifier.wasm: $(WASM_SIMPLIFIER_SOURCES)

js/meshopt_decoder.js: build/decoder_base.wasm build/decoder_simd.wasm tools/wasmpack.py
sed -i "s#Built with clang.*#Built with $$($(WASMCC) --version | head -n 1 | sed 's/\s\+(.*//')#" $@
sed -i "s#Built from meshoptimizer .*#Built from meshoptimizer $$(cat src/meshoptimizer.h | grep -Po '(?<=version )[0-9.]+')#" $@
sed -i "s#\(var wasm_base = \)\".*\";#\\1\"$$(cat build/decoder_base.wasm | python3 tools/wasmpack.py)\";#" $@
sed -i "s#\(var wasm_simd = \)\".*\";#\\1\"$$(cat build/decoder_simd.wasm | python3 tools/wasmpack.py)\";#" $@

js/meshopt_encoder.js: build/encoder.wasm tools/wasmpack.py
sed -i "s#Built with clang.*#Built with $$($(WASMCC) --version | head -n 1 | sed 's/\s\+(.*//')#" $@
sed -i "s#Built from meshoptimizer .*#Built from meshoptimizer $$(cat src/meshoptimizer.h | grep -Po '(?<=version )[0-9.]+')#" $@
sed -i "s#\(var wasm = \)\".*\";#\\1\"$$(cat build/encoder.wasm | python3 tools/wasmpack.py)\";#" $@

js/meshopt_simplifier.js: build/simplifier.wasm tools/wasmpack.py
sed -i "s#Built with clang.*#Built with $$($(WASMCC) --version | head -n 1 | sed 's/\s\+(.*//')#" $@
sed -i "s#Built from meshoptimizer .*#Built from meshoptimizer $$(cat src/meshoptimizer.h | grep -Po '(?<=version )[0-9.]+')#" $@
sed -i "s#\(var wasm = \)\".*\";#\\1\"$$(cat build/simplifier.wasm | python3 tools/wasmpack.py)\";#" $@

js/%.module.js: js/%.js
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The library provides a C and C++ interface for all algorithms; you can use it fr
meshoptimizer is hosted on GitHub; you can download the latest release using git:

```
git clone -b v0.18 https://github.com/zeux/meshoptimizer.git
git clone -b v0.19 https://github.com/zeux/meshoptimizer.git
```

Alternatively you can [download the .zip archive from GitHub](https://github.com/zeux/meshoptimizer/archive/v0.18.zip).
Expand Down
79 changes: 68 additions & 11 deletions demo/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,29 +730,85 @@ void encodeFilterQuat12()

void encodeFilterExp()
{
const float data[3] = {
const float data[4] = {
1,
-23.4f,
-0.1f,
11.0f,
};

const unsigned int expected[3] = {
// separate exponents: each component gets its own value
const unsigned int expected1[4] = {
0xf3002000,
0xf7ffd133,
0xefffcccd,
0xf6002c00,
};

// shared exponents (vector): all components of each vector get the same value
const unsigned int expected2[4] = {
0xf7000200,
0xf7ffd133,
0xf7ffffcd,
0xf6ffff9a,
0xf6002c00,
};

unsigned int encoded[3];
meshopt_encodeFilterExp(encoded, 1, 12, 15, data);
// shared exponents (component): each component gets the same value across all vectors
const unsigned int expected3[4] = {
0xf3002000,
0xf7ffd133,
0xf3fffccd,
0xf7001600,
};

assert(memcmp(encoded, expected, sizeof(expected)) == 0);
unsigned int encoded1[4];
meshopt_encodeFilterExp(encoded1, 2, 8, 15, data, meshopt_EncodeExpSeparate);

float decoded[3];
memcpy(decoded, encoded, sizeof(decoded));
meshopt_decodeFilterExp(decoded, 3, 4);
unsigned int encoded2[4];
meshopt_encodeFilterExp(encoded2, 2, 8, 15, data, meshopt_EncodeExpSharedVector);

unsigned int encoded3[4];
meshopt_encodeFilterExp(encoded3, 2, 8, 15, data, meshopt_EncodeExpSharedComponent);

assert(memcmp(encoded1, expected1, sizeof(expected1)) == 0);
assert(memcmp(encoded2, expected2, sizeof(expected2)) == 0);
assert(memcmp(encoded3, expected3, sizeof(expected3)) == 0);

float decoded1[4];
memcpy(decoded1, encoded1, sizeof(decoded1));
meshopt_decodeFilterExp(decoded1, 2, 8);

float decoded2[4];
memcpy(decoded2, encoded2, sizeof(decoded2));
meshopt_decodeFilterExp(decoded2, 2, 8);

float decoded3[4];
memcpy(decoded3, encoded3, sizeof(decoded3));
meshopt_decodeFilterExp(decoded3, 2, 8);

for (size_t i = 0; i < 4; ++i)
{
assert(fabsf(decoded1[i] - data[i]) < 1e-3f);
assert(fabsf(decoded2[i] - data[i]) < 1e-3f);
assert(fabsf(decoded3[i] - data[i]) < 1e-3f);
}
}

void encodeFilterExpZero()
{
const float data = 0.f;
const unsigned int expected = 0xf2000000;

unsigned int encoded;
meshopt_encodeFilterExp(&encoded, 1, 4, 15, &data, meshopt_EncodeExpSeparate);

assert(encoded == expected);

float decoded;
memcpy(&decoded, &encoded, sizeof(decoded));
meshopt_decodeFilterExp(&decoded, 1, 4);

for (size_t i = 0; i < 3; ++i)
assert(fabsf(decoded[i] - data[i]) < 1e-3f);
assert(decoded == data);
}

static void clusterBoundsDegenerate()
Expand Down Expand Up @@ -1127,6 +1183,7 @@ void runTests()
encodeFilterOct12();
encodeFilterQuat12();
encodeFilterExp();
encodeFilterExpZero();

clusterBoundsDegenerate();

Expand Down
Loading

0 comments on commit e54bbf6

Please sign in to comment.