Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  AABBTest  (Read 1396 times)
0 Members and 1 Guest are viewing this topic.
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Posted 2006-02-02 11:59:18 »

Hey t_larkworthy
in the javadoc of AABBTest it says that the default implementation returns 1, is this because you were to lazy to implement the real test, or because of other reasons (e.g. because it said already so in ODE)? I need a proper working AABBTest (I'll implement it somewhere else in case of the latter)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
   /**
    * test whether the given AABB object intersects with this object, return
    * 1=yes, 0=no. this is used as an early-exit test in the space collision
    * functions. the default implementation returns 1, which is the correct
    * behavior if no more detailed implementation can be provided. utility
    * functions compute the AABB only if it is not current. this function
    * manipulates the GEOM_AABB_BAD flag.
    */


   public boolean AABBTest(Geom other, float[] aabb){
      return true;
   }

:: JOODE :: Xith3d :: OdeJava ::
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #1 - Posted 2006-02-02 12:11:13 »

mmh I searched now if there are any methods using or overwriting it, there are none, which a correct implementation would hurt.
But I'll better wait for your response (I can paste and copy it afterwards in)

:: JOODE :: Xith3d :: OdeJava ::
Offline t_larkworthy

Senior Member


Medals: 1
Projects: 1


Google App Engine Rocks!


« Reply #2 - Posted 2006-02-02 16:22:39 »

yeah this is correct.

Its so that clever optimizations can be done:

It allows a geom that knows its own geometry can quickly rule out a collision with another geom, even if it only knows the other geoms AABB. So returning true only means the collision system will go onto the next round of collision testing (i.e. using the colliders).

So the AABBTest function is not the test to see whether two AABB intersect. It is a test a Geom can perform (so its geom specific) against an unkown other geom. It is not used very widley used, if at all at in ODE (it is ODE's archetecture not mine).

The real AABB test for two AABB is in Space:-

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
public static void collideAABBs(Geom g1, Geom g2, Object data,
         NearCallback callback) {
      if (!((g1.gflags & GEOM_AABB_BAD) == 0))
         throw new IllegalArgumentException(g1.getClass().getName());
      if (!((g2.gflags & GEOM_AABB_BAD) == 0))
         throw new IllegalArgumentException();

      // no contacts if both geoms on the same body, and the body is not 0
     if (g1.body == g2.body && g1.body != null)
         return;

      // test if the category and collide bitfields match
     if ((((g1.category_bits & g2.collide_bits) !=0 || (g2.category_bits & g1.collide_bits) != 0)) == false) {
         return;
      }

      // if the bounding boxes are disjoint then don't do anything
     float[] bounds1 = g1.aabb;
      float[] bounds2 = g2.aabb;
      if (bounds1[0] > bounds2[1] || bounds1[1] < bounds2[0]
            || bounds1[2] > bounds2[3] || bounds1[3] < bounds2[2]
            || bounds1[4] > bounds2[5] || bounds1[5] < bounds2[4]) {
         return;
      }

      // check if either object is able to prove that it doesn't intersect the
     // AABB of the other
     if (g1.AABBTest(g2, bounds2) == false)
         return;
      if (g2.AABBTest(g1, bounds1) == false)
         return;

      // the objects might actually intersect - call the space callback
     // function
     callback.call(data, g1, g2);
   }



Runesketch: an Online CCG built on Google App Engine where players draw their cards and trade. Fight, draw or trade yourself to success.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #3 - Posted 2006-02-02 16:31:27 »

ok I understand - then I don't do this - I've seen now, I don't need it anyways.

:: JOODE :: Xith3d :: OdeJava ::
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (20 views)
2014-09-21 02:42:18

BurntPizza (14 views)
2014-09-21 01:30:30

moogie (14 views)
2014-09-21 00:26:15

UprightPath (25 views)
2014-09-20 20:14:06

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (42 views)
2014-09-12 09:08:26

Norakomi (73 views)
2014-09-10 13:57:51

TehJavaDev (97 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!