mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-05-04 16:41:43 +00:00
fixed broken collisions
This commit is contained in:
parent
c817886672
commit
8919809912
2 changed files with 7 additions and 7 deletions
BIN
marblegame.hl
BIN
marblegame.hl
Binary file not shown.
|
|
@ -29,9 +29,9 @@ class CollisionSurface implements IOctreeObject {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
normals = [for (n in points) null];
|
normals = [for (n in points) null];
|
||||||
while (i < indices.length) {
|
while (i < indices.length) {
|
||||||
var p1 = points[indices[i]];
|
var p1 = points[indices[i]].clone();
|
||||||
var p2 = points[indices[i + 1]];
|
var p2 = points[indices[i + 1]].clone();
|
||||||
var p3 = points[indices[i + 2]];
|
var p3 = points[indices[i + 2]].clone();
|
||||||
var n = p2.sub(p1).cross(p3.sub(p1)).normalized().multiply(-1);
|
var n = p2.sub(p1).cross(p3.sub(p1)).normalized().multiply(-1);
|
||||||
normals[indices[i]] = n;
|
normals[indices[i]] = n;
|
||||||
normals[indices[i + 1]] = n;
|
normals[indices[i + 1]] = n;
|
||||||
|
|
@ -80,10 +80,10 @@ class CollisionSurface implements IOctreeObject {
|
||||||
var intersections = [];
|
var intersections = [];
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (i < indices.length) {
|
while (i < indices.length) {
|
||||||
var p1 = points[indices[i]];
|
var p1 = points[indices[i]].clone();
|
||||||
var p2 = points[indices[i + 1]];
|
var p2 = points[indices[i + 1]].clone();
|
||||||
var p3 = points[indices[i + 2]];
|
var p3 = points[indices[i + 2]].clone();
|
||||||
var n = normals[indices[i]];
|
var n = normals[indices[i]].clone();
|
||||||
var d = -p1.dot(n);
|
var d = -p1.dot(n);
|
||||||
|
|
||||||
var t = -(rayOrigin.dot(n) + d) / (rayDirection.dot(n));
|
var t = -(rayOrigin.dot(n) + d) / (rayDirection.dot(n));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue