package NET.worlds.scape; import java.io.IOException; public class BoxBumpCalc extends BumpCalc { private static Object classCookie = new Object(); @Override public void detectBump(BumpEventTemp b, WObject owner) { BoundBoxTemp box = owner.getBoundBox(); BoundBoxTemp sourceBox = ((WObject)b.source).getBoundBox(); box.lo.minus(sourceBox.hi.minus(b.sourceAt)); box.hi.minus(sourceBox.lo.minus(b.sourceAt)); Point3Temp pos = Point3Temp.make(); pos.x = box.lo.x; pos.y = box.lo.y; float xExtent = box.hi.x - box.lo.x; float yExtent = box.hi.y - box.lo.y; Point3Temp d = Point3Temp.make(xExtent, 0.0F, 0.0F); Point3Temp extent = Point3Temp.make(0.0F, yExtent / 2.0F, 0.0F); if (!b.hitTriRegion(owner, pos, d, extent)) { pos.x = box.hi.x; pos.y = box.hi.y; d.x = -d.x; extent.y = -extent.y; if (!b.hitTriRegion(owner, pos, d, extent)) { pos.y = box.lo.y; d.y = yExtent; d.x = 0.0F; extent.x = -xExtent / 2.0F; extent.y = 0.0F; if (!b.hitTriRegion(owner, pos, d, extent)) { pos.x = box.lo.x; pos.y = box.hi.y; d.y = -d.y; extent.x = -extent.x; if (!b.hitTriRegion(owner, pos, d, extent)) { ; } } } } } @Override public void saveState(Saver s) throws IOException { s.saveVersion(0, classCookie); super.saveState(s); } @Override public void restoreState(Restorer r) throws IOException, TooNewException { switch (r.restoreVersion(classCookie)) { case 0: super.restoreState(r); return; default: throw new TooNewException(); } } }