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_box_overlap.go at v1.6.0 · setanarut/coll Expand file tree/ Copy pathbox_box_overlap.goMore file actions 50 lines (40 loc) · 884 Bytes / Copy pathbox_box_overlap.goFile metadata and controls50 lines (40 loc) · 884 Bytes 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 42 43 44 45 46 47 48 49 50 package coll import ( "math" "github.com/setanarut/v" ) // BoxBoxOverlap checks whether a and b overlap. // // If h is not nil, the function fills it with for box b: // - Normal: Collision surface normal for box b // - Data: the penetration depth for box b (overlap distance) // // This method can behave poorly for moving objects. // // For continuous motion, BoxBoxSweep1() of BoxBoxSweep2() should be used instead. func BoxBoxOverlap(a, b *AABB, h *Hit) bool { d := b.Pos.Sub(a.Pos) absD := d.Abs() hSum := a.Half.Add(b.Half) px := hSum.X - absD.X if px <= 0 { return false } py := hSum.Y - absD.Y if py <= 0 { return false } if h == nil { return true } if px < py { sx := math.Copysign(1, d.X) h.Normal = v.Vec{X: sx, Y: 0} h.Data = px } else { sy := math.Copysign(1, d.Y) h.Normal = v.Vec{X: 0, Y: sy} h.Data = py } return true } |
| 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. |