About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
PathWorld Contains Shape
Author Message
fatcoder Offline
Member

Post: #1
PathWorld Contains Shape
Is it possible to get a method added to PathWorld that lets you test if it fully contains a Shape in the x,z plane.

Code:
Bool Contains(C Shape &s);

Returns true if the given shape is fully contained within the PathWorld nav mesh. Otherwise returns false if the shape cuts the edge of the nav mesh or is outside the nav mesh.

Even if it could just support some of the basic shapes like Vec, Edge, Box and Circle or Tube for example.
11-15-2011 01:02 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: PathWorld Contains Shape
why not use nearestWall, and check if it's furhter than some radius
11-15-2011 01:05 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #3
RE: PathWorld Contains Shape
Yes, I have been doing this, which works great for a circle shape. It doesn't work properly however with a box shape.
11-16-2011 01:20 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #4
RE: PathWorld Contains Shape
Another problem I've found with just using nearestWall is that you have no way of telling if the point you are testing is inside or outside the nav mesh.

I've tried using nearestSurface, but it doesn't appear to work the way it should. It seems to find a surface point outside of the extents most of the time so is therefore not reliable at all (unless I'm using it wrong).

Basically what I'm trying to do is allow the user to place box and circle shaped objects on the terrain, but only inside the nav mesh. The objects cannot be placed outside the nav mesh. With the current set of methods I don't think this can be achieved.

If it is possible to add a method to check if a single Vec2 point (on the xz plane) is inside the nav mesh, then I believe I can solve the problem for both circles and boxes using a combination of nearestWall, ray and point checks.

Something like this (on PathWorld), which returns true if the point is inside the nav mesh and false if it is outside the nav mesh would be perfect.

Code:
Bool containsPoint(Vec2 point);
11-16-2011 01:30 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: PathWorld Contains Shape
can you measure the distance between given point and the point that nearestSurface returns?
11-16-2011 09:56 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #6
RE: PathWorld Contains Shape
I actually found a way around it using nearestSurface by checking if the returned position.xz matches the desired position.xz within an epsilon (EPS). Seems to do the trick. Your idea would also work and might be cleaner as it would remove the epsilon.

One thing I've noticed with nearestSurface however is that the extent parameter seems to have no effect? Unless I am misunderstanding its use. nearestSurface seems to always return a point regardless of the extent. I'm assuming extent means to limit the range it checks for a nearest surface, but it doesn't do that. Oh well, I guess it is probably a recast bug?

Anyway, this problem doesn't effect my solution but might be a problem for others in the future. If you can confirm there is a recast bug there, it might be worth report on the recast site.

Thanks for your help on this one.
11-17-2011 12:14 AM
Find all posts by this user Quote this message in a reply
Post Reply