mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-09-15 19:03:15 +08:00
Add transcoder testing to Draco's Github CI tests. (#821)
This enabled CI testing of transcoder configs and includes a few minor Windows-only bug fixes. Note that this adds flags to skip GltfDecoderTest.ThreeMeshesOneNoMaterialMesh for Windows MSVC CI builds. See https://github.com/google/draco/issues/826 for details. Windows specific updates (these do impact non-Windows builds, but are essentially a no-op there): - Use a local dupe of a constant to avoid DLL linkage issues on Windows in the GLTF encoder test.. - Define DRACO_PI to avoid M_PI and entertaining include ordering issues related to _USE_MATH_DEFINES and interactions between <cmath> and <math.h> on Windows (fun include guards and order related things). This is done in core/constants.h.
This commit is contained in:
parent
4d78a070c1
commit
34c693fe78
131
.github/workflows/ci.yml
vendored
131
.github/workflows/ci.yml
vendored
@ -28,6 +28,16 @@ jobs:
|
|||||||
-DDRACO_TESTS=ON
|
-DDRACO_TESTS=ON
|
||||||
cmake_build_command: cmake --build . -- -j2
|
cmake_build_command: cmake --build . -- -j2
|
||||||
draco_test_command: ./draco_tests
|
draco_test_command: ./draco_tests
|
||||||
|
- test_name: macos-make-release-shared-with-transcoder
|
||||||
|
os: macos-latest
|
||||||
|
cmake_configure_command: |-
|
||||||
|
cmake .. -G "Unix Makefiles" \
|
||||||
|
-DBUILD_SHARED_LIBS=ON \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DDRACO_TESTS=ON \
|
||||||
|
-DDRACO_TRANSCODER_SUPPORTED=ON
|
||||||
|
cmake_build_command: cmake --build . -- -j2
|
||||||
|
draco_test_command: ./draco_tests
|
||||||
|
|
||||||
- test_name: macos-make-release-static
|
- test_name: macos-make-release-static
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
@ -38,6 +48,16 @@ jobs:
|
|||||||
-DDRACO_TESTS=ON
|
-DDRACO_TESTS=ON
|
||||||
cmake_build_command: cmake --build . -- -j2
|
cmake_build_command: cmake --build . -- -j2
|
||||||
draco_test_command: ./draco_tests
|
draco_test_command: ./draco_tests
|
||||||
|
- test_name: macos-make-release-static-with-transcoder
|
||||||
|
os: macos-latest
|
||||||
|
cmake_configure_command: |-
|
||||||
|
cmake .. -G "Unix Makefiles" \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DDRACO_TESTS=ON \
|
||||||
|
-DDRACO_TRANSCODER_SUPPORTED=ON
|
||||||
|
cmake_build_command: cmake --build . -- -j2
|
||||||
|
draco_test_command: ./draco_tests
|
||||||
|
|
||||||
- test_name: macos-xcode-release-shared
|
- test_name: macos-xcode-release-shared
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
@ -48,6 +68,16 @@ jobs:
|
|||||||
-DDRACO_TESTS=ON
|
-DDRACO_TESTS=ON
|
||||||
cmake_build_command: cmake --build . --config Release
|
cmake_build_command: cmake --build . --config Release
|
||||||
draco_test_command: Release/draco_tests
|
draco_test_command: Release/draco_tests
|
||||||
|
- test_name: macos-xcode-release-shared-with-transcoder
|
||||||
|
os: macos-latest
|
||||||
|
cmake_configure_command: |-
|
||||||
|
cmake .. -G Xcode \
|
||||||
|
-DBUILD_SHARED_LIBS=ON \
|
||||||
|
-DCMAKE_CONFIGURATION_TYPES=Release \
|
||||||
|
-DDRACO_TESTS=ON \
|
||||||
|
-DDRACO_TRANSCODER_SUPPORTED=ON
|
||||||
|
cmake_build_command: cmake --build . --config Release
|
||||||
|
draco_test_command: Release/draco_tests
|
||||||
|
|
||||||
- test_name: macos-xcode-release-static
|
- test_name: macos-xcode-release-static
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
@ -58,6 +88,16 @@ jobs:
|
|||||||
-DDRACO_TESTS=ON
|
-DDRACO_TESTS=ON
|
||||||
cmake_build_command: cmake --build . --config Release
|
cmake_build_command: cmake --build . --config Release
|
||||||
draco_test_command: Release/draco_tests
|
draco_test_command: Release/draco_tests
|
||||||
|
- test_name: macos-xcode-release-static-with-transcoder
|
||||||
|
os: macos-latest
|
||||||
|
cmake_configure_command: |-
|
||||||
|
cmake .. -G Xcode \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DCMAKE_CONFIGURATION_TYPES=Release \
|
||||||
|
-DDRACO_TESTS=ON \
|
||||||
|
-DDRACO_TRANSCODER_SUPPORTED=ON
|
||||||
|
cmake_build_command: cmake --build . --config Release
|
||||||
|
draco_test_command: Release/draco_tests
|
||||||
|
|
||||||
- test_name: ubuntu-make-release-shared
|
- test_name: ubuntu-make-release-shared
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
@ -70,6 +110,18 @@ jobs:
|
|||||||
-DDRACO_TESTS=ON
|
-DDRACO_TESTS=ON
|
||||||
cmake_build_command: cmake --build . -- -j2
|
cmake_build_command: cmake --build . -- -j2
|
||||||
draco_test_command: ./draco_tests
|
draco_test_command: ./draco_tests
|
||||||
|
- test_name: ubuntu-make-release-shared-with-transcoder
|
||||||
|
os: ubuntu-latest
|
||||||
|
cmake_configure_command: |-
|
||||||
|
cmake .. -G "Unix Makefiles" \
|
||||||
|
-DBUILD_SHARED_LIBS=ON \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_C_COMPILER=gcc-10 \
|
||||||
|
-DCMAKE_CXX_COMPILER=g++-10 \
|
||||||
|
-DDRACO_TESTS=ON \
|
||||||
|
-DDRACO_TRANSCODER_SUPPORTED=ON
|
||||||
|
cmake_build_command: cmake --build . -- -j2
|
||||||
|
draco_test_command: ./draco_tests
|
||||||
|
|
||||||
- test_name: ubuntu-make-release-static
|
- test_name: ubuntu-make-release-static
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
@ -82,6 +134,18 @@ jobs:
|
|||||||
-DDRACO_TESTS=ON
|
-DDRACO_TESTS=ON
|
||||||
cmake_build_command: cmake --build . -- -j2
|
cmake_build_command: cmake --build . -- -j2
|
||||||
draco_test_command: ./draco_tests
|
draco_test_command: ./draco_tests
|
||||||
|
- test_name: ubuntu-make-release-static-with-transcoder
|
||||||
|
os: ubuntu-latest
|
||||||
|
cmake_configure_command: |-
|
||||||
|
cmake .. -G "Unix Makefiles" \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_C_COMPILER=gcc-10 \
|
||||||
|
-DCMAKE_CXX_COMPILER=g++-10 \
|
||||||
|
-DDRACO_TESTS=ON \
|
||||||
|
-DDRACO_TRANSCODER_SUPPORTED=ON
|
||||||
|
cmake_build_command: cmake --build . -- -j2
|
||||||
|
draco_test_command: ./draco_tests
|
||||||
|
|
||||||
- test_name: windows-msvc-release-shared
|
- test_name: windows-msvc-release-shared
|
||||||
os: windows-2019
|
os: windows-2019
|
||||||
@ -92,6 +156,20 @@ jobs:
|
|||||||
-DDRACO_TESTS=ON
|
-DDRACO_TESTS=ON
|
||||||
cmake_build_command: cmake --build . --config Release -- -m:2
|
cmake_build_command: cmake --build . --config Release -- -m:2
|
||||||
draco_test_command: Release/draco_tests
|
draco_test_command: Release/draco_tests
|
||||||
|
- test_name: windows-msvc-release-shared-with-transcoder
|
||||||
|
os: windows-2019
|
||||||
|
cmake_configure_command: |-
|
||||||
|
cmake .. -G "Visual Studio 16 2019" \
|
||||||
|
-DBUILD_SHARED_LIBS=ON \
|
||||||
|
-DCMAKE_CONFIGURATION_TYPES=Release \
|
||||||
|
-DDRACO_TESTS=ON \
|
||||||
|
-DDRACO_TRANSCODER_SUPPORTED=ON
|
||||||
|
cmake_build_command: cmake --build . --config Release -- -m:2
|
||||||
|
# TODO(https://github.com/google/draco/issues/826)
|
||||||
|
draco_test_command: |-
|
||||||
|
Release/draco_tests \
|
||||||
|
--gtest_filter=-GltfDecoderTest.ThreeMeshesOneNoMaterialMesh
|
||||||
|
|
||||||
|
|
||||||
- test_name: windows-msvc-release-static
|
- test_name: windows-msvc-release-static
|
||||||
os: windows-2019
|
os: windows-2019
|
||||||
@ -102,6 +180,20 @@ jobs:
|
|||||||
-DDRACO_TESTS=ON
|
-DDRACO_TESTS=ON
|
||||||
cmake_build_command: cmake --build . --config Release -- -m:2
|
cmake_build_command: cmake --build . --config Release -- -m:2
|
||||||
draco_test_command: Release/draco_tests
|
draco_test_command: Release/draco_tests
|
||||||
|
- test_name: windows-msvc-release-static-with-transcoder
|
||||||
|
os: windows-2019
|
||||||
|
cmake_configure_command: |-
|
||||||
|
cmake .. -G "Visual Studio 16 2019" \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DCMAKE_CONFIGURATION_TYPES=Release \
|
||||||
|
-DDRACO_TESTS=ON \
|
||||||
|
-DDRACO_TRANSCODER_SUPPORTED=ON
|
||||||
|
cmake_build_command: cmake --build . --config Release -- -m:2
|
||||||
|
# TODO(https://github.com/google/draco/issues/826)
|
||||||
|
draco_test_command: |-
|
||||||
|
Release/draco_tests \
|
||||||
|
--gtest_filter=-GltfDecoderTest.ThreeMeshesOneNoMaterialMesh
|
||||||
|
|
||||||
|
|
||||||
- test_name: windows-make-release-shared
|
- test_name: windows-make-release-shared
|
||||||
os: windows-2019
|
os: windows-2019
|
||||||
@ -114,6 +206,18 @@ jobs:
|
|||||||
-DDRACO_TESTS=ON
|
-DDRACO_TESTS=ON
|
||||||
cmake_build_command: cmake --build . -- -j2
|
cmake_build_command: cmake --build . -- -j2
|
||||||
draco_test_command: ./draco_tests
|
draco_test_command: ./draco_tests
|
||||||
|
- test_name: windows-make-release-shared-with-transcoder
|
||||||
|
os: windows-2019
|
||||||
|
cmake_configure_command: |-
|
||||||
|
cmake .. -G "MinGW Makefiles" \
|
||||||
|
-DBUILD_SHARED_LIBS=ON \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
|
||||||
|
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
|
||||||
|
-DDRACO_TESTS=ON \
|
||||||
|
-DDRACO_TRANSCODER_SUPPORTED=ON
|
||||||
|
cmake_build_command: cmake --build . -- -j2
|
||||||
|
draco_test_command: ./draco_tests
|
||||||
|
|
||||||
- test_name: windows-make-release-static
|
- test_name: windows-make-release-static
|
||||||
os: windows-2019
|
os: windows-2019
|
||||||
@ -126,6 +230,18 @@ jobs:
|
|||||||
-DDRACO_TESTS=ON
|
-DDRACO_TESTS=ON
|
||||||
cmake_build_command: cmake --build . -- -j2
|
cmake_build_command: cmake --build . -- -j2
|
||||||
draco_test_command: ./draco_tests
|
draco_test_command: ./draco_tests
|
||||||
|
- test_name: windows-make-release-static-with-transcoder
|
||||||
|
os: windows-2019
|
||||||
|
cmake_configure_command: |-
|
||||||
|
cmake .. -G "MinGW Makefiles" \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
|
||||||
|
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
|
||||||
|
-DDRACO_TESTS=ON \
|
||||||
|
-DDRACO_TRANSCODER_SUPPORTED=ON
|
||||||
|
cmake_build_command: cmake --build . -- -j2
|
||||||
|
draco_test_command: ./draco_tests
|
||||||
|
|
||||||
name: test-${{ matrix.test_name }}
|
name: test-${{ matrix.test_name }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@ -163,22 +279,37 @@ jobs:
|
|||||||
- test_name: ubuntu-make
|
- test_name: ubuntu-make
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
test_command: python3 test.py -v -G "Unix Makefiles"
|
test_command: python3 test.py -v -G "Unix Makefiles"
|
||||||
|
- test_name: ubuntu-make-with-transcoder
|
||||||
|
os: ubuntu-latest
|
||||||
|
test_command: python3 test.py -v -t -G "Unix Makefiles"
|
||||||
|
|
||||||
- test_name: macos-make
|
- test_name: macos-make
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
test_command: python3 test.py -v -G "Unix Makefiles"
|
test_command: python3 test.py -v -G "Unix Makefiles"
|
||||||
|
- test_name: macos-make-with-transcoder
|
||||||
|
os: macos-latest
|
||||||
|
test_command: python3 test.py -v -t -G "Unix Makefiles"
|
||||||
|
|
||||||
- test_name: macos-xcode
|
- test_name: macos-xcode
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
test_command: python3 test.py -v -G Xcode
|
test_command: python3 test.py -v -G Xcode
|
||||||
|
- test_name: macos-xcode-with-transcoder
|
||||||
|
os: macos-latest
|
||||||
|
test_command: python3 test.py -v -t -G Xcode
|
||||||
|
|
||||||
- test_name: windows-make
|
- test_name: windows-make
|
||||||
os: windows-2019
|
os: windows-2019
|
||||||
test_command: python3 test.py -v -G "MinGW Makefiles"
|
test_command: python3 test.py -v -G "MinGW Makefiles"
|
||||||
|
- test_name: windows-make-with-transcoder
|
||||||
|
os: windows-2019
|
||||||
|
test_command: python3 test.py -v -t -G "MinGW Makefiles"
|
||||||
|
|
||||||
- test_name: windows-msvc
|
- test_name: windows-msvc
|
||||||
os: windows-2019
|
os: windows-2019
|
||||||
test_command: python3 test.py -v -G "Visual Studio 16 2019"
|
test_command: python3 test.py -v -G "Visual Studio 16 2019"
|
||||||
|
- test_name: windows-msvc-with-transcoder
|
||||||
|
os: windows-2019
|
||||||
|
test_command: python3 test.py -v -t -G "Visual Studio 16 2019"
|
||||||
|
|
||||||
name: install-test-${{ matrix.test_name }}
|
name: install-test-${{ matrix.test_name }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
@ -246,9 +246,11 @@ list(APPEND draco_dec_config_sources
|
|||||||
|
|
||||||
list(APPEND draco_compression_decode_sources
|
list(APPEND draco_compression_decode_sources
|
||||||
"${draco_src_root}/compression/decode.cc"
|
"${draco_src_root}/compression/decode.cc"
|
||||||
"${draco_src_root}/compression/decode.h")
|
"${draco_src_root}/compression/decode.h"
|
||||||
|
"${draco_src_root}/compression/draco_compression_options.h")
|
||||||
|
|
||||||
list(APPEND draco_compression_encode_sources
|
list(APPEND draco_compression_encode_sources
|
||||||
|
"${draco_src_root}/compression/draco_compression_options.h"
|
||||||
"${draco_src_root}/compression/encode.cc"
|
"${draco_src_root}/compression/encode.cc"
|
||||||
"${draco_src_root}/compression/encode.h"
|
"${draco_src_root}/compression/encode.h"
|
||||||
"${draco_src_root}/compression/encode_base.h"
|
"${draco_src_root}/compression/encode_base.h"
|
||||||
@ -337,6 +339,7 @@ list(APPEND draco_core_sources
|
|||||||
"${draco_src_root}/core/bit_utils.h"
|
"${draco_src_root}/core/bit_utils.h"
|
||||||
"${draco_src_root}/core/bounding_box.cc"
|
"${draco_src_root}/core/bounding_box.cc"
|
||||||
"${draco_src_root}/core/bounding_box.h"
|
"${draco_src_root}/core/bounding_box.h"
|
||||||
|
"${draco_src_root}/core/constants.h"
|
||||||
"${draco_src_root}/core/cycle_timer.cc"
|
"${draco_src_root}/core/cycle_timer.cc"
|
||||||
"${draco_src_root}/core/cycle_timer.h"
|
"${draco_src_root}/core/cycle_timer.h"
|
||||||
"${draco_src_root}/core/data_buffer.cc"
|
"${draco_src_root}/core/data_buffer.cc"
|
||||||
|
6
src/draco/core/constants.h
Normal file
6
src/draco/core/constants.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef DRACO_CORE_CONSTANTS_H_
|
||||||
|
#define DRACO_CORE_CONSTANTS_H_
|
||||||
|
|
||||||
|
#define DRACO_PI 3.14159265358979323846
|
||||||
|
|
||||||
|
#endif // DRACO_CORE_CONSTANTS_H_
|
@ -22,6 +22,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef DRACO_TRANSCODER_SUPPORTED
|
#ifdef DRACO_TRANSCODER_SUPPORTED
|
||||||
|
#include "draco/core/constants.h"
|
||||||
#include "draco/core/draco_test_base.h"
|
#include "draco/core/draco_test_base.h"
|
||||||
#include "draco/core/draco_test_utils.h"
|
#include "draco/core/draco_test_utils.h"
|
||||||
#include "draco/core/draco_types.h"
|
#include "draco/core/draco_types.h"
|
||||||
@ -1156,7 +1157,7 @@ TEST(GltfDecoderTest, DecodeLightsIntoScene) {
|
|||||||
ASSERT_EQ(light.GetType(), draco::Light::POINT);
|
ASSERT_EQ(light.GetType(), draco::Light::POINT);
|
||||||
ASSERT_EQ(light.GetRange(), 1000);
|
ASSERT_EQ(light.GetRange(), 1000);
|
||||||
ASSERT_EQ(light.GetInnerConeAngle(), 0.0);
|
ASSERT_EQ(light.GetInnerConeAngle(), 0.0);
|
||||||
ASSERT_NEAR(light.GetOuterConeAngle(), M_PI / 4.0f, 1e-8);
|
ASSERT_NEAR(light.GetOuterConeAngle(), DRACO_PI / 4.0f, 1e-8);
|
||||||
|
|
||||||
// Check directional light with some properties specified.
|
// Check directional light with some properties specified.
|
||||||
light = *scene->GetLight(LightIndex(2));
|
light = *scene->GetLight(LightIndex(2));
|
||||||
@ -1174,7 +1175,7 @@ TEST(GltfDecoderTest, DecodeLightsIntoScene) {
|
|||||||
ASSERT_EQ(light.GetType(), draco::Light::SPOT);
|
ASSERT_EQ(light.GetType(), draco::Light::SPOT);
|
||||||
ASSERT_EQ(light.GetRange(), std::numeric_limits<float>::max());
|
ASSERT_EQ(light.GetRange(), std::numeric_limits<float>::max());
|
||||||
ASSERT_EQ(light.GetInnerConeAngle(), 0.0);
|
ASSERT_EQ(light.GetInnerConeAngle(), 0.0);
|
||||||
ASSERT_NEAR(light.GetOuterConeAngle(), M_PI / 4.0f, 1e-8);
|
ASSERT_NEAR(light.GetOuterConeAngle(), DRACO_PI / 4.0f, 1e-8);
|
||||||
|
|
||||||
// Check that lights are referenced by the scene nodes.
|
// Check that lights are referenced by the scene nodes.
|
||||||
ASSERT_EQ(scene->GetNode(SceneNodeIndex(0))->GetLightIndex(),
|
ASSERT_EQ(scene->GetNode(SceneNodeIndex(0))->GetLightIndex(),
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
#ifdef DRACO_TRANSCODER_SUPPORTED
|
#ifdef DRACO_TRANSCODER_SUPPORTED
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "draco/core/draco_test_base.h"
|
#include "draco/core/draco_test_base.h"
|
||||||
#include "draco/core/draco_test_utils.h"
|
#include "draco/core/draco_test_utils.h"
|
||||||
@ -411,8 +413,9 @@ TEST_F(GltfEncoderTest, EncodeNamedGenericAttribute) {
|
|||||||
// Set metadata for first attribute so it gets written out by glTF encoder.
|
// Set metadata for first attribute so it gets written out by glTF encoder.
|
||||||
std::unique_ptr<draco::AttributeMetadata> am(new draco::AttributeMetadata());
|
std::unique_ptr<draco::AttributeMetadata> am(new draco::AttributeMetadata());
|
||||||
constexpr char kAttributeName[] = "MyAttributeName";
|
constexpr char kAttributeName[] = "MyAttributeName";
|
||||||
am->AddEntryString(GltfEncoder::kDracoMetadataGltfAttributeName,
|
constexpr char kDracoMetadataGltfAttributeName[] =
|
||||||
kAttributeName);
|
"//GLTF/ApplicationSpecificAttributeName";
|
||||||
|
am->AddEntryString(kDracoMetadataGltfAttributeName, kAttributeName);
|
||||||
mesh->AddAttributeMetadata(new_att_id_0, std::move(am));
|
mesh->AddAttributeMetadata(new_att_id_0, std::move(am));
|
||||||
|
|
||||||
// Make sure the GLTF contains a reference to the named attribute.
|
// Make sure the GLTF contains a reference to the named attribute.
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
|
|
||||||
#ifdef DRACO_TRANSCODER_SUPPORTED
|
#ifdef DRACO_TRANSCODER_SUPPORTED
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#include "draco/core/constants.h"
|
||||||
|
|
||||||
namespace draco {
|
namespace draco {
|
||||||
|
|
||||||
Light::Light()
|
Light::Light()
|
||||||
@ -27,7 +28,7 @@ Light::Light()
|
|||||||
type_(POINT),
|
type_(POINT),
|
||||||
range_(std::numeric_limits<float>::max()), // Infinity.
|
range_(std::numeric_limits<float>::max()), // Infinity.
|
||||||
inner_cone_angle_(0.0),
|
inner_cone_angle_(0.0),
|
||||||
outer_cone_angle_(M_PI / 4.0) {}
|
outer_cone_angle_(DRACO_PI / 4.0) {}
|
||||||
|
|
||||||
void Light::Copy(const Light &light) {
|
void Light::Copy(const Light &light) {
|
||||||
name_ = light.name_;
|
name_ = light.name_;
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
//
|
//
|
||||||
#include "draco/scene/light.h"
|
#include "draco/scene/light.h"
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#include "draco/core/constants.h"
|
||||||
#include "draco/core/draco_test_base.h"
|
#include "draco/core/draco_test_base.h"
|
||||||
#include "draco/core/draco_test_utils.h"
|
#include "draco/core/draco_test_utils.h"
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ TEST(LightTest, TestDefaults) {
|
|||||||
ASSERT_EQ(light.GetType(), draco::Light::POINT);
|
ASSERT_EQ(light.GetType(), draco::Light::POINT);
|
||||||
ASSERT_EQ(light.GetRange(), std::numeric_limits<float>::max());
|
ASSERT_EQ(light.GetRange(), std::numeric_limits<float>::max());
|
||||||
ASSERT_EQ(light.GetInnerConeAngle(), 0.0);
|
ASSERT_EQ(light.GetInnerConeAngle(), 0.0);
|
||||||
ASSERT_EQ(light.GetOuterConeAngle(), M_PI / 4.0);
|
ASSERT_EQ(light.GetOuterConeAngle(), DRACO_PI / 4.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(LightTest, TestCopy) {
|
TEST(LightTest, TestCopy) {
|
||||||
@ -44,8 +44,8 @@ TEST(LightTest, TestCopy) {
|
|||||||
light.SetIntensity(5.0);
|
light.SetIntensity(5.0);
|
||||||
light.SetType(draco::Light::SPOT);
|
light.SetType(draco::Light::SPOT);
|
||||||
light.SetRange(1000.0);
|
light.SetRange(1000.0);
|
||||||
light.SetInnerConeAngle(M_PI / 8.0);
|
light.SetInnerConeAngle(DRACO_PI / 8.0);
|
||||||
light.SetOuterConeAngle(M_PI / 2.0);
|
light.SetOuterConeAngle(DRACO_PI / 2.0);
|
||||||
|
|
||||||
// Create a copy of the initialized light and check all properties.
|
// Create a copy of the initialized light and check all properties.
|
||||||
draco::Light copy;
|
draco::Light copy;
|
||||||
@ -55,8 +55,8 @@ TEST(LightTest, TestCopy) {
|
|||||||
ASSERT_EQ(copy.GetIntensity(), 5.0);
|
ASSERT_EQ(copy.GetIntensity(), 5.0);
|
||||||
ASSERT_EQ(copy.GetType(), draco::Light::SPOT);
|
ASSERT_EQ(copy.GetType(), draco::Light::SPOT);
|
||||||
ASSERT_EQ(copy.GetRange(), 1000.0);
|
ASSERT_EQ(copy.GetRange(), 1000.0);
|
||||||
ASSERT_EQ(copy.GetInnerConeAngle(), M_PI / 8.0);
|
ASSERT_EQ(copy.GetInnerConeAngle(), DRACO_PI / 8.0);
|
||||||
ASSERT_EQ(copy.GetOuterConeAngle(), M_PI / 2.0);
|
ASSERT_EQ(copy.GetOuterConeAngle(), DRACO_PI / 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DRACO_TRANSCODER_SUPPORTED
|
#endif // DRACO_TRANSCODER_SUPPORTED
|
||||||
|
@ -18,13 +18,27 @@
|
|||||||
// against an installed version of Draco without errors. It does not perform
|
// against an installed version of Draco without errors. It does not perform
|
||||||
// any sort of library tests.
|
// any sort of library tests.
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "draco/core/decoder_buffer.h"
|
#include "draco/core/decoder_buffer.h"
|
||||||
|
|
||||||
|
#if defined DRACO_TRANSCODER_SUPPORTED
|
||||||
|
#include "draco/scene/scene.h"
|
||||||
|
#include "draco/scene/scene_utils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int /*argc*/, char** /*argv*/) {
|
int main(int /*argc*/, char** /*argv*/) {
|
||||||
std::vector<char> empty_buffer;
|
std::vector<char> empty_buffer;
|
||||||
draco::DecoderBuffer buffer;
|
draco::DecoderBuffer buffer;
|
||||||
buffer.Init(empty_buffer.data(), empty_buffer.size());
|
buffer.Init(empty_buffer.data(), empty_buffer.size());
|
||||||
|
|
||||||
|
#if defined DRACO_TRANSCODER_SUPPORTED
|
||||||
|
draco::Scene empty_scene;
|
||||||
|
const int num_meshes = empty_scene.NumMeshes();
|
||||||
|
(void)num_meshes;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Partial sanity test passed.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,16 @@ CMAKE = shutil.which('cmake')
|
|||||||
# List of generators available in the current CMake executable.
|
# List of generators available in the current CMake executable.
|
||||||
CMAKE_AVAILABLE_GENERATORS = []
|
CMAKE_AVAILABLE_GENERATORS = []
|
||||||
|
|
||||||
|
# List of variable defs to be passed through to CMake via its -D argument.
|
||||||
|
CMAKE_DEFINES = []
|
||||||
|
|
||||||
# CMake builds use the specified generator.
|
# CMake builds use the specified generator.
|
||||||
CMAKE_GENERATOR = None
|
CMAKE_GENERATOR = None
|
||||||
|
|
||||||
|
# Enable the transcoder before running tests (sets DRACO_TRANSCODER_SUPPORTED
|
||||||
|
# and builds transcoder support dependencies).
|
||||||
|
ENABLE_TRANSCODER = False
|
||||||
|
|
||||||
# The Draco tree that this script uses.
|
# The Draco tree that this script uses.
|
||||||
DRACO_SOURCES_PATH = os.path.abspath(os.path.join('..', '..', '..', '..'))
|
DRACO_SOURCES_PATH = os.path.abspath(os.path.join('..', '..', '..', '..'))
|
||||||
|
|
||||||
@ -136,6 +143,9 @@ def run_process_and_capture_output(cmd, env=None):
|
|||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
|
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
|
||||||
|
|
||||||
|
if VERBOSE:
|
||||||
|
print('COMMAND output:')
|
||||||
|
|
||||||
stdout = ''
|
stdout = ''
|
||||||
for line in iter(proc.stdout.readline, b''):
|
for line in iter(proc.stdout.readline, b''):
|
||||||
decoded_line = line.decode('utf-8')
|
decoded_line = line.decode('utf-8')
|
||||||
@ -183,6 +193,10 @@ def cmake_configure(source_path, cmake_args=None):
|
|||||||
for arg in cmake_args:
|
for arg in cmake_args:
|
||||||
command += f' {arg}'
|
command += f' {arg}'
|
||||||
|
|
||||||
|
if CMAKE_DEFINES:
|
||||||
|
for arg in CMAKE_DEFINES:
|
||||||
|
command += f' -D{arg}'
|
||||||
|
|
||||||
if VERBOSE:
|
if VERBOSE:
|
||||||
print(f'CONFIGURE command:\n{command}')
|
print(f'CONFIGURE command:\n{command}')
|
||||||
|
|
||||||
@ -191,9 +205,6 @@ def cmake_configure(source_path, cmake_args=None):
|
|||||||
if result[0] != 0:
|
if result[0] != 0:
|
||||||
raise Exception(f'CONFIGURE failed!\nexit_code: {result[0]}\n{result[1]}')
|
raise Exception(f'CONFIGURE failed!\nexit_code: {result[0]}\n{result[1]}')
|
||||||
|
|
||||||
if VERBOSE:
|
|
||||||
print(f'CONFIGURE result:\nexit_code: {result[0]}\n{result[1]}')
|
|
||||||
|
|
||||||
|
|
||||||
def cmake_build(cmake_args=None, build_args=None):
|
def cmake_build(cmake_args=None, build_args=None):
|
||||||
"""Runs a CMake build."""
|
"""Runs a CMake build."""
|
||||||
@ -225,30 +236,116 @@ def cmake_build(cmake_args=None, build_args=None):
|
|||||||
if result[0] != 0:
|
if result[0] != 0:
|
||||||
raise Exception(f'BUILD failed!\nexit_code: {result[0]}\n{result[1]}')
|
raise Exception(f'BUILD failed!\nexit_code: {result[0]}\n{result[1]}')
|
||||||
|
|
||||||
if VERBOSE:
|
|
||||||
print(f'BUILD result:\nexit_code: {result[0]}\n{result[1]}')
|
|
||||||
|
|
||||||
|
|
||||||
def run_install_check(install_path):
|
def run_install_check(install_path):
|
||||||
"""Runs the install_check program."""
|
"""Runs the install_check program."""
|
||||||
cmd = os.path.join(install_path, 'bin', 'install_check')
|
cmd = os.path.join(install_path, 'bin', 'install_check')
|
||||||
result = run_process_and_capture_output(cmd)
|
if VERBOSE:
|
||||||
|
print(f'RUN command: {cmd}')
|
||||||
|
|
||||||
|
result = run_process_and_capture_output(cmd)
|
||||||
if result[0] != 0:
|
if result[0] != 0:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f'install_check run failed!\nexit_code: {result[0]}\n{result[1]}')
|
f'install_check run failed!\nexit_code: {result[0]}\n{result[1]}')
|
||||||
|
|
||||||
|
|
||||||
|
def build_and_install_transcoder_dependencies():
|
||||||
|
"""Builds and installs Draco dependencies for transcoder enabled builds."""
|
||||||
|
orig_dir = os.getcwd()
|
||||||
|
|
||||||
|
# The Eigen CMake build in the release Draco has pinned is, to put it mildly,
|
||||||
|
# user unfriendly. Instead of wasting time trying to integrate it here, just
|
||||||
|
# shutil.copytree() everything in $eigen_submodule_path to
|
||||||
|
# $CMAKE_INSTALL_PREFIX/include/Eigen.
|
||||||
|
# Eigen claims to be header-only, so this should be adequate for Draco's
|
||||||
|
# needs here.
|
||||||
|
eigen_submodule_path = os.path.join(
|
||||||
|
DRACO_SOURCES_PATH, 'third_party', 'eigen', 'Eigen')
|
||||||
|
|
||||||
|
# "Install" Eigen for the shared install root.
|
||||||
|
eigen_install_path = os.path.join(
|
||||||
|
DRACO_SHARED_INSTALL_PATH, 'include', 'Eigen')
|
||||||
|
shutil.copytree(src=eigen_submodule_path, dst=eigen_install_path)
|
||||||
|
|
||||||
|
# "Install" Eigen for the static install root.
|
||||||
|
eigen_install_path = os.path.join(
|
||||||
|
DRACO_STATIC_INSTALL_PATH, 'include', 'Eigen')
|
||||||
|
shutil.copytree(src=eigen_submodule_path, dst=eigen_install_path)
|
||||||
|
|
||||||
|
# Build and install gulrak/filesystem for shared and static configurations.
|
||||||
|
# Note that this is basically running gulrak/filesystem's CMake build as an
|
||||||
|
# install script.
|
||||||
|
fs_submodule_path = os.path.join(
|
||||||
|
DRACO_SOURCES_PATH, 'third_party', 'filesystem')
|
||||||
|
|
||||||
|
# Install gulrak/filesystem in the shared draco install root.
|
||||||
|
fs_shared_build = os.path.join(DRACO_SHARED_BUILD_PATH, '_fs')
|
||||||
|
pathlib.Path(fs_shared_build).mkdir(parents=True, exist_ok=True)
|
||||||
|
os.chdir(fs_shared_build)
|
||||||
|
cmake_args = []
|
||||||
|
cmake_args.append(f'-DCMAKE_INSTALL_PREFIX={DRACO_SHARED_INSTALL_PATH}')
|
||||||
|
cmake_args.append('-DBUILD_SHARED_LIBS=ON')
|
||||||
|
cmake_args.append('-DGHC_FILESYSTEM_BUILD_TESTING=OFF')
|
||||||
|
cmake_args.append('-DGHC_FILESYSTEM_BUILD_EXAMPLES=OFF')
|
||||||
|
cmake_configure(source_path=fs_submodule_path, cmake_args=cmake_args)
|
||||||
|
cmake_build(cmake_args=['--target install'])
|
||||||
|
|
||||||
|
# Install gulrak/filesystem in the shared draco install root.
|
||||||
|
fs_static_build = os.path.join(DRACO_STATIC_BUILD_PATH, '_fs')
|
||||||
|
pathlib.Path(fs_static_build).mkdir(parents=True, exist_ok=True)
|
||||||
|
os.chdir(fs_static_build)
|
||||||
|
cmake_args = []
|
||||||
|
cmake_args.append(f'-DCMAKE_INSTALL_PREFIX={DRACO_SHARED_INSTALL_PATH}')
|
||||||
|
cmake_args.append('-DBUILD_SHARED_LIBS=OFF')
|
||||||
|
cmake_args.append('-DGHC_FILESYSTEM_BUILD_TESTING=OFF')
|
||||||
|
cmake_args.append('-DGHC_FILESYSTEM_BUILD_EXAMPLES=OFF')
|
||||||
|
cmake_configure(source_path=fs_submodule_path, cmake_args=cmake_args)
|
||||||
|
cmake_build(cmake_args=['--target install'])
|
||||||
|
|
||||||
|
# Build and install TinyGLTF for shared and static configurations.
|
||||||
|
# Note, as above, that this is basically running TinyGLTF's CMake build as an
|
||||||
|
# install script.
|
||||||
|
tinygltf_submodule_path = os.path.join(
|
||||||
|
DRACO_SOURCES_PATH, 'third_party', 'tinygltf')
|
||||||
|
|
||||||
|
# Install TinyGLTF in the shared draco install root.
|
||||||
|
tinygltf_shared_build = os.path.join(DRACO_SHARED_BUILD_PATH, '_TinyGLTF')
|
||||||
|
pathlib.Path(tinygltf_shared_build).mkdir(parents=True, exist_ok=True)
|
||||||
|
os.chdir(tinygltf_shared_build)
|
||||||
|
cmake_args = []
|
||||||
|
cmake_args.append(f'-DCMAKE_INSTALL_PREFIX={DRACO_SHARED_INSTALL_PATH}')
|
||||||
|
cmake_args.append('-DTINYGLTF_BUILD_EXAMPLES=OFF')
|
||||||
|
cmake_configure(source_path=tinygltf_submodule_path, cmake_args=cmake_args)
|
||||||
|
cmake_build(cmake_args=['--target install'])
|
||||||
|
|
||||||
|
# Install TinyGLTF in the static draco install root.
|
||||||
|
tinygltf_static_build = os.path.join(DRACO_STATIC_BUILD_PATH, '_TinyGLTF')
|
||||||
|
pathlib.Path(tinygltf_static_build).mkdir(parents=True, exist_ok=True)
|
||||||
|
os.chdir(tinygltf_static_build)
|
||||||
|
cmake_args = []
|
||||||
|
cmake_args.append(f'-DCMAKE_INSTALL_PREFIX={DRACO_STATIC_INSTALL_PATH}')
|
||||||
|
cmake_args.append('-DTINYGLTF_BUILD_EXAMPLES=OFF')
|
||||||
|
cmake_configure(source_path=tinygltf_submodule_path, cmake_args=cmake_args)
|
||||||
|
cmake_build(cmake_args=['--target install'])
|
||||||
|
|
||||||
|
os.chdir(orig_dir)
|
||||||
|
|
||||||
|
|
||||||
def build_and_install_draco():
|
def build_and_install_draco():
|
||||||
"""Builds Draco in shared and static configurations."""
|
"""Builds Draco in shared and static configurations."""
|
||||||
orig_dir = os.getcwd()
|
orig_dir = os.getcwd()
|
||||||
|
|
||||||
|
if ENABLE_TRANSCODER:
|
||||||
|
build_and_install_transcoder_dependencies()
|
||||||
|
|
||||||
# Build and install Draco in shared library config for the current host
|
# Build and install Draco in shared library config for the current host
|
||||||
# machine.
|
# machine.
|
||||||
os.chdir(DRACO_SHARED_BUILD_PATH)
|
os.chdir(DRACO_SHARED_BUILD_PATH)
|
||||||
cmake_args = []
|
cmake_args = []
|
||||||
cmake_args.append(f'-DCMAKE_INSTALL_PREFIX={DRACO_SHARED_INSTALL_PATH}')
|
cmake_args.append(f'-DCMAKE_INSTALL_PREFIX={DRACO_SHARED_INSTALL_PATH}')
|
||||||
cmake_args.append('-DBUILD_SHARED_LIBS=ON')
|
cmake_args.append('-DBUILD_SHARED_LIBS=ON')
|
||||||
|
if ENABLE_TRANSCODER:
|
||||||
|
cmake_args.append('-DDRACO_TRANSCODER_SUPPORTED=ON')
|
||||||
cmake_configure(source_path=DRACO_SOURCES_PATH, cmake_args=cmake_args)
|
cmake_configure(source_path=DRACO_SOURCES_PATH, cmake_args=cmake_args)
|
||||||
cmake_build(cmake_args=['--target install'])
|
cmake_build(cmake_args=['--target install'])
|
||||||
|
|
||||||
@ -257,6 +354,8 @@ def build_and_install_draco():
|
|||||||
cmake_args = []
|
cmake_args = []
|
||||||
cmake_args.append(f'-DCMAKE_INSTALL_PREFIX={DRACO_STATIC_INSTALL_PATH}')
|
cmake_args.append(f'-DCMAKE_INSTALL_PREFIX={DRACO_STATIC_INSTALL_PATH}')
|
||||||
cmake_args.append('-DBUILD_SHARED_LIBS=OFF')
|
cmake_args.append('-DBUILD_SHARED_LIBS=OFF')
|
||||||
|
if ENABLE_TRANSCODER:
|
||||||
|
cmake_args.append('-DDRACO_TRANSCODER_SUPPORTED=ON')
|
||||||
cmake_configure(source_path=DRACO_SOURCES_PATH, cmake_args=cmake_args)
|
cmake_configure(source_path=DRACO_SOURCES_PATH, cmake_args=cmake_args)
|
||||||
cmake_build(cmake_args=['--target install'])
|
cmake_build(cmake_args=['--target install'])
|
||||||
|
|
||||||
@ -301,6 +400,14 @@ if __name__ == '__main__':
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-G', '--generator', help='CMake builds use the specified generator.')
|
'-G', '--generator', help='CMake builds use the specified generator.')
|
||||||
|
parser.add_argument(
|
||||||
|
'-D', '--cmake_define',
|
||||||
|
action='append',
|
||||||
|
help='Passes argument through to CMake as a CMake variable via cmake -D.')
|
||||||
|
parser.add_argument(
|
||||||
|
'-t', '--with_transcoder',
|
||||||
|
action='store_true',
|
||||||
|
help='Run tests with Draco transcoder support enabled.')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-v',
|
'-v',
|
||||||
'--verbose',
|
'--verbose',
|
||||||
@ -308,15 +415,21 @@ if __name__ == '__main__':
|
|||||||
help='Show configuration and build output.')
|
help='Show configuration and build output.')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.cmake_define:
|
||||||
|
CMAKE_DEFINES = args.cmake_define
|
||||||
if args.generator:
|
if args.generator:
|
||||||
CMAKE_GENERATOR = args.generator
|
CMAKE_GENERATOR = args.generator
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
VERBOSE = True
|
VERBOSE = True
|
||||||
|
if args.with_transcoder:
|
||||||
|
ENABLE_TRANSCODER = True
|
||||||
|
|
||||||
if VERBOSE:
|
if VERBOSE:
|
||||||
print(f'CMAKE={CMAKE}')
|
print(f'CMAKE={CMAKE}')
|
||||||
|
print(f'CMAKE_DEFINES={CMAKE_DEFINES}')
|
||||||
print(f'CMAKE_GENERATOR={CMAKE_GENERATOR}')
|
print(f'CMAKE_GENERATOR={CMAKE_GENERATOR}')
|
||||||
print(f'CMAKE_AVAILABLE_GENERATORS={CMAKE_AVAILABLE_GENERATORS}')
|
print(f'CMAKE_AVAILABLE_GENERATORS={CMAKE_AVAILABLE_GENERATORS}')
|
||||||
|
print(f'ENABLE_TRANSCODER={ENABLE_TRANSCODER}')
|
||||||
print(f'DRACO_SOURCES_PATH={DRACO_SOURCES_PATH}')
|
print(f'DRACO_SOURCES_PATH={DRACO_SOURCES_PATH}')
|
||||||
print(f'DRACO_SHARED_BUILD_PATH={DRACO_SHARED_BUILD_PATH}')
|
print(f'DRACO_SHARED_BUILD_PATH={DRACO_SHARED_BUILD_PATH}')
|
||||||
print(f'DRACO_STATIC_BUILD_PATH={DRACO_STATIC_BUILD_PATH}')
|
print(f'DRACO_STATIC_BUILD_PATH={DRACO_STATIC_BUILD_PATH}')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user