79 const std::optional<std::string>&
name() const noexcept {
80 return _pPropertyTable->name;
90 int64_t
size() const noexcept {
138 template <
typename T,
bool Normalized = false>
141 if (this->
size() <= 0) {
147 if (!pClassProperty) {
152 return getPropertyViewImpl<T, Normalized>(propertyId, *pClassProperty);
177 template <
typename Callback>
180 if (this->
size() <= 0) {
189 if (!pClassProperty) {
202 const auto& enumDefinitionIt =
203 this->_pEnumDefinitions->find(*pClassProperty->
enumType);
204 if (enumDefinitionIt == this->_pEnumDefinitions->end()) {
213 enumDefinitionIt->second.valueType);
246 if (pClassProperty->
array) {
248 getArrayPropertyViewImpl<Callback, true>(
253 std::forward<Callback>(callback));
255 getArrayPropertyViewImpl<Callback, false>(
260 std::forward<Callback>(callback));
267 getScalarPropertyViewImpl<Callback, true>(
271 std::forward<Callback>(callback));
273 getScalarPropertyViewImpl<Callback, false>(
277 std::forward<Callback>(callback));
284 getVecNPropertyViewImpl<Callback, true>(
289 std::forward<Callback>(callback));
291 getVecNPropertyViewImpl<Callback, false>(
296 std::forward<Callback>(callback));
303 getMatNPropertyViewImpl<Callback, true>(
308 std::forward<Callback>(callback));
310 getMatNPropertyViewImpl<Callback, false>(
315 std::forward<Callback>(callback));
323 getPropertyViewImpl<std::string_view, false>(
332 getPropertyViewImpl<bool, false>(propertyId, *pClassProperty));
364 for (
const auto& property : this->_pClass->properties) {
370 template <
typename Callback,
bool Normalized>
371 void getScalarArrayPropertyViewImpl(
372 const std::string& propertyId,
375 Callback&& callback)
const {
376 switch (componentType) {
456 template <
typename Callback, glm::length_t N,
bool Normalized>
457 void getVecNArrayPropertyViewImpl(
458 const std::string& propertyId,
459 const ClassProperty& classProperty,
461 Callback&& callback)
const {
462 switch (componentType) {
467 PropertyArrayView<glm::vec<N, int8_t>>,
468 Normalized>(propertyId, classProperty));
474 PropertyArrayView<glm::vec<N, uint8_t>>,
475 Normalized>(propertyId, classProperty));
481 PropertyArrayView<glm::vec<N, int16_t>>,
482 Normalized>(propertyId, classProperty));
488 PropertyArrayView<glm::vec<N, uint16_t>>,
489 Normalized>(propertyId, classProperty));
495 PropertyArrayView<glm::vec<N, int32_t>>,
496 Normalized>(propertyId, classProperty));
502 PropertyArrayView<glm::vec<N, uint32_t>>,
503 Normalized>(propertyId, classProperty));
509 PropertyArrayView<glm::vec<N, int64_t>>,
510 Normalized>(propertyId, classProperty));
516 PropertyArrayView<glm::vec<N, uint64_t>>,
517 Normalized>(propertyId, classProperty));
522 getPropertyViewImpl<PropertyArrayView<glm::vec<N, float>>,
false>(
529 getPropertyViewImpl<PropertyArrayView<glm::vec<N, double>>,
false>(
536 PropertyTablePropertyView<uint8_t>(
542 template <
typename Callback,
bool Normalized>
543 void getVecNArrayPropertyViewImpl(
544 const std::string& propertyId,
545 const ClassProperty& classProperty,
548 Callback&& callback)
const {
552 getVecNArrayPropertyViewImpl<Callback, 2, Normalized>(
556 std::forward<Callback>(callback));
559 getVecNArrayPropertyViewImpl<Callback, 3, Normalized>(
563 std::forward<Callback>(callback));
566 getVecNArrayPropertyViewImpl<Callback, 4, Normalized>(
570 std::forward<Callback>(callback));
575 PropertyTablePropertyView<uint8_t>(
581 template <
typename Callback, glm::length_t N,
bool Normalized>
582 void getMatNArrayPropertyViewImpl(
583 const std::string& propertyId,
584 const ClassProperty& classProperty,
586 Callback&& callback)
const {
587 switch (componentType) {
592 PropertyArrayView<glm::mat<N, N, int8_t>>,
593 Normalized>(propertyId, classProperty));
599 PropertyArrayView<glm::mat<N, N, uint8_t>>,
600 Normalized>(propertyId, classProperty));
606 PropertyArrayView<glm::mat<N, N, int16_t>>,
607 Normalized>(propertyId, classProperty));
613 PropertyArrayView<glm::mat<N, N, uint16_t>>,
614 Normalized>(propertyId, classProperty));
620 PropertyArrayView<glm::mat<N, N, int32_t>>,
621 Normalized>(propertyId, classProperty));
627 PropertyArrayView<glm::mat<N, N, uint32_t>>,
628 Normalized>(propertyId, classProperty));
634 PropertyArrayView<glm::mat<N, N, int64_t>>,
635 Normalized>(propertyId, classProperty));
641 PropertyArrayView<glm::mat<N, N, uint64_t>>,
642 Normalized>(propertyId, classProperty));
647 getPropertyViewImpl<PropertyArrayView<glm::mat<N, N, float>>,
false>(
654 getPropertyViewImpl<PropertyArrayView<glm::mat<N, N, double>>,
false>(
661 PropertyTablePropertyView<uint8_t>(
667 template <
typename Callback,
bool Normalized>
668 void getMatNArrayPropertyViewImpl(
669 const std::string& propertyId,
670 const ClassProperty& classProperty,
673 Callback&& callback)
const {
677 getMatNArrayPropertyViewImpl<Callback, 2, Normalized>(
681 std::forward<Callback>(callback));
684 getMatNArrayPropertyViewImpl<Callback, 3, Normalized>(
688 std::forward<Callback>(callback));
691 getMatNArrayPropertyViewImpl<Callback, 4, Normalized>(
695 std::forward<Callback>(callback));
700 PropertyTablePropertyView<uint8_t>(
706 template <
typename Callback,
bool Normalized>
707 void getArrayPropertyViewImpl(
708 const std::string& propertyId,
709 const ClassProperty& classProperty,
712 Callback&& callback)
const {
714 getScalarArrayPropertyViewImpl<Callback, Normalized>(
718 std::forward<Callback>(callback));
720 getVecNArrayPropertyViewImpl<Callback, Normalized>(
725 std::forward<Callback>(callback));
727 getMatNArrayPropertyViewImpl<Callback, Normalized>(
732 std::forward<Callback>(callback));
736 getPropertyViewImpl<PropertyArrayView<bool>,
false>(
743 getPropertyViewImpl<PropertyArrayView<std::string_view>,
false>(
749 PropertyTablePropertyView<uint8_t>(
754 template <
typename Callback, glm::length_t N,
bool Normalized>
755 void getVecNPropertyViewImpl(
756 const std::string& propertyId,
757 const ClassProperty& classProperty,
759 Callback&& callback)
const {
761 switch (componentType) {
765 getPropertyViewImpl<glm::vec<N, int8_t>, Normalized>(
772 getPropertyViewImpl<glm::vec<N, uint8_t>, Normalized>(
779 getPropertyViewImpl<glm::vec<N, int16_t>, Normalized>(
786 getPropertyViewImpl<glm::vec<N, uint16_t>, Normalized>(
793 getPropertyViewImpl<glm::vec<N, int32_t>, Normalized>(
800 getPropertyViewImpl<glm::vec<N, uint32_t>, Normalized>(
807 getPropertyViewImpl<glm::vec<N, int64_t>, Normalized>(
814 getPropertyViewImpl<glm::vec<N, uint64_t>, Normalized>(
821 getPropertyViewImpl<glm::vec<N, float>,
false>(
828 getPropertyViewImpl<glm::vec<N, double>,
false>(
835 PropertyTablePropertyView<uint8_t>(
841 template <
typename Callback,
bool Normalized>
842 void getVecNPropertyViewImpl(
843 const std::string& propertyId,
844 const ClassProperty& classProperty,
847 Callback&& callback)
const {
851 getVecNPropertyViewImpl<Callback, 2, Normalized>(
855 std::forward<Callback>(callback));
858 getVecNPropertyViewImpl<Callback, 3, Normalized>(
862 std::forward<Callback>(callback));
865 getVecNPropertyViewImpl<Callback, 4, Normalized>(
869 std::forward<Callback>(callback));
874 PropertyTablePropertyView<uint8_t>(
880 template <
typename Callback, glm::length_t N,
bool Normalized>
881 void getMatNPropertyViewImpl(
882 const std::string& propertyId,
883 const ClassProperty& classProperty,
885 Callback&& callback)
const {
886 switch (componentType) {
890 getPropertyViewImpl<glm::mat<N, N, int8_t>, Normalized>(
897 getPropertyViewImpl<glm::mat<N, N, uint8_t>, Normalized>(
904 getPropertyViewImpl<glm::mat<N, N, int16_t>, Normalized>(
911 getPropertyViewImpl<glm::mat<N, N, uint16_t>, Normalized>(
918 getPropertyViewImpl<glm::mat<N, N, int32_t>, Normalized>(
925 getPropertyViewImpl<glm::mat<N, N, uint32_t>, Normalized>(
932 getPropertyViewImpl<glm::mat<N, N, int64_t>, Normalized>(
939 getPropertyViewImpl<glm::mat<N, N, uint64_t>, Normalized>(
946 getPropertyViewImpl<glm::mat<N, N, float>,
false>(
953 getPropertyViewImpl<glm::mat<N, N, double>,
false>(
960 PropertyTablePropertyView<uint8_t>(
966 template <
typename Callback,
bool Normalized>
967 void getMatNPropertyViewImpl(
968 const std::string& propertyId,
969 const ClassProperty& classProperty,
972 Callback&& callback)
const {
976 getMatNPropertyViewImpl<Callback, 2, Normalized>(
980 std::forward<Callback>(callback));
983 getMatNPropertyViewImpl<Callback, 3, Normalized>(
987 std::forward<Callback>(callback));
990 getMatNPropertyViewImpl<Callback, 4, Normalized>(
994 std::forward<Callback>(callback));
999 PropertyTablePropertyView<uint8_t>(
1005 template <
typename Callback,
bool Normalized>
1006 void getScalarPropertyViewImpl(
1007 const std::string& propertyId,
1008 const ClassProperty& classProperty,
1010 Callback&& callback)
const {
1011 switch (componentType) {
1015 getPropertyViewImpl<int8_t, Normalized>(propertyId, classProperty));
1020 getPropertyViewImpl<uint8_t, Normalized>(propertyId, classProperty));
1025 getPropertyViewImpl<int16_t, Normalized>(propertyId, classProperty));
1030 getPropertyViewImpl<uint16_t, Normalized>(propertyId, classProperty));
1035 getPropertyViewImpl<int32_t, Normalized>(propertyId, classProperty));
1040 getPropertyViewImpl<uint32_t, Normalized>(propertyId, classProperty));
1045 getPropertyViewImpl<int64_t, Normalized>(propertyId, classProperty));
1050 getPropertyViewImpl<uint64_t, Normalized>(propertyId, classProperty));
1055 getPropertyViewImpl<float, false>(propertyId, classProperty));
1060 getPropertyViewImpl<double, false>(propertyId, classProperty));
1065 PropertyTablePropertyView<uint8_t>(
1071 template <
typename T,
bool Normalized>
1072 PropertyTablePropertyView<T, Normalized> getPropertyViewImpl(
1073 const std::string& propertyId,
1074 const ClassProperty& classProperty)
const {
1075 auto propertyTablePropertyIter =
1076 _pPropertyTable->properties.find(propertyId);
1077 if (propertyTablePropertyIter == _pPropertyTable->properties.end()) {
1078 if (!classProperty.required && classProperty.defaultProperty) {
1082 return PropertyTablePropertyView<T, Normalized>(
1084 _pPropertyTable->count);
1088 return PropertyTablePropertyView<T, Normalized>(
1092 const PropertyTableProperty& propertyTableProperty =
1093 propertyTablePropertyIter->second;
1096 return getNumericOrBooleanPropertyValues<T, Normalized>(
1098 propertyTableProperty);
1101 if constexpr (IsMetadataString<T>::value) {
1102 return getStringPropertyValues(classProperty, propertyTableProperty);
1105 if constexpr (IsMetadataBooleanArray<T>::value) {
1106 return getBooleanArrayPropertyValues(
1108 propertyTableProperty);
1111 if constexpr (IsMetadataNumericArray<T>::value) {
1112 return getNumericArrayPropertyValues<
1114 Normalized>(classProperty, propertyTableProperty);
1117 if constexpr (IsMetadataStringArray<T>::value) {
1118 return getStringArrayPropertyValues(classProperty, propertyTableProperty);
1122 template <
typename T,
bool Normalized>
1123 PropertyTablePropertyView<T, Normalized> getNumericOrBooleanPropertyValues(
1124 const ClassProperty& classProperty,
1125 const PropertyTableProperty& propertyTableProperty)
const {
1126 if (classProperty.array) {
1127 return PropertyTablePropertyView<T, Normalized>(
1133 return PropertyTablePropertyView<T, Normalized>(
1138 classProperty.componentType.value_or(
""));
1141 const auto& enumDefinitionIt =
1142 this->_pEnumDefinitions->find(*classProperty.enumType);
1143 if (enumDefinitionIt == this->_pEnumDefinitions->end()) {
1144 return PropertyTablePropertyView<T, Normalized>(
1149 enumDefinitionIt->second.valueType);
1152 return PropertyTablePropertyView<T, Normalized>(
1155 pEnumDefinition = &enumDefinitionIt->second;
1157 return PropertyTablePropertyView<T, Normalized>(
1161 if (TypeToPropertyType<T>::component != componentType) {
1162 return PropertyTablePropertyView<T, Normalized>(
1166 if (classProperty.normalized != Normalized ||
1168 return PropertyTablePropertyView<T, Normalized>(
1172 std::span<const std::byte> values;
1173 const auto status = getBufferSafe(propertyTableProperty.values, values);
1175 return PropertyTablePropertyView<T, Normalized>(
status);
1178 if (values.size() %
sizeof(T) != 0) {
1179 return PropertyTablePropertyView<T, Normalized>(
1180 PropertyTablePropertyViewStatus::
1181 ErrorBufferViewSizeNotDivisibleByTypeSize);
1184 size_t maxRequiredBytes = 0;
1185 if (IsMetadataBoolean<T>::value) {
1186 maxRequiredBytes =
static_cast<size_t>(
1187 glm::ceil(
static_cast<double>(_pPropertyTable->count) / 8.0));
1190 static_cast<size_t>(_pPropertyTable->count) *
sizeof(T);
1193 if (values.size() < maxRequiredBytes) {
1194 return PropertyTablePropertyView<T, Normalized>(
1195 PropertyTablePropertyViewStatus::
1196 ErrorBufferViewSizeDoesNotMatchPropertyTableCount);
1199 if constexpr (!Normalized) {
1200 return PropertyTablePropertyView<T, Normalized>(
1201 propertyTableProperty,
1204 _pPropertyTable->count,
1207 return PropertyTablePropertyView<T, Normalized>(
1208 propertyTableProperty,
1210 _pPropertyTable->count,
1215 PropertyTablePropertyView<std::string_view> getStringPropertyValues(
1216 const ClassProperty& classProperty,
1217 const PropertyTableProperty& propertyTableProperty)
const;
1219 PropertyTablePropertyView<PropertyArrayView<bool>>
1220 getBooleanArrayPropertyValues(
1221 const ClassProperty& classProperty,
1222 const PropertyTableProperty& propertyTableProperty)
const;
1224 template <
typename T,
bool Normalized>
1225 PropertyTablePropertyView<PropertyArrayView<T>, Normalized>
1226 getNumericArrayPropertyValues(
1227 const ClassProperty& classProperty,
1228 const PropertyTableProperty& propertyTableProperty)
const {
1229 if (!classProperty.array) {
1230 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1236 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1241 classProperty.componentType.value_or(
""));
1244 const auto& enumDefinitionIt =
1245 this->_pEnumDefinitions->find(*classProperty.enumType);
1246 if (enumDefinitionIt == this->_pEnumDefinitions->end()) {
1247 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1252 enumDefinitionIt->second.valueType);
1256 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1259 pEnumDefinition = &enumDefinitionIt->second;
1261 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1265 if (TypeToPropertyType<T>::component != componentType) {
1266 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1270 if (classProperty.normalized != Normalized) {
1271 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1275 std::span<const std::byte> values;
1276 auto status = getBufferSafe(propertyTableProperty.values, values);
1278 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1282 if (values.size() %
sizeof(T) != 0) {
1283 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1284 PropertyTablePropertyViewStatus::
1285 ErrorBufferViewSizeNotDivisibleByTypeSize);
1288 const int64_t fixedLengthArrayCount = classProperty.count.value_or(0);
1289 if (fixedLengthArrayCount > 0 && propertyTableProperty.arrayOffsets >= 0) {
1290 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1291 PropertyTablePropertyViewStatus::
1292 ErrorArrayCountAndOffsetBufferCoexist);
1295 if (fixedLengthArrayCount <= 0 && propertyTableProperty.arrayOffsets < 0) {
1296 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1297 PropertyTablePropertyViewStatus::
1298 ErrorArrayCountAndOffsetBufferDontExist);
1302 if (fixedLengthArrayCount > 0) {
1303 size_t maxRequiredBytes =
1304 static_cast<size_t>(_pPropertyTable->count * fixedLengthArrayCount) *
1307 if (values.size() < maxRequiredBytes) {
1308 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1309 PropertyTablePropertyViewStatus::
1310 ErrorBufferViewSizeDoesNotMatchPropertyTableCount);
1313 if constexpr (!Normalized) {
1314 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1315 propertyTableProperty,
1318 _pPropertyTable->count,
1321 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1322 propertyTableProperty,
1324 _pPropertyTable->count,
1332 propertyTableProperty.arrayOffsetType);
1334 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1338 constexpr bool checkBitsSize =
false;
1339 std::span<const std::byte> arrayOffsets;
1340 status = getArrayOffsetsBufferSafe(
1341 propertyTableProperty.arrayOffsets,
1344 static_cast<size_t>(_pPropertyTable->count),
1348 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1352 if constexpr (Normalized) {
1353 return PropertyTablePropertyView<PropertyArrayView<T>,
true>(
1354 propertyTableProperty,
1356 _pPropertyTable->count,
1361 return PropertyTablePropertyView<PropertyArrayView<T>,
false>(
1362 propertyTableProperty,
1365 _pPropertyTable->count,
1368 std::span<const std::byte>(),
1374 PropertyTablePropertyView<PropertyArrayView<std::string_view>>
1375 getStringArrayPropertyValues(
1376 const ClassProperty& classProperty,
1377 const PropertyTableProperty& propertyTableProperty)
const;
1381 std::span<const std::byte>& buffer)
const noexcept;
1384 int32_t arrayOffsetsBufferView,
1386 size_t valuesBufferSize,
1387 size_t propertyTableCount,
1389 std::span<const std::byte>& arrayOffsetsBuffer)
const noexcept;
1392 int32_t stringOffsetsBufferView,
1394 size_t valuesBufferSize,
1395 size_t propertyTableCount,
1396 std::span<const std::byte>& stringOffsetsBuffer)
const noexcept;
1398 const Model* _pModel;
1399 const PropertyTable* _pPropertyTable;
1400 const Class* _pClass;
1401 const std::unordered_map<std::string, CesiumGltf::Enum>* _pEnumDefinitions;