Skip to content

Commit

Permalink
Hacky fix for overlay undefined behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Nov 20, 2024
1 parent 6b938d7 commit efbbcbb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 5 additions & 3 deletions Source/CesiumRuntime/Private/CesiumGltfComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,9 +1522,7 @@ static void loadPrimitive(
material.emissiveTexture,
gltfToUnrealTexCoordMap);

for (size_t i = 0;
i < primitiveResult.overlayTextureCoordinateIDToUVIndex.size();
++i) {
for (size_t i = 0; i < 3; ++i) {
std::string attributeName = "_CESIUMOVERLAY_" + std::to_string(i);
auto overlayIt = primitive.attributes.find(attributeName);
if (overlayIt != primitive.attributes.end()) {
Expand Down Expand Up @@ -3404,6 +3402,10 @@ void UCesiumGltfComponent::AttachRasterTile(
rasterTile.getOverlay().getName(),
"_TranslationScale"),
translationAndScale);
check(
primData.overlayTextureCoordinateIDToUVIndex.find(
textureCoordinateID) !=
primData.overlayTextureCoordinateIDToUVIndex.end());
pMaterial->SetScalarParameterValue(
createSafeName(
rasterTile.getOverlay().getName(),
Expand Down
3 changes: 1 addition & 2 deletions Source/CesiumRuntime/Private/CesiumRasterOverlays.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ constexpr size_t maximumOverlayTextureCoordinateIDs = 2;
* @brief Maps an overlay texture coordinate ID to the index of the
* corresponding texture coordinates in the static mesh's UVs array.
*/
using OverlayTextureCoordinateIDMap =
std::array<int32_t, maximumOverlayTextureCoordinateIDs>;
using OverlayTextureCoordinateIDMap = std::map<size_t, int32_t>;

0 comments on commit efbbcbb

Please sign in to comment.