mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
fix some CCD and trigger bugs
This commit is contained in:
parent
e87411794c
commit
c56d382c3a
5 changed files with 24 additions and 14 deletions
|
|
@ -999,10 +999,11 @@ class Marble extends GameObject {
|
|||
|
||||
// for (iter in 0...10) {
|
||||
// var iterationFound = false;
|
||||
for (obj in foundObjs.filter(x -> x.go is InteriorObject || (x.go is PathedInterior))) {
|
||||
for (obj in foundObjs) {
|
||||
// Its an MP so bruh
|
||||
if (!obj.go.isCollideable)
|
||||
continue;
|
||||
|
||||
var invMatrix = @:privateAccess obj.invTransform;
|
||||
if (obj.go is PathedInterior)
|
||||
invMatrix = obj.transform.getInverse();
|
||||
|
|
@ -1063,8 +1064,9 @@ class Marble extends GameObject {
|
|||
testTriangles.push({
|
||||
v: [v0, v, v2],
|
||||
n: surfaceNormal,
|
||||
edge: surf.edgeData[Math.floor(i / 3)],
|
||||
concavity: surface.edgeConcavities.slice(Math.floor(i / 3), Math.floor(i / 3) + 3)
|
||||
edge: surf.edgeData != null ? surf.edgeData[Math.floor(i / 3)] : 0,
|
||||
concavity: surface.edgeConcavities != null ? surface.edgeConcavities.slice(Math.floor(i / 3),
|
||||
Math.floor(i / 3) + 3) : [false, false, false],
|
||||
});
|
||||
|
||||
// Time until collision with the plane
|
||||
|
|
|
|||
|
|
@ -1606,10 +1606,12 @@ class MarbleWorld extends Scheduler {
|
|||
for (collider in endpadBB) {
|
||||
if (collider.go == this.endPad) {
|
||||
var chull = cast(collider, collision.CollisionHull);
|
||||
var chullinvT = @:privateAccess chull.invTransform.clone();
|
||||
chullinvT.clone();
|
||||
for (surface in chull.surfaces) {
|
||||
var i = 0;
|
||||
while (i < surface.indices.length) {
|
||||
var surfaceN = surface.normals[surface.indices[i]].transformed3x3(chull.transform);
|
||||
var surfaceN = surface.normals[surface.indices[i]].transformed3x3(chullinvT);
|
||||
var v1 = surface.points[surface.indices[i]].transformed(chull.transform);
|
||||
var surfaceD = -surfaceN.dot(v1);
|
||||
|
||||
|
|
|
|||
|
|
@ -257,9 +257,10 @@ class PathedInterior extends InteriorObject {
|
|||
var m2:PathedInteriorMarker = this.markerData[1];
|
||||
if (m1 == null) {
|
||||
// Incase there are no markers at all
|
||||
var mat = new Matrix();
|
||||
this.baseOrientation.toMatrix(mat);
|
||||
mat.scale(this.baseScale.x, this.baseScale.y, this.baseScale.z);
|
||||
var tmp = new Matrix();
|
||||
var mat = Matrix.S(this.baseScale.x, this.baseScale.y, this.baseScale.z);
|
||||
this.baseOrientation.toMatrix(tmp);
|
||||
mat.multiply3x4(mat, tmp);
|
||||
mat.setPosition(this.basePosition);
|
||||
return mat;
|
||||
}
|
||||
|
|
@ -310,10 +311,10 @@ class PathedInterior extends InteriorObject {
|
|||
position = position.sub(firstPosition);
|
||||
position = position.add(basePosition); // Add the base position
|
||||
|
||||
var mat = new Matrix();
|
||||
this.baseOrientation.toMatrix(mat);
|
||||
|
||||
mat.scale(this.baseScale.x, this.baseScale.y, this.baseScale.z);
|
||||
var tmp = new Matrix();
|
||||
var mat = Matrix.S(this.baseScale.x, this.baseScale.y, this.baseScale.z);
|
||||
this.baseOrientation.toMatrix(tmp);
|
||||
mat.multiply3x4(mat, tmp);
|
||||
mat.setPosition(position);
|
||||
|
||||
return mat;
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ class CollisionEntity implements IOctreeObject implements IBVHObject {
|
|||
|
||||
public function rayCast(rayOrigin:Vector, rayDirection:Vector):Array<RayIntersectionData> {
|
||||
var invMatrix = invTransform;
|
||||
var invTPos = invMatrix.clone();
|
||||
invTPos.transpose();
|
||||
var rStart = rayOrigin.clone();
|
||||
rStart.transform(invMatrix);
|
||||
var rDir = rayDirection.transformed3x3(invMatrix);
|
||||
|
|
@ -128,7 +130,7 @@ class CollisionEntity implements IOctreeObject implements IBVHObject {
|
|||
var iData:Array<RayIntersectionData> = [];
|
||||
for (i in intersections) {
|
||||
i.point.transform(transform);
|
||||
i.normal.transform3x3(transform);
|
||||
i.normal.transform3x3(invTPos);
|
||||
i.normal.normalize();
|
||||
iData.push({point: i.point, normal: i.normal, object: i.object});
|
||||
}
|
||||
|
|
@ -137,7 +139,7 @@ class CollisionEntity implements IOctreeObject implements IBVHObject {
|
|||
var intersections = this.bvh.rayCast(rStart, rDir);
|
||||
for (i in intersections) {
|
||||
i.point.transform(transform);
|
||||
i.normal.transform3x3(transform);
|
||||
i.normal.transform3x3(invTPos);
|
||||
i.normal.normalize();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,10 @@ class MustChangeTrigger extends Trigger {
|
|||
}
|
||||
|
||||
public override function onMarbleEnter(time:TimeState) {
|
||||
this.interior.setTargetTime(time, MisParser.parseNumber(this.element.targettime) / 1000);
|
||||
var ttime = MisParser.parseNumber(this.element.targettime);
|
||||
if (ttime > 0)
|
||||
ttime /= 1000;
|
||||
this.interior.setTargetTime(time, ttime);
|
||||
if (this.element.instant == "1") {
|
||||
if (this.element.icontinuetottime != null && this.element.icontinuetottime != "0") {
|
||||
// Absolutely strange, and not sure if it's even a thing in MBG, but is implement nonetheless.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue