Merge branch 'additional-property-details' into property-attributes

This commit is contained in:
Janine Liu 2023-08-29 12:32:34 -04:00
commit b0a49c2e97
4 changed files with 59 additions and 52 deletions

View File

@ -133,20 +133,7 @@ public:
static const PropertyViewStatusType ErrorStringOffsetOutOfBounds = 29;
};
inline int64_t getOffsetTypeSize(PropertyComponentType offsetType) noexcept {
switch (offsetType) {
case PropertyComponentType::Uint8:
return sizeof(uint8_t);
case PropertyComponentType::Uint16:
return sizeof(uint16_t);
case PropertyComponentType::Uint32:
return sizeof(uint32_t);
case PropertyComponentType::Uint64:
return sizeof(uint64_t);
default:
return 0;
}
}
int64_t getOffsetTypeSize(PropertyComponentType offsetType) noexcept;
/**
* @brief A view on the data of the {@link PropertyTableProperty} that is created

View File

@ -190,41 +190,8 @@ assembleValueFromChannels(const std::vector<uint8_t>& bytes) noexcept {
}
}
inline double applySamplerWrapS(const double u, const int32_t wrapS) noexcept {
if (wrapS == Sampler::WrapS::REPEAT) {
double integral = 0;
double fraction = std::modf(u, &integral);
return fraction < 0 ? 1.0 - fraction : fraction;
}
if (wrapS == Sampler::WrapS::MIRRORED_REPEAT) {
double integral = 0;
double fraction = std::abs(std::modf(u, &integral));
int64_t integer = static_cast<int64_t>(std::abs(integral));
// If the integer part is odd, the direction is reversed.
return integer % 2 == 1 ? 1.0 - fraction : fraction;
}
return glm::clamp(u, 0.0, 1.0);
}
inline double applySamplerWrapT(const double v, const int32_t wrapT) noexcept {
if (wrapT == Sampler::WrapT::REPEAT) {
double integral = 0;
double fraction = std::modf(v, &integral);
return fraction < 0 ? 1.0 - fraction : fraction;
}
if (wrapT == Sampler::WrapT::MIRRORED_REPEAT) {
double integral = 0;
double fraction = std::abs(std::modf(v, &integral));
int64_t integer = static_cast<int64_t>(std::abs(integral));
// If the integer part is odd, the direction is reversed.
return integer % 2 == 1 ? 1.0 - fraction : fraction;
}
return glm::clamp(v, 0.0, 1.0);
}
double applySamplerWrapS(const double u, const int32_t wrapS);
double applySamplerWrapT(const double v, const int32_t wrapT);
/**
* @brief A view of the data specified by a {@link PropertyTextureProperty}.

View File

@ -1,7 +1,6 @@
#include "CesiumGltf/PropertyTablePropertyView.h"
using namespace CesiumGltf;
namespace CesiumGltf {
// Re-initialize consts here to avoid "undefined reference" errors with GCC /
// Clang.
const PropertyViewStatusType
@ -40,3 +39,19 @@ const PropertyViewStatusType
PropertyTablePropertyViewStatus::ErrorArrayOffsetOutOfBounds;
const PropertyViewStatusType
PropertyTablePropertyViewStatus::ErrorStringOffsetOutOfBounds;
int64_t getOffsetTypeSize(PropertyComponentType offsetType) noexcept {
switch (offsetType) {
case PropertyComponentType::Uint8:
return sizeof(uint8_t);
case PropertyComponentType::Uint16:
return sizeof(uint16_t);
case PropertyComponentType::Uint32:
return sizeof(uint32_t);
case PropertyComponentType::Uint64:
return sizeof(uint64_t);
default:
return 0;
}
}
} // namespace CesiumGltf

View File

@ -1,6 +1,6 @@
#include "CesiumGltf/PropertyTexturePropertyView.h"
using namespace CesiumGltf;
namespace CesiumGltf {
// Re-initialize consts here to avoid "undefined reference" errors with GCC /
// Clang.
@ -21,3 +21,41 @@ const PropertyViewStatusType
PropertyTexturePropertyViewStatus::ErrorInvalidChannels;
const PropertyViewStatusType
PropertyTexturePropertyViewStatus::ErrorChannelsAndTypeMismatch;
double applySamplerWrapS(const double u, const int32_t wrapS) {
if (wrapS == Sampler::WrapS::REPEAT) {
double integral = 0;
double fraction = std::modf(u, &integral);
return fraction < 0 ? 1.0 - fraction : fraction;
}
if (wrapS == Sampler::WrapS::MIRRORED_REPEAT) {
double integral = 0;
double fraction = std::abs(std::modf(u, &integral));
int64_t integer = static_cast<int64_t>(std::abs(integral));
// If the integer part is odd, the direction is reversed.
return integer % 2 == 1 ? 1.0 - fraction : fraction;
}
return glm::clamp(u, 0.0, 1.0);
}
double applySamplerWrapT(const double v, const int32_t wrapT) {
if (wrapT == Sampler::WrapT::REPEAT) {
double integral = 0;
double fraction = std::modf(v, &integral);
return fraction < 0 ? 1.0 - fraction : fraction;
}
if (wrapT == Sampler::WrapT::MIRRORED_REPEAT) {
double integral = 0;
double fraction = std::abs(std::modf(v, &integral));
int64_t integer = static_cast<int64_t>(std::abs(integral));
// If the integer part is odd, the direction is reversed.
return integer % 2 == 1 ? 1.0 - fraction : fraction;
}
return glm::clamp(v, 0.0, 1.0);
}
} // namespace CesiumGltf