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

Replace tinygltf #106

Merged
merged 69 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
7a0f190
WIP transition to cgltf.
kring Dec 8, 2020
817b7ed
Merge remote-tracking branch 'origin/master' into gltf
kring Dec 18, 2020
6cb6cdd
Add simdjson.
kring Dec 19, 2020
306886b
Merge remote-tracking branch 'origin/master' into gltf
kring Dec 23, 2020
72b07bc
WIP glTF wrapper
kring Dec 23, 2020
767b5d3
WIP glTF
kring Dec 27, 2020
e8eb102
Merge remote-tracking branch 'origin/master' into gltf
kring Dec 29, 2020
c29069f
Some very broken experiments.
kring Jan 2, 2021
a72c111
Another experiment.
kring Jan 2, 2021
0d7d7d0
Add Mesh and Primitve to POC.
kring Jan 4, 2021
ae16a48
Separate files for glTF reader PoC.
kring Jan 4, 2021
e4a69c6
Support attributes, names.
kring Jan 4, 2021
a67ed6a
Add support for primitive targets.
kring Jan 4, 2021
1504ed3
Add materials.
kring Jan 4, 2021
e49e655
Deserialize materials.
kring Jan 4, 2021
232b87c
Generate glTF classes from JSON Schema.
kring Jan 5, 2021
b27f43b
Include doc in generated classes.
kring Jan 5, 2021
d206b09
Generate reader header files.
kring Jan 5, 2021
bd1a51c
Generate reader implementations.
kring Jan 5, 2021
33db3a2
Generate enum readers.
kring Jan 5, 2021
a26418d
Fix some code generation problems.
kring Jan 5, 2021
87a030a
Generated classes now compiling.
kring Jan 6, 2021
068df1c
Improve error handling.
kring Jan 6, 2021
32dca3f
Improved error reporting.
kring Jan 6, 2021
1c8bdac
Remove unused submodules.
kring Jan 6, 2021
c153c4c
Fix test failure.
kring Jan 6, 2021
bd0290b
Generated doc improvements.
kring Jan 7, 2021
3f6e301
GLB support.
kring Jan 7, 2021
08d173d
Use CesiumGltf instead of tinygltf.
kring Jan 8, 2021
2ec456e
Fix test compiler error.
kring Jan 8, 2021
7f914af
Improve error handling for arrays.
kring Jan 8, 2021
32f0c37
Raster image loading.
kring Jan 8, 2021
2b2c4a8
Add support for extensions, especially Draco.
kring Jan 11, 2021
6a6d2d9
Draco loading.
kring Jan 12, 2021
c999c76
Load embedded images.
kring Jan 12, 2021
e28f181
Remove unnecessary map.
kring Jan 13, 2021
cc97307
Cleanup.
kring Jan 13, 2021
0820875
Default glTF IDs to -1.
kring Jan 13, 2021
cb297c4
More defaults.
kring Jan 13, 2021
edb8fe2
Add extras, reactivate support for RTC_CENTER.
kring Jan 14, 2021
6d9e834
Merge remote-tracking branch 'origin/master' into gltf
kring Jan 14, 2021
11ea310
Optional properties, thorough initialization.
kring Jan 16, 2021
52dbaf2
Merge remote-tracking branch 'origin/master' into gltf
kring Jan 17, 2021
c36a271
Allow for augmentation of generated classes via inheritance.
kring Jan 18, 2021
3bd988f
Remove Helpers entirely.
kring Jan 18, 2021
614b59d
Remove GltfAccessor and GltfWriter.
kring Jan 19, 2021
6147e0b
Clear arrays in StartArray.
kring Jan 20, 2021
dfa5f01
Remove tinygltf.
kring Jan 20, 2021
5d069f2
Fix test failures.
kring Jan 20, 2021
168798f
Don't use a C++ reserved word as a parameter name.
kring Jan 20, 2021
5b1550d
Remove another "default".
kring Jan 20, 2021
8fdc751
Fix Clang problems.
kring Jan 20, 2021
3fe36a7
Fix GCC build problems.
kring Jan 20, 2021
b8bfe33
More signed/unsigned warnings.
kring Jan 20, 2021
56feb19
List of errors and warnings instead of a single string for each.
kring Jan 20, 2021
8d0b1f9
Move and rename test.
kring Jan 20, 2021
d75c55e
Merge remote-tracking branch 'origin/master' into gltf
kring Jan 20, 2021
28b6434
Incorporate changes from review and from the cmpt branch.
kring Jan 25, 2021
f11089f
Fix warnings.
kring Jan 25, 2021
dccfcf0
More picky clang signedness warnings.
kring Jan 25, 2021
7ef8d42
WIP decoding of data URIs.
kring Jan 25, 2021
eee83c9
Remove extraneous namespace qualification.
kring Jan 25, 2021
5226530
Merge remote-tracking branch 'origin/master' into gltf
kring Jan 25, 2021
7b47c7e
Merge remote-tracking branch 'origin/master' into gltf
kring Jan 27, 2021
243f486
Add base64 decoding.
kring Jan 27, 2021
474a2b8
Bring over generator changes from the cmpt branch.
kring Jan 27, 2021
2932b56
Add test for decoding data urls.
kring Jan 28, 2021
92af1b4
Fix gcc/clang warning.
kring Jan 28, 2021
e692908
Fix gcc warning.
kring Jan 28, 2021
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
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "extern/tinygltf"]
path = extern/tinygltf
url = https://github.com/syoyo/tinygltf
[submodule "extern/glm"]
path = extern/glm
url = https://github.com/g-truc/glm.git
Expand Down Expand Up @@ -28,3 +25,9 @@
[submodule "extern/rapidjson"]
path = extern/rapidjson
url = https://github.com/Tencent/rapidjson.git
[submodule "extern/glTF"]
path = extern/glTF
url = https://github.com/KhronosGroup/glTF.git
[submodule "extern/stb"]
path = extern/stb
url = https://github.com/nothings/stb.git
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@
"shared_mutex": "cpp",
"gsl_assert": "cpp",
"compare": "cpp",
"resumable": "cpp"
"resumable": "cpp",
"codecvt": "cpp",
"ranges": "cpp",
"scoped_allocator": "cpp",
"typeindex": "cpp"
},
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"cmake.configureOnOpen": true
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ target_link_libraries(cesium-native-tests PUBLIC Catch2::Catch2)
add_subdirectory(CesiumUtility)
add_subdirectory(CesiumGeometry)
add_subdirectory(CesiumGeospatial)
add_subdirectory(CesiumGltf)
add_subdirectory(CesiumGltfReader)
add_subdirectory(CesiumAsync)
add_subdirectory(Cesium3DTiles)

Expand Down
7 changes: 2 additions & 5 deletions Cesium3DTiles/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ target_sources(
target_include_directories(
Cesium3DTiles
SYSTEM PUBLIC
# We're not using CMake for tinygltf at all, but it's header only. Add its headers here.
${CMAKE_CURRENT_SOURCE_DIR}/../extern/tinygltf

# Same with RapidJSON
${CMAKE_CURRENT_SOURCE_DIR}/../extern/rapidjson/include

# Draco's CMake doesn't use target_include_directories, so we need to manually add draco's include dirs here.
${CMAKE_CURRENT_SOURCE_DIR}/../extern/draco/src

${CMAKE_BINARY_DIR}
PUBLIC
include
Expand All @@ -33,4 +30,4 @@ target_include_directories(
"$<BUILD_INTERFACE:$<$<BOOL:$<TARGET_PROPERTY:Cesium3DTiles_PRIVATE_SRC>>:${CMAKE_CURRENT_SOURCE_DIR}/src>>"
)

target_link_libraries(Cesium3DTiles PUBLIC CesiumAsync CesiumGeospatial CesiumGeometry CesiumUtility uriparser draco tinyxml2 spdlog)
target_link_libraries(Cesium3DTiles PUBLIC CesiumAsync CesiumGeospatial CesiumGeometry CesiumGltf CesiumGltfReader CesiumUtility uriparser draco tinyxml2 spdlog)
56 changes: 13 additions & 43 deletions Cesium3DTiles/include/Cesium3DTiles/Gltf.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#pragma once

#include "Cesium3DTiles/Library.h"
#include "CesiumGltf/Model.h"
#include <glm/mat4x4.hpp>
#include <gsl/span>
#include <optional>
#include <tiny_gltf.h>
#include <functional>

namespace Cesium3DTiles {

/**
* @brief Functions for loading and processing glTF models.
*
* This class offers basic functions for loading glTF models as `tinygltf::Model`
* This class offers basic functions for loading glTF models as `CesiumGltf::Model`
* instances, and for processing the mesh primitives that appear in the resulting
* models.
*/
Expand All @@ -22,45 +23,14 @@ namespace Cesium3DTiles {
/** @brief This class cannot be instantiated */
Gltf() = delete;

/**
* @brief A summary of the result of loading a glTF model from raw data.
*/
struct LoadResult {
/**
* @brief The gltf model that was loaded.
*
* This will be `std::nullopt` if the model was not loaded successfully.
*/
std::optional<tinygltf::Model> model;

/**
* @brief Warning messages from the attempt to load the model.
*/
std::string warnings;

/**
* @brief Error messages from the attempt to load the model.
*/
std::string errors;
};

/**
* @brief Load a glTF model from the given input data.
*
* @param data The input data.
* @return The {@link LoadResult} containing the model (if it could be loaded),
* and possible warning- or error messages.
*/
static LoadResult load(const gsl::span<const uint8_t>& data);

/**
* @brief A callback function for {@link Gltf::forEachPrimitiveInScene}.
*/
typedef void ForEachPrimitiveInSceneCallback(
tinygltf::Model& gltf,
tinygltf::Node& node,
tinygltf::Mesh& mesh,
tinygltf::Primitive& primitive,
CesiumGltf::Model& gltf,
CesiumGltf::Node& node,
CesiumGltf::Mesh& mesh,
CesiumGltf::MeshPrimitive& primitive,
const glm::dmat4& transform
);

Expand All @@ -86,21 +56,21 @@ namespace Cesium3DTiles {
* @param sceneID The scene ID (index)
* @param callback The callback to apply
*/
static void forEachPrimitiveInScene(tinygltf::Model& gltf, int sceneID, std::function<ForEachPrimitiveInSceneCallback>&& callback);
static void forEachPrimitiveInScene(CesiumGltf::Model& gltf, int sceneID, std::function<ForEachPrimitiveInSceneCallback>&& callback);

/**
* @brief A callback function for {@link Gltf::forEachPrimitiveInScene}.
*/
typedef void ForEachPrimitiveInSceneConstCallback(
const tinygltf::Model& gltf,
const tinygltf::Node& node,
const tinygltf::Mesh& mesh,
const tinygltf::Primitive& primitive,
const CesiumGltf::Model& gltf,
const CesiumGltf::Node& node,
const CesiumGltf::Mesh& mesh,
const CesiumGltf::MeshPrimitive& primitive,
const glm::dmat4& transform
);

/** @copydoc Gltf::forEachPrimitiveInScene() */
static void forEachPrimitiveInScene(const tinygltf::Model& gltf, int sceneID, std::function<ForEachPrimitiveInSceneConstCallback>&& callback);
static void forEachPrimitiveInScene(const CesiumGltf::Model& gltf, int sceneID, std::function<ForEachPrimitiveInSceneConstCallback>&& callback);
};


Expand Down
154 changes: 0 additions & 154 deletions Cesium3DTiles/include/Cesium3DTiles/GltfAccessor.h

This file was deleted.

2 changes: 1 addition & 1 deletion Cesium3DTiles/include/Cesium3DTiles/GltfContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace Cesium3DTiles {
* @return The bounding region.
*/
static CesiumGeospatial::BoundingRegion createRasterOverlayTextureCoordinates(
tinygltf::Model& gltf,
CesiumGltf::Model& gltf,
uint32_t textureCoordinateID,
const CesiumGeospatial::Projection& projection,
const CesiumGeometry::Rectangle& rectangle
Expand Down
Loading