diff --git a/src/Marble.hx b/src/Marble.hx index 274e1dec..3a93db2a 100644 --- a/src/Marble.hx +++ b/src/Marble.hx @@ -1534,6 +1534,7 @@ class Marble extends GameObject { this.setRotationQuat(quat); var totMatrix = quat.toMatrix(); + newPos.w = 1; // Fix shit blowing up totMatrix.setPosition(newPos); this.setPosition(newPos.x, newPos.y, newPos.z); diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index c45d57be..9dfd3edf 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -1723,7 +1723,10 @@ class MarbleWorld extends Scheduler { playGui.setCenterText('outofbounds'); AudioManager.playSound(ResourceLoader.getResource('data/sound/whoosh.wav', ResourceLoader.getAudio, this.soundResources)); // if (this.replay.mode != = 'playback') - this.schedule(this.timeState.currentAttemptTime + 2, () -> playGui.setCenterText('none')); + this.schedule(this.timeState.currentAttemptTime + 2, () -> { + playGui.setCenterText('none'); + return null; + }); this.schedule(this.timeState.currentAttemptTime + 2.5, () -> this.restart()); } diff --git a/src/collision/CollisionEntity.hx b/src/collision/CollisionEntity.hx index ce453624..f2739cff 100644 --- a/src/collision/CollisionEntity.hx +++ b/src/collision/CollisionEntity.hx @@ -143,8 +143,8 @@ class CollisionEntity implements IOctreeObject { var sphereBounds = new Bounds(); var localPos = position.clone(); localPos.transform(invMatrix); - sphereBounds.addSpherePos(position.x, position.y, position.z, radius * 1.1); - sphereBounds.transform(invMatrix); + // sphereBounds.addSpherePos(position.x, position.y, position.z, radius * 1.1); + // sphereBounds.transform(invMatrix); sphereBounds.addSpherePos(localPos.x, localPos.y, localPos.z, radius * 1.1); var surfaces = bvh == null ? octree.boundingSearch(sphereBounds).map(x -> cast x) : bvh.boundingSearch(sphereBounds); diff --git a/src/collision/Grid.hx b/src/collision/Grid.hx index 1f11987f..cd713ec8 100644 --- a/src/collision/Grid.hx +++ b/src/collision/Grid.hx @@ -73,13 +73,12 @@ class Grid { var hash = hashVector(i, j, k); if (this.map.exists(hash)) { var surfs = this.map.get(hash); - var actualsurfs = surfs.map(x -> this.surfaces[x]); - for (surf in actualsurfs) { - if (surf.key) + for (surf in surfs) { + if (surfaces[surf].key) continue; - if (searchbox.containsBounds(surf.boundingBox) || searchbox.collide(surf.boundingBox)) { - foundSurfaces.push(surf); - surf.key = true; + if (searchbox.containsBounds(surfaces[surf].boundingBox) || searchbox.collide(surfaces[surf].boundingBox)) { + foundSurfaces.push(surfaces[surf]); + surfaces[surf].key = true; } } } diff --git a/src/collision/gjk/Cylinder.hx b/src/collision/gjk/Cylinder.hx index e4a18111..2d70381f 100644 --- a/src/collision/gjk/Cylinder.hx +++ b/src/collision/gjk/Cylinder.hx @@ -17,7 +17,7 @@ class Cylinder implements GJKShape { public function support(dir:Vector) { var axis = p2.sub(p1); var v = axis.dot(dir) > 0 ? p2 : p1; - var rejection = dir.sub(axis.multiply(dir.dot(axis) / (axis.dot(axis) * dir.dot(dir)))).normalized().multiply(radius); + var rejection = dir.sub(axis.multiply(dir.dot(axis) / (axis.dot(axis)))).normalized().multiply(radius); return v.add(rejection); } } diff --git a/src/shapes/EndPad.hx b/src/shapes/EndPad.hx index 12cd1732..45541342 100644 --- a/src/shapes/EndPad.hx +++ b/src/shapes/EndPad.hx @@ -27,7 +27,7 @@ import h3d.mat.Texture; class EndPad extends DtsObject { var fireworks:Array = []; - var finishCollider:Cylinder; + var finishCollider:ConvexHull; var finishBounds:Bounds; var inFinish:Bool = false; @@ -74,12 +74,19 @@ class EndPad extends DtsObject { vertices.push(new Vector(x * radius * this.scaleX, (i != 0 ? 4.8 : 0) * 1, z * radius * this.scaleY)); } } - finishCollider = new Cylinder(); - finishCollider.p1 = this.getAbsPos().getPosition(); - finishCollider.p2 = finishCollider.p1.clone(); - var vertDir = this.getAbsPos().up(); - finishCollider.p2 = finishCollider.p2.add(vertDir.multiply(height)); - finishCollider.radius = radius * this.scaleY; + // var m = new h3d.prim.Cylinder(64, radius, height); + // m.addNormals(); + // m.addUVs(); + // var cmesh = new h3d.scene.Mesh(m); + // cmesh.setTransform(this.getAbsPos()); + // MarbleGame.instance.scene.addChild(cmesh); + finishCollider = new ConvexHull(vertices); + // finishCollider = new Cylinder(); + // finishCollider.p1 = this.getAbsPos().getPosition(); + // finishCollider.p2 = finishCollider.p1.clone(); + // var vertDir = this.getAbsPos().up(); + // finishCollider.p2 = finishCollider.p2.add(vertDir.multiply(height)); + // finishCollider.radius = radius; finishBounds = new Bounds(); for (vert in vertices) @@ -92,7 +99,7 @@ class EndPad extends DtsObject { var tform = this.getAbsPos().clone(); tform.prependRotation(Math.PI / 2, 0, 0); - // finishCollider.transform = tform; + finishCollider.transform = tform; finishBounds.transform(tform);