class CSG::Node

Overview

Holds a node in a BSP tree. A BSP tree is built from a collection of polygons by picking a polygon to split along. That polygon (and all other coplanar polygons) are added directly to that node and the other polygons are added to the front and/or back subtrees. This is not a leafy BSP tree since there is no distinction between internal and leaf nodes.

Defined in:

primitives/node.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(polygons : Array(Polygon)) #

[View source]
def self.new #

[View source]

Instance Method Detail

def add_polygon(p : Polygon) #

[View source]
def all_polygons : Array(Polygon) #

Return a list of all polygons in this BSP tree.


[View source]
def back=(back : Nil | CSG::Node) #

[View source]
def build(polygons : Array(Polygon)) #

Build a BSP tree out of polygons. When called on an existing tree, the new polygons are filtered down to the bottom of the tree and become new nodes there. Each set of polygons is partitioned using the first polygon (no heuristic is used to pick a good split).


[View source]
def clip_polygons(polygons : Array(Polygon)) : Array(Polygon) #

Recursively remove all polygons in polygons that are inside this BSP tree.


[View source]
def clip_to(bsp : Node) #

Remove all polygons in this BSP tree that are inside the other BSP tree bsp


[View source]
def clone #

[View source]
def front=(front : Nil | CSG::Node) #

[View source]
def invert #

Convert solid space to empty space and empty space to solid space.


[View source]
def plane=(plane : Nil | CSG::Plane) #

[View source]