Skip to content

Commit cf5cfe0

Browse files
committed
Add SPZ extension, library
1 parent fe8d2f0 commit cf5cfe0

16 files changed

+371
-23
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "extern/cmake-modules"]
22
path = extern/cmake-modules
33
url = https://github.com/bilke/cmake-modules.git
4+
[submodule "extern/spz"]
5+
path = extern/spz
6+
url = https://github.com/nianticlabs/spz.git

CesiumGltf/generated/include/CesiumGltf/ExtensionKhrGaussianSplatting.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace CesiumGltf {
99
/**
10-
* @brief glTF extension for rendering Gaussian splats.
10+
* @brief Data for a 3D Gaussian Splat primitive.
1111
*/
1212
struct CESIUMGLTF_API ExtensionKhrGaussianSplatting final
1313
: public CesiumUtility::ExtensibleObject {
@@ -19,11 +19,6 @@ struct CESIUMGLTF_API ExtensionKhrGaussianSplatting final
1919
* key in the `extensions` object. */
2020
static constexpr const char* ExtensionName = "KHR_gaussian_splatting";
2121

22-
/**
23-
* @brief Scale used when dequantizing position attribute values
24-
*/
25-
double quantizedPositionScale = 1;
26-
2722
/**
2823
* @brief Calculates the size in bytes of this object, including the contents
2924
* of all collections, pointers, and strings. This will NOT include the size
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// This file was generated by generate-classes.
2+
// DO NOT EDIT THIS FILE!
3+
#pragma once
4+
5+
#include <CesiumGltf/Library.h>
6+
#include <CesiumUtility/ExtensibleObject.h>
7+
8+
#include <cstdint>
9+
10+
namespace CesiumGltf {
11+
/**
12+
* @brief Compressed data for SPZ primitive.
13+
*/
14+
struct CESIUMGLTF_API ExtensionKhrGaussianSplattingCompressionSpz final
15+
: public CesiumUtility::ExtensibleObject {
16+
/**
17+
* @brief The original name of this type.
18+
*/
19+
static constexpr const char* TypeName =
20+
"ExtensionKhrGaussianSplattingCompressionSpz";
21+
/** @brief The official name of the extension. This should be the same as its
22+
* key in the `extensions` object. */
23+
static constexpr const char* ExtensionName =
24+
"KHR_gaussian_splatting_compression_spz";
25+
26+
/**
27+
* @brief The index of the bufferView.
28+
*/
29+
int32_t bufferView = -1;
30+
31+
/**
32+
* @brief Calculates the size in bytes of this object, including the contents
33+
* of all collections, pointers, and strings. This will NOT include the size
34+
* of any extensions attached to the object. Calling this method may be slow
35+
* as it requires traversing the object's entire structure.
36+
*/
37+
int64_t getSizeBytes() const {
38+
int64_t accum = 0;
39+
accum += int64_t(sizeof(ExtensionKhrGaussianSplattingCompressionSpz));
40+
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
41+
int64_t(sizeof(CesiumUtility::ExtensibleObject));
42+
43+
return accum;
44+
}
45+
};
46+
} // namespace CesiumGltf

CesiumGltf/generated/include/CesiumGltf/ExtensionTextureWebp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct CESIUMGLTF_API ExtensionTextureWebp final
2222
static constexpr const char* ExtensionName = "EXT_texture_webp";
2323

2424
/**
25-
* @brief The index of the images node which points to a WebP image.
25+
* @brief The index of the WebP image.
2626
*/
2727
int32_t source = -1;
2828

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// This file was generated by generate-classes.
2+
// DO NOT EDIT THIS FILE!
3+
#pragma once
4+
5+
#include <CesiumGltf/ExtensionKhrGaussianSplattingCompressionSpz.h>
6+
#include <CesiumGltfReader/Library.h>
7+
#include <CesiumJsonReader/JsonReader.h>
8+
#include <CesiumJsonReader/JsonReaderOptions.h>
9+
10+
#include <rapidjson/fwd.h>
11+
12+
#include <span>
13+
#include <vector>
14+
15+
namespace CesiumGltf {
16+
struct ExtensionKhrGaussianSplattingCompressionSpz;
17+
} // namespace CesiumGltf
18+
19+
namespace CesiumGltfReader {
20+
21+
/**
22+
* @brief Reads \ref CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz
23+
* "ExtensionKhrGaussianSplattingCompressionSpz" instances from JSON.
24+
*/
25+
class CESIUMGLTFREADER_API ExtensionKhrGaussianSplattingCompressionSpzReader {
26+
public:
27+
/**
28+
* @brief Constructs a new instance.
29+
*/
30+
ExtensionKhrGaussianSplattingCompressionSpzReader();
31+
32+
/**
33+
* @brief Gets the options controlling how the JSON is read.
34+
*/
35+
CesiumJsonReader::JsonReaderOptions& getOptions();
36+
37+
/**
38+
* @brief Gets the options controlling how the JSON is read.
39+
*/
40+
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
41+
42+
/**
43+
* @brief Reads an instance of ExtensionKhrGaussianSplattingCompressionSpz
44+
* from a byte buffer.
45+
*
46+
* @param data The buffer from which to read the instance.
47+
* @return The result of reading the instance.
48+
*/
49+
CesiumJsonReader::ReadJsonResult<
50+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz>
51+
readFromJson(const std::span<const std::byte>& data) const;
52+
53+
/**
54+
* @brief Reads an instance of ExtensionKhrGaussianSplattingCompressionSpz
55+
* from a rapidJson::Value.
56+
*
57+
* @param value The value from which to read the instance.
58+
* @return The result of reading the instance.
59+
*/
60+
CesiumJsonReader::ReadJsonResult<
61+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz>
62+
readFromJson(const rapidjson::Value& value) const;
63+
64+
/**
65+
* @brief Reads an array of instances of
66+
* ExtensionKhrGaussianSplattingCompressionSpz from a rapidJson::Value.
67+
*
68+
* @param value The value from which to read the array of instances.
69+
* @return The result of reading the array of instances.
70+
*/
71+
CesiumJsonReader::ReadJsonResult<
72+
std::vector<CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz>>
73+
readArrayFromJson(const rapidjson::Value& value) const;
74+
75+
private:
76+
CesiumJsonReader::JsonReaderOptions _options;
77+
};
78+
79+
} // namespace CesiumGltfReader
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// This file was generated by generate-classes.
2+
// DO NOT EDIT THIS FILE!
3+
#pragma once
4+
5+
#include <CesiumGltf/ExtensionKhrGaussianSplattingCompressionSpz.h>
6+
#include <CesiumJsonReader/ExtensibleObjectJsonHandler.h>
7+
#include <CesiumJsonReader/IntegerJsonHandler.h>
8+
9+
namespace CesiumJsonReader {
10+
class JsonReaderOptions;
11+
} // namespace CesiumJsonReader
12+
13+
namespace CesiumGltfReader {
14+
class ExtensionKhrGaussianSplattingCompressionSpzJsonHandler
15+
: public CesiumJsonReader::ExtensibleObjectJsonHandler,
16+
public CesiumJsonReader::IExtensionJsonHandler {
17+
public:
18+
using ValueType = CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz;
19+
20+
static constexpr const char* ExtensionName =
21+
"KHR_gaussian_splatting_compression_spz";
22+
23+
explicit ExtensionKhrGaussianSplattingCompressionSpzJsonHandler(
24+
const CesiumJsonReader::JsonReaderOptions& options) noexcept;
25+
void reset(
26+
IJsonHandler* pParentHandler,
27+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz* pObject);
28+
29+
IJsonHandler* readObjectKey(const std::string_view& str) override;
30+
31+
void reset(
32+
IJsonHandler* pParentHandler,
33+
CesiumUtility::ExtensibleObject& o,
34+
const std::string_view& extensionName) override;
35+
36+
IJsonHandler& getHandler() override { return *this; }
37+
38+
protected:
39+
IJsonHandler* readObjectKeyExtensionKhrGaussianSplattingCompressionSpz(
40+
const std::string& objectType,
41+
const std::string_view& str,
42+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz& o);
43+
44+
private:
45+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz* _pObject = nullptr;
46+
CesiumJsonReader::IntegerJsonHandler<int32_t> _bufferView;
47+
};
48+
} // namespace CesiumGltfReader

CesiumGltfReader/generated/src/ExtensionKhrGaussianSplattingJsonHandler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#pragma once
44

55
#include <CesiumGltf/ExtensionKhrGaussianSplatting.h>
6-
#include <CesiumJsonReader/DoubleJsonHandler.h>
76
#include <CesiumJsonReader/ExtensibleObjectJsonHandler.h>
87

98
namespace CesiumJsonReader {
@@ -42,6 +41,5 @@ class ExtensionKhrGaussianSplattingJsonHandler
4241

4342
private:
4443
CesiumGltf::ExtensionKhrGaussianSplatting* _pObject = nullptr;
45-
CesiumJsonReader::DoubleJsonHandler _quantizedPositionScale;
4644
};
4745
} // namespace CesiumGltfReader

CesiumGltfReader/generated/src/GeneratedJsonHandlers.cpp

Lines changed: 127 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,8 +3005,7 @@ namespace CesiumGltfReader {
30053005
ExtensionKhrGaussianSplattingJsonHandler::
30063006
ExtensionKhrGaussianSplattingJsonHandler(
30073007
const CesiumJsonReader::JsonReaderOptions& options) noexcept
3008-
: CesiumJsonReader::ExtensibleObjectJsonHandler(options),
3009-
_quantizedPositionScale() {}
3008+
: CesiumJsonReader::ExtensibleObjectJsonHandler(options) {}
30103009

30113010
void ExtensionKhrGaussianSplattingJsonHandler::reset(
30123011
CesiumJsonReader::IJsonHandler* pParentHandler,
@@ -3045,12 +3044,7 @@ CesiumJsonReader::IJsonHandler* ExtensionKhrGaussianSplattingJsonHandler::
30453044
CesiumGltf::ExtensionKhrGaussianSplatting& o) {
30463045
using namespace std::string_literals;
30473046

3048-
if ("quantizedPositionScale"s == str) {
3049-
return property(
3050-
"quantizedPositionScale",
3051-
this->_quantizedPositionScale,
3052-
o.quantizedPositionScale);
3053-
}
3047+
(void)o;
30543048

30553049
return this->readObjectKeyExtensibleObject(objectType, str, *this->_pObject);
30563050
}
@@ -3094,6 +3088,131 @@ ExtensionKhrGaussianSplattingReader::readArrayFromJson(
30943088
return CesiumJsonReader::JsonReader::readJson(value, handler);
30953089
}
30963090

3091+
} // namespace CesiumGltfReader
3092+
// This file was generated by generate-classes.
3093+
// DO NOT EDIT THIS FILE!
3094+
// NOLINTBEGIN(readability-duplicate-include)
3095+
#include "ExtensionKhrGaussianSplattingCompressionSpzJsonHandler.h"
3096+
#include "registerReaderExtensions.h"
3097+
3098+
#include <CesiumGltf/ExtensionKhrGaussianSplattingCompressionSpz.h>
3099+
#include <CesiumGltfReader/ExtensionKhrGaussianSplattingCompressionSpzReader.h>
3100+
#include <CesiumJsonReader/ArrayJsonHandler.h>
3101+
#include <CesiumJsonReader/ExtensibleObjectJsonHandler.h>
3102+
#include <CesiumJsonReader/IJsonHandler.h>
3103+
#include <CesiumJsonReader/JsonReader.h>
3104+
#include <CesiumUtility/Assert.h>
3105+
#include <CesiumUtility/ExtensibleObject.h>
3106+
3107+
#include <rapidjson/document.h>
3108+
3109+
#include <any>
3110+
#include <cstddef>
3111+
#include <span>
3112+
#include <string>
3113+
#include <string_view>
3114+
#include <vector>
3115+
// NOLINTEND(readability-duplicate-include)
3116+
3117+
namespace CesiumGltfReader {
3118+
3119+
ExtensionKhrGaussianSplattingCompressionSpzJsonHandler::
3120+
ExtensionKhrGaussianSplattingCompressionSpzJsonHandler(
3121+
const CesiumJsonReader::JsonReaderOptions& options) noexcept
3122+
: CesiumJsonReader::ExtensibleObjectJsonHandler(options), _bufferView() {}
3123+
3124+
void ExtensionKhrGaussianSplattingCompressionSpzJsonHandler::reset(
3125+
CesiumJsonReader::IJsonHandler* pParentHandler,
3126+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz* pObject) {
3127+
CesiumJsonReader::ExtensibleObjectJsonHandler::reset(pParentHandler, pObject);
3128+
this->_pObject = pObject;
3129+
}
3130+
3131+
CesiumJsonReader::IJsonHandler*
3132+
ExtensionKhrGaussianSplattingCompressionSpzJsonHandler::readObjectKey(
3133+
const std::string_view& str) {
3134+
CESIUM_ASSERT(this->_pObject);
3135+
return this->readObjectKeyExtensionKhrGaussianSplattingCompressionSpz(
3136+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz::TypeName,
3137+
str,
3138+
*this->_pObject);
3139+
}
3140+
3141+
void ExtensionKhrGaussianSplattingCompressionSpzJsonHandler::reset(
3142+
CesiumJsonReader::IJsonHandler* pParentHandler,
3143+
CesiumUtility::ExtensibleObject& o,
3144+
const std::string_view& extensionName) {
3145+
std::any& value =
3146+
o.extensions
3147+
.emplace(
3148+
extensionName,
3149+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz())
3150+
.first->second;
3151+
this->reset(
3152+
pParentHandler,
3153+
&std::any_cast<CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz&>(
3154+
value));
3155+
}
3156+
3157+
CesiumJsonReader::IJsonHandler*
3158+
ExtensionKhrGaussianSplattingCompressionSpzJsonHandler::
3159+
readObjectKeyExtensionKhrGaussianSplattingCompressionSpz(
3160+
const std::string& objectType,
3161+
const std::string_view& str,
3162+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz& o) {
3163+
using namespace std::string_literals;
3164+
3165+
if ("bufferView"s == str) {
3166+
return property("bufferView", this->_bufferView, o.bufferView);
3167+
}
3168+
3169+
return this->readObjectKeyExtensibleObject(objectType, str, *this->_pObject);
3170+
}
3171+
3172+
ExtensionKhrGaussianSplattingCompressionSpzReader::
3173+
ExtensionKhrGaussianSplattingCompressionSpzReader() {
3174+
registerReaderExtensions(this->_options);
3175+
}
3176+
3177+
CesiumJsonReader::JsonReaderOptions&
3178+
ExtensionKhrGaussianSplattingCompressionSpzReader::getOptions() {
3179+
return this->_options;
3180+
}
3181+
3182+
const CesiumJsonReader::JsonReaderOptions&
3183+
ExtensionKhrGaussianSplattingCompressionSpzReader::getOptions() const {
3184+
return this->_options;
3185+
}
3186+
3187+
CesiumJsonReader::ReadJsonResult<
3188+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz>
3189+
ExtensionKhrGaussianSplattingCompressionSpzReader::readFromJson(
3190+
const std::span<const std::byte>& data) const {
3191+
ExtensionKhrGaussianSplattingCompressionSpzJsonHandler handler(
3192+
this->_options);
3193+
return CesiumJsonReader::JsonReader::readJson(data, handler);
3194+
}
3195+
3196+
CesiumJsonReader::ReadJsonResult<
3197+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz>
3198+
ExtensionKhrGaussianSplattingCompressionSpzReader::readFromJson(
3199+
const rapidjson::Value& value) const {
3200+
ExtensionKhrGaussianSplattingCompressionSpzJsonHandler handler(
3201+
this->_options);
3202+
return CesiumJsonReader::JsonReader::readJson(value, handler);
3203+
}
3204+
3205+
CesiumJsonReader::ReadJsonResult<
3206+
std::vector<CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz>>
3207+
ExtensionKhrGaussianSplattingCompressionSpzReader::readArrayFromJson(
3208+
const rapidjson::Value& value) const {
3209+
CesiumJsonReader::ArrayJsonHandler<
3210+
CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz,
3211+
ExtensionKhrGaussianSplattingCompressionSpzJsonHandler>
3212+
handler(this->_options);
3213+
return CesiumJsonReader::JsonReader::readJson(value, handler);
3214+
}
3215+
30973216
} // namespace CesiumGltfReader
30983217
// This file was generated by generate-classes.
30993218
// DO NOT EDIT THIS FILE!

0 commit comments

Comments
 (0)