Class TSectorList

Unit

Declaration

type TSectorList = class(specialize TObjectList<TSector>)

Description

Hierarchy

  • TObject
  • TList
  • TObjectList
  • TSectorList

Overview

Methods

Public procedure LinkToWaypoints(Waypoints: TWaypointList);
Public function SectorWithPoint(const Point: TVector3): TSector;
Public class function FindWay(SectorBegin, SectorEnd: TSector; Waypoints: TWaypointList): boolean;

Description

Methods

Public procedure LinkToWaypoints(Waypoints: TWaypointList);

Connect sectors and waypoints into a graph. Adds appropriate waypoints to sectors and sectors to waypoints, knowing which waypoint belongs (presumably, lies at the border of) to which sector. A waypoint belongs to the sector simply when TWaypoint.Box collides with one of the sector boxes.

Exceptions raised
ESectorNotInitialized
When some sector is nil.
EWaypointNotInitialized
When some waypoint is nil.
Public function SectorWithPoint(const Point: TVector3): TSector;

Returns sector with given point (using TSector.Contains of each sector). Returns nil if no such sector.

Public class function FindWay(SectorBegin, SectorEnd: TSector; Waypoints: TWaypointList): boolean;

This sets Waypoints contents to the list of waypoints that must be passed to travel from sector SectorBegin to SectorEnd.

Special cases: when either SectorBegin or SectorEnd are nil (this can easily happen if you pass here results of SectorWithPoint method), or when SectorBegin = SectorEnd, or when there is no possible way, it returns False and just clears Waypoints (i.e. sets Waypoints.Count to 0).

Otherwise (if a way is found) it returns True and sets Waypoints items as appropriate. The order of Waypoints is significant: starting from SectorBegin, you should first travel to Waypoints[0], then to Waypoints[1] etc. In this case for sure we have at least one Waypoint.

(So the result of this function is actually just a comfortable thing, you can get the same result just checking Waypoints.Count <> 0)

TODO: This should use breadth-first search. Right now it uses depth-first search. For small sectors+waypoints graphs it doesn't matter.


Generated by PasDoc 0.15.0.