75 const std::optional<std::string>&
name() const noexcept {
76 return _pPropertyTexture->
name;
121 template <
typename T,
bool Normalized = false>
123 const std::string& propertyId,
131 if (!pClassProperty) {
136 return getPropertyViewImpl<T, Normalized>(
163 template <
typename Callback>
165 const std::string& propertyId,
177 if (!pClassProperty) {
202 if (pClassProperty->
array) {
204 getArrayPropertyViewImpl<Callback, true>(
209 std::forward<Callback>(callback),
212 getArrayPropertyViewImpl<Callback, false>(
217 std::forward<Callback>(callback),
225 getScalarPropertyViewImpl<Callback, true>(
229 std::forward<Callback>(callback),
232 getScalarPropertyViewImpl<Callback, false>(
236 std::forward<Callback>(callback),
244 getVecNPropertyViewImpl<Callback, true>(
249 std::forward<Callback>(callback),
252 getVecNPropertyViewImpl<Callback, false>(
257 std::forward<Callback>(callback),
292 template <
typename Callback>
296 for (
const auto& property : this->_pClass->
properties) {
299 std::forward<Callback>(callback),
305 template <
typename T,
bool Normalized>
307 const std::string& propertyId,
310 auto propertyTexturePropertyIter =
311 _pPropertyTexture->
properties.find(propertyId);
312 if (propertyTexturePropertyIter == _pPropertyTexture->
properties.end()) {
320 return PropertyTexturePropertyView<T, Normalized>(
324 const PropertyTextureProperty& propertyTextureProperty =
325 propertyTexturePropertyIter->second;
327 if constexpr (IsMetadataScalar<T>::value) {
328 return createScalarPropertyView<T, Normalized>(
330 propertyTextureProperty,
334 if constexpr (IsMetadataVecN<T>::value) {
335 return createVecNPropertyView<T, Normalized>(
337 propertyTextureProperty,
341 if constexpr (IsMetadataArray<T>::value) {
342 return createArrayPropertyView<
344 Normalized>(classProperty, propertyTextureProperty, propertyOptions);
348 template <
typename Callback,
bool Normalized>
349 void getArrayPropertyViewImpl(
350 const std::string& propertyId,
351 const ClassProperty& classProperty,
355 const TextureViewOptions& propertyOptions)
const {
360 PropertyTexturePropertyView<uint8_t>(
365 int64_t count = classProperty.count.value_or(0);
366 if (count <= 0 || count > 4) {
369 PropertyTexturePropertyView<uint8_t>(
374 switch (componentType) {
378 getPropertyViewImpl<PropertyArrayView<int8_t>, Normalized>(
386 getPropertyViewImpl<PropertyArrayView<uint8_t>, Normalized>(
394 getPropertyViewImpl<PropertyArrayView<int16_t>, Normalized>(
402 getPropertyViewImpl<PropertyArrayView<uint16_t>, Normalized>(
410 PropertyTexturePropertyView<uint8_t>(
416 template <
typename Callback,
bool Normalized>
417 void getScalarPropertyViewImpl(
418 const std::string& propertyId,
419 const ClassProperty& classProperty,
422 const TextureViewOptions& propertyOptions)
const {
423 switch (componentType) {
427 getPropertyViewImpl<int8_t, Normalized>(
435 getPropertyViewImpl<uint8_t, Normalized>(
443 getPropertyViewImpl<int16_t, Normalized>(
451 getPropertyViewImpl<uint16_t, Normalized>(
459 getPropertyViewImpl<int32_t, Normalized>(
467 getPropertyViewImpl<uint32_t, Normalized>(
475 getPropertyViewImpl<float, false>(
483 PropertyTexturePropertyView<uint8_t>(
489 template <
typename Callback, glm::length_t N,
bool Normalized>
490 void getVecNPropertyViewImpl(
491 const std::string& propertyId,
492 const ClassProperty& classProperty,
495 const TextureViewOptions& propertyOptions)
const {
496 switch (componentType) {
500 getPropertyViewImpl<glm::vec<N, int8_t>, Normalized>(
508 getPropertyViewImpl<glm::vec<N, uint8_t>, Normalized>(
514 if constexpr (N == 2) {
517 getPropertyViewImpl<glm::vec<N, int16_t>, Normalized>(
525 if constexpr (N == 2) {
528 getPropertyViewImpl<glm::vec<N, uint16_t>, Normalized>(
538 PropertyTexturePropertyView<uint8_t>(
544 template <
typename Callback,
bool Normalized>
545 void getVecNPropertyViewImpl(
546 const std::string& propertyId,
547 const ClassProperty& classProperty,
551 const TextureViewOptions& propertyOptions)
const {
555 getVecNPropertyViewImpl<Callback, 2, Normalized>(
559 std::forward<Callback>(callback),
563 getVecNPropertyViewImpl<Callback, 3, Normalized>(
567 std::forward<Callback>(callback),
571 getVecNPropertyViewImpl<Callback, 4, Normalized>(
575 std::forward<Callback>(callback),
581 PropertyTexturePropertyView<uint8_t>(
587 template <
typename T,
bool Normalized>
588 PropertyTexturePropertyView<T, Normalized> createScalarPropertyView(
589 const ClassProperty& classProperty,
590 [[maybe_unused]]
const PropertyTextureProperty& propertyTextureProperty,
591 const TextureViewOptions& propertyOptions)
const {
592 if (classProperty.array) {
593 return PropertyTexturePropertyView<T, Normalized>(
598 if (TypeToPropertyType<T>::value != type) {
599 return PropertyTexturePropertyView<T, Normalized>(
605 classProperty.componentType.value_or(
""));
606 if (TypeToPropertyType<T>::component != componentType) {
607 return PropertyTexturePropertyView<T, Normalized>(
611 if (classProperty.normalized != Normalized) {
612 return PropertyTexturePropertyView<T, Normalized>(
617 if constexpr (
sizeof(T) <= 4) {
618 return createPropertyViewImpl<T, Normalized>(
620 propertyTextureProperty,
624 return PropertyTexturePropertyView<T, Normalized>(
629 template <
typename T,
bool Normalized>
630 PropertyTexturePropertyView<T, Normalized> createVecNPropertyView(
631 const ClassProperty& classProperty,
632 [[maybe_unused]]
const PropertyTextureProperty& propertyTextureProperty,
633 [[maybe_unused]]
const TextureViewOptions& propertyOptions)
const {
634 if (classProperty.array) {
635 return PropertyTexturePropertyView<T, Normalized>(
640 if (TypeToPropertyType<T>::value != type) {
641 return PropertyTexturePropertyView<T, Normalized>(
647 classProperty.componentType.value_or(
""));
648 if (TypeToPropertyType<T>::component != componentType) {
649 return PropertyTexturePropertyView<T, Normalized>(
653 if (classProperty.normalized != Normalized) {
654 return PropertyTexturePropertyView<T, Normalized>(
659 if constexpr (
sizeof(T) <= 4) {
660 return createPropertyViewImpl<T, Normalized>(
662 propertyTextureProperty,
666 return PropertyTexturePropertyView<T, Normalized>(
671 template <
typename T,
bool Normalized>
672 PropertyTexturePropertyView<PropertyArrayView<T>, Normalized>
673 createArrayPropertyView(
674 const ClassProperty& classProperty,
675 [[maybe_unused]]
const PropertyTextureProperty& propertyTextureProperty,
676 [[maybe_unused]]
const TextureViewOptions& propertyOptions)
const {
677 if (!classProperty.array) {
678 return PropertyTexturePropertyView<PropertyArrayView<T>, Normalized>(
683 if (TypeToPropertyType<T>::value != type) {
684 return PropertyTexturePropertyView<PropertyArrayView<T>, Normalized>(
690 classProperty.componentType.value_or(
""));
691 if (TypeToPropertyType<T>::component != componentType) {
692 return PropertyTexturePropertyView<PropertyArrayView<T>, Normalized>(
696 if (classProperty.normalized != Normalized) {
697 return PropertyTexturePropertyView<PropertyArrayView<T>, Normalized>(
703 if constexpr (IsMetadataScalar<T>::value &&
sizeof(T) <= 4) {
705 int64_t count = classProperty.count.value_or(0);
706 if (count <= 0 || count > 4) {
707 return PropertyTexturePropertyView<PropertyArrayView<T>, Normalized>(
711 if (count *
sizeof(T) > 4) {
712 return PropertyTexturePropertyView<PropertyArrayView<T>, Normalized>(
716 return createPropertyViewImpl<PropertyArrayView<T>, Normalized>(
718 propertyTextureProperty,
722 return PropertyTexturePropertyView<PropertyArrayView<T>, Normalized>(
727 template <
typename T,
bool Normalized>
728 PropertyTexturePropertyView<T, Normalized> createPropertyViewImpl(
729 const ClassProperty& classProperty,
730 const PropertyTextureProperty& propertyTextureProperty,
732 const TextureViewOptions& propertyOptions)
const {
733 int32_t samplerIndex;
737 getTextureSafe(propertyTextureProperty.index, samplerIndex, imageIndex);
740 return PropertyTexturePropertyView<T, Normalized>(
status);
743 status = checkSampler(samplerIndex);
745 return PropertyTexturePropertyView<T, Normalized>(
status);
748 status = checkImage(imageIndex);
750 return PropertyTexturePropertyView<T, Normalized>(
status);
754 _pModel->
images[imageIndex].pAsset;
755 const std::vector<int64_t>& channels = propertyTextureProperty.channels;
757 status = checkChannels(channels, *pImage);
759 return PropertyTexturePropertyView<T, Normalized>(
status);
762 if (channels.size() * pImage->bytesPerChannel != elementSize) {
766 return PropertyTexturePropertyView<T, Normalized>(
767 propertyTextureProperty,
775 const int32_t textureIndex,
776 int32_t& samplerIndex,
777 int32_t& imageIndex)
const noexcept;
780 checkSampler(
const int32_t samplerIndex)
const noexcept;
785 const std::vector<int64_t>& channels,
786 const ImageAsset& image)
const noexcept;
788 const Model* _pModel;
789 const PropertyTexture* _pPropertyTexture;
790 const Class* _pClass;
PropertyTexturePropertyView< T, Normalized > getPropertyView(const std::string &propertyId, const TextureViewOptions &propertyOptions=TextureViewOptions()) const
Gets a PropertyTexturePropertyView that views the data of a property stored in the PropertyTexture.
void getPropertyView(const std::string &propertyId, Callback &&callback, const TextureViewOptions &propertyOptions=TextureViewOptions()) const
Gets a PropertyTexturePropertyView through a callback that accepts a property id and a PropertyTextur...
std::unordered_map< std::string, CesiumGltf::PropertyTextureProperty > properties
A dictionary, where each key corresponds to a property ID in the class' properties dictionary and eac...