GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — coll/box_orientedbox_overlap.go at v1.6.0 · setanarut/coll Expand file tree/ Copy pathbox_orientedbox_overlap.goMore file actions 41 lines (33 loc) · 1.01 KB / Copy pathbox_orientedbox_overlap.goFile metadata and controls41 lines (33 loc) · 1.01 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 package coll import ( "math" "github.com/setanarut/v" ) // BoxOrientedBoxOverlap tests if an AABB and OBB are currently intersecting. // For moving objects, use BoxOrientedBoxSweep2 to prevent tunneling. func BoxOrientedBoxOverlap(a *AABB, o *OBB) bool { d := o.Pos.Sub(a.Pos) // Precompute axes and their absolute values bAxisX := v.FromAngle(o.Angle) bAxisY := v.Vec{X: -bAxisX.Y, Y: bAxisX.X} bAxisXAbs := bAxisX.Abs() bAxisYAbs := bAxisY.Abs() // Check AABB axes projBOnAx := bAxisXAbs.X*o.Half.X + bAxisYAbs.X*o.Half.Y if math.Abs(d.X) > a.Half.X+projBOnAx { return false } projBOnAy := bAxisXAbs.Y*o.Half.X + bAxisYAbs.Y*o.Half.Y if math.Abs(d.Y) > a.Half.Y+projBOnAy { return false } // Check OBB axes distOnObbX := math.Abs(d.Dot(bAxisX)) projAOnObbX := bAxisXAbs.X*a.Half.X + bAxisXAbs.Y*a.Half.Y if distOnObbX > o.Half.X+projAOnObbX { return false } distOnObbY := math.Abs(d.Dot(bAxisY)) projAOnObbY := bAxisYAbs.X*a.Half.X + bAxisYAbs.Y*a.Half.Y return distOnObbY <= o.Half.Y+projAOnObbY } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |