mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
attempt fix internal edge collisions
This commit is contained in:
parent
ef392a17b1
commit
cfd40df7b6
2 changed files with 19 additions and 18 deletions
|
|
@ -1046,21 +1046,19 @@ class Marble extends GameObject {
|
|||
|
||||
var isOnEdge:Bool = false;
|
||||
|
||||
for (i in 0...surface.indices.length) {
|
||||
{
|
||||
var thisVert = surface.points[surface.indices[i]];
|
||||
if (thisVert != lastVert) {
|
||||
var edgePlane = PlaneF.ThreePoints(toDifPoint(thisVert).add(polyPlane.getNormal()), toDifPoint(thisVert),
|
||||
toDifPoint(lastVert));
|
||||
lastVert = thisVert;
|
||||
for (j in 0...surface.indices.length) {
|
||||
var thisVert = surface.points[surface.indices[j]];
|
||||
if (thisVert != lastVert) {
|
||||
var edgePlane = PlaneF.ThreePoints(toDifPoint(thisVert).add(polyPlane.getNormal()), toDifPoint(thisVert),
|
||||
toDifPoint(lastVert));
|
||||
lastVert = thisVert;
|
||||
|
||||
// if we are on the far side of the edge
|
||||
if (edgePlane.getNormal().dot(toDifPoint(collisionPos)) + edgePlane.d < 0.0)
|
||||
break;
|
||||
}
|
||||
// if we are on the far side of the edge
|
||||
if (edgePlane.getNormal().dot(toDifPoint(collisionPos)) + edgePlane.d < 0.0)
|
||||
break;
|
||||
}
|
||||
|
||||
isOnEdge = i != surface.indices.length;
|
||||
isOnEdge = j != surface.indices.length;
|
||||
}
|
||||
|
||||
// If we're inside the poly, just get the position
|
||||
|
|
@ -1084,7 +1082,7 @@ class Marble extends GameObject {
|
|||
}
|
||||
var radSq = radius * radius;
|
||||
for (iter in 0...surface.indices.length) {
|
||||
var thisVert = surface.points[surface.indices[i]];
|
||||
var thisVert = surface.points[surface.indices[iter]];
|
||||
|
||||
var vertDiff = lastVert.sub(thisVert);
|
||||
var posDiff = position.sub(thisVert);
|
||||
|
|
|
|||
|
|
@ -131,11 +131,14 @@ class Collision {
|
|||
// } else
|
||||
var edgeDotAng = Math.acos(edgeDots[chosenEdge]);
|
||||
if (edgeDotAng < Math.PI / 12) {
|
||||
if (edgeDotAng == 0) {
|
||||
res.normal = center.sub(res.point).normalized();
|
||||
} else {
|
||||
res.normal = normal; // edgeNormals[chosenEdge];
|
||||
}
|
||||
// if (edgeDotAng == 0) {
|
||||
// res.normal = center.sub(res.point).normalized();
|
||||
// } else {
|
||||
// res.normal = normal; // edgeNormals[chosenEdge];
|
||||
// }
|
||||
res.point = null;
|
||||
res.normal = null;
|
||||
res.result = false;
|
||||
} else {
|
||||
res.result = false;
|
||||
res.normal = center.sub(res.point).normalized();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue