Skip to content

Instantly share code, notes, and snippets.

@dustinlacewell
Created April 7, 2017 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinlacewell/d9a748b7bcc5e85094e84377da825a43 to your computer and use it in GitHub Desktop.
Save dustinlacewell/d9a748b7bcc5e85094e84377da825a43 to your computer and use it in GitHub Desktop.
proc split[T](self: BSPTree[T], target: Leaf, parent: ParentNode[T]): Leaf[T] =
var mp: int
parent.backward = target
if (parent of VSplit[T]):
var casted = (VSplit[T])parent
mp = midpoint(casted, target)
casted.adjustSource(target, mp)
casted.forward = casted.newSibling(target, mp)
else:
var casted = (HSplit[T])parent
mp = midpoint(casted, target)
casted.adjustSource(target, mp)
casted.forward = casted.newSibling(target, mp)
return (Leaf)parent.forward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment