fix list updating exception
This commit is contained in:
		
							parent
							
								
									c0c0e81327
								
							
						
					
					
						commit
						e303ac4a03
					
				| @ -128,15 +128,19 @@ public class NavMeshUtils { | |||||||
| //            ); | //            ); | ||||||
|             toRemove.clear(); |             toRemove.clear(); | ||||||
|             //TODO: iterate this backwards and check for x adjacency, if no adjacency end loop early |             //TODO: iterate this backwards and check for x adjacency, if no adjacency end loop early | ||||||
|  |             List<SecondPhaseBox> neighborUpdateList = new LinkedList<SecondPhaseBox>(); | ||||||
|             for(SecondPhaseBox interim : secondPhaseBoxes){ |             for(SecondPhaseBox interim : secondPhaseBoxes){ | ||||||
|                 if(firstPhaseBox.yStart == interim.boundMinY && firstPhaseBox.yEnd == interim.boundMaxY && firstPhaseBox.x == interim.boundMaxX){ |                 if(firstPhaseBox.yStart == interim.boundMinY && firstPhaseBox.yEnd == interim.boundMaxY && firstPhaseBox.x == interim.boundMaxX){ | ||||||
|                     for(SecondPhaseBox neighbor : interim.getNeighbors()){ |                     for(SecondPhaseBox neighbor : interim.getNeighbors()){ | ||||||
|                         neighbor.removeNeighbor(interim); |                         neighborUpdateList.add(neighbor); | ||||||
|                         interim.removeNeighbor(neighbor); |  | ||||||
|                         neighbor.addNeighbor(newBox); |  | ||||||
|                         newBox.addNeighbor(neighbor); |  | ||||||
| //                        System.out.println("ADD NEIGHBOR: " + neighbor.boundMaxX + " " + neighbor.boundMaxY + " " + neighbor.boundMinX + " " + neighbor.boundMinY); | //                        System.out.println("ADD NEIGHBOR: " + neighbor.boundMaxX + " " + neighbor.boundMaxY + " " + neighbor.boundMinX + " " + neighbor.boundMinY); | ||||||
|                     } |                     } | ||||||
|  |                     for(SecondPhaseBox update : neighborUpdateList){ | ||||||
|  |                         update.removeNeighbor(interim); | ||||||
|  |                         interim.removeNeighbor(update); | ||||||
|  |                         update.addNeighbor(newBox); | ||||||
|  |                         newBox.addNeighbor(update); | ||||||
|  |                     } | ||||||
|                     toRemove.add(interim); |                     toRemove.add(interim); | ||||||
|                     newBox.setBoundMinX(interim.getBoundMinX()); |                     newBox.setBoundMinX(interim.getBoundMinX()); | ||||||
|                     //TODO: calculate new min/max height |                     //TODO: calculate new min/max height | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user