box重载overlaps

This commit is contained in:
yhh
2020-07-07 18:54:19 +08:00
parent ace8fb685d
commit b14fee1685
13 changed files with 127 additions and 34 deletions

View File

@@ -22,7 +22,9 @@ class Mover extends Component {
let bounds = collider.bounds;
bounds.x += motion.x;
bounds.y += motion.y;
let neighbors = Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers);
let boxcastResult = Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers);
bounds = boxcastResult.bounds;
let neighbors = boxcastResult.tempHashSet;
for (let j = 0; j < neighbors.length; j ++){
let neighbor = neighbors[j];
@@ -42,7 +44,7 @@ class Mover extends Component {
ListPool.free(colliders);
return collisionResult;
return {collisionResult: collisionResult, motion: motion};
}
public applyMovement(motion: Vector2){
@@ -53,7 +55,9 @@ class Mover extends Component {
}
public move(motion: Vector2){
let collisionResult = this.calculateMovement(motion);
let movementResult = this.calculateMovement(motion);
let collisionResult = movementResult.collisionResult;
motion = movementResult.motion;
this.applyMovement(motion);