Skip to content

Commit

Permalink
Merge pull request #1574 from CesiumGS/rename-features-getter
Browse files Browse the repository at this point in the history
Rename vertex-specific functions in `FCesiumFeatureIdAttribute`
  • Loading branch information
kring authored Dec 24, 2024
2 parents 98932e5 + 9485561 commit 633b037
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 43 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
6 changes: 5 additions & 1 deletion Config/Engine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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")
+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")
8 changes: 4 additions & 4 deletions Source/CesiumRuntime/Private/CesiumFeatureIdAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
6 changes: 3 additions & 3 deletions Source/CesiumRuntime/Private/CesiumFeatureIdSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int64 UCesiumFeatureIdSetBlueprintLibrary::GetFeatureIDForVertex(
if (FeatureIDSet._featureIDSetType == ECesiumFeatureIdSetType::Attribute) {
FCesiumFeatureIdAttribute attribute =
std::get<FCesiumFeatureIdAttribute>(FeatureIDSet._featureID);
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
attribute,
VertexIndex);
}
Expand Down Expand Up @@ -189,7 +189,7 @@ int64 UCesiumFeatureIdSetBlueprintLibrary::GetFeatureIDForInstance(
}
const auto& featureIdAttribute =
std::get<FCesiumFeatureIdAttribute>(FeatureIDSet._featureID);
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
featureIdAttribute,
InstanceIndex);
}
Expand Down Expand Up @@ -239,7 +239,7 @@ int64 UCesiumFeatureIdSetBlueprintLibrary::GetFeatureIDFromHit(
if (FeatureIDSet._featureIDSetType == ECesiumFeatureIdSetType::Attribute) {
FCesiumFeatureIdAttribute attribute =
std::get<FCesiumFeatureIdAttribute>(FeatureIDSet._featureID);
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
attribute,
VertexIndex);
}
Expand Down
34 changes: 20 additions & 14 deletions Source/CesiumRuntime/Private/CesiumGltfComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -731,8 +732,9 @@ static void updateTextureCoordinatesForFeaturesMetadata(
uint32 vertexIndex = indices[i];
if (vertexIndex >= 0 && vertexIndex < vertexCount) {
float featureId = static_cast<float>(
UCesiumFeatureIdAttributeBlueprintLibrary::
GetFeatureIDForVertex(featureIDAttribute, vertexIndex));
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
featureIDAttribute,
vertexIndex));
vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f);
} else {
vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f);
Expand All @@ -743,8 +745,9 @@ static void updateTextureCoordinatesForFeaturesMetadata(
FStaticMeshBuildVertex& vertex = vertices[i];
if (i < vertexCount) {
float featureId = static_cast<float>(
UCesiumFeatureIdAttributeBlueprintLibrary::
GetFeatureIDForVertex(featureIDAttribute, i));
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
featureIDAttribute,
i));
vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f);
} else {
vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f);
Expand Down Expand Up @@ -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.
Expand All @@ -888,8 +892,9 @@ static void updateTextureCoordinatesForMetadata_DEPRECATED(
uint32 vertexIndex = indices[i];
if (vertexIndex >= 0 && vertexIndex < vertexCount) {
float featureId = static_cast<float>(
UCesiumFeatureIdAttributeBlueprintLibrary::
GetFeatureIDForVertex(featureIdAttribute, vertexIndex));
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
featureIdAttribute,
vertexIndex));
vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f);
} else {
vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f);
Expand All @@ -900,8 +905,9 @@ static void updateTextureCoordinatesForMetadata_DEPRECATED(
FStaticMeshBuildVertex& vertex = vertices[i];
if (i < vertexCount) {
float featureId = static_cast<float>(
UCesiumFeatureIdAttributeBlueprintLibrary::
GetFeatureIDForVertex(featureIdAttribute, i));
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
featureIdAttribute,
i));
vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f);
} else {
vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -149,7 +149,7 @@ void FCesiumFeatureIdAttributeSpec::Define() {
ECesiumFeatureIdAttributeStatus::ErrorInvalidAccessor);
TestEqual(
"VertexCount",
UCesiumFeatureIdAttributeBlueprintLibrary::GetVertexCount(
UCesiumFeatureIdAttributeBlueprintLibrary::GetCount(
featureIDAttribute),
0);
});
Expand Down Expand Up @@ -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();
Expand All @@ -206,7 +206,7 @@ void FCesiumFeatureIdAttributeSpec::Define() {
ECesiumFeatureIdAttributeStatus::ErrorInvalidAccessor);
TestEqual(
"FeatureIDForVertex",
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
featureIDAttribute,
0),
-1);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<int64>(i)),
featureIDs[i]);
Expand Down
32 changes: 20 additions & 12 deletions Source/CesiumRuntime/Public/CesiumFeatureIdAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -109,7 +110,6 @@ class CESIUMRUNTIME_API UCesiumFeatureIdAttributeBlueprintLibrary
UFUNCTION(
BlueprintCallable,
BlueprintPure,
Category = "Cesium|Metadata|FeatureIdAttribute",
Meta =
(DeprecatedFunction,
DeprecationMessage =
Expand All @@ -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);
};

0 comments on commit 633b037

Please sign in to comment.