Skip to content

Add fetched data and heightmap margins to improve tile transition ☼ - #123

Open
pyrollo wants to merge 2 commits into
mainfrom
pyr/margins
Open

pyrollo wants to merge 2 commits into
mainfrom
pyr/margins

Conversation

@pyrollo

@pyrollo pyrollo commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

Changes

Add margins around heightmaps, models and voxelization area.

To make tile edges totally invisible, renderers need to know a bit about what's around current tile, in order to be able to draw things that overpass neighbor tile borders (placeable structures in particular).

Voxelization areas

Enlarging voxelization area is quite straightforward. The renderers know what they have to place and can enlarge voxelization area accordingly. They only needed that Placeables tells what space they could take. A bbox method has been added for that to Placeable interface.

Model fetch areas

To perform proper voxelization, model fetch area also needs to be enlarged according to renderer needs. For example, a rendrer placing trees needs to know about forest area near the edge of other tiles. It also needs to know about what altitude trees outside have to be placed.

This means that a renderer may add margins to several model types (in the above example : vegetation areas and altitude).

To manage that, a list of model type margins have been added to Generation, to store all the needs. Margins don't add but they overlap. A list of model type volumes have also been added to GenerationTile. It stores actual needed volume per model type (this will be really useful for further development, see below).

TileTaskParams has a new AddMarginsTo field where can be told which model types should be enlarged according to the task needs. placementMargins method has been added to TileTask interface to express that volume need as a 'margin' bounding box (margins the six +X/-X/+Y/-Y/+Z/-Z directions stored in a bounding box).

Heightmap areas

Heightmaps may also need to overpass tile limits. This is the responsibility of task writing data to the heightmap to do that.

WritableHeightmap interface have been modified so its now possible to increase its area, until some data is written.

Showcase

Before the PR:
Capture d’écran du 2025-09-03 14-32-03
Some tree parts are missing around tile edge (in the middle of the image). Tile transition can be guessed.

After the PR:
Capture d’écran du 2025-09-03 14-34-23
No missing tree parts. Tile edge is totally invisible.

Next step

This PR makes it possible to create tasks enlarging model type volumes according to other already fetched models (typically buildings).

This is not included in this PR as it implies some more development (extra needed volume depends on vector feature voxelization and this may be complex).

--> It would be better to wait for #113 to be merged before developing something new on voxelizers.

TODOs

  • Check everything has been updated with new features (for example: water rendering code and yaml parameters)

Self-checks

  • The code has unit tests associated
  • The code has Javadoc Comments associated
  • Complex / Unexpected code is explained / justified with a small comment
  • Relevant documentation inside the /docs folder has been updated
  • All examples in docs/usage/Examples.md work the same (or have been adapted if subject to changes in this PR)
  • Git history is clean (each commit accomplish a single task and describe it accordingly)
  • The texts have been proofread (documentation, error messages, logs, comments...)

@github-actions

github-actions Bot commented Sep 3, 2025

Copy link
Copy Markdown

[Maven Build Status]

📑 Commit: 25c1ef8ac7b909ddef5df1198377ab84edda98e6
⌚️ Date: 2026-02-16T10:20:40 (CET)
🛠️ Status: ✅ Success

📦 Download artifact: Generator.jar

@pyrollo pyrollo changed the title Add fetched data and heightmap margins to improve tile transition Add fetched data and heightmap margins to improve tile transition ☼ Sep 4, 2025

@naulan-chrzaszcz naulan-chrzaszcz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

J'ai que des questions

Comment thread docs/usage/parameters/TileTasks.md Outdated
Comment thread src/main/java/com/ignfab/minalac/generator/utils/world2d/WorldBBox2d.java Outdated
@pyrollo
pyrollo marked this pull request as ready for review September 15, 2025 15:35
@pyrollo

pyrollo commented Sep 17, 2025

Copy link
Copy Markdown
Contributor Author

Deux choses à vérifier suite à une présentation à Naulan :

  • Les marges devraient être inversées par rapport aux structures (on part du voxel pour retrouver le point d'origine);
  • Comment les marges parviennent-elles aux heightmaps ?

Comment on lines +33 to +35
- `addMarginsTo`: Model types to add margins to (optional).

In order to perfectly stitch tiles together, rendering tasks may need to get a bit data overpassing the tile area/volume. This field indicates which model type(s) are concerned. This field could contain a single model type name or a list of model type names.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Est-ce qu'il faut preciser que cela ne fonctionnera pas avec les models de bâtiment ? et que ca fonctionne uniquement sur un model qui place des structures ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Alors, ça marchera pour tous les modèles, il n'y a pas de distinction. En revanche cela ne marchera pas pour toutes les marges effectivement. Seulement celles qui peuvent être déterminées avant de lancer les tâches.

Dans le cas des statistiques sur les heightmaps, et selon ce que l'on veut faire, il va falloir procéder autrement puisqu'il faut peut être appliquer des marges en fonction des modèles téléchargés.

Comment thread src/main/java/com/ignfab/minalac/generator/tasks/RenderVectorsTask.java Outdated
Comment on lines 49 to 52
@Override
public WorldBBox3d placementMargins() {
return bbox;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Je me demande si c'est pas plus simple comme ca et enlever l'attribut bbox

Suggested change
@Override
public WorldBBox3d placementMargins() {
return bbox;
}
@Override
public WorldBBox3d placeableBBox() {
return WorldBBox3d.surrounding(inside, borders);
}

@pyrollo pyrollo Oct 27, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ça fait un peu de calcul en moins de la stocker mais effectivement on peut s'en passer (c'est appelé une fois par tache x tuile x relation si je ne me trompe pas).

En revanche renommer placementMargins en placeableBBox risque d'être très confusant. Dans l'interface, il s'agit de renvoyer les marges à appliquer et cela peut être totalement indépendant des placeables (ça pourrait être autre chose).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Je viens de voir, c'est utilisé à plusieurs endroits. Supprimer l'attribut va plutôt compliquer les choses (faire le calcul à deux endroits + le refaire plein de fois pour rien).

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants