Skip to content

Fix height relative to terrain#1797

Open
david-lively wants to merge 62 commits intomainfrom
fix-height-relative-to-terrain
Open

Fix height relative to terrain#1797
david-lively wants to merge 62 commits intomainfrom
fix-height-relative-to-terrain

Conversation

@david-lively
Copy link
Contributor

@david-lively david-lively commented Feb 13, 2026

Description

When an object is moving, or the camera moves resulting in tileset LOD changes, objects may float above or sink below the terrain. This PR adjusts the actual height as needed to maintain the given distance to the tileset. Properties to control this are added to UCesiumGlobeAnchorComponent.

HeightReference is an enum indicating whether the height of the actor is fixed relative to the tileset or to the ellipsoid. ECesiumHeightReferenceMode::Ellipsoid is identical to the behavior before this PR; no height adjustment will be made.

HeightReferenceTileset specifies an ACesium3DTileset actor, relative to which Height will be interpreted when HeightReference is ECesiumHeightReferenceMode::Tileset. If HeightReferenceTileset is nullptr, no adjustments will be made.

TilesetHeightUpdateInterval how frequently, in TickComponent() calls, for the height to be checked and the actor moved. A value of 1 indicates that this will happen on every call. A value of 2 indicates every second call, and so forth.

image
clamp-to-ground.mov

Issue number or link

#1472

Author checklist

- [ ] I have submitted a Contributor License Agreement (only needed once).

  • I have done a full self-review of my code.
  • I have updated CHANGES.md with a short summary of my change (for user-facing changes).

- [ ] I have added or updated unit tests to ensure consistent code coverage as necessary.
- [ ] I have updated the documentation as necessary.

Testing plan

  1. Open a test scene.
  2. Add a cube to the scene.
  3. Set the cube's Mobility to Movable.
  4. Add a CesiumGlobeAnchor component.
  5. Set the Height Reference value to Tileset.
  6. Set the HeightReferenceTileset value to CesiumWorldTerrain or another ACesium3DTileset actor.
  7. Run the scene.
  8. In the Outliner, select the cube, and modify it's Transform to move it above a hill or other area where the tileset height is different.
  9. Observe that the cube adjusts its height to stay the same distance from the tileset.

It might be easier to set these fields on Dynamic Pawn's CesiumGlobeAnchor, and fly over some terrain while observing that the pawn will remain a fixed height above the tileset.

@j9liu j9liu added this to the March 2026 Release milestone Feb 13, 2026
@j9liu j9liu self-requested a review February 13, 2026 17:07
@j9liu j9liu linked an issue Feb 13, 2026 that may be closed by this pull request
Copy link
Contributor

@j9liu j9liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @david-lively for the PR! Excited to see this feature come to life.

There are some design choices I would iterate on, so I left some basic feedback for that. I'm happy to do a deeper dive once the design solidifies.

@david-lively david-lively marked this pull request as ready for review February 18, 2026 21:23
@david-lively david-lively requested a review from j9liu February 18, 2026 21:23
@david-lively david-lively requested a review from j9liu February 26, 2026 19:41
Copy link
Contributor

@j9liu j9liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @david-lively! This is looking a lot better. There's still a few things that need to be addressed (beyond comment/style cleanup) but I think the implementation seems solid. 😎

Category = "Cesium",
Meta = (ReturnDisplayName = "Height"))
double GetHeight() const { return this->GetLongitudeLatitudeHeight().Z; }
double GetHeight(const bool IgnoreHeightReference = true) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment under GetLongitudeLatitudeHeight

Meta = (ReturnDisplayName = "LongitudeLatitudeHeight"))
FVector GetLongitudeLatitudeHeight() const;
FVector
GetLongitudeLatitudeHeight(const bool IgnoreHeightReference = false) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, almost wonder if you need a None option and call this parameter HeightReferenceOverride. Or Use Existing Reference or something. Would need to namesmith.

david-lively and others added 13 commits February 27, 2026 15:31
…ferenceTileset values. This makes sure the actor maintains its position when changing those values.
Co-authored-by: Janine Liu <32226860+j9liu@users.noreply.github.com>
Co-authored-by: Janine Liu <32226860+j9liu@users.noreply.github.com>
Co-authored-by: Janine Liu <32226860+j9liu@users.noreply.github.com>
…-to-terrain' into fix-height-relative-to-terrain
Copy link
Contributor

@j9liu j9liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @david-lively, this is looking really close!! I confirmed that you were able to fix the few UI bugs I noticed.

I still have one concern re: the OverrideHeightReference boolean in the Blueprints functions, but I don't think it will be a huge lift to address. Happy to talk about alternative solutions too.

…set(). Added ECesiumHeightReference::None to indicate allow clear overriding of the HeightReference value where needed.
Copy link
Contributor

@j9liu j9liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking better @david-lively ! My suggestions are only about comments, that's it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* and height relative to the specified height reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Easy way to clamp objects to the ground

2 participants