Skip to content

Conversation

@rpgshooter
Copy link
Contributor

Fixes #891
Adds update_region() method to update collision for a single region instead of rebuilding all regions.

Currently, runtime terrain modification (craters, explosions, deformation) requires calling update() which rebuilds collision for every region. This is expensive for large terrains.

New method Terrain3DCollision::update_region(region_loc: Vector2i) updates only the specified region's collision shape.

Usage

# After modifying terrain heights
terrain.collision.update_region(region_loc)
  • Only applicable in Full mode (FULL_GAME/FULL_EDITOR)

void build();
void reset_target_position() { _last_snapped_pos = V2I_MAX; }
void update(const bool p_rebuild = false);
void update_region(const Vector2i &p_region_loc);
Copy link
Owner

Choose a reason for hiding this comment

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

Like our other update functions, this location selection should be incorporated into update().
https://github.com/TokisanGames/Terrain3D/blob/main/src/terrain_3d_instancer.h#L97
https://github.com/TokisanGames/Terrain3D/blob/main/src/terrain_3d_data.h#L134

Then it should be able to reuse code in the same function.

It should have a location parameter that defaults to V2I_MAX to indicate all regions.

Copy link
Contributor Author

@rpgshooter rpgshooter Dec 16, 2025

Choose a reason for hiding this comment

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

Your right, similar to the update_maps overload for the visual terrain, I should do an implementation/integration for the update function that already exist. When I get the chance Ill restructure it

@TokisanGames TokisanGames added this to the 1.2 milestone Dec 19, 2025
@NaiJii
Copy link

NaiJii commented Feb 13, 2026

This would be super useful! Hard agree

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.

Update collision by region

3 participants