mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
match collision callback code with mbg/u
This commit is contained in:
parent
c9d8aeda72
commit
84257d1903
2 changed files with 18 additions and 17 deletions
|
|
@ -1716,13 +1716,6 @@ class Marble extends GameObject {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.controllable && this.prevPos != null) {
|
||||
var tempTimeState = timeState.clone();
|
||||
tempState.currentAttemptTime = passedTime;
|
||||
tempState.dt = timeStep;
|
||||
this.level.callCollisionHandlers(cast this, tempTimeState, pos, newPos, rot, quat);
|
||||
}
|
||||
|
||||
if (contacts.length != 0)
|
||||
contactTime += timeStep;
|
||||
|
||||
|
|
@ -1750,6 +1743,13 @@ class Marble extends GameObject {
|
|||
this.queuedContacts = [];
|
||||
|
||||
newPos = this.collider.transform.getPosition();
|
||||
|
||||
if (this.controllable && this.prevPos != null) {
|
||||
var tempTimeState = timeState.clone();
|
||||
tempTimeState.currentAttemptTime = passedTime;
|
||||
this.level.callCollisionHandlers(cast this, tempTimeState, oldPos, newPos);
|
||||
}
|
||||
|
||||
this.updateRollSound(timeState, contactTime / timeState.dt, this._slipAmount);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1278,21 +1278,22 @@ class MarbleWorld extends Scheduler {
|
|||
this.gameMode.onGemPickup(gem);
|
||||
}
|
||||
|
||||
public function callCollisionHandlers(marble:Marble, timeState:TimeState, start:Vector, end:Vector, startQuat:Quat, endQuat:Quat) {
|
||||
public function callCollisionHandlers(marble:Marble, timeState:TimeState, start:Vector, end:Vector) {
|
||||
var expansion = marble._radius + 0.2;
|
||||
var minP = new Vector(Math.min(start.x, end.x) - expansion, Math.min(start.y, end.y) - expansion, Math.min(start.z, end.z) - expansion);
|
||||
var maxP = new Vector(Math.max(start.x, end.x) + expansion, Math.max(start.y, end.y) + expansion, Math.max(start.z, end.z) + expansion);
|
||||
var box = Bounds.fromPoints(minP.toPoint(), maxP.toPoint());
|
||||
|
||||
var marbleHitbox = new Bounds();
|
||||
marbleHitbox.addSpherePos(0, 0, 0, marble._radius);
|
||||
marbleHitbox.transform(startQuat.toMatrix());
|
||||
marbleHitbox.transform(endQuat.toMatrix());
|
||||
marbleHitbox.offset(end.x, end.y, end.z);
|
||||
// var marbleHitbox = new Bounds();
|
||||
// marbleHitbox.addSpherePos(0, 0, 0, marble._radius);
|
||||
// marbleHitbox.transform(startQuat.toMatrix());
|
||||
// marbleHitbox.transform(endQuat.toMatrix());
|
||||
// marbleHitbox.offset(end.x, end.y, end.z);
|
||||
|
||||
// spherebounds.addSpherePos(gjkCapsule.p2.x, gjkCapsule.p2.y, gjkCapsule.p2.z, gjkCapsule.radius);
|
||||
// var contacts = this.collisionWorld.radiusSearch(marble.getAbsPos().getPosition(), marble._radius);
|
||||
var contacts = marble.contactEntities;
|
||||
// var contacts = marble.contactEntities;
|
||||
var contacts = this.collisionWorld.boundingSearch(box);
|
||||
var inside = [];
|
||||
|
||||
for (contact in contacts) {
|
||||
|
|
@ -1300,7 +1301,7 @@ class MarbleWorld extends Scheduler {
|
|||
if (contact.go is DtsObject) {
|
||||
var shape:DtsObject = cast contact.go;
|
||||
|
||||
if (contact.boundingBox.collide(marbleHitbox)) {
|
||||
if (contact.boundingBox.collide(box)) {
|
||||
shape.onMarbleInside(timeState);
|
||||
if (!this.shapeOrTriggerInside.contains(contact.go)) {
|
||||
this.shapeOrTriggerInside.push(contact.go);
|
||||
|
|
@ -1313,7 +1314,7 @@ class MarbleWorld extends Scheduler {
|
|||
var trigger:Trigger = cast contact.go;
|
||||
var triggeraabb = trigger.collider.boundingBox;
|
||||
|
||||
if (triggeraabb.collide(marbleHitbox)) {
|
||||
if (triggeraabb.collide(box)) {
|
||||
trigger.onMarbleInside(timeState);
|
||||
if (!this.shapeOrTriggerInside.contains(contact.go)) {
|
||||
this.shapeOrTriggerInside.push(contact.go);
|
||||
|
|
@ -1333,7 +1334,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
if (this.finishTime == null && this.endPad != null) {
|
||||
if (marbleHitbox.collide(this.endPad.finishBounds)) {
|
||||
if (box.collide(this.endPad.finishBounds)) {
|
||||
var padUp = this.endPad.getAbsPos().up();
|
||||
padUp = padUp.multiply(10);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue