55 * main method is here as well.
66 *
77 * @author Arash J. Farmand
8- * @version 3.1
9- * @date 2019-12-01
8+ * @version 3.12
9+ * @date 2019-12-02
1010 * @since 2019-11-24
1111 */
1212import java .awt .event .*;
@@ -315,7 +315,6 @@ private void add_AABB(int n) {
315315 System .arraycopy (aabbs , 0 , temp_AABBs , 0 , aabbs .length );
316316 for (int i = n ; i > 0 ; i --) {
317317 AABB new_AABB = new AABB ();
318- //new_AABB.set_Color((int) (new Random().nextInt(255) * 0.3f), (int) (85 + new Random().nextInt(255) * 0.5f), (int) (85 + new Random().nextInt(255) * 0.5f), 200);
319318 new_AABB .set_Size (20 + new Random ().nextInt (hght / 20 ), 20 + new Random ().nextInt (hght / 20 ));
320319 new_AABB .set_Velocity (3 - new Random ().nextFloat () * 6 , 3 - new Random ().nextFloat () * 6 );
321320 new_AABB .relocate (1 + new Random ().nextInt (wdth - (int ) new_AABB .x2 - (int ) new_AABB .x1 - 2 ), 1 + new Random ().nextInt (hght - (int ) new_AABB .y2 - (int ) new_AABB .y1 - 2 ));
@@ -325,7 +324,6 @@ private void add_AABB(int n) {
325324
326325 aabbs = temp_AABBs ;
327326 quadtree .all_AABBs = aabbs ;
328- quadtree .set_Max_Tree_Depth (max_Tree_Depth );
329327 }
330328
331329 /*******************************************************************************
@@ -434,7 +432,7 @@ private void remove_AABB() {
434432 private void remove_All_AABBs () {
435433 number_Of_AABBs = 0 ;
436434 aabbs = new AABB [0 ];
437- quadtree . all_AABBs = aabbs ;
435+ quadtree = new Quadtree ( aabbs , 0 , 0 , wdth , hght , max_Tree_Depth , square_Quadtree ) ;
438436 }
439437
440438 /**
@@ -512,14 +510,14 @@ private void update_Scene() {
512510 * ***************************************************************************
513511 */
514512 private void update_AABB_locations () {
515- for (int i = 0 ; i < aabbs . length ; i ++ ) {
516- if (aabbs [ i ] .x2 + aabbs [ i ] .dx >= wdth || aabbs [ i ] .x1 + aabbs [ i ] .dx <= 0 ) {
517- aabbs [ i ] .dx = -aabbs [ i ] .dx ;
513+ for (AABB aabb : aabbs ) {
514+ if (aabb .x2 + aabb .dx >= wdth || aabb .x1 + aabb .dx <= 0 ) {
515+ aabb .dx = -aabb .dx ;
518516 }
519- if (aabbs [ i ] .y2 + aabbs [ i ] .dy >= hght || aabbs [ i ] .y1 + aabbs [ i ] .dy <= 0 ) {
520- aabbs [ i ] .dy = -aabbs [ i ] .dy ;
517+ if (aabb .y2 + aabb .dy >= hght || aabb .y1 + aabb .dy <= 0 ) {
518+ aabb .dy = -aabb .dy ;
521519 }
522- aabbs [ i ] .relocate (aabbs [ i ] .dx , aabbs [ i ] .dy );
520+ aabb .relocate (aabb .dx , aabb .dy );
523521 }
524522 }
525523
0 commit comments