Skip to content

Commit c2f5e42

Browse files
committed
AOI use distance from InitAOI
1 parent 2762bd1 commit c2f5e42

File tree

5 files changed

+9
-17
lines changed

5 files changed

+9
-17
lines changed

XZListAOIManager.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package aoi
22

3-
const _DEFAULT_AOI_DISTANCE = 100
4-
53
type xzaoi struct {
64
aoi *AOI
75
neighbors map[*xzaoi]struct{}

aoi.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ type AOI struct {
1010

1111
callback AOICallback
1212
implData interface{}
13-
14-
//// Fields for XZListAOIManager
15-
//neighbors AOISet
16-
//xPrev, xNext *AOI
17-
//yPrev, yNext *AOI
18-
//markVal int
1913
}
2014

2115
func InitAOI(aoi *AOI, dist Coord, data interface{}, callback AOICallback) {

aoi_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func testAOI(t *testing.T, manname string, aoiman AOIManager, numAOI int) {
8080
objs := []*TestObj{}
8181
for i := 0; i < numAOI; i++ {
8282
obj := &TestObj{Id: i + 1, neighbors: map[*TestObj]struct{}{}}
83-
InitAOI(&obj.aoi, _DEFAULT_AOI_DISTANCE, obj, obj)
83+
InitAOI(&obj.aoi, 100, obj, obj)
8484
objs = append(objs, obj)
8585
aoiman.Enter(&obj.aoi, randCoord(MIN_X, MAX_X), randCoord(MIN_Y, MAX_Y))
8686
}

xAOIList.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ func (sl *xAOIList) Mark(aoi *xzaoi) {
129129
prev := aoi.xPrev
130130
coord := aoi.aoi.x
131131

132-
minCoord := coord - _DEFAULT_AOI_DISTANCE
132+
minCoord := coord - aoi.aoi.dist
133133
for prev != nil && prev.aoi.x >= minCoord {
134134
prev.markVal += 1
135135
prev = prev.xPrev
136136
}
137137

138138
next := aoi.xNext
139-
maxCoord := coord + _DEFAULT_AOI_DISTANCE
139+
maxCoord := coord + aoi.aoi.dist
140140
for next != nil && next.aoi.x <= maxCoord {
141141
next.markVal += 1
142142
next = next.xNext
@@ -146,7 +146,7 @@ func (sl *xAOIList) Mark(aoi *xzaoi) {
146146
func (sl *xAOIList) GetClearMarkedNeighbors(aoi *xzaoi) {
147147
prev := aoi.xPrev
148148
coord := aoi.aoi.x
149-
minCoord := coord - _DEFAULT_AOI_DISTANCE
149+
minCoord := coord - aoi.aoi.dist
150150
for prev != nil && prev.aoi.x >= minCoord {
151151
if prev.markVal == 2 {
152152
aoi.neighbors[prev] = struct{}{}
@@ -159,7 +159,7 @@ func (sl *xAOIList) GetClearMarkedNeighbors(aoi *xzaoi) {
159159
}
160160

161161
next := aoi.xNext
162-
maxCoord := coord + _DEFAULT_AOI_DISTANCE
162+
maxCoord := coord + aoi.aoi.dist
163163
for next != nil && next.aoi.x <= maxCoord {
164164
if next.markVal == 2 {
165165
aoi.neighbors[next] = struct{}{}

zAOIList.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ func (sl *yAOIList) Mark(aoi *xzaoi) {
129129
prev := aoi.yPrev
130130
coord := aoi.aoi.y
131131

132-
minCoord := coord - _DEFAULT_AOI_DISTANCE
132+
minCoord := coord - aoi.aoi.dist
133133
for prev != nil && prev.aoi.y >= minCoord {
134134
prev.markVal += 1
135135
prev = prev.yPrev
136136
}
137137

138138
next := aoi.yNext
139-
maxCoord := coord + _DEFAULT_AOI_DISTANCE
139+
maxCoord := coord + aoi.aoi.dist
140140
for next != nil && next.aoi.y <= maxCoord {
141141
next.markVal += 1
142142
next = next.yNext
@@ -147,14 +147,14 @@ func (sl *yAOIList) ClearMark(aoi *xzaoi) {
147147
prev := aoi.yPrev
148148
coord := aoi.aoi.y
149149

150-
minCoord := coord - _DEFAULT_AOI_DISTANCE
150+
minCoord := coord - aoi.aoi.dist
151151
for prev != nil && prev.aoi.y >= minCoord {
152152
prev.markVal = 0
153153
prev = prev.yPrev
154154
}
155155

156156
next := aoi.yNext
157-
maxCoord := coord + _DEFAULT_AOI_DISTANCE
157+
maxCoord := coord + aoi.aoi.dist
158158
for next != nil && next.aoi.y <= maxCoord {
159159
next.markVal = 0
160160
next = next.yNext

0 commit comments

Comments
 (0)