Download

procedural coding help with viewport/character distance needed

Working with some procedural code:


return FMath::Clamp(FMath::CeilToInt(FMath::Log2(Size / float(CHUNK_SIZE))), 1, MAX_WORLD_DEPTH - 1);

returns an int based on Size. I don’t want to calculate based on Size only, want to generate based on 2 additional things:

  1. If character is within certain range return

FMath::Log2(Size / float(CHUNK_SIZE))

  1. The more complicated part:

If character is outside of a certain range and the the object is within character viewport return an int


FMath::Log2(Size / float(CHUNK_SIZE))

If the object is not within the character viewport and is also not in range I want it to be


FMath::Log10(Size / float(CHUNK_SIZE))

instead.

In essence returning a smaller exponential increase in lod on the front of a sphere with a rapid lod increase on the non-visible backside of a sphere.

Any help/tips would be appreciated.

There’s a static function FVector:: Dist() to get you the distance between two vectors;

Actor->GetLastRenderTime() will tell you if that Actor has been rendered on screen recently.

If the class in question runs procedural algorithms external to the player character how would you get the location of the player character camera to use the Dist() function?

Followup: How would you get the camera look direction?