Vixen
feb85697
csharp
public sealed class TerrainPhysicsModule

Gives the editor's play sessions terrain collision, and the sculpt tools a seam to push into.

Read the guide page for this →

Remarks

The reach half of docs/plan/31 § D10. TerrainColliders and TerrainColliderSystem were both written and both tested, and nothing in the product constructed either: TerrainEdit.Colliders 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. This is the module that closes it — registered in EditorModules.Standard beside Terrain, through the same door a third-party plugin comes through.

⚠ Two contributions with two different lifetimes, and confusing them is the trap. The ITerrainColliders contributed to the registry lives as long as this module, and TerrainModule.BindColliders follows it — so a per-session adapter would be rebound every Play and Stop for no reason. The TerrainColliderSystem behind it lives for one play session, because that is when there is a PhysicsScene to build bodies in. The published object is a switch between the two.

⚠ It builds no simulation of its own and refuses to. The PhysicsScene comes from PlaySession.TryGet — the editor application provides one — and a session that has none runs no collider system at all, which is ITerrainColliders' own "a terrain with no collision, not an error". A module that stood up a second physics world would be a scene in which the ground and everything else collided with nothing, silently.

⚠ And it does not catch what Rebuild throws. An out-of-range tile index is a caller's bug that used to corrupt a *different* tile in silence — see that method's own remarks — and a module that swallowed the exception here would put the silence back with an extra step in front of it.

Fields and properties (2)

  • public const string ModuleId

    What the host activates it under, and what a plugin depending on it names.

  • public const string ModuleName

    What a plugin-management panel calls it.

Methods (2)

  • public void Activate(PluginContext context)

    Adds everything the plugin contributes.

  • public void Deactivate()

    Releases what the registration scope does not know about.

Used by (2)

  • EditorModulesVixen.Editor.Host
  • TerrainModuleReachTestsVixen.Editor.App.Tests