boxTest (kinda like rayTest)?

Hey all,

I’m working on 3089, and I’d like to do a single “boxtest” (e.g. determine if a volume box collides with any physics objects). I know of rayTest, which works great for rays… I also know there is a sweepTest, but that must do a “sweep” (and it apparently can return false even if it is in an object but moving away from it…?). I could write my own boxTest which just does a bunch of rayTests within the volume, but that seems inefficient… is there another solution I am missing? :expressionless:

Thanks in advance!

Would a PhysicsGhostObject do the trick?

A PhysicsGhostObject works on AABB… so I’m not sure it will work. I want to do a Box vs. Mesh check. If PhysicsGhostObject only does AABB for itself, then it could work… however, if I recall correctly, I was having trouble getting PhysicsGhostObjects to work in Gentrieve 2, because it seemed to be doing AABB for both objects (e.g. the physics ghost object and the other “overlapping” objects).

Just do a rayTest sweepTest from the previous position and ignore stuff with a hitfraction below what interests you?

Yeah, I may have to stick with a sweepTest, although I am worried about the disclaimer that says it won’t detect collisions if inside the object but moving away… I would also prefer a stationary test instead of a sweep, but apparently no such test exists :frowning: I wonder how the sweepTest method compares to a handful of rayTests within the volume on performance and accuracy…

If the box is a moving object then you would never miss a collision since you do a sweep from the previous frame until the current frame - everything in between will be detected. If its a “teleport” test where the box could be in an arbitrary position, that makes it a bit harder. There’s no concept of “inside” or “outside” in triangle meshes so doing what you said is impossible given the data you have available.

The box isn’t a moving object… I am checking a volume to see if I can place an enemy there safely. I can determine if a given point is above ground or not (e.g. if I am “outside” or “inside” the terrain’s triangle mesh) – but I want to quickly know if there is any terrain edges within that volume of space. I have cliffs & caves, so I can’t just check if the volume is all above a height function. My terrain is a static physics object, so I’d like to do some jbullet collision checking to solve this… sweepTest might be the closest thing I am looking for, but it leaves me wishing there was a boxTest like a rayTest :stuck_out_tongue:

You can do a sweep test from top to bottom at a certain point (X, Z) … If you can make it ignore triangles facing downwards, then you can use the hit fraction to determine the highest point on the terrain that is pathable.

Another (much faster) way is to use navigation meshes. MonkeyZone comes with a navmesh generator and navmesh A* pathfinder out of the box. It includes the sort of features you’re looking for like detecting pathable areas within some volume. Have you considered using it?

I have not considered using MonkeyZone… so many sources of useful code, hard to keep track! Thanks for bringing it up – I will look into it.

I will also give that sweepTest method a try and see how it goes… I’ll compare it with doing a bunch of rayTests in the area and see what works better. Thanks.