Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added NN grid init code for flocking
- Loading branch information
1 parent
13ebd53
commit e082e6e
Showing
6 changed files
with
46 additions
and
4 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,4 +1,24 @@ | |||
final float FLOCK_CENTERING_RADIUS = 0.2; | |||
|
|||
HashMap flockCenterGrid; | |||
|
|||
void initNeighborGrids() { | |||
flockCenterGrid = new HashMap(); | |||
} | |||
|
|||
void computeNeighborGrids() { | void computeNeighborGrids() { | ||
//use active forces and compute separate neighbor grids for each force | //use active forces and compute separate neighbor grids for each force | ||
|
float radius = FLOCK_CENTERING_RADIUS; | ||
flockCenterGrid.clear(); | |||
for (int i = 0; i < NUM_CREATURES; i++) { | |||
String key = int(creatures[i].posX/radius) + "," + int(creatures[i].posY/radius); | |||
ArrayList val = (ArrayList)flockCenterGrid.get(key); | |||
if (val != null) { | |||
val.add(i); | |||
} | |||
else { | |||
flockCenterGrid.put(key, new ArrayList()); | |||
} | |||
} | |||
|
|||
} | } |
Binary file not shown.
Binary file not shown.
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