diff --git a/CHANGES.md b/CHANGES.md index 81ccb3ecc..9e253e0d9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,8 @@ ##### Breaking Changes :mega: - Removed support for Unreal Engine 5.2. Unreal Engine 5.3 or later is now required. +- Renamed `FCesiumFeatureIdAttribute::GetFeatureIDForVertex` to `FCesiumFeatureIdAttribute::GetFeatureID`. +- Renamed `FCesiumFeatureIdAttribute::GetVertexCount` to `FCesiumFeatureIdAttribute::GetCount`. ##### Fixes :wrench: diff --git a/Config/Engine.ini b/Config/Engine.ini index 0387c9315..65028cd35 100644 --- a/Config/Engine.ini +++ b/Config/Engine.ini @@ -158,4 +158,8 @@ AspectRatioAxisConstraint=AspectRatio_MaintainXFOV +PropertyRedirects=(OldName="CesiumWebMapTileServiceRasterOverlay.South", NewName="CesiumWebMapTileServiceRasterOverlay.RectangleSouth") +PropertyRedirects=(OldName="CesiumWebMapTileServiceRasterOverlay.East", NewName="CesiumWebMapTileServiceRasterOverlay.RectangleEast") +PropertyRedirects=(OldName="CesiumWebMapTileServiceRasterOverlay.North", NewName="CesiumWebMapTileServiceRasterOverlay.RectangleNorth") -+PropertyRedirects=(OldName="CesiumWebMapTileServiceRasterOverlay.UseWebMercatorProjection", NewName="CesiumWebMapTileServiceRasterOverlay.UseWebMercatorProjection_DEPRECATED") \ No newline at end of file ++PropertyRedirects=(OldName="CesiumWebMapTileServiceRasterOverlay.UseWebMercatorProjection", NewName="CesiumWebMapTileServiceRasterOverlay.UseWebMercatorProjection_DEPRECATED") + ++FunctionRedirects=(OldName="CesiumFeatureIdAttributeBlueprintLibrary.GetFeatureIDForVertex", NewName="CesiumFeatureIdAttributeBlueprintLibrary.GetFeatureID") ++PropertyRedirects=(OldName="CesiumFeatureIdAttributeBlueprintLibrary.GetFeatureIDForVertex.VertexIndex", NewName="CesiumFeatureIdAttributeBlueprintLibrary.GetFeatureID.Index") ++FunctionRedirects=(OldName="CesiumFeatureIdAttributeBlueprintLibrary.GetVertexCount", NewName="CesiumFeatureIdAttributeBlueprintLibrary.GetCount") diff --git a/Source/CesiumRuntime/Private/CesiumFeatureIdAttribute.cpp b/Source/CesiumRuntime/Private/CesiumFeatureIdAttribute.cpp index c8045a59a..60936b34e 100644 --- a/Source/CesiumRuntime/Private/CesiumFeatureIdAttribute.cpp +++ b/Source/CesiumRuntime/Private/CesiumFeatureIdAttribute.cpp @@ -73,17 +73,17 @@ UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDAttributeStatus( return FeatureIDAttribute._status; } -int64 UCesiumFeatureIdAttributeBlueprintLibrary::GetVertexCount( +int64 UCesiumFeatureIdAttributeBlueprintLibrary::GetCount( UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute) { return std::visit( CesiumGltf::CountFromAccessor{}, FeatureIDAttribute._featureIdAccessor); } -int64 UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex( +int64 UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute, - int64 VertexIndex) { + int64 Index) { return std::visit( - CesiumGltf::FeatureIdFromAccessor{VertexIndex}, + CesiumGltf::FeatureIdFromAccessor{Index}, FeatureIDAttribute._featureIdAccessor); } diff --git a/Source/CesiumRuntime/Private/CesiumFeatureIdSet.cpp b/Source/CesiumRuntime/Private/CesiumFeatureIdSet.cpp index 36a45ce70..50d475b9f 100644 --- a/Source/CesiumRuntime/Private/CesiumFeatureIdSet.cpp +++ b/Source/CesiumRuntime/Private/CesiumFeatureIdSet.cpp @@ -152,7 +152,7 @@ int64 UCesiumFeatureIdSetBlueprintLibrary::GetFeatureIDForVertex( if (FeatureIDSet._featureIDSetType == ECesiumFeatureIdSetType::Attribute) { FCesiumFeatureIdAttribute attribute = std::get(FeatureIDSet._featureID); - return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex( + return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( attribute, VertexIndex); } @@ -189,7 +189,7 @@ int64 UCesiumFeatureIdSetBlueprintLibrary::GetFeatureIDForInstance( } const auto& featureIdAttribute = std::get(FeatureIDSet._featureID); - return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex( + return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( featureIdAttribute, InstanceIndex); } @@ -239,7 +239,7 @@ int64 UCesiumFeatureIdSetBlueprintLibrary::GetFeatureIDFromHit( if (FeatureIDSet._featureIDSetType == ECesiumFeatureIdSetType::Attribute) { FCesiumFeatureIdAttribute attribute = std::get(FeatureIDSet._featureID); - return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex( + return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( attribute, VertexIndex); } diff --git a/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp b/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp index e2c2624c3..1bd96e4ad 100644 --- a/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp +++ b/Source/CesiumRuntime/Private/CesiumGltfComponent.cpp @@ -719,9 +719,10 @@ static void updateTextureCoordinatesForFeaturesMetadata( UCesiumFeatureIdSetBlueprintLibrary::GetAsFeatureIDAttribute( featureIDSet); - int64 vertexCount = - UCesiumFeatureIdAttributeBlueprintLibrary::GetVertexCount( - featureIDAttribute); + // Each feature ID corresponds to a vertex, so the vertex count is just + // the length of the attribute. + int64 vertexCount = UCesiumFeatureIdAttributeBlueprintLibrary::GetCount( + featureIDAttribute); // We encode unsigned integer feature ids as floats in the u-channel of // a texture coordinate slot. @@ -731,8 +732,9 @@ static void updateTextureCoordinatesForFeaturesMetadata( uint32 vertexIndex = indices[i]; if (vertexIndex >= 0 && vertexIndex < vertexCount) { float featureId = static_cast( - UCesiumFeatureIdAttributeBlueprintLibrary:: - GetFeatureIDForVertex(featureIDAttribute, vertexIndex)); + UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( + featureIDAttribute, + vertexIndex)); vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f); } else { vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f); @@ -743,8 +745,9 @@ static void updateTextureCoordinatesForFeaturesMetadata( FStaticMeshBuildVertex& vertex = vertices[i]; if (i < vertexCount) { float featureId = static_cast( - UCesiumFeatureIdAttributeBlueprintLibrary:: - GetFeatureIDForVertex(featureIDAttribute, i)); + UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( + featureIDAttribute, + i)); vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f); } else { vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f); @@ -876,9 +879,10 @@ static void updateTextureCoordinatesForMetadata_DEPRECATED( encodedFeatureIdAttribute.name, textureCoordinateIndex); - int64 vertexCount = - UCesiumFeatureIdAttributeBlueprintLibrary::GetVertexCount( - featureIdAttribute); + // Each feature ID corresponds to a vertex, so the vertex count is just + // the length of the attribute. + int64 vertexCount = UCesiumFeatureIdAttributeBlueprintLibrary::GetCount( + featureIdAttribute); // We encode unsigned integer feature ids as floats in the u-channel of // a texture coordinate slot. @@ -888,8 +892,9 @@ static void updateTextureCoordinatesForMetadata_DEPRECATED( uint32 vertexIndex = indices[i]; if (vertexIndex >= 0 && vertexIndex < vertexCount) { float featureId = static_cast( - UCesiumFeatureIdAttributeBlueprintLibrary:: - GetFeatureIDForVertex(featureIdAttribute, vertexIndex)); + UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( + featureIdAttribute, + vertexIndex)); vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f); } else { vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f); @@ -900,8 +905,9 @@ static void updateTextureCoordinatesForMetadata_DEPRECATED( FStaticMeshBuildVertex& vertex = vertices[i]; if (i < vertexCount) { float featureId = static_cast( - UCesiumFeatureIdAttributeBlueprintLibrary:: - GetFeatureIDForVertex(featureIdAttribute, i)); + UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( + featureIdAttribute, + i)); vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f); } else { vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f); diff --git a/Source/CesiumRuntime/Private/CesiumMetadataUtilityBlueprintLibrary.cpp b/Source/CesiumRuntime/Private/CesiumMetadataUtilityBlueprintLibrary.cpp index d9a5db2f8..a4df00533 100644 --- a/Source/CesiumRuntime/Private/CesiumMetadataUtilityBlueprintLibrary.cpp +++ b/Source/CesiumRuntime/Private/CesiumMetadataUtilityBlueprintLibrary.cpp @@ -100,7 +100,7 @@ int64 UCesiumMetadataUtilityBlueprintLibrary::GetFeatureIDFromFaceID( UPARAM(ref) const FCesiumMetadataPrimitive& Primitive, UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute, int64 FaceID) { - return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex( + return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( FeatureIDAttribute, UCesiumMetadataPrimitiveBlueprintLibrary::GetFirstVertexIDFromFaceID( Primitive, diff --git a/Source/CesiumRuntime/Private/Tests/CesiumFeatureIdAttribute.spec.cpp b/Source/CesiumRuntime/Private/Tests/CesiumFeatureIdAttribute.spec.cpp index 0abfb1ca8..b517b4c1b 100644 --- a/Source/CesiumRuntime/Private/Tests/CesiumFeatureIdAttribute.spec.cpp +++ b/Source/CesiumRuntime/Private/Tests/CesiumFeatureIdAttribute.spec.cpp @@ -126,7 +126,7 @@ void FCesiumFeatureIdAttributeSpec::Define() { }); }); - Describe("GetVertexCount", [this]() { + Describe("GetCount", [this]() { BeforeEach([this]() { model = CesiumGltf::Model(); CesiumGltf::Mesh& mesh = model.meshes.emplace_back(); @@ -149,7 +149,7 @@ void FCesiumFeatureIdAttributeSpec::Define() { ECesiumFeatureIdAttributeStatus::ErrorInvalidAccessor); TestEqual( "VertexCount", - UCesiumFeatureIdAttributeBlueprintLibrary::GetVertexCount( + UCesiumFeatureIdAttributeBlueprintLibrary::GetCount( featureIDAttribute), 0); }); @@ -177,13 +177,13 @@ void FCesiumFeatureIdAttributeSpec::Define() { ECesiumFeatureIdAttributeStatus::Valid); TestEqual( "VertexCount", - UCesiumFeatureIdAttributeBlueprintLibrary::GetVertexCount( + UCesiumFeatureIdAttributeBlueprintLibrary::GetCount( featureIDAttribute), vertexCount); }); }); - Describe("GetFeatureIDForVertex", [this]() { + Describe("GetFeatureID", [this]() { BeforeEach([this]() { model = CesiumGltf::Model(); CesiumGltf::Mesh& mesh = model.meshes.emplace_back(); @@ -206,7 +206,7 @@ void FCesiumFeatureIdAttributeSpec::Define() { ECesiumFeatureIdAttributeStatus::ErrorInvalidAccessor); TestEqual( "FeatureIDForVertex", - UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex( + UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( featureIDAttribute, 0), -1); @@ -234,13 +234,13 @@ void FCesiumFeatureIdAttributeSpec::Define() { ECesiumFeatureIdAttributeStatus::Valid); TestEqual( "FeatureIDForNegativeVertex", - UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex( + UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( featureIDAttribute, -1), -1); TestEqual( "FeatureIDForOutOfBoundsVertex", - UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex( + UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( featureIDAttribute, 10), -1); @@ -269,7 +269,7 @@ void FCesiumFeatureIdAttributeSpec::Define() { for (size_t i = 0; i < featureIDs.size(); i++) { TestEqual( "FeatureIDForVertex", - UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex( + UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID( featureIDAttribute, static_cast(i)), featureIDs[i]); diff --git a/Source/CesiumRuntime/Public/CesiumFeatureIdAttribute.h b/Source/CesiumRuntime/Public/CesiumFeatureIdAttribute.h index 5f9ea6cf0..7604a1239 100644 --- a/Source/CesiumRuntime/Public/CesiumFeatureIdAttribute.h +++ b/Source/CesiumRuntime/Public/CesiumFeatureIdAttribute.h @@ -28,8 +28,9 @@ enum class ECesiumFeatureIdAttributeStatus : uint8 { /** * @brief A blueprint-accessible wrapper for a feature ID attribute from a glTF - * primitive. Provides access to per-vertex feature IDs which can be used with - * the corresponding {@link FCesiumPropertyTable} to access per-vertex metadata. + * model. Provides access to feature IDs which can be used with the + * corresponding {@link FCesiumPropertyTable} to access metadata. These feature + * IDs may be defined per-vertex or per-instance. */ USTRUCT(BlueprintType) struct CESIUMRUNTIME_API FCesiumFeatureIdAttribute { @@ -109,7 +110,6 @@ class CESIUMRUNTIME_API UCesiumFeatureIdAttributeBlueprintLibrary UFUNCTION( BlueprintCallable, BlueprintPure, - Category = "Cesium|Metadata|FeatureIdAttribute", Meta = (DeprecatedFunction, DeprecationMessage = @@ -131,27 +131,35 @@ class CESIUMRUNTIME_API UCesiumFeatureIdAttributeBlueprintLibrary UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute); /** - * Get the number of vertices in the primitive containing the feature - * ID attribute. If the feature ID attribute is invalid, this returns 0. + * Gets the number of elements in the attribute. This is distinct from the + * number of unique feature IDs within the attribute. + * + * For a feature ID attribute of a regular mesh, this is the number of + * vertices. For a per-instance feature ID, this is the number of instances. + * + * If the feature ID attribute is invalid, this returns 0. */ UFUNCTION( BlueprintCallable, BlueprintPure, Category = "Cesium|Features|FeatureIDAttribute") static int64 - GetVertexCount(UPARAM(ref) - const FCesiumFeatureIdAttribute& FeatureIDAttribute); + GetCount(UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute); /** - * Gets the feature ID associated with the given vertex. The feature ID can be - * used with a FCesiumFeatureTable to retrieve the per-vertex metadata. If - * the feature ID attribute is invalid, this returns -1. + * Gets the feature ID at the given index. A feature ID can be used with a + * FCesiumPropertyTable to retrieve the metadata for that ID. If the feature + * ID attribute is invalid, this returns -1. + * + * For a feature ID attribute of a regular mesh, the provided Index is the + * index of a vertex within the mesh. For a per-instance feature ID, the + * provided Index is the index of the instance. */ UFUNCTION( BlueprintCallable, BlueprintPure, Category = "Cesium|Features|FeatureIDAttribute") - static int64 GetFeatureIDForVertex( + static int64 GetFeatureID( UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute, - int64 VertexIndex); + int64 Index); };