public BlockPosSide[] LineIntersection(DelegateIsBlockEmpty isEmpty, DelegateGetBlockHeight getBlockHeight, Line3D line, IntRef retCount) { lCount = 0; currentLine = line; currentHit[0] = 0; currentHit[1] = 0; currentHit[2] = 0; ListBox3d l1 = Search(PredicateBox3DHit.Create(this)); for (int i = 0; i < l1.count; i++) { Box3D node = l1.arr[i]; float[] hit = currentHit; float x = node.MinEdge[0]; float y = node.MinEdge[2]; float z = node.MinEdge[1]; if (!isEmpty.IsBlockEmpty(platform.FloatToInt(x), platform.FloatToInt(y), platform.FloatToInt(z))) { Box3D node2 = new Box3D(); node2.MinEdge = Vec3.CloneIt(node.MinEdge); node2.MaxEdge = Vec3.CloneIt(node.MaxEdge); node2.MaxEdge[1] = node2.MinEdge[1] + getBlockHeight.GetBlockHeight(platform.FloatToInt(x), platform.FloatToInt(y), platform.FloatToInt(z)); BlockPosSide b = new BlockPosSide(); float[] hit2 = new float[3]; float[] dir = new float[3]; dir[0] = line.End[0] - line.Start[0]; dir[1] = line.End[1] - line.Start[1]; dir[2] = line.End[2] - line.Start[2]; bool ishit = Intersection.HitBoundingBox(node2.MinEdge, node2.MaxEdge, line.Start, dir, hit2); if (ishit) { //hit2.pos = Vec3.FromValues(x, z, y); b.blockPos = Vec3.FromValues(platform.FloatToInt(x), platform.FloatToInt(z), platform.FloatToInt(y)); b.collisionPos = hit2; l[lCount++] = b; } } } BlockPosSide[] ll = new BlockPosSide[lCount]; for (int i = 0; i < lCount; i++) { ll[i] = l[i]; } retCount.value = lCount; return(ll); }
public BlockPosSide[] LineIntersection(DelegateIsBlockEmpty isEmpty, DelegateGetBlockHeight getBlockHeight, Line3D line, IntRef retCount) { lCount = 0; currentLine = line; currentHit[0] = 0; currentHit[1] = 0; currentHit[2] = 0; ListBox3d l1 = Search(PredicateBox3DHit.Create(this)); for (int i = 0; i < l1.count; i++) { Box3D node = l1.arr[i]; float[] hit = currentHit; float x = node.MinEdge[0]; float y = node.MinEdge[2]; float z = node.MinEdge[1]; if (!isEmpty.IsBlockEmpty(platform.FloatToInt(x),platform.FloatToInt(y),platform.FloatToInt( z))) { Box3D node2 = new Box3D(); node2.MinEdge = Vec3.CloneIt(node.MinEdge); node2.MaxEdge = Vec3.CloneIt(node.MaxEdge); node2.MaxEdge[1] = node2.MinEdge[1] + getBlockHeight.GetBlockHeight(platform.FloatToInt(x),platform.FloatToInt(y),platform.FloatToInt(z)); BlockPosSide b = new BlockPosSide(); float[] hit2 = new float[3]; float[] dir = new float[3]; dir[0] = line.End[0] - line.Start[0]; dir[1] = line.End[1] - line.Start[1]; dir[2] = line.End[2] - line.Start[2]; bool ishit = Intersection.HitBoundingBox(node2.MinEdge, node2.MaxEdge, line.Start, dir, hit2); if (ishit) { //hit2.pos = Vec3.FromValues(x, z, y); b.blockPos = Vec3.FromValues(platform.FloatToInt(x), platform.FloatToInt(z), platform.FloatToInt(y)); b.collisionPos = hit2; l[lCount++] = b; } } } BlockPosSide[] ll = new BlockPosSide[lCount]; for (int i = 0; i < lCount; i++) { ll[i] = l[i]; } retCount.value = lCount; return ll; }