mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-01-02 05:12:21 +00:00
match mbg collision callback code and add deadzone to touch camera
This commit is contained in:
parent
914418cfa7
commit
180a29de75
2 changed files with 21 additions and 18 deletions
|
|
@ -1553,6 +1553,8 @@ class Marble extends GameObject {
|
|||
|
||||
var passedTime = timeState.currentAttemptTime;
|
||||
|
||||
var oldPos = this.getAbsPos().getPosition().clone();
|
||||
|
||||
if (this.controllable) {
|
||||
for (interior in pathedInteriors) {
|
||||
// interior.pushTickState();
|
||||
|
|
@ -1712,13 +1714,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;
|
||||
|
||||
|
|
@ -1745,6 +1740,14 @@ class Marble extends GameObject {
|
|||
}
|
||||
this.queuedContacts = [];
|
||||
|
||||
var newPos = this.getAbsPos().getPosition().clone();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1395,21 +1395,21 @@ class MarbleWorld extends Scheduler {
|
|||
this.playGui.formatGemCounter(this.gemCount, this.totalGems);
|
||||
}
|
||||
|
||||
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 = this.collisionWorld.boundingSearch(box);
|
||||
// var contacts = marble.contactEntities;
|
||||
var inside = [];
|
||||
|
||||
for (contact in contacts) {
|
||||
|
|
@ -1417,7 +1417,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);
|
||||
|
|
@ -1430,7 +1430,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);
|
||||
|
|
@ -1450,7 +1450,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
if (this.finishTime == 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