Fixed stale faraway object

This commit is contained in:
tidwall 2018-08-18 15:53:02 -07:00
parent 8bde592092
commit 73f2cac9a4
1 changed files with 9 additions and 3 deletions

View File

@ -399,9 +399,15 @@ func fenceMatchRoam(
return true return true
}, },
) )
faraways = prevNearbys for i := 0; i < len(prevNearbys); i++ {
for i := 0; i < len(faraways); i++ { obj, _, ok := col.Get(prevNearbys[i].id)
faraways[i].meters = faraways[i].obj.CalculatedPoint().DistanceTo(p) if ok {
faraways = append(faraways, roamMatch{
id: prevNearbys[i].id,
obj: obj,
meters: obj.CalculatedPoint().DistanceTo(p),
})
}
} }
if len(nearbys) == 0 { if len(nearbys) == 0 {
if fence.roam.nearbys != nil { if fence.roam.nearbys != nil {