Skip to content

Commit d229470

Browse files
committed
Deps: Use original golang/geo master (now has ConvexHullQuery)
1 parent 0fa30bd commit d229470

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

Gopkg.lock

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@
3030
version = "1.0.0"
3131

3232
[[constraint]]
33-
branch = "convex-hull"
33+
branch = "master"
3434
name = "github.com/golang/geo"
35-
source = "github.com/markus-wa/geo"
3635

3736
[[constraint]]
3837
name = "github.com/markus-wa/gobitread"

common/structs.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,24 @@ func (inf Inferno) Active() Inferno {
214214
return res
215215
}
216216

217-
// ConvexHull returns the convex hull of all the fires in the inferno.
218-
func (inf Inferno) ConvexHull() *s2.Loop {
217+
// ConvexHull2D returns the 2D convex hull of all the fires in the inferno.
218+
// Useful for drawing on 2D maps.
219+
func (inf Inferno) ConvexHull2D() *s2.Loop {
220+
q := s2.NewConvexHullQuery()
221+
for i := range inf.Fires {
222+
q.AddPoint(s2.Point{
223+
Vector: r3.Vector{
224+
X: inf.Fires[i].Vector.X,
225+
Y: inf.Fires[i].Vector.Y,
226+
Z: 1,
227+
},
228+
})
229+
}
230+
return q.ConvexHull()
231+
}
232+
233+
// ConvexHull3D returns the 3D convex hull of all the fires in the inferno.
234+
func (inf Inferno) ConvexHull3D() *s2.Loop {
219235
q := s2.NewConvexHullQuery()
220236
for i := range inf.Fires {
221237
q.AddPoint(s2.Point{Vector: inf.Fires[i].Vector})

examples/nade-trajectories/nade_trajectories.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,17 @@ func main() {
5757

5858
p.RegisterEventHandler(func(e events.NadeProjectileDestroyedEvent) {
5959
id := e.Projectile.UniqueID()
60+
61+
// Sometimes the thrower is nil, in that case we want the team to be unassigned (which is the default value)
62+
var team common.Team
63+
if e.Projectile.Thrower != nil {
64+
team = e.Projectile.Thrower.Team
65+
}
66+
6067
if nadeTrajectories[id] == nil {
6168
nadeTrajectories[id] = &nadePath{
6269
wep: e.Projectile.Weapon,
63-
team: e.Projectile.Thrower.Team,
70+
team: team,
6471
}
6572
}
6673

@@ -131,7 +138,7 @@ func drawInfernos(gc *draw2dimg.GraphicContext, infernos []*common.Inferno) {
131138
// Calculate hulls
132139
hulls := make([]*s2.Loop, len(infernos))
133140
for i := range infernos {
134-
hulls[i] = infernos[i].ConvexHull()
141+
hulls[i] = infernos[i].ConvexHull2D()
135142
}
136143

137144
for _, hull := range hulls {

0 commit comments

Comments
 (0)