mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-26 12:41:40 +00:00
match mbg collision callback code and add deadzone to touch camera
This commit is contained in:
parent
f9279359b4
commit
6aaedfded6
3 changed files with 25 additions and 18 deletions
|
|
@ -1334,6 +1334,8 @@ class Marble extends GameObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldPos = this.getAbsPos().getPosition().clone();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (timeRemaining <= 0)
|
if (timeRemaining <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
@ -1483,13 +1485,6 @@ class Marble extends GameObject {
|
||||||
this.heldPowerup = null;
|
this.heldPowerup = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
if (contacts.length != 0)
|
||||||
contactTime += timeStep;
|
contactTime += timeStep;
|
||||||
|
|
||||||
|
|
@ -1516,6 +1511,14 @@ class Marble extends GameObject {
|
||||||
}
|
}
|
||||||
this.queuedContacts = [];
|
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(contactTime / timeState.dt, this._slipAmount);
|
this.updateRollSound(contactTime / timeState.dt, this._slipAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1198,21 +1198,21 @@ class MarbleWorld extends Scheduler {
|
||||||
this.playGui.formatGemCounter(this.gemCount, this.totalGems);
|
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 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 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 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 box = Bounds.fromPoints(minP.toPoint(), maxP.toPoint());
|
||||||
|
|
||||||
var marbleHitbox = new Bounds();
|
// var marbleHitbox = new Bounds();
|
||||||
marbleHitbox.addSpherePos(0, 0, 0, marble._radius);
|
// marbleHitbox.addSpherePos(0, 0, 0, marble._radius);
|
||||||
marbleHitbox.transform(startQuat.toMatrix());
|
// marbleHitbox.transform(startQuat.toMatrix());
|
||||||
marbleHitbox.transform(endQuat.toMatrix());
|
// marbleHitbox.transform(endQuat.toMatrix());
|
||||||
marbleHitbox.offset(end.x, end.y, end.z);
|
// marbleHitbox.offset(end.x, end.y, end.z);
|
||||||
|
|
||||||
// spherebounds.addSpherePos(gjkCapsule.p2.x, gjkCapsule.p2.y, gjkCapsule.p2.z, gjkCapsule.radius);
|
// 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 = this.collisionWorld.boundingSearch(box);
|
||||||
var contacts = marble.contactEntities;
|
// var contacts = marble.contactEntities;
|
||||||
var inside = [];
|
var inside = [];
|
||||||
|
|
||||||
for (contact in contacts) {
|
for (contact in contacts) {
|
||||||
|
|
@ -1220,7 +1220,7 @@ class MarbleWorld extends Scheduler {
|
||||||
if (contact.go is DtsObject) {
|
if (contact.go is DtsObject) {
|
||||||
var shape:DtsObject = cast contact.go;
|
var shape:DtsObject = cast contact.go;
|
||||||
|
|
||||||
if (contact.boundingBox.collide(marbleHitbox)) {
|
if (contact.boundingBox.collide(box)) {
|
||||||
shape.onMarbleInside(timeState);
|
shape.onMarbleInside(timeState);
|
||||||
if (!this.shapeOrTriggerInside.contains(contact.go)) {
|
if (!this.shapeOrTriggerInside.contains(contact.go)) {
|
||||||
this.shapeOrTriggerInside.push(contact.go);
|
this.shapeOrTriggerInside.push(contact.go);
|
||||||
|
|
@ -1233,7 +1233,7 @@ class MarbleWorld extends Scheduler {
|
||||||
var trigger:Trigger = cast contact.go;
|
var trigger:Trigger = cast contact.go;
|
||||||
var triggeraabb = trigger.collider.boundingBox;
|
var triggeraabb = trigger.collider.boundingBox;
|
||||||
|
|
||||||
if (triggeraabb.collide(marbleHitbox)) {
|
if (triggeraabb.collide(box)) {
|
||||||
trigger.onMarbleInside(timeState);
|
trigger.onMarbleInside(timeState);
|
||||||
if (!this.shapeOrTriggerInside.contains(contact.go)) {
|
if (!this.shapeOrTriggerInside.contains(contact.go)) {
|
||||||
this.shapeOrTriggerInside.push(contact.go);
|
this.shapeOrTriggerInside.push(contact.go);
|
||||||
|
|
@ -1253,7 +1253,7 @@ class MarbleWorld extends Scheduler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.finishTime == null) {
|
if (this.finishTime == null) {
|
||||||
if (marbleHitbox.collide(this.endPad.finishBounds)) {
|
if (box.collide(this.endPad.finishBounds)) {
|
||||||
var padUp = this.endPad.getAbsPos().up();
|
var padUp = this.endPad.getAbsPos().up();
|
||||||
padUp = padUp.multiply(10);
|
padUp = padUp.multiply(10);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,10 @@ class CameraInput {
|
||||||
if (jumpcam) {
|
if (jumpcam) {
|
||||||
scaleFactor /= Settings.touchSettings.buttonJoystickMultiplier;
|
scaleFactor /= Settings.touchSettings.buttonJoystickMultiplier;
|
||||||
}
|
}
|
||||||
|
if (Math.abs(delta.x) < 0.03)
|
||||||
|
delta.x = 0;
|
||||||
|
if (Math.abs(delta.y) < 0.03)
|
||||||
|
delta.y = 0;
|
||||||
MarbleGame.instance.world.marble.camera.orbit(applyNonlinearScale(delta.x / scaleFactor), applyNonlinearScale(delta.y / scaleFactor), true);
|
MarbleGame.instance.world.marble.camera.orbit(applyNonlinearScale(delta.x / scaleFactor), applyNonlinearScale(delta.y / scaleFactor), true);
|
||||||
prevMouse.x = e.relX;
|
prevMouse.x = e.relX;
|
||||||
prevMouse.y = e.relY;
|
prevMouse.y = e.relY;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue