Skip to content

Commit 633b037

Browse files
authored
Merge pull request #1574 from CesiumGS/rename-features-getter
Rename vertex-specific functions in `FCesiumFeatureIdAttribute`
2 parents 98932e5 + 9485561 commit 633b037

File tree

8 files changed

+63
-43
lines changed

8 files changed

+63
-43
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
##### Breaking Changes :mega:
66

77
- Removed support for Unreal Engine 5.2. Unreal Engine 5.3 or later is now required.
8+
- Renamed `FCesiumFeatureIdAttribute::GetFeatureIDForVertex` to `FCesiumFeatureIdAttribute::GetFeatureID`.
9+
- Renamed `FCesiumFeatureIdAttribute::GetVertexCount` to `FCesiumFeatureIdAttribute::GetCount`.
810

911
##### Fixes :wrench:
1012

Config/Engine.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,8 @@ AspectRatioAxisConstraint=AspectRatio_MaintainXFOV
158158
+PropertyRedirects=(OldName="CesiumWebMapTileServiceRasterOverlay.South", NewName="CesiumWebMapTileServiceRasterOverlay.RectangleSouth")
159159
+PropertyRedirects=(OldName="CesiumWebMapTileServiceRasterOverlay.East", NewName="CesiumWebMapTileServiceRasterOverlay.RectangleEast")
160160
+PropertyRedirects=(OldName="CesiumWebMapTileServiceRasterOverlay.North", NewName="CesiumWebMapTileServiceRasterOverlay.RectangleNorth")
161-
+PropertyRedirects=(OldName="CesiumWebMapTileServiceRasterOverlay.UseWebMercatorProjection", NewName="CesiumWebMapTileServiceRasterOverlay.UseWebMercatorProjection_DEPRECATED")
161+
+PropertyRedirects=(OldName="CesiumWebMapTileServiceRasterOverlay.UseWebMercatorProjection", NewName="CesiumWebMapTileServiceRasterOverlay.UseWebMercatorProjection_DEPRECATED")
162+
163+
+FunctionRedirects=(OldName="CesiumFeatureIdAttributeBlueprintLibrary.GetFeatureIDForVertex", NewName="CesiumFeatureIdAttributeBlueprintLibrary.GetFeatureID")
164+
+PropertyRedirects=(OldName="CesiumFeatureIdAttributeBlueprintLibrary.GetFeatureIDForVertex.VertexIndex", NewName="CesiumFeatureIdAttributeBlueprintLibrary.GetFeatureID.Index")
165+
+FunctionRedirects=(OldName="CesiumFeatureIdAttributeBlueprintLibrary.GetVertexCount", NewName="CesiumFeatureIdAttributeBlueprintLibrary.GetCount")

Source/CesiumRuntime/Private/CesiumFeatureIdAttribute.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDAttributeStatus(
7373
return FeatureIDAttribute._status;
7474
}
7575

76-
int64 UCesiumFeatureIdAttributeBlueprintLibrary::GetVertexCount(
76+
int64 UCesiumFeatureIdAttributeBlueprintLibrary::GetCount(
7777
UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute) {
7878
return std::visit(
7979
CesiumGltf::CountFromAccessor{},
8080
FeatureIDAttribute._featureIdAccessor);
8181
}
8282

83-
int64 UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
83+
int64 UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
8484
UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute,
85-
int64 VertexIndex) {
85+
int64 Index) {
8686
return std::visit(
87-
CesiumGltf::FeatureIdFromAccessor{VertexIndex},
87+
CesiumGltf::FeatureIdFromAccessor{Index},
8888
FeatureIDAttribute._featureIdAccessor);
8989
}

Source/CesiumRuntime/Private/CesiumFeatureIdSet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ int64 UCesiumFeatureIdSetBlueprintLibrary::GetFeatureIDForVertex(
152152
if (FeatureIDSet._featureIDSetType == ECesiumFeatureIdSetType::Attribute) {
153153
FCesiumFeatureIdAttribute attribute =
154154
std::get<FCesiumFeatureIdAttribute>(FeatureIDSet._featureID);
155-
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
155+
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
156156
attribute,
157157
VertexIndex);
158158
}
@@ -189,7 +189,7 @@ int64 UCesiumFeatureIdSetBlueprintLibrary::GetFeatureIDForInstance(
189189
}
190190
const auto& featureIdAttribute =
191191
std::get<FCesiumFeatureIdAttribute>(FeatureIDSet._featureID);
192-
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
192+
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
193193
featureIdAttribute,
194194
InstanceIndex);
195195
}
@@ -239,7 +239,7 @@ int64 UCesiumFeatureIdSetBlueprintLibrary::GetFeatureIDFromHit(
239239
if (FeatureIDSet._featureIDSetType == ECesiumFeatureIdSetType::Attribute) {
240240
FCesiumFeatureIdAttribute attribute =
241241
std::get<FCesiumFeatureIdAttribute>(FeatureIDSet._featureID);
242-
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
242+
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
243243
attribute,
244244
VertexIndex);
245245
}

Source/CesiumRuntime/Private/CesiumGltfComponent.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,10 @@ static void updateTextureCoordinatesForFeaturesMetadata(
719719
UCesiumFeatureIdSetBlueprintLibrary::GetAsFeatureIDAttribute(
720720
featureIDSet);
721721

722-
int64 vertexCount =
723-
UCesiumFeatureIdAttributeBlueprintLibrary::GetVertexCount(
724-
featureIDAttribute);
722+
// Each feature ID corresponds to a vertex, so the vertex count is just
723+
// the length of the attribute.
724+
int64 vertexCount = UCesiumFeatureIdAttributeBlueprintLibrary::GetCount(
725+
featureIDAttribute);
725726

726727
// We encode unsigned integer feature ids as floats in the u-channel of
727728
// a texture coordinate slot.
@@ -731,8 +732,9 @@ static void updateTextureCoordinatesForFeaturesMetadata(
731732
uint32 vertexIndex = indices[i];
732733
if (vertexIndex >= 0 && vertexIndex < vertexCount) {
733734
float featureId = static_cast<float>(
734-
UCesiumFeatureIdAttributeBlueprintLibrary::
735-
GetFeatureIDForVertex(featureIDAttribute, vertexIndex));
735+
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
736+
featureIDAttribute,
737+
vertexIndex));
736738
vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f);
737739
} else {
738740
vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f);
@@ -743,8 +745,9 @@ static void updateTextureCoordinatesForFeaturesMetadata(
743745
FStaticMeshBuildVertex& vertex = vertices[i];
744746
if (i < vertexCount) {
745747
float featureId = static_cast<float>(
746-
UCesiumFeatureIdAttributeBlueprintLibrary::
747-
GetFeatureIDForVertex(featureIDAttribute, i));
748+
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
749+
featureIDAttribute,
750+
i));
748751
vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f);
749752
} else {
750753
vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f);
@@ -876,9 +879,10 @@ static void updateTextureCoordinatesForMetadata_DEPRECATED(
876879
encodedFeatureIdAttribute.name,
877880
textureCoordinateIndex);
878881

879-
int64 vertexCount =
880-
UCesiumFeatureIdAttributeBlueprintLibrary::GetVertexCount(
881-
featureIdAttribute);
882+
// Each feature ID corresponds to a vertex, so the vertex count is just
883+
// the length of the attribute.
884+
int64 vertexCount = UCesiumFeatureIdAttributeBlueprintLibrary::GetCount(
885+
featureIdAttribute);
882886

883887
// We encode unsigned integer feature ids as floats in the u-channel of
884888
// a texture coordinate slot.
@@ -888,8 +892,9 @@ static void updateTextureCoordinatesForMetadata_DEPRECATED(
888892
uint32 vertexIndex = indices[i];
889893
if (vertexIndex >= 0 && vertexIndex < vertexCount) {
890894
float featureId = static_cast<float>(
891-
UCesiumFeatureIdAttributeBlueprintLibrary::
892-
GetFeatureIDForVertex(featureIdAttribute, vertexIndex));
895+
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
896+
featureIdAttribute,
897+
vertexIndex));
893898
vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f);
894899
} else {
895900
vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f);
@@ -900,8 +905,9 @@ static void updateTextureCoordinatesForMetadata_DEPRECATED(
900905
FStaticMeshBuildVertex& vertex = vertices[i];
901906
if (i < vertexCount) {
902907
float featureId = static_cast<float>(
903-
UCesiumFeatureIdAttributeBlueprintLibrary::
904-
GetFeatureIDForVertex(featureIdAttribute, i));
908+
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
909+
featureIdAttribute,
910+
i));
905911
vertex.UVs[textureCoordinateIndex] = TMeshVector2(featureId, 0.0f);
906912
} else {
907913
vertex.UVs[textureCoordinateIndex] = TMeshVector2(0.0f, 0.0f);

Source/CesiumRuntime/Private/CesiumMetadataUtilityBlueprintLibrary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ int64 UCesiumMetadataUtilityBlueprintLibrary::GetFeatureIDFromFaceID(
100100
UPARAM(ref) const FCesiumMetadataPrimitive& Primitive,
101101
UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute,
102102
int64 FaceID) {
103-
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
103+
return UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
104104
FeatureIDAttribute,
105105
UCesiumMetadataPrimitiveBlueprintLibrary::GetFirstVertexIDFromFaceID(
106106
Primitive,

Source/CesiumRuntime/Private/Tests/CesiumFeatureIdAttribute.spec.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void FCesiumFeatureIdAttributeSpec::Define() {
126126
});
127127
});
128128

129-
Describe("GetVertexCount", [this]() {
129+
Describe("GetCount", [this]() {
130130
BeforeEach([this]() {
131131
model = CesiumGltf::Model();
132132
CesiumGltf::Mesh& mesh = model.meshes.emplace_back();
@@ -149,7 +149,7 @@ void FCesiumFeatureIdAttributeSpec::Define() {
149149
ECesiumFeatureIdAttributeStatus::ErrorInvalidAccessor);
150150
TestEqual(
151151
"VertexCount",
152-
UCesiumFeatureIdAttributeBlueprintLibrary::GetVertexCount(
152+
UCesiumFeatureIdAttributeBlueprintLibrary::GetCount(
153153
featureIDAttribute),
154154
0);
155155
});
@@ -177,13 +177,13 @@ void FCesiumFeatureIdAttributeSpec::Define() {
177177
ECesiumFeatureIdAttributeStatus::Valid);
178178
TestEqual(
179179
"VertexCount",
180-
UCesiumFeatureIdAttributeBlueprintLibrary::GetVertexCount(
180+
UCesiumFeatureIdAttributeBlueprintLibrary::GetCount(
181181
featureIDAttribute),
182182
vertexCount);
183183
});
184184
});
185185

186-
Describe("GetFeatureIDForVertex", [this]() {
186+
Describe("GetFeatureID", [this]() {
187187
BeforeEach([this]() {
188188
model = CesiumGltf::Model();
189189
CesiumGltf::Mesh& mesh = model.meshes.emplace_back();
@@ -206,7 +206,7 @@ void FCesiumFeatureIdAttributeSpec::Define() {
206206
ECesiumFeatureIdAttributeStatus::ErrorInvalidAccessor);
207207
TestEqual(
208208
"FeatureIDForVertex",
209-
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
209+
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
210210
featureIDAttribute,
211211
0),
212212
-1);
@@ -234,13 +234,13 @@ void FCesiumFeatureIdAttributeSpec::Define() {
234234
ECesiumFeatureIdAttributeStatus::Valid);
235235
TestEqual(
236236
"FeatureIDForNegativeVertex",
237-
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
237+
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
238238
featureIDAttribute,
239239
-1),
240240
-1);
241241
TestEqual(
242242
"FeatureIDForOutOfBoundsVertex",
243-
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
243+
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
244244
featureIDAttribute,
245245
10),
246246
-1);
@@ -269,7 +269,7 @@ void FCesiumFeatureIdAttributeSpec::Define() {
269269
for (size_t i = 0; i < featureIDs.size(); i++) {
270270
TestEqual(
271271
"FeatureIDForVertex",
272-
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureIDForVertex(
272+
UCesiumFeatureIdAttributeBlueprintLibrary::GetFeatureID(
273273
featureIDAttribute,
274274
static_cast<int64>(i)),
275275
featureIDs[i]);

Source/CesiumRuntime/Public/CesiumFeatureIdAttribute.h

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ enum class ECesiumFeatureIdAttributeStatus : uint8 {
2828

2929
/**
3030
* @brief A blueprint-accessible wrapper for a feature ID attribute from a glTF
31-
* primitive. Provides access to per-vertex feature IDs which can be used with
32-
* the corresponding {@link FCesiumPropertyTable} to access per-vertex metadata.
31+
* model. Provides access to feature IDs which can be used with the
32+
* corresponding {@link FCesiumPropertyTable} to access metadata. These feature
33+
* IDs may be defined per-vertex or per-instance.
3334
*/
3435
USTRUCT(BlueprintType)
3536
struct CESIUMRUNTIME_API FCesiumFeatureIdAttribute {
@@ -109,7 +110,6 @@ class CESIUMRUNTIME_API UCesiumFeatureIdAttributeBlueprintLibrary
109110
UFUNCTION(
110111
BlueprintCallable,
111112
BlueprintPure,
112-
Category = "Cesium|Metadata|FeatureIdAttribute",
113113
Meta =
114114
(DeprecatedFunction,
115115
DeprecationMessage =
@@ -131,27 +131,35 @@ class CESIUMRUNTIME_API UCesiumFeatureIdAttributeBlueprintLibrary
131131
UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute);
132132

133133
/**
134-
* Get the number of vertices in the primitive containing the feature
135-
* ID attribute. If the feature ID attribute is invalid, this returns 0.
134+
* Gets the number of elements in the attribute. This is distinct from the
135+
* number of unique feature IDs within the attribute.
136+
*
137+
* For a feature ID attribute of a regular mesh, this is the number of
138+
* vertices. For a per-instance feature ID, this is the number of instances.
139+
*
140+
* If the feature ID attribute is invalid, this returns 0.
136141
*/
137142
UFUNCTION(
138143
BlueprintCallable,
139144
BlueprintPure,
140145
Category = "Cesium|Features|FeatureIDAttribute")
141146
static int64
142-
GetVertexCount(UPARAM(ref)
143-
const FCesiumFeatureIdAttribute& FeatureIDAttribute);
147+
GetCount(UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute);
144148

145149
/**
146-
* Gets the feature ID associated with the given vertex. The feature ID can be
147-
* used with a FCesiumFeatureTable to retrieve the per-vertex metadata. If
148-
* the feature ID attribute is invalid, this returns -1.
150+
* Gets the feature ID at the given index. A feature ID can be used with a
151+
* FCesiumPropertyTable to retrieve the metadata for that ID. If the feature
152+
* ID attribute is invalid, this returns -1.
153+
*
154+
* For a feature ID attribute of a regular mesh, the provided Index is the
155+
* index of a vertex within the mesh. For a per-instance feature ID, the
156+
* provided Index is the index of the instance.
149157
*/
150158
UFUNCTION(
151159
BlueprintCallable,
152160
BlueprintPure,
153161
Category = "Cesium|Features|FeatureIDAttribute")
154-
static int64 GetFeatureIDForVertex(
162+
static int64 GetFeatureID(
155163
UPARAM(ref) const FCesiumFeatureIdAttribute& FeatureIDAttribute,
156-
int64 VertexIndex);
164+
int64 Index);
157165
};

0 commit comments

Comments
 (0)