Skip to content

Commit

Permalink
Minor tweaks from PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
j9liu committed Feb 29, 2024
1 parent 636c40f commit f17e484
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CesiumGltf/include/CesiumGltf/FeatureIdTextureView.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class FeatureIdTextureView : public TextureView {
FeatureIdTextureView(
const Model& model,
const FeatureIdTexture& featureIdTexture,
TextureViewOptions options = TextureViewOptions()) noexcept;
const TextureViewOptions& options = TextureViewOptions()) noexcept;

/**
* @brief Get the feature ID from the texture at the given texture
Expand Down
9 changes: 4 additions & 5 deletions CesiumGltf/include/CesiumGltf/PropertyTexturePropertyView.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class PropertyTexturePropertyView<ElementType, false>
const ClassProperty& classProperty,
const Sampler& sampler,
const ImageCesium& image,
TextureViewOptions options = TextureViewOptions()) noexcept
const TextureViewOptions& options = TextureViewOptions()) noexcept
: PropertyView<ElementType, false>(classProperty, property),
TextureView(
sampler,
Expand Down Expand Up @@ -482,9 +482,8 @@ class PropertyTexturePropertyView<ElementType, true>
/**
* @brief Constructs an instance of an empty property that specifies a
* default value. Although this property has no data, it can return the
* default value
* when {@link PropertyTexturePropertyView::get} is called. However,
* {@link PropertyTexturePropertyView::getRaw} cannot be used.
* default value when {@link PropertyTexturePropertyView::get} is called.
* However, {@link PropertyTexturePropertyView::getRaw} cannot be used.
*
* @param classProperty The {@link ClassProperty} this property conforms to.
*/
Expand Down Expand Up @@ -526,7 +525,7 @@ class PropertyTexturePropertyView<ElementType, true>
const ClassProperty& classProperty,
const Sampler& sampler,
const ImageCesium& image,
TextureViewOptions options = TextureViewOptions()) noexcept
const TextureViewOptions& options = TextureViewOptions()) noexcept
: PropertyView<ElementType, true>(classProperty, property),
TextureView(
sampler,
Expand Down
10 changes: 5 additions & 5 deletions CesiumGltf/include/CesiumGltf/PropertyTextureView.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include "CesiumGltf/Class.h"
#include "CesiumGltf/ClassProperty.h"
#include "CesiumGltf/ExtensionModelExtStructuralMetadata.h"
#include "CesiumGltf/Model.h"
#include "CesiumGltf/PropertyTexture.h"
#include "CesiumGltf/PropertyTexturePropertyView.h"
#include "CesiumGltf/TextureView.h"
#include "Model.h"

namespace CesiumGltf {
/**
Expand Down Expand Up @@ -121,7 +121,7 @@ class PropertyTextureView {
template <typename T, bool Normalized = false>
PropertyTexturePropertyView<T, Normalized> getPropertyView(
const std::string& propertyId,
TextureViewOptions propertyOptions = TextureViewOptions()) const {
const TextureViewOptions& propertyOptions = TextureViewOptions()) const {
if (this->_status != PropertyTextureViewStatus::Valid) {
return PropertyTexturePropertyView<T, Normalized>(
PropertyTexturePropertyViewStatus::ErrorInvalidPropertyTexture);
Expand Down Expand Up @@ -163,7 +163,7 @@ class PropertyTextureView {
void getPropertyView(
const std::string& propertyId,
Callback&& callback,
TextureViewOptions propertyOptions = TextureViewOptions()) const {
const TextureViewOptions& propertyOptions = TextureViewOptions()) const {
if (this->_status != PropertyTextureViewStatus::Valid) {
callback(
propertyId,
Expand Down Expand Up @@ -290,7 +290,7 @@ class PropertyTextureView {
template <typename Callback>
void forEachProperty(
Callback&& callback,
TextureViewOptions propertyOptions = TextureViewOptions()) const {
const TextureViewOptions& propertyOptions = TextureViewOptions()) const {
for (const auto& property : this->_pClass->properties) {
getPropertyView(
property.first,
Expand Down Expand Up @@ -586,7 +586,7 @@ class PropertyTextureView {
PropertyTexturePropertyView<T, Normalized> createScalarPropertyView(
const ClassProperty& classProperty,
[[maybe_unused]] const PropertyTextureProperty& propertyTextureProperty,
TextureViewOptions propertyOptions) const {
const TextureViewOptions& propertyOptions) const {
if (classProperty.array) {
return PropertyTexturePropertyView<T, Normalized>(
PropertyTexturePropertyViewStatus::ErrorArrayTypeMismatch);
Expand Down
11 changes: 4 additions & 7 deletions CesiumGltf/include/CesiumGltf/TextureView.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct TextureViewOptions {
* the original TEXCOORD set index will be preserved. The extension's values
* may still be retrieved using getTextureTransform, if desired.
*/
bool applyKhrTextureTransformExtension;
bool applyKhrTextureTransformExtension = false;

/**
* @brief Whether to copy the input image.
Expand All @@ -43,10 +43,7 @@ struct TextureViewOptions {
* original glTF model. When this flag is true, the view will manage its own
* copy of the pixel data to avoid such issues.
*/
bool makeImageCopy;

TextureViewOptions()
: applyKhrTextureTransformExtension(false), makeImageCopy(false) {}
bool makeImageCopy = false;
};

/**
Expand Down Expand Up @@ -111,7 +108,7 @@ class TextureView {
TextureView(
const Model& model,
const TextureInfo& textureInfo,
TextureViewOptions options = TextureViewOptions()) noexcept;
const TextureViewOptions& options = TextureViewOptions()) noexcept;

/**
* @brief Constructs a view of the texture specified by the given {@link Sampler}
Expand All @@ -131,7 +128,7 @@ class TextureView {
int64_t textureCoordinateSetIndex,
const ExtensionKhrTextureTransform* pKhrTextureTransformExtension =
nullptr,
TextureViewOptions options = TextureViewOptions()) noexcept;
const TextureViewOptions& options = TextureViewOptions()) noexcept;

/**
* @brief Get the status of this texture view.
Expand Down
2 changes: 1 addition & 1 deletion CesiumGltf/src/FeatureIdTextureView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ FeatureIdTextureView::FeatureIdTextureView() noexcept
FeatureIdTextureView::FeatureIdTextureView(
const Model& model,
const FeatureIdTexture& featureIdTexture,
TextureViewOptions options) noexcept
const TextureViewOptions& options) noexcept
: TextureView(model, featureIdTexture, options),
_status(FeatureIdTextureViewStatus::ErrorUninitialized),
_channels() {
Expand Down
8 changes: 4 additions & 4 deletions CesiumGltf/src/TextureView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TextureView::TextureView() noexcept
TextureView::TextureView(
const Model& model,
const TextureInfo& textureInfo,
TextureViewOptions options) noexcept
const TextureViewOptions& options) noexcept
: _textureViewStatus(TextureViewStatus::ErrorUninitialized),
_pSampler(nullptr),
_pImage(nullptr),
Expand Down Expand Up @@ -69,7 +69,7 @@ TextureView::TextureView(
}

if (options.makeImageCopy) {
this->_imageCopy = ImageCesium(*this->_pImage);
this->_imageCopy = *this->_pImage;
}

this->_textureViewStatus = TextureViewStatus::Valid;
Expand All @@ -80,7 +80,7 @@ TextureView::TextureView(
const ImageCesium& image,
int64_t textureCoordinateSetIndex,
const ExtensionKhrTextureTransform* pKhrTextureTransformExtension,
TextureViewOptions options) noexcept
const TextureViewOptions& options) noexcept
: _textureViewStatus(TextureViewStatus::ErrorUninitialized),
_pSampler(&sampler),
_pImage(&image),
Expand All @@ -102,7 +102,7 @@ TextureView::TextureView(
}

if (options.makeImageCopy) {
this->_imageCopy = ImageCesium(*this->_pImage);
this->_imageCopy = *this->_pImage;
}

this->_textureViewStatus = TextureViewStatus::Valid;
Expand Down

0 comments on commit f17e484

Please sign in to comment.