Constant World Translations when determining Height above Terrain

Hi. Firstly, I was trying to retreive current terrain altitude as in this topic: [How to get altitude above terrain - How to get altitude above terrain - #3 by Raffaele_Bortoli - Cesium for Unreal - Cesium Community (shortly: place a component on a Pawn below by some significant distance so it would be lower then terrain level and retreive current height above terrain by projecting a ray with LineTraceByChannel).
But I bumped into a problem: when I am moving around with my Pawn I noticed that the world’s origin keeps being rebuilt (which affects current altitude above terrain).
Example from logs:

LogLevel: WORLD TRANSLATION BEGIN {172119, -234008, -274360} -> {162435, -243913, -284556}
LogLevel: WORLD TRANSLATION END {162435, -243913, -284556} took 0.7787 ms

I decided to try flying with DynamicPawn and the result was the same.
According to this topic: Is World Origin Rebasing working? - World Creation - Epic Developer Community Forums
I figured out that there is a UWorldComposition somewhere and it has RebaseOriginDistance property which I would like to change and test if it will affect my problem.
But when I tried to get WorldComposition with

	UWorldComposition* WorldComposition = GetWorld()->WorldComposition;

it turned out that WorldComposition is nullptr. I tried doint it inside BeginPlay event of my Pawn and inside Constructor also (just to be sure).

So I have two questions:

  1. Are there any workarounds that prevent World Translation? (I suppose the most straightforwarded is just increase RebaseOriginDistance)
  2. How can access WorldComposition so it won’t be nullptr? Should I create it somehow by myself or make a component which would be inherited from it?
  3. Is there a better way to get current altitude above terrain with cesium and unreal?

What are you trying to do exactly?

The height of Object X in world space is all you need, and you have direct access to it by retriving Actor Location in world space and looking at the value of Z.

If you somehow have a moving height landscape (which you don’t since the landscape system doesn’t allow anything like it).

Then you can add any object(actor) to the persistent level as a marker for “sea level”

And then you simply do basic math between the marker and the ObjectX z values to figure out where you are at in relation.

Also, in case you want the height from the terrain right under you.

A line trace returns the local distance. Always. Regardless of where in worldspace it is (similar to the math suggested above actually).

If you trace down on Z by a huge amount - and you get a result - that result will already contain the correct distance.

If you trace by channel and you only want the landscape to respond - you probably need custom collision channels set up.
Otherwise you will get false positives.

Sorry for my late answer.
Firstly, the solution was found. It is just below

What are you trying to do exactly?
I am trying to determine current height above terrain. I am using Cesium for Unreal plugin which kinda pulls 2d tiles on the geoid (ellipsoid actually).
The height of Object X in world space is all you need
Probably I haven’t been clear that I am using a Cesium plugin (info above). The terrain is another object on the level which has it’s own surface.

The height of the object can be represented as Unreal coordinates and possibly could be transformed to Lonigtude, Latitude, Altitude with help of Cesium plugin.
So, I just want to know the distance between an object and the object right above in a Z-axis.
And as I mentioned:

place a component on a Pawn below by some significant distance so it would be lower then terrain level and retreive current height above terrain by projecting a ray with LineTraceByChannel

It is working. But there was a problem - which solution I wanted to know (constant rebasement).

Also.

If you trace down on Z by a huge amount - and you get a result - that result will already contain the correct distance.

Okay, but again, I didn’t say that Unreal is giving me wrong results, I wanted to know why the world is being rebased when I am moving through the Cesium map. This doesn’t answer my question. It’s like I am talking about color - you answer me about the taste. Please, read the question more carefully next time…

But anyway, thank you for your replies and time!

So, the solution for someone who probably would be faced to the same problem:

  1. turn off the rebasing with a checkbox on the CesiumGeoreference object, something along the lines of “Keep World Origin Near Camera”

    (Constant World Translations when determining Height above Terrain - Cesium for Unreal - Cesium Community)

  2. If you for some reasons cannot turn off this property, just set the distance for rebasing more (if you are not going to travel for a long distance) or set it to a smaller one if you are going to travel a lot (it will be rebasing all the time but it kinda works) - I am not sure if it is a good practice for doing like this but it works.

You cannot just turn off rebasing. Look into floating point errors to learn why.

You didn’t ask “what is rebasing” you asked how to turn it off - which is something no one in their right mind would even try do unless they are dealing with a 200m^2 map.

Yo answer the question you never asked:
World rebasing (world origin shifting) is how you get the engine to actually work, when the player distance from world origin is larger than x (say 200m in x or y direction).

Without it, you get floating point errors and usually jitters in rendering and animations because of it.

In extreme cases 200km from x or y even material distortion.

There is no need for an object to be “right above” if you just compare the z.
The distance is always vertical, not horizontal or linked in any way to the x/y position of the object.
So your objects can be anywhere.

No. That’s definitely not a solution just a recipie for ruining a working project…

Also a recipie for ruining a project.

The default value is set to whatever the engine can comfortably handle.
Increasing the distance will break things.

I don’t think anyone is clear on what “works” for you.

The line trace solution would probbably work locally without any math involved if set to trace the correct channel.

Please read links which I am including. My previous reply was quite big so I can’t really check If all my statements were clear and right. If you would visit links which I included, you wouldn’t ask those questions which I am going to answer you rn.

  1. You didn’t ask “what is rebasing” you asked how to turn it off - which is something no one in their right mind would even try do unless they are dealing with a 200m^2 map.

Neither I said that I asked “what is rebasing” and I didn’t want to turn it off… I literally said:

Are there any workarounds

  1. Yo answer the question you never asked:
    World rebasing (world origin shifting) is how you get the engine to actually work, when the player distance from world origin is larger than x (say 200m in x or y direction).

Yep. Exactly. The question I never asked. Then why are you writing this?

  1. There is no need for an object to be “right above” if you just compare the z.

I mentioned “right above” for more clear explanation what I did and what was my method for determining the altitude.

  1. No. That’s definitely not a solution just a recipie for ruining a working project…

Firstly: that was a quote. Secondly: it was a figure of speech. If you’d visited the links I included (guess it’s the second or third time I am repeating this…) you wouldn’t be confused :slight_smile:
5. > Also a recipie for ruining a project.

Well, probably. But as I mentioned:

it kinda works

I am not sure if it is a good practice for doing like this

  1. I don’t think anyone is clear on what “works” for you.

Oh, yeah, of course, there are hundreds of meanings for this word.

Please do not answer. This discussion would not lead us to anything.

The only confused person here is you.
I was trying to go easy on you since you sound like an a s s but its obious english is not your main language (and if it is, they do offer remedial schooling ffs).
You obviously just lack the ability to write intelligible sentences, so maybe don’t go to English forums to get answers * with an atitude to boot *.

Essere coglioni non è bello, e esibirsi così è anche peggio…

Yes, english is not my first language. And I suppose that it is quite understandable for other people. Especially for native people, which I suppose you are, cause I see you know what they are teaching in remedial schools in english-native speaking countries.

I guess you just didn’t have enough time to get into the question and main problem cause you were busy grinding for posts number and activity on this forum :smiley:

Nonetheless, the only coglioni here is you :slight_smile:

And again:

Please do not answer. This discussion would not lead us to anything.

Bye!