What steps will reproduce the problem?
1. After using the code from 'FixedSpatialHashGrid.java' that was posted by
Rieder.A...@gmail.com, there were still errors. The problem was that the
following methods were trying to access ArrayList items indexed as -1 (cellId
's marked as not containing the obj GameObject):
insertStaticObject, insertDynamicObject, removeObject, and getPotentialColliders
Example:
Original:
public void insertDynamicObject(GameObject obj) {
int[] cellIds = getCellIds(obj);
int i = 0;
int cellId = -1;
for(i = 0; i < cellIds.length; ++i) {
cellId = cellIds[i];
dynamicCells[cellId].add(obj);
}
}
Fixed:
public void insertDynamicObject(GameObject obj){
int[] cellIds = getCellIds(obj);
int cellId = -1;
for (int i = 0; i < cellIds.length; ++i){
cellId = cellIds[i];
if (cellId == -1)
continue;
dynamicCells[cellId].add(obj);
}
}
Attached working version of the complete class
Thank you for writing such a great book!
Original issue reported on code.google.com by imse...@gmail.com on 12 Oct 2011 at 6:48
Original issue reported on code.google.com by
imse...@gmail.com
on 12 Oct 2011 at 6:48Attachments: