Commit 733400c8 authored by Anthony Kleine's avatar Anthony Kleine

Collision should be working now but for some reason it still isn't.

parent c31a1762
Pipeline #1926308 skipped
......@@ -24,6 +24,7 @@ import com.matt.difinspector.structures.PlaneF;
import com.matt.difinspector.structures.Point2F;
import com.matt.difinspector.structures.Point3F;
import com.matt.difinspector.structures.Portal;
import com.matt.difinspector.structures.SphereF;
import com.matt.difinspector.structures.Surface;
import com.matt.difinspector.structures.TexGenPlanes;
import com.matt.difinspector.structures.TexMatrix;
......@@ -60,6 +61,9 @@ public class InteriorBuilder
{
Mesh mesh = builder.build();
Interior result = new Interior();
System.out.println("Adding Min Pixels");
result.setMinPixels(250);
System.out.println("Adding Points");
ItrPaddedPoint[] points = new ItrPaddedPoint[mesh.getVertices().length];
......@@ -263,8 +267,8 @@ public class InteriorBuilder
System.out.println("Adding Solid Leaf Surfaces");
// TODO: Solid Leaf Surfaces
int[] solidLeafSurfaces = new int[planes.sizeIndices()];
for (int i = 0; i < planes.sizeIndices(); i++)
int[] solidLeafSurfaces = new int[surfaces.sizeIndices()];
for (int i = 0; i < surfaces.sizeIndices(); i++)
solidLeafSurfaces[i] = i;
result.setSolidLeafSurfaces(solidLeafSurfaces);
......@@ -402,8 +406,8 @@ public class InteriorBuilder
result.setHullIndices(hullIndices);
// TODO: Hull Plane Indices
System.out.println("Adding Hull Plane Indices");
// just the planeIndexes in some order
// it's worth noting that sometimes this is -32768 in DIF files. Hopefully we can ignore this fact.
// this is an index for every surface
// a value for -32768 means no collision for this surface
short[] hullPlaneIndices = new short[planes.sizeIndices()];
for (short i = 0; i < planes.sizeIndices(); i++)
hullPlaneIndices[i] = i;
......@@ -528,22 +532,37 @@ public class InteriorBuilder
// TODO: BSPNodes
System.out.println("Adding BSPNodes");
// bspNodes frontIndex and backIndex variables are actually indices for the bspSolidLeaves array
// (with each referring to different planes to use if the marble hits the front or back of the shape)
// (and with some bitwise operations applied to them, more specifically Index AND 0011111111111111)
// which in turn actually refers to solidLeafSurfaces variable
// which in turn contains indices for Surfaces
// which in turn contains planeIndex which refers to planes.
// bspNodes > bspSolidLeaves > solidLeafSurfaces > Surfaces > Planes
// What a stupid, confusing way of doing things. Is this really saving any space?
BSPNode[] bspNodes = new BSPNode[surfaces.sizeIndices()];
for (int i = 0; i < surfaces.sizeIndices(); i++)
{
// BSPNodes may be incorrect
// Consider revisiting
short oppositeIndex = (short)(surfaces.sizeIndices() - i);
int backIndex = i + 1;
if (backIndex == surfaces.sizeIndices())
backIndex = -16384 + i;
bspNodes[i] = new BSPNode(oppositeIndex, -32768, backIndex);
short planeIndex = (short)surfaces.getObject(i).getPlaneIndex();
//short planeIndexOpposite = (short)(surfaces.sizeIndices() - i);
// Basically, in order to tell Torque we aren't referring to
// another BSPNode which contains the actual value
// we need the number to be at least 1100000000000000 in binary
// (the first 1s both have different meanings but basically they both need to be true)
// this happens to be 49152
// the 1s are cut in a bitwise AND operation later and we're left with the original number
int bspSolidLeafFrontBackIndex = 49152 + i;
//if (backIndex == surfaces.sizeIndices())
//backIndex = -16384 + i;
bspNodes[i] = new BSPNode(planeIndex, bspSolidLeafFrontBackIndex, bspSolidLeafFrontBackIndex);
}
result.setBspNodes(bspNodes);
System.out.println("Adding BSPSolidLeaves");
BSPSolidLeaf[] bspSolidLeaves = new BSPSolidLeaf[surfaces.sizeIndices()];
for (int i = 0; i < surfaces.sizeIndices(); i++)
BSPSolidLeaf[] bspSolidLeaves = new BSPSolidLeaf[solidLeafSurfaces.length];
for (int i = 0; i < solidLeafSurfaces.length; i++)
bspSolidLeaves[i] = new BSPSolidLeaf(i, (short)1);
result.setBspSolidLeaves(bspSolidLeaves);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment