Class BspNode
Represents a node in a BSP tree.
Inheritance
System.Object
BspNode
Namespace: InsaneScatterbrain.MapGraph
Syntax
public class BspNode : object
Constructors
BspNode()
Declaration
public BspNode()
BspNode(BspTree, BspNode, RectInt)
Creates a new BSP node.
Declaration
public BspNode(BspTree bspTree, BspNode parent, RectInt bounds)
Parameters
Type | Name | Description |
---|---|---|
BspTree | bspTree | The BSP tree. |
BspNode | parent | The node's parent. |
RectInt | bounds | The node's bounds. |
Properties
Bounds
Gets the bounds of this node.
Declaration
public RectInt Bounds { get; }
Property Value
Type | Description |
---|---|
RectInt |
LeftChild
Gets the left child.
Declaration
public BspNode LeftChild { get; }
Property Value
Type | Description |
---|---|
BspNode |
Parent
Gets the parent node.
Declaration
public BspNode Parent { get; }
Property Value
Type | Description |
---|---|
BspNode |
RightChild
Gets the right child.
Declaration
public BspNode RightChild { get; }
Property Value
Type | Description |
---|---|
BspNode |
Sibling
Gets this node's sibling.
Declaration
public BspNode Sibling { get; }
Property Value
Type | Description |
---|---|
BspNode |
Methods
GetLeafClosestToPoint(Vector2)
Gets the leaf closest to this node, based on the given point.
Declaration
public BspNode GetLeafClosestToPoint(Vector2 point)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | point | The point. |
Returns
Type | Description |
---|---|
BspNode | The closest leaf node. |
Reset()
Declaration
public void Reset()
Set(BspTree, BspNode, RectInt)
Declaration
public void Set(BspTree tree, BspNode parentNode, RectInt leafBounds)
Parameters
Type | Name | Description |
---|---|---|
BspTree | tree | |
BspNode | parentNode | |
RectInt | leafBounds |
Split(BspNode, BspNode, Single, Boolean)
Split the BSP node in two. Creating two new nodes.
Declaration
public void Split(BspNode leftChildNode, BspNode rightChildNode, float splitPoint = 0.5F, bool splitVertical = false)
Parameters
Type | Name | Description |
---|---|---|
BspNode | leftChildNode | The node to assign left child data to. |
BspNode | rightChildNode | The node to assign right child data to. |
System.Single | splitPoint | The split point between 0 and 1, where .5 is the center. |
System.Boolean | splitVertical | If true, the node is split vertically, else horizontally. |
Split(Single, Boolean)
Split the BSP node in two. Creating two new nodes.
Declaration
public void Split(float splitPoint = 0.5F, bool splitVertical = false)
Parameters
Type | Name | Description |
---|---|---|
System.Single | splitPoint | The split point between 0 and 1, where .5 is the center. |
System.Boolean | splitVertical | If true, the node is split vertically, else horizontally. |