Frequent Failures When Sampling Heights at Runtime with Cesium for Unreal

Hi Cesium Team,

I’m using Cesium for Unreal to sample terrain heights at runtime for a set of points (used for vegetation placement). However, I’m encountering frequent sampling failures. Many of the points return SampleSuccess as false. These failures happen consistently for certain coordinates. I am using SampleHeightMostDetialed function to sample the heights. What are the typical reasons for height sampling to fail at runtime in Cesium for Unreal? How can I improve the reliability of sampling large batches of points?

Best Regards.

make sure tiles are correctly loaded for points for which you want to sample the height.

to simply check this execute the the process and when you get the result back go to properties of the cesium3dtileset actor and freez the updates. zoomout a little bit and you will see if tiles where you want to sample the height is loaded or not.

pictures are just to put point across you will find simillar option in the unreal engine.

I hope this helps.

We cannot sample height for the points when the Tileset is freeze(suspend update is true). I tried zooming out, the tiles were loaded in that area but sampling in failing consistently on some specific points.

Hi @sensors_afise,

SampleHeightMostDetailed fails if it isn’t able to intersect the dataset at the specified longitude / latitude coordinates. I’m not sure why it wouldn’t work otherwise, but it would help to know more details, such as:

  • What versions of Unreal Engine and Cesium for Unreal are you using?
  • What dataset are you trying to sample heights from?
  • Are you using Blueprints or C++ to call the function? Can you share your code?

And for future reference, SampleHeightMostDetailed is an asynchronous function, so it requires the tileset to continuously update so it can traverse and query tiles. That’s why it freezes when SuspendUpdate is enabled.

@sensors_afise Is there any pattern to points for which it returens false as you mentioned not all points returns false.

Thanks

Unreal 5.4.4 and cesium 2.16. I amusing C++ to call the function. Below is the code:

FCesiumSampleHeightMostDetailedCallback Callback;
Callback.BindLambda([this, Points, Data](ACesium3DTileset* InTileset, const TArray<FCesiumSampleHeightResult>& SampledResults, const TArray<FString>& Warnings)
    {
        if (SampledResults.Num() != Points.Num())
        {
            UE_LOG(LogTemp, Error, TEXT("Sampled results do not match polygon point count."));
            return;
        }

        TArray<FVector> AdjustedPoints;
        for (int32 i = 0; i < SampledResults.Num(); ++i)
        {
            FVector UnrealPos;

            if (SampledResults[i].SampleSuccess) {
                UnrealPos = CesiumGeoreference->TransformLongitudeLatitudeHeightPositionToUnreal(SampledResults[i].LongitudeLatitudeHeight);

                UE_LOG(LogTemp, Warning, TEXT("Original Points from file on polygon id: %d (%f,%f,%f)"), Data.Id, Points[i].X, Points[i].Y, Points[i].Z);


                UE_LOG(LogTemp, Warning, TEXT("Success Sample on polygon id: %d (%f,%f,%f)"), Data.Id, SampledResults[i].LongitudeLatitudeHeight[0], SampledResults[i].LongitudeLatitudeHeight[1], SampledResults[i].LongitudeLatitudeHeight[2]);*/

                AdjustedPoints.Add(UnrealPos);

            }

            else {
                UnrealPos = CesiumGeoreference->TransformLongitudeLatitudeHeightPositionToUnreal(Points[i]);
                UE_LOG(LogTemp, Error, TEXT("Failed Sample on polygon id: %d (%f,%f,%f)"), Data.Id,Points[i].X, Points[i].Y, Points[i].Z);

            }
      
        }

    });

Tileset->SampleHeightMostDetailed(Points, Callback);