Skip to content

Commit 946dc2b

Browse files
authored
Merge pull request #1697 from CesiumGS/default-null-feature
Change default null feature ID to `-1` instead of `0`
2 parents ed38004 + 4b32d5c commit 946dc2b

File tree

4 files changed

+25
-31
lines changed

4 files changed

+25
-31
lines changed

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log {#changes}
22

3+
### ? - ?
4+
5+
##### Breaking Changes :mega:
6+
7+
- Feature IDs that are encoded by `UCesiumFeaturesMetadataComponent` will now use a default null feature ID of `-1` instead of `0`.
8+
- Materials generated by `UCesiumFeaturesMetadataComponent` now always check for null feature IDs, assuming a default value of `-1`.
9+
310
### v2.16.1 - 2025-06-02
411

512
##### Additions :tada:

Source/CesiumRuntime/Private/CesiumFeaturesMetadataComponent.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,6 @@ void AutoFillFeatureIdSetDescriptions(
317317
pDescription->PropertyTableName = getNameForPropertyTable(propertyTable);
318318
}
319319

320-
pDescription->bHasNullFeatureId =
321-
UCesiumFeatureIdSetBlueprintLibrary::GetNullFeatureID(featureIDSet) >
322-
-1;
323-
324320
if (type == ECesiumFeatureIdSetType::Texture) {
325321
FCesiumFeatureIdTexture featureIdTexture =
326322
UCesiumFeatureIdSetBlueprintLibrary::GetAsFeatureIDTexture(
@@ -1362,7 +1358,7 @@ void GenerateNodesForNullFeatureId(
13621358
UMaterialExpressionScalarParameter* NullFeatureId =
13631359
NewObject<UMaterialExpressionScalarParameter>(TargetMaterialLayer);
13641360
NullFeatureId->ParameterName = FName(SafeName + MaterialNullFeatureIdSuffix);
1365-
NullFeatureId->DefaultValue = 0;
1361+
NullFeatureId->DefaultValue = -1.0f;
13661362
NullFeatureId->MaterialExpressionEditorX = NodeX;
13671363
NullFeatureId->MaterialExpressionEditorY = NodeY;
13681364
AutoGeneratedNodes.Add(NullFeatureId);
@@ -2349,23 +2345,23 @@ void GenerateMaterialNodes(
23492345
}
23502346
}
23512347

2352-
if (featureIdSet.bHasNullFeatureId) {
2353-
// Spatial nitpicking; this aligns the if statement to the same Y as the
2354-
// PropertyTableFunction node then resets the Y so that the next section
2355-
// appears below all of the just-generated nodes.
2356-
int32 OriginalY = NodeY;
2357-
NodeY = BeginSectionY;
2348+
// Spatial nitpicking; this aligns the if statement to the same Y as the
2349+
// PropertyTableFunction node then resets the Y so that the next section
2350+
// appears below all of the just-generated nodes.
2351+
int32 OriginalY = NodeY;
2352+
NodeY = BeginSectionY;
23582353

2359-
GenerateNodesForNullFeatureId(
2360-
featureIdSet,
2361-
MaterialState.AutoGeneratedNodes,
2362-
pComponent->TargetMaterialLayer,
2363-
NodeX,
2364-
NodeY,
2365-
LastNode);
2354+
// Even if a feature ID set doesn't specify a `nullFeatureId`, we use -1
2355+
// as the default.
2356+
GenerateNodesForNullFeatureId(
2357+
featureIdSet,
2358+
MaterialState.AutoGeneratedNodes,
2359+
pComponent->TargetMaterialLayer,
2360+
NodeX,
2361+
NodeY,
2362+
LastNode);
23662363

2367-
NodeY = OriginalY;
2368-
}
2364+
NodeY = OriginalY;
23692365
MaximumSectionX = FMath::Max(MaximumSectionX, NodeX);
23702366

23712367
NodeX = BeginSectionX;

Source/CesiumRuntime/Private/CesiumGltfComponent.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ void copyFeatureIds(
390390
vertices.SetVertexUV(
391391
i,
392392
textureCoordinateIndex,
393-
FVector2f(glm::max(featureId, 0.0f), 0.0f));
393+
FVector2f(featureId, 0.0f));
394394
}
395395
} else {
396396
for (int64_t i = 0; i < vertices.GetNumVertices(); ++i) {
@@ -400,7 +400,7 @@ void copyFeatureIds(
400400
vertices.SetVertexUV(
401401
i,
402402
textureCoordinateIndex,
403-
FVector2f(glm::max(featureId, 0.0f), 0.0f));
403+
FVector2f(featureId, 0.0f));
404404
}
405405
}
406406
}

Source/CesiumRuntime/Public/CesiumFeaturesMetadataDescription.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,6 @@ struct CESIUMRUNTIME_API FCesiumFeatureIdSetDescription {
6868
*/
6969
UPROPERTY(EditAnywhere, Category = "Cesium")
7070
FString PropertyTableName;
71-
72-
/**
73-
* The null feature ID for the feature ID set. This value indicates that no
74-
* feature is associated with the vertex or texel containing the value. If no
75-
* such value is specified, this defaults to -1, which prevents it from being
76-
* unnecessarily included in the generated material.
77-
*/
78-
UPROPERTY(EditAnywhere, Category = "Cesium")
79-
bool bHasNullFeatureId = false;
8071
};
8172

8273
/**

0 commit comments

Comments
 (0)