Polyobject

From DoomWiki.org

Revision as of 19:28, 26 May 2009 by Quasar (talk | contribs) (Edit to fix up link in section title.)


A polyobject is a movable convex group of one-sided linedefs. This extension of the Doom engine was originally implemented in Hexen by programmer Ben Gokey of Raven Software.

Theory

Although binary space partitioning results in a static BSP tree which is not amenable to dynamic geometry, it is possible to exploit the complete convex mapping of space provided by the tree to insert dynamic objects, so long as they obey certain restrictions:[1]

  • The dynamic objects must not intersect with any static geometry.
  • The dynamic objects must not intersect with one another.
  • The dynamic objects must themselves be convex, and must either be contained entirely within a single subsector or be split into fragments which are themselves contained within single subsectors.

So long as the dynamic geometry in each subsector follows these rules, it can be drawn first, before the normal contents of the subsector, and the other assumptions implicit within the BSP rendering algorithm will be maintained.

Original implementation

As mentioned above, polyobjects were originally an innovation in the Hexen codebase. In Hexen, polyobjects are chiefly used to create sliding and rotating doors, pushable walls, and dangerous horizontal crushers. Since polyobjects are also linked into the blockmap like normal linedefs, it is possible for them to clip the movement of things, as well as push things that block them and optionally inflict crushing damage while doing this.

Common setup of sliding door polyobjects.
Screenshot of above setup in-game.

The Hexen line specials which allow the creation and manipulation of polyobjects are known by the following ACS names:

  • Polyobj_DoorSlide
  • Polyobj_RotateLeft
  • Polyobj_OR_RotateLeft
  • Polyobj_RotateRight
  • Polyobj_OR_RotateRight
  • Polyobj_DoorSwing
  • Polyobj_Move
  • Polyobj_OR_Move
  • Polyobj_MoveTimes8
  • Polyobj_OR_MoveTimes8
  • Polyobj_StartLine
  • Polyobj_ExplicitLine

The latter two line specials are used to identify the lines that belong to the polyobject. Due to limitations of the Hexen map format, there cannot be more than 256 polyobjects in a single map. In addition, Hexen imposes an artificial limit of 64 segs per polyobject. Hexen can only reliably support one polyobject per subsector, and cannot deal properly with polyobjects that overlap into adjacent subsectors or that are made to move too far from their spawnpoint.

Hexen polyobjects additionally require two mapthings to identify the position at which they were built on the map, and how that point relates to the position at which they should be placed at runtime. These thing types are the "anchor point," with DoomEd number 3000, which must be placed near the linedefs that are part of the object, and the "spawn points," with DoomEd numbers 3001 or 3002, which are used as the runtime spawning location of the polyobject. The polyobject is translated to this location by moving the anchor point to the spawn point, and moving all linedefs so that their relationship to the anchor point remains constant. Use of the 3002 spawnpoint type denotes that the polyobject should do crushing damage to objects which block its motion.

Via use of line arguments, it is also possible to cause polyobjects to mirror the motion of other objects. When a move or rotate special is applied to an object, it will cause any objects mirroring it to move or rotate in the opposite direction.

Source port implementations

The ZDoom source port also implements polyobjects, but prefers the use of thing types 9000, 9001, and 9002 to those used by Hexen (the numbers used by Hexen conflict with Doom, 3001 for example being the Imp). The ZDoom implementation of polyobjects is nearly functionally identical to that in Hexen, including the inherent limitations on location and motion. Glitches in rendering that can be caused when polyobjects cross node lines (and thus overlap with static geometry or into adjacent subsectors) can be partially but not entirely abated by use of a so-called "polyobject-aware" node builder, which includes the popular zdbsp.

The Eternity Engine completed implementation of a dynamic seg rendering system which splits polyobjects through the BSP to generate subsector-contained fragments, in a system similar to how some true 3D engines deal with models and complex moving objects. This not only completely eliminates the need for a polyobject-aware node builder, but also allows any number of polyobjects per subsector and arbitrary motion of polyobjects between subsectors with reasonably similar properties. Eternity is currently capable of allowing use of polyobjects inside Doom-format maps via the use of ExtraData, and will also support them in the Hexen and UDMF map formats when support for those formats has been finalized.

References

  1. Binary Space Partitioning Trees FAQ