# Scalability and Precision

<figure><img src="/files/Y9l2tVJmm6yp3WKB9KCJ" alt=""><figcaption></figcaption></figure>

Planetary Oceans is designed to simulate ocean surfaces on both small planetary bodies and massive planets, with support (with some caveats described below) for oceans exceeding **10,000,000,000 Unreal Units** (100,000 km) in radius.

## Mesh Generation (CPU)

Vertex position calculations are performed using **64-bit doubles**. After the mesh data is finalized, both the mesh origin and vertex positions are **rebased to the camera location** to avoid floating-point imprecision during rendering. The vertex data is then **converted to 32-bit floats** and passed to the engine for rendering, as the engine expects all vertex data to be represented in floats.

#### Parameters in `BP_PlanetaryOcean` (comes from `SphereMeshComponent`):

| Parameter                  | Description                                                                                                                                                                                         |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GeometryUpdateDistanceCm` | Distance in centimeters camera (both editor and in-game camera) must be traveled before the ocean geometry is regenerated to keep dense geometry near the observer. This does not shift the origin. |
| `OriginShiftDistanceCm`    | Distance in centimeters the camera must move before the mesh origin is rebased (shifted) to the current camera location. This helps prevent precision loss in large-radius scenarios.               |

#### How and When the Mesh Origin Is Rebased

* Once the level is loaded, the mesh origin is initially placed at the **editor camera** location.
* Once the game starts, the mesh origin is placed at the **in-game camera** location (e.g., the camera component of your character).
* Both before and after `BeginPlay`, the mesh origin is **rebased every time** the camera travels a distance greater than the value specified by the `OriginShiftDistanceCm` parameter. The distance is measured from the most recent mesh origin location.

## Waves generation (GPU)

The ocean material tries to avoid absolute world space as much as possible. It also takes into account the mesh origin and calculates vertex positions relative to it.

{% hint style="warning" %}
Each origin shift causes the entire wave system to visually shift as well. It takes one frame to shift the waves. Chances you will see this artifact are slim to none for the following reasons:

* If you keep `OriginShiftDistanceCm` high (around **10,000,000 units**, or **100 km**), you will need to move really far to see it happening.
* You will have to move relatively slowly to notice this artifact.
* You will have to be really close to the ocean surface to see the artifact.

Generally speaking, keep the `OriginShiftDistanceCm` value around the default (**10,000,000**). If you want to disable origin shifting completely, set `OriginShiftDistanceCm` to a very large number. For instance, a planet with a radius of \~10,000,000 doesn't suffer from floating-point issues at all. If you have several planets like this, you will still need origin shifting.
{% endhint %}

## Buoyancy (CPU)

The **buoyancy system** takes the mesh origin into account and adapts to wave positions when the origin is rebased. All material calculations related to avoiding floating point imprecision are mirrored in the buoyancy component (check `UOceanFunctionLibrary::WorldToPeriodicWorldSpace`).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.planetaryoceans.com/guide-v.-2.1/scalability-and-precision.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
