-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
major update to eve, with basic box-based collision detection and ren…
…aming to support path toward physics-based system working.
- Loading branch information
Randall C. O'Reilly
committed
Mar 30, 2020
1 parent
7f5afbe
commit 09ec980
Showing
18 changed files
with
594 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) 2019, The Emergent Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package eve | ||
|
||
import ( | ||
"github.com/goki/ki/ki" | ||
"github.com/goki/mat32" | ||
) | ||
|
||
// Contact is one pairwise point of contact between two bodies. | ||
// Contacts are represented in spherical terms relative to the | ||
// spherical BBox of A and B. | ||
type Contact struct { | ||
A Body `desc:"one body"` | ||
B Body `desc:"the other body"` | ||
NormB mat32.Vec3 `desc:"normal pointing from center of B to center of A"` | ||
PtB mat32.Vec3 `desc:"point on spherical shell of B where A is contacting"` | ||
Dist float32 `desc:"distance from PtB along NormB to contact point on spherical shell of A"` | ||
} | ||
|
||
// UpdtDist updates the distance information for the contact | ||
func (c *Contact) UpdtDist() { | ||
|
||
} | ||
|
||
// Contacts is a slice list of contacts | ||
type Contacts []*Contact | ||
|
||
// AddNew adds a new contact to the list | ||
func (cs *Contacts) AddNew(a, b Body) *Contact { | ||
c := &Contact{A: a, B: b} | ||
*cs = append(*cs, c) | ||
return c | ||
} | ||
|
||
// BodyVelBBoxIntersects returns the list of potential contact nodes between a and b | ||
// (could be the same or different groups) that have intersecting velocity-projected | ||
// bounding boxes. In general a should be dynamic bodies and b either dynamic or static. | ||
// This is the broad first-pass filtering. | ||
func BodyVelBBoxIntersects(a, b Node) Contacts { | ||
var cts Contacts | ||
a.FuncDownMeFirst(0, a.This(), func(k ki.Ki, level int, d interface{}) bool { | ||
aii, ai := KiToNode(k) | ||
if aii == nil { | ||
return false // going into a different type of thing, bail | ||
} | ||
if aii.NodeType() != BODY { | ||
return true | ||
} | ||
abod := aii.AsBody() // only consider bodies from a | ||
|
||
b.FuncDownMeFirst(0, b.This(), func(k ki.Ki, level int, d interface{}) bool { | ||
bii, bi := KiToNode(k) | ||
if bii == nil { | ||
return false // going into a different type of thing, bail | ||
} | ||
if !ai.BBox.IntersectsVelBox(&bi.BBox) { | ||
return false // done | ||
} | ||
if bii.NodeType() == BODY { | ||
cts.AddNew(abod, bii.AsBody()) | ||
return false // done | ||
} | ||
return true // keep going | ||
}) | ||
|
||
return false | ||
}) | ||
return cts | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.