AABBTest

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)

	/**
	 * 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;
	}


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)

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:-

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);
	}

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