mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-16 13:34:06 +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.terrarum.gameactors.physicssolver
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.ActorWithSprite
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -20,9 +20,9 @@ object CollisionSolver {
|
||||
private val collListX = ArrayList<CollisionMarkings>(COLL_LIST_SIZE)
|
||||
private val collListY = ArrayList<CollisionMarkings>(COLL_LIST_SIZE)
|
||||
|
||||
private val collCandidateX = ArrayList<Pair<ActorWithBody, ActorWithBody>>(COLL_CANDIDATES_SIZE)
|
||||
private val collCandidateY = ArrayList<Pair<ActorWithBody, ActorWithBody>>(COLL_CANDIDATES_SIZE)
|
||||
private var collCandidates = ArrayList<Pair<ActorWithBody, ActorWithBody>>(COLL_FINAL_CANDIDATES_SIZE)
|
||||
private val collCandidateX = ArrayList<Pair<ActorWithSprite, ActorWithSprite>>(COLL_CANDIDATES_SIZE)
|
||||
private val collCandidateY = ArrayList<Pair<ActorWithSprite, ActorWithSprite>>(COLL_CANDIDATES_SIZE)
|
||||
private var collCandidates = ArrayList<Pair<ActorWithSprite, ActorWithSprite>>(COLL_FINAL_CANDIDATES_SIZE)
|
||||
|
||||
private val collCandidateStack = Stack<CollisionMarkings>()
|
||||
|
||||
@@ -40,7 +40,7 @@ object CollisionSolver {
|
||||
|
||||
// mark list x
|
||||
Terrarum.ingame.actorContainer.forEach { it ->
|
||||
if (it is ActorWithBody) {
|
||||
if (it is ActorWithSprite) {
|
||||
collListX.add(CollisionMarkings(it.hitbox.hitboxStart.x, STARTPOINT, it))
|
||||
collListX.add(CollisionMarkings(it.hitbox.hitboxEnd.x, ENDPOINT, it))
|
||||
}
|
||||
@@ -73,7 +73,7 @@ object CollisionSolver {
|
||||
|
||||
// mark list y
|
||||
Terrarum.ingame.actorContainer.forEach { it ->
|
||||
if (it is ActorWithBody) {
|
||||
if (it is ActorWithSprite) {
|
||||
collListY.add(CollisionMarkings(it.hitbox.hitboxStart.y, STARTPOINT, it))
|
||||
collListY.add(CollisionMarkings(it.hitbox.hitboxEnd.y, ENDPOINT, it))
|
||||
}
|
||||
@@ -89,7 +89,7 @@ object CollisionSolver {
|
||||
else if (it.kind == ENDPOINT) {
|
||||
val mark_this = it
|
||||
val mark_other = collCandidateStack.pop()
|
||||
val collCandidate: Pair<ActorWithBody, ActorWithBody>
|
||||
val collCandidate: Pair<ActorWithSprite, ActorWithSprite>
|
||||
// make sure actor with lower ID comes first
|
||||
if (mark_this.actor < mark_other.actor)
|
||||
collCandidate = Pair(mark_this.actor, mark_other.actor)
|
||||
@@ -137,7 +137,7 @@ object CollisionSolver {
|
||||
return indexOfEqFn(this, other) >= 0
|
||||
}
|
||||
|
||||
private fun solveCollision(a: ActorWithBody, b: ActorWithBody) {
|
||||
private fun solveCollision(a: ActorWithSprite, b: ActorWithSprite) {
|
||||
// some of the Pair(a, b) are either duplicates or erroneously reported.
|
||||
// e.g. (A, B), (B, C) and then (A, C);
|
||||
// in some situation (A, C) will not making any contact with each other
|
||||
@@ -170,11 +170,11 @@ object CollisionSolver {
|
||||
}
|
||||
}
|
||||
|
||||
private infix fun ActorWithBody.makesCollisionWith(other: ActorWithBody) =
|
||||
this.collisionType != ActorWithBody.COLLISION_NOCOLLIDE &&
|
||||
other.collisionType != ActorWithBody.COLLISION_NOCOLLIDE
|
||||
private infix fun ActorWithSprite.makesCollisionWith(other: ActorWithSprite) =
|
||||
this.collisionType != ActorWithSprite.COLLISION_NOCOLLIDE &&
|
||||
other.collisionType != ActorWithSprite.COLLISION_NOCOLLIDE
|
||||
|
||||
private infix fun ActorWithBody.isCollidingWith(other: ActorWithBody): Boolean {
|
||||
private infix fun ActorWithSprite.isCollidingWith(other: ActorWithSprite): Boolean {
|
||||
val ax = this.hitbox.centeredX
|
||||
val ay = this.hitbox.centeredY
|
||||
val bx = other.hitbox.centeredX
|
||||
@@ -205,7 +205,7 @@ object CollisionSolver {
|
||||
data class CollisionMarkings(
|
||||
val pos: Double,
|
||||
val kind: Int,
|
||||
val actor: ActorWithBody
|
||||
val actor: ActorWithSprite
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors.physicssolver
|
||||
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.ActorWithSprite
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-05-01.
|
||||
@@ -11,7 +11,7 @@ object VelocitySolver {
|
||||
|
||||
}
|
||||
|
||||
private fun applyGravity(actor: ActorWithBody) {
|
||||
private fun applyGravity(actor: ActorWithSprite) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user