-
Notifications
You must be signed in to change notification settings - Fork 330
Store property attributes in FCesiumPrimitiveMetadata
#1694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
25b1470
Style edits, add GetInteger64 to texture properties
j9liu f030fd8
Add PropertyAttributeProperty, minor test changes
j9liu a130c7c
Put property attributes in primitive metadata
j9liu ae2e747
Add property attribute tests
j9liu 0bf603a
Doc and style changes for FCesiumPropertyTexture
j9liu a5e8904
Formatting and int64_t casts
j9liu 0d817a3
Various style and correctness fixes
j9liu 81ab376
Update changelog, additional style fixes
j9liu 5cf60c3
Fix typo
j9liu 93d4e6e
CI fix and style
j9liu 0e140c5
Merge branch 'main' into property-attributes
j9liu 2169ed0
Merge branch 'farewell-5.3' into property-attributes
j9liu 3aa7f64
Merge branch 'main' into property-attributes
j9liu 879ae27
Add checks for property size
j9liu 02d7eed
Remove unnecessary if
j9liu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
Source/CesiumRuntime/Private/CesiumPropertyAttribute.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| // Copyright 2020-2024 CesiumGS, Inc. and Contributors | ||
|
|
||
| #include "CesiumPropertyAttribute.h" | ||
| #include <CesiumGltf/PropertyAttributeView.h> | ||
|
|
||
| static FCesiumPropertyAttributeProperty EmptyPropertyAttributeProperty; | ||
|
|
||
| FCesiumPropertyAttribute::FCesiumPropertyAttribute( | ||
| const CesiumGltf::Model& model, | ||
| const CesiumGltf::MeshPrimitive& primitive, | ||
| const CesiumGltf::PropertyAttribute& propertyAttribute, | ||
| const TSharedPtr<FCesiumMetadataEnumCollection>& pEnumCollection) | ||
| : _status( | ||
| ECesiumPropertyAttributeStatus::ErrorInvalidPropertyAttributeClass), | ||
| _name(propertyAttribute.name.value_or("").c_str()), | ||
| _className(propertyAttribute.classProperty.c_str()), | ||
| _properties() { | ||
| CesiumGltf::PropertyAttributeView propertyAttributeView{ | ||
| model, | ||
| propertyAttribute}; | ||
| switch (propertyAttributeView.status()) { | ||
| case CesiumGltf::PropertyAttributeViewStatus::Valid: | ||
| _status = ECesiumPropertyAttributeStatus::Valid; | ||
| break; | ||
| default: | ||
| // Status was already set in initializer list. | ||
| return; | ||
| } | ||
|
|
||
| const CesiumGltf::ExtensionModelExtStructuralMetadata* pExtension = | ||
| model.getExtension<CesiumGltf::ExtensionModelExtStructuralMetadata>(); | ||
| // If there was no schema, we would've gotten ErrorMissingSchema for the | ||
| // propertyAttributeView status. | ||
| check(pExtension != nullptr && pExtension->schema != nullptr); | ||
|
|
||
| propertyAttributeView.forEachProperty( | ||
| primitive, | ||
| [&properties = _properties, | ||
| &Schema = *pExtension->schema, | ||
| &propertyAttributeView, | ||
| &pEnumCollection]( | ||
| const std::string& propertyName, | ||
| auto propertyValue) mutable { | ||
| FString key(UTF8_TO_TCHAR(propertyName.data())); | ||
| const CesiumGltf::ClassProperty* pClassProperty = | ||
| propertyAttributeView.getClassProperty(propertyName); | ||
| check(pClassProperty); | ||
|
|
||
| TSharedPtr<FCesiumMetadataEnum> pEnumDefinition(nullptr); | ||
| if (pEnumCollection.IsValid() && pClassProperty->enumType.has_value()) { | ||
| pEnumDefinition = pEnumCollection->Get( | ||
| FString(UTF8_TO_TCHAR(pClassProperty->enumType.value().c_str()))); | ||
| } | ||
|
|
||
| properties.Add( | ||
| key, | ||
| FCesiumPropertyAttributeProperty(propertyValue, pEnumDefinition)); | ||
| }); | ||
| } | ||
|
|
||
| /*static*/ ECesiumPropertyAttributeStatus | ||
| UCesiumPropertyAttributeBlueprintLibrary::GetPropertyAttributeStatus( | ||
| UPARAM(ref) const FCesiumPropertyAttribute& PropertyAttribute) { | ||
| return PropertyAttribute._status; | ||
| } | ||
|
|
||
| /*static*/ const FString& | ||
| UCesiumPropertyAttributeBlueprintLibrary::GetPropertyAttributeName( | ||
| UPARAM(ref) const FCesiumPropertyAttribute& PropertyAttribute) { | ||
| return PropertyAttribute._name; | ||
| } | ||
|
|
||
| /*static*/ const TMap<FString, FCesiumPropertyAttributeProperty>& | ||
| UCesiumPropertyAttributeBlueprintLibrary::GetProperties( | ||
| UPARAM(ref) const FCesiumPropertyAttribute& PropertyAttribute) { | ||
| return PropertyAttribute._properties; | ||
| } | ||
|
|
||
| /*static*/ const TArray<FString> | ||
| UCesiumPropertyAttributeBlueprintLibrary::GetPropertyNames( | ||
| UPARAM(ref) const FCesiumPropertyAttribute& PropertyAttribute) { | ||
| TArray<FString> names; | ||
| PropertyAttribute._properties.GenerateKeyArray(names); | ||
| return names; | ||
| } | ||
|
|
||
| /*static*/ const FCesiumPropertyAttributeProperty& | ||
| UCesiumPropertyAttributeBlueprintLibrary::FindProperty( | ||
| UPARAM(ref) const FCesiumPropertyAttribute& PropertyAttribute, | ||
| const FString& PropertyName) { | ||
| const FCesiumPropertyAttributeProperty* property = | ||
| PropertyAttribute._properties.Find(PropertyName); | ||
| return property ? *property : EmptyPropertyAttributeProperty; | ||
| } | ||
|
|
||
| /*static*/ TMap<FString, FCesiumMetadataValue> | ||
| UCesiumPropertyAttributeBlueprintLibrary::GetMetadataValuesAtIndex( | ||
| UPARAM(ref) const FCesiumPropertyAttribute& PropertyAttribute, | ||
| int64 Index) { | ||
| TMap<FString, FCesiumMetadataValue> values; | ||
| if (Index < 0) { | ||
| return values; | ||
| } | ||
|
|
||
| for (const auto& pair : PropertyAttribute._properties) { | ||
| const FCesiumPropertyAttributeProperty& property = pair.Value; | ||
| ECesiumPropertyAttributePropertyStatus status = | ||
| UCesiumPropertyAttributePropertyBlueprintLibrary:: | ||
| GetPropertyAttributePropertyStatus(property); | ||
| if (status == ECesiumPropertyAttributePropertyStatus::Valid) { | ||
| values.Add( | ||
| pair.Key, | ||
| UCesiumPropertyAttributePropertyBlueprintLibrary::GetValue( | ||
| pair.Value, | ||
| Index)); | ||
| } else if ( | ||
| status == | ||
| ECesiumPropertyAttributePropertyStatus::EmptyPropertyWithDefault) { | ||
| values.Add( | ||
| pair.Key, | ||
| UCesiumPropertyAttributePropertyBlueprintLibrary::GetDefaultValue( | ||
| pair.Value)); | ||
| } | ||
| } | ||
|
|
||
| return values; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.