RecastJSPlugin query extents

Hi @cedric,
I’m experimenting with the navmesh plugin and trying to understand how ‘defaultQueryExtents’ work.

It seems like getClosestPoint() always fails when the extents are (1,1,1).
But setting them to anything more than that makes everything work as expected.

how does setting the extents affect the search area?
does the extent vector scale the bounding box of the navmesh geometry when calculating the search area?

Thanks for any help!

Hi @Matt_Poindexter

Imagine a bounding box sized by the extents value, then when doing a query, the results are filtered by that box.
It does not scale the navmesh geometry. It only affects search results.
You can change extents between queries.

So, the extents always translate to a cube scaled by extents centered at the origin? (Independent of navmesh geometry)
If I never want an out of bounds closest point query should I just set extents to x,y,z = huge number?
Or does that incur some performance penalty?

I don’t understand what you mean for ‘an out of bounds closest point query’
The function getClosestPoint tries to find the closest point to the Vector3 send as parameter that belongs to the navmesh and is in a bounding box. That bounding box size is determined by setDefaultQueryExtent
I guess there is a performance penalty at some point with a large extent size. As that bounding box is used to filter navmesh polygons. So the penalty will depend on the complexity of the navmesh and the size of the box. I didn’t do any performance/stress test so I can tell you if it’s neglectable or not.

OK. Thanks Cedric.
My confusion came from not understanding that the query extent bounding box is centered on the query point (that gets passed to getClosestPoint). Not sure why this didn’t occur to me sooner! For some reason, I thought the query extent was defining a border around the entire navmesh (or something like that).
I drew a picture, in case it helps anyone else.
Can you confirm that this is the right idea?

pg for this picture:

Yes! That’s it. The extent is around query point :slight_smile:

Phew! Many thanks!

1 Like