Skip to content

Commit 668318a

Browse files
authored
Merge pull request #1770 from jayyabsley/fix/ue5.5-getinputsview-deprecation
Fix UE 5.5+ GetInputsView deprecation warnings
2 parents 2f8fe56 + ea3c5cf commit 668318a

File tree

2 files changed

+59
-29
lines changed

2 files changed

+59
-29
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
### ? - ?
44

5+
##### Fixes :wrench:
6+
7+
- Fixed deprecation warnings when compiling with Unreal Engine 5.5+ by replacing deprecated `GetInputsView()` calls with `FExpressionInputIterator` while maintaining compatibility with Unreal Engine 5.4.
8+
59
##### Additions :tada:
610

711
- Added an optional glTF model post-processing stage after the tile loading step, before the tile can be displayed.

Source/CesiumRuntime/Private/CesiumFeaturesMetadataComponent.cpp

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "CesiumFeaturesMetadataComponent.h"
44
#include "Cesium3DTileset.h"
5+
#include "CesiumCommon.h"
56
#include "CesiumGltfComponent.h"
67
#include "CesiumGltfPrimitiveComponent.h"
78
#include "CesiumModelMetadata.h"
@@ -511,6 +512,22 @@ static void ClearAutoGeneratedNodes(
511512
TMap<FString, TArray<FExpressionInput*>>& ConnectionOutputRemap,
512513
const MaterialFunctionLibrary& FunctionLibrary) {
513514

515+
#if ENGINE_VERSION_5_5_OR_HIGHER
516+
// UE 5.5+: Use FExpressionInputIterator
517+
auto IterateInputs = [](UMaterialExpression* Expression, auto Callback) {
518+
for (FExpressionInputIterator It(Expression); It; ++It) {
519+
Callback(It.Input);
520+
}
521+
};
522+
#else
523+
// UE 5.4: Use GetInputsView()
524+
auto IterateInputs = [](UMaterialExpression* Expression, auto Callback) {
525+
for (FExpressionInput* Input : Expression->GetInputsView()) {
526+
Callback(Input);
527+
}
528+
};
529+
#endif
530+
514531
FeaturesMetadataClassification Classification =
515532
ClassifyNodes(Layer, FunctionLibrary);
516533

@@ -528,12 +545,12 @@ static void ClearAutoGeneratedNodes(
528545
// Should not happen, but just in case, this node would be invalid. Break
529546
// any user-made connections to this node and don't attempt to remap it.
530547
for (UMaterialExpression* UserNode : Classification.UserAddedNodes) {
531-
for (FExpressionInput* Input : UserNode->GetInputsView()) {
548+
IterateInputs(UserNode, [GetFeatureIdNode](FExpressionInput* Input) {
532549
if (Input->Expression == GetFeatureIdNode &&
533550
Input->OutputIndex == 0) {
534551
Input->Expression = nullptr;
535552
}
536-
}
553+
});
537554
}
538555
continue;
539556
}
@@ -553,26 +570,29 @@ static void ClearAutoGeneratedNodes(
553570
// In case, treat the node as invalid. Break any user-made connections to
554571
// this node and don't attempt to remap it.
555572
for (UMaterialExpression* UserNode : Classification.UserAddedNodes) {
556-
for (FExpressionInput* Input : UserNode->GetInputsView()) {
573+
IterateInputs(UserNode, [GetFeatureIdNode](FExpressionInput* Input) {
557574
if (Input->Expression == GetFeatureIdNode &&
558575
Input->OutputIndex == 0) {
559576
Input->Expression = nullptr;
560577
}
561-
}
578+
});
562579
}
563580
continue;
564581
}
565582

566583
FString Key = GetFeatureIdNode->GetDescription() + ParameterName;
567584
TArray<FExpressionInput*> Connections;
568585
for (UMaterialExpression* UserNode : Classification.UserAddedNodes) {
569-
for (FExpressionInput* Input : UserNode->GetInputsView()) {
570-
// Look for user-made connections to this node.
571-
if (Input->Expression == GetFeatureIdNode && Input->OutputIndex == 0) {
572-
Connections.Add(Input);
573-
Input->Expression = nullptr;
574-
}
575-
}
586+
IterateInputs(
587+
UserNode,
588+
[GetFeatureIdNode, &Connections](FExpressionInput* Input) {
589+
// Look for user-made connections to this node.
590+
if (Input->Expression == GetFeatureIdNode &&
591+
Input->OutputIndex == 0) {
592+
Connections.Add(Input);
593+
Input->Expression = nullptr;
594+
}
595+
});
576596
}
577597
ConnectionOutputRemap.Emplace(MoveTemp(Key), MoveTemp(Connections));
578598
}
@@ -590,13 +610,16 @@ static void ClearAutoGeneratedNodes(
590610
// Look for user-made connections to this property.
591611
TArray<FExpressionInput*> Connections;
592612
for (UMaterialExpression* UserNode : Classification.UserAddedNodes) {
593-
for (FExpressionInput* Input : UserNode->GetInputsView()) {
594-
if (Input->Expression == GetPropertyValueNode &&
595-
Input->OutputIndex == OutputIndex) {
596-
Connections.Add(Input);
597-
Input->Expression = nullptr;
598-
}
599-
}
613+
IterateInputs(
614+
UserNode,
615+
[GetPropertyValueNode, OutputIndex, &Connections](
616+
FExpressionInput* Input) {
617+
if (Input->Expression == GetPropertyValueNode &&
618+
Input->OutputIndex == OutputIndex) {
619+
Connections.Add(Input);
620+
Input->Expression = nullptr;
621+
}
622+
});
600623
}
601624

602625
ConnectionOutputRemap.Emplace(MoveTemp(Key), MoveTemp(Connections));
@@ -617,13 +640,16 @@ static void ClearAutoGeneratedNodes(
617640
// Look for user-made connections to this property.
618641
TArray<FExpressionInput*> Connections;
619642
for (UMaterialExpression* UserNode : Classification.UserAddedNodes) {
620-
for (FExpressionInput* Input : UserNode->GetInputsView()) {
621-
if (Input->Expression == ApplyValueTransformNode &&
622-
Input->OutputIndex == OutputIndex) {
623-
Connections.Add(Input);
624-
Input->Expression = nullptr;
625-
}
626-
}
643+
IterateInputs(
644+
UserNode,
645+
[ApplyValueTransformNode, OutputIndex, &Connections](
646+
FExpressionInput* Input) {
647+
if (Input->Expression == ApplyValueTransformNode &&
648+
Input->OutputIndex == OutputIndex) {
649+
Connections.Add(Input);
650+
Input->Expression = nullptr;
651+
}
652+
});
627653
}
628654

629655
ConnectionOutputRemap.Emplace(MoveTemp(Key), MoveTemp(Connections));
@@ -663,25 +689,25 @@ static void ClearAutoGeneratedNodes(
663689
// In case, treat the node as invalid. Break any user-made connections to
664690
// this node and don't attempt to remap it.
665691
for (UMaterialExpression* UserNode : Classification.UserAddedNodes) {
666-
for (FExpressionInput* Input : UserNode->GetInputsView()) {
692+
IterateInputs(UserNode, [IfNode](FExpressionInput* Input) {
667693
if (Input->Expression == IfNode && Input->OutputIndex == 0) {
668694
Input->Expression = nullptr;
669695
}
670-
}
696+
});
671697
}
672698
continue;
673699
}
674700

675701
FString Key = IfNode->GetDescription() + IfNodeName;
676702
TArray<FExpressionInput*> Connections;
677703
for (UMaterialExpression* UserNode : Classification.UserAddedNodes) {
678-
for (FExpressionInput* Input : UserNode->GetInputsView()) {
704+
IterateInputs(UserNode, [IfNode, &Connections](FExpressionInput* Input) {
679705
// Look for user-made connections to this node.
680706
if (Input->Expression == IfNode && Input->OutputIndex == 0) {
681707
Connections.Add(Input);
682708
Input->Expression = nullptr;
683709
}
684-
}
710+
});
685711
}
686712
ConnectionOutputRemap.Emplace(Key, MoveTemp(Connections));
687713

0 commit comments

Comments
 (0)