Created
April 8, 2017 04:58
-
-
Save dustinlacewell/d2142bac3a0ede5172ba4aa031f167f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main.nim(8, 3) Error: cannot instantiate 'resize' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
BSPNode[T] = ref object of RootObj | |
parent: BSPNode[T] | |
region: Region[float] | |
ParentNode[T] = ref object of BSPNode[T] | |
forward, backward: BSPNode[T] | |
ratio: float | |
Leaf[T]= ref object of BSPNode[T] | |
content: T | |
HSplit[T] = ref object of ParentNode[T] | |
VSplit[T] = ref object of ParentNode[T] | |
BSPTree[T] = ref object | |
root: BSPNode[T] | |
leaves: seq[Leaf[T]] | |
method resize[T](self: BSPNode[T], region: Region[float]) = | |
self.region = region | |
method resize[T](self: VSplit[T], region: Region[float]) = | |
self.region = region | |
let | |
mp = self.midpoint | |
bw = self.backward | |
fw = self.forward | |
bw.resize(Region[T]( | |
left:self.left, | |
top:self.top, | |
right:mp, | |
bottom:self.bottom)) | |
fw.resize(Region[T]( | |
left:mp, | |
top:self.top, | |
right:self.right, | |
bottom:self.bottom)) | |
proc resize[T](self: HSplit[T], region: Region[float]) = | |
self.region = region | |
let | |
mp = self.midpoint | |
bw = self.backward | |
fw = self.forward | |
bw.resize(Region[T]( | |
left:self.left, | |
top:self.top, | |
right:self.right, | |
bottom:mp)) | |
fw.resize(Region[T]( | |
left:self.left, | |
top:mp, | |
right:self.right, | |
bottom:self.bottom)) | |
method adjust[T](self: ParentNode[T], ratio: float) = | |
self.ratio = ratio | |
resize(self, self.region) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment