mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-16 00:26:07 +09:00
actorwithbody splitted in favour of new particle type
Former-commit-id: 121bd069d0a9eeef60f5ecb085a11a93c4b4a84d Former-commit-id: 539b4b6916e808c01298190cf347e928f61fe62e
This commit is contained in:
@@ -2,7 +2,7 @@ package net.torvald.aa
|
||||
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.ActorWithSprite
|
||||
import net.torvald.terrarum.gameactors.sqr
|
||||
import java.util.*
|
||||
|
||||
@@ -23,7 +23,7 @@ class KDHeapifiedTree() {
|
||||
|
||||
private val dimension = 2
|
||||
private val initialSize = 128
|
||||
private val nodes = Array<ActorWithBody?>(initialSize, { null })
|
||||
private val nodes = Array<ActorWithSprite?>(initialSize, { null })
|
||||
|
||||
private val root: Int = 0
|
||||
|
||||
@@ -34,13 +34,13 @@ class KDHeapifiedTree() {
|
||||
private fun Int.getActor() = nodes[this]
|
||||
private fun Int.getLeft() = this * 2 + 1
|
||||
private fun Int.getRight() = this * 2 + 2
|
||||
private fun Int.set(value: ActorWithBody?) { nodes[this] = value }
|
||||
private fun Int.setLeftChild(value: ActorWithBody?) { nodes[this.getLeft()] = value }
|
||||
private fun Int.setRightChild(value: ActorWithBody?) { nodes[this.getRight()] = value }
|
||||
private fun Int.set(value: ActorWithSprite?) { nodes[this] = value }
|
||||
private fun Int.setLeftChild(value: ActorWithSprite?) { nodes[this.getLeft()] = value }
|
||||
private fun Int.setRightChild(value: ActorWithSprite?) { nodes[this.getRight()] = value }
|
||||
|
||||
private val zeroPoint = Point2d(0.0, 0.0)
|
||||
|
||||
private fun create(points: List<ActorWithBody?>, depth: Int, index: Int): ActorWithBody? {
|
||||
private fun create(points: List<ActorWithSprite?>, depth: Int, index: Int): ActorWithSprite? {
|
||||
if (points.isEmpty()) {
|
||||
index.set(null)
|
||||
|
||||
@@ -91,7 +91,7 @@ class KDHeapifiedTree() {
|
||||
|
||||
private fun expandArray() {
|
||||
val prevNodes = nodes.copyOf()
|
||||
Array<ActorWithBody?>(prevNodes.size * 2, { null })
|
||||
Array<ActorWithSprite?>(prevNodes.size * 2, { null })
|
||||
create(prevNodes.toList(), 0, 0)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user