Vixen
dd8b0a81
csharp
public interface ITerrainColliders

What rebuilds a terrain's collision when its ground moves.

Read the guide page for this →

Remarks

An interface for the reason IMeshBaker is one: this assembly does not reference Vixen.Physics, and should not. Nothing in the editor does — physics is a leaf of the graph, reached by the runtime and by the play session rather than by the tools — so the editor says which tiles moved and whatever holds a physics world turns that into shapes. The pieces on the other side already exist: TerrainSamples.FillCollisionSamples fills a tile's heights in metres with holes written as the caller's sentinel, and PhysicsShapes.HeightField takes exactly that.

✅ Implemented by Vixen.Editor.Terrain.Physics.TerrainColliders, over Vixen.Terrain.Physics.TerrainColliderSystem — one height-field shape per tile, over an ITerrainPlacements. It is a third assembly because it has to be: a runtime assembly may not reference Editor/, and this one may not link physics.

⚠ The remark here used to say an adapter was "three lines", and that was nearly true in the way that costs a day. TerrainColliderSystem's two Rebuild overloads return where these return , and means that system has never heard of that terrain — so a wrapper that forwarded and discarded would succeed, loudly, at rebuilding nothing.

⚠ Who sets TerrainEdit.Colliders was the other half, and it was the half nobody had counted. For a year this was assigned in five test files and nowhere else, so every assertion about a stroke naming the right tiles was one double talking to another. TerrainModule now takes an implementation from PluginServices when the host published one.

⚠ Per tile, and that is [§ D2]'s whole argument rather than an optimisation. A tile is one Jolt height-field shape; a stroke touches one or two of them out of sixteen, and rebuilding the terrain's collision because somebody smoothed a ridge is a pause an artist feels every time they let go of the mouse.

⚠ Null is a terrain with no collision, not an error. A scene being sculpted before anybody has pressed play has no physics world, and a mode that refused to work without one would be a mode that cannot be used until the game runs.

⚠ And what the shipped editor publishes is a switch rather than a rebuilder, because the two ends have different lifetimes. BindColliders below resolves the service once and keeps the answer; the physics world it would rebuild in exists only while a play session does. Vixen.Editor.Terrain.Physics' module publishes one long-lived implementation that forwards to whatever is simulating and counts the strokes that arrived when nothing was — which is the paragraph above, with a number attached.

Methods (2)

  • void Rebuild(Terrain terrain, int tileX, int tileZ)

    Rebuilds one tile's collision shape.

  • void Rebuild(Terrain terrain, TerrainRect rect)

    Rebuilds every tile a rectangle of samples touches.

Used by (6)

  • PlayCollidersVixen.Editor.Terrain.Physics
  • RecordingCollidersVixen.Editor.Terrain.Tests
  • TerrainCollidersVixen.Editor.Terrain.Physics
  • TerrainEditVixen.Editor.Terrain
  • TerrainModuleVixen.Editor.Terrain
  • TerrainPhysicsModuleVixen.Editor.Terrain.Physics