MCPcopy Create free account
hub / github.com/CesiumGS/cesium-native / postprocess

Function postprocess

CesiumGltfReader/src/GltfReader.cpp:258–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258void postprocess(GltfReaderResult& readGltf, const GltfReaderOptions& options) {
259 if (!readGltf.model) {
260 return;
261 }
262
263 Model& model = readGltf.model.value();
264
265 auto extFeatureMetadataIter = std::find(
266 model.extensionsUsed.begin(),
267 model.extensionsUsed.end(),
268 "EXT_feature_metadata");
269
270 if (extFeatureMetadataIter != model.extensionsUsed.end()) {
271 readGltf.warnings.emplace_back(
272 "glTF contains EXT_feature_metadata extension, which is no longer "
273 "supported. The model will still be loaded, but views cannot be "
274 "constructed on its metadata.");
275 }
276
277 if (options.decodeDataUrls) {
278 decodeDataUrls(readGltf, options);
279 }
280
281 if (options.decodeEmbeddedImages) {
282 CESIUM_TRACE("CesiumGltfReader::decodeEmbeddedImages");
283 for (Image& image : model.images) {
284 // Ignore external images for now.
285 if (image.uri) {
286 continue;
287 }
288
289 // Image has already been decoded
290 if (image.pAsset) {
291 continue;
292 }
293
294 const BufferView& bufferView =
295 Model::getSafe(model.bufferViews, image.bufferView);
296 const Buffer& buffer = Model::getSafe(model.buffers, bufferView.buffer);
297
298 if (bufferView.byteOffset + bufferView.byteLength >
299 static_cast<int64_t>(buffer.cesium.data.size())) {
300 readGltf.warnings.emplace_back(
301 "Image bufferView's byte offset is " +
302 std::to_string(bufferView.byteOffset) + " and the byteLength is " +
303 std::to_string(bufferView.byteLength) + ", the result is " +
304 std::to_string(bufferView.byteOffset + bufferView.byteLength) +
305 ", which is more than the available " +
306 std::to_string(buffer.cesium.data.size()) + " bytes.");
307 continue;
308 }
309
310 const std::span<const std::byte> bufferSpan(buffer.cesium.data);
311 const std::span<const std::byte> bufferViewSpan = bufferSpan.subspan(
312 static_cast<size_t>(bufferView.byteOffset),
313 static_cast<size_t>(bufferView.byteLength));
314 ImageReaderResult imageResult =
315 ImageDecoder::readImage(bufferViewSpan, options.ktx2TranscodeTargets);

Callers 6

loadBinaryMethod · 0.85
loadJsonMethod · 0.85
readGltfMethod · 0.85
loadGltfMethod · 0.85
postprocessGltfMethod · 0.85

Calls 13

decodeDataUrlsFunction · 0.85
getSafeFunction · 0.85
decodeMeshOptFunction · 0.85
hasSpzExtensionFunction · 0.85
decodeSpzFunction · 0.85
dequantizeMeshDataFunction · 0.85
applyKhrTextureTransformFunction · 0.85
convertPrimitiveModesFunction · 0.85
decodeDracoFunction · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected