Working group: navigation
by Daniel Buckmaster · in Torque 3D Professional · 06/21/2013 (6:44 pm) · 25 replies
Since I've started porting the Recast Resource to T3D 3.0 with a new code structure and improvements from Walkabout, I thought it might be a good idea to try to sort of convene a small focus group of people who want to work on navigation in T3D.
Sorry, didn't realise the image was that wide!
Even if you're not interested in coding, just editor design and so on, I'd love to have a bit of discussion here about what features we should develop for stock T3D's navigation.
My code at the moment is here, and it was based of Luis's work getting Recast into a separate library module, which was excellent. He submitted basically the entire Recast Resource as published on this site, and I've since redone most of it, basing the NavMesh class's code off Walkabout's code instead. It's also been reorganised a bit.
You'll recognise some changes to the wider engine if you use Walkabout - I added the PLC_Navigation enum to make use of the new geometry loading code. It's strictly not necessary, but makes loading certain difficult object types much nicer.
You may also notice some feature differences. The biggest functional difference is in NavPath: now paths will not automatically update themselves when their NavMesh updates. Also, NavPaths can no longer be 'slices': they always plan instantly. This was because sliced planning wasn't really useful for anything yet.
Also, since I pulled in Walkabout's navmesh generation code (well, the core of it), we now have tiled navmeshes. Which means you can use the script API to rebuild individual tiles. Hurrah!
So there are a few key things I'd like to discuss here.
Have at ye!
Sorry, didn't realise the image was that wide!Even if you're not interested in coding, just editor design and so on, I'd love to have a bit of discussion here about what features we should develop for stock T3D's navigation.
My code at the moment is here, and it was based of Luis's work getting Recast into a separate library module, which was excellent. He submitted basically the entire Recast Resource as published on this site, and I've since redone most of it, basing the NavMesh class's code off Walkabout's code instead. It's also been reorganised a bit.
You'll recognise some changes to the wider engine if you use Walkabout - I added the PLC_Navigation enum to make use of the new geometry loading code. It's strictly not necessary, but makes loading certain difficult object types much nicer.
You may also notice some feature differences. The biggest functional difference is in NavPath: now paths will not automatically update themselves when their NavMesh updates. Also, NavPaths can no longer be 'slices': they always plan instantly. This was because sliced planning wasn't really useful for anything yet.
Also, since I pulled in Walkabout's navmesh generation code (well, the core of it), we now have tiled navmeshes. Which means you can use the script API to rebuild individual tiles. Hurrah!
Okay
So there are a few key things I'd like to discuss here.
- Editor workflow. Using the console to build navmeshes all the time is nasty.
- Pathing features. Should we try bring sliced pathfinding back? Automatic path replanning?
- Script API for tile rebuilds. Walkabout has a bit of this going on, and we should look into something similar.
- Advanced Recast/Detour features. Off-mesh links, crowds, area painting, dynamic obstacles, etc.
Have at ye!
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
Initially, I'd like to make this stuff as little-dependent on the editor as possible. For example, now that navmeshes can be built tile-by-tile in the background, I'd like to have the navmesh automatically rebuild itself whenever you unselect it in the editor. So if you select it, change its position, scale it a bit, the unselect it, it will update automatically. I also want to make it such that adding or dragging shapes in the editor triggers an update for the tiles that are affected.
This means the workflow becomes very simple, and the navmesh keeps itself up-to-date automatically. Of course, if we wanted to add features like jump links and area painting, we'd have to look into a dedicated nav editor like Walkabout's, and that'd definitely benefit from being developed alongside an AI editor.
The problem is, every game's AI will be so unique that coming up with a generic editor sounds very complex - or, like we could develop an editor that is so generic it's pretty much useless. The same goes for navigation, unfortunately, but I think pathfinding is similar enough among a lot of game types that we should be able to make better progress.
EDIT: personally, I'm kind of waiting to see what happens to Jeff Raab's behavior/component system. I think that will cause a lot of change in T3D's editors if it becomes widely adopted, and I think it should be part of any AI system that is stock in T3D.
06/21/2013 (10:10 pm)
By automatic, do you mean replanning when the navmesh changes, or planning when the path is first created? The former I removed because the API was messy, and we should decide on a standard as a community. The latter I removed because it made the NavPath API unclear - it seems better to have an explicit call to plan() so you know for sure when the path will be available.Initially, I'd like to make this stuff as little-dependent on the editor as possible. For example, now that navmeshes can be built tile-by-tile in the background, I'd like to have the navmesh automatically rebuild itself whenever you unselect it in the editor. So if you select it, change its position, scale it a bit, the unselect it, it will update automatically. I also want to make it such that adding or dragging shapes in the editor triggers an update for the tiles that are affected.
This means the workflow becomes very simple, and the navmesh keeps itself up-to-date automatically. Of course, if we wanted to add features like jump links and area painting, we'd have to look into a dedicated nav editor like Walkabout's, and that'd definitely benefit from being developed alongside an AI editor.
The problem is, every game's AI will be so unique that coming up with a generic editor sounds very complex - or, like we could develop an editor that is so generic it's pretty much useless. The same goes for navigation, unfortunately, but I think pathfinding is similar enough among a lot of game types that we should be able to make better progress.
EDIT: personally, I'm kind of waiting to see what happens to Jeff Raab's behavior/component system. I think that will cause a lot of change in T3D's editors if it becomes widely adopted, and I think it should be part of any AI system that is stock in T3D.
#3
Thx for all your work.
06/25/2013 (11:19 am)
I need more time to play with recast, but i want to contribute to Torque AI/Navigation stuff.Thx for all your work.
#4
06/25/2013 (8:09 pm)
Awesome. Are you interested in any parts in particular?
#5
Yes I was talking about automatic replanning when the navmesh changes. Honestly you are more of a expert in the area than I am, so I think you would have a better more thought out plan for how things should work. I totally agree that it should be done with or in parallel to Jeff's behavior system. The behavior system should be basic. Maybe something like having the ability to create a new datablock for the AI. Set up things like predefined visual states, Simple actions, High-level actions like fighting enemy with different types of weapon (melee or distant), chase/flee enemy, patrol territory, wandering around. A sensor system allows AI entity to emulate eyesight and hearing in the virtual environment.
These are things MOST if not all games would use, so it's not gerne specific. That way the Navigation part would take care of the pathfinding. Actually guidebot's system would be a good place to look at for a NavMesh and AI behavior editor.
This is a related topic but should things like dynamic cover points be handled?
06/25/2013 (9:00 pm)
@Daniel,Yes I was talking about automatic replanning when the navmesh changes. Honestly you are more of a expert in the area than I am, so I think you would have a better more thought out plan for how things should work. I totally agree that it should be done with or in parallel to Jeff's behavior system. The behavior system should be basic. Maybe something like having the ability to create a new datablock for the AI. Set up things like predefined visual states, Simple actions, High-level actions like fighting enemy with different types of weapon (melee or distant), chase/flee enemy, patrol territory, wandering around. A sensor system allows AI entity to emulate eyesight and hearing in the virtual environment.
These are things MOST if not all games would use, so it's not gerne specific. That way the Navigation part would take care of the pathfinding. Actually guidebot's system would be a good place to look at for a NavMesh and AI behavior editor.
This is a related topic but should things like dynamic cover points be handled?
#6
I guess important events to consider are:
Disclaimer: if any owners of Walkabout are worried about me being so blase disclosing information about its insides, and porting features to MIT3D: don't panic. I'm treating the two projects as very separate beasts. Walkabout is all about the editor, advanced features like coverpoint generation, and total integration (for example, AIPlayer::setPathDestination). This MIT port is about solid basics, providing a platform for other people to work on, and modifying the rest of T3D as little as possible. Improvements will be ported in both directions, but I'll rarely be grabbing code wholesale out of Walkabout for MIT3D. (Exceptions include support code like the debug drawer, recastPolyList, etc.)
Kory: that makes sense. I guess a good first port of call would be to ensure we have a complete list of desired basic functionality in pathfinding. For example, following a path defined by waypoints in the level.
I also think a lot of this functionality should be implemented in scripts - for example, path following - but I'd like to wait and see what Mike's modular templates look like first. When they happen, we should focus on creating a pathfinding script module that adds common features like that.
Also, while we're here, we should probably ensure we fix all the bugs that need to be fixed from the RR. Off the top of my head:
If someone coomes up with an automatic coverpoint generation solution, then you could simply remove all the cover points in the tile and regenerate them.
ALso on the to-do list should be properly multi-threading the build process, rather than just spreading it out over multiple ticks.
Recast resource, because I keep needing to find it and Google isn't helping.
06/25/2013 (11:43 pm)
Heh, fair enough - I guess once the basic pull-request is submitted I'll start to work on some additional features like that, propose them, and see what people think. Basically, in the original resource (and still a bit in Walkabout, unfortunately) the navmesh event API was very unclear and a bit ad-hoc: I just added in whatever events I needed to make stuff work, without any forethought.I guess important events to consider are:
- A single tile has been rebuilt (this event might be fired during gameplay)
- The entire navmesh has been rebuilt (avoids having a spam of individual rebuild messages; will probably only happen when the editor is running)
Disclaimer: if any owners of Walkabout are worried about me being so blase disclosing information about its insides, and porting features to MIT3D: don't panic. I'm treating the two projects as very separate beasts. Walkabout is all about the editor, advanced features like coverpoint generation, and total integration (for example, AIPlayer::setPathDestination). This MIT port is about solid basics, providing a platform for other people to work on, and modifying the rest of T3D as little as possible. Improvements will be ported in both directions, but I'll rarely be grabbing code wholesale out of Walkabout for MIT3D. (Exceptions include support code like the debug drawer, recastPolyList, etc.)
Kory: that makes sense. I guess a good first port of call would be to ensure we have a complete list of desired basic functionality in pathfinding. For example, following a path defined by waypoints in the level.
I also think a lot of this functionality should be implemented in scripts - for example, path following - but I'd like to wait and see what Mike's modular templates look like first. When they happen, we should focus on creating a pathfinding script module that adds common features like that.
Also, while we're here, we should probably ensure we fix all the bugs that need to be fixed from the RR. Off the top of my head:
- Long paths fail, as pointed out by Steve.
- Terrain is only half built, though this may not be anything to do with the recast code (but we should still try to fix it, if the issue is present with the new meshloader code)
If someone coomes up with an automatic coverpoint generation solution, then you could simply remove all the cover points in the tile and regenerate them.
ALso on the to-do list should be properly multi-threading the build process, rather than just spreading it out over multiple ticks.
Recast resource, because I keep needing to find it and Google isn't helping.
#7
06/26/2013 (9:42 am)
Quote:ALso on the to-do list should be properly multi-threading the build process,And the rest of the engine... lol
#8
Having learned a little more about concurrency since then and having implemented a tiled navmesh the process should be much easier. Now the main thread can parse collision geometry one tile at a time, and add those tiles to a dirty pool. The entire recast process can be performed in a separate thread for each tile (or even among a group of threads that all grab tiles from the pool), and then the data is dumped back into the navmesh in the main thread.
The idea is to do only Recast stuff in the separate thread, sidestepping all Torque's non-multithreadedness.
06/26/2013 (4:03 pm)
Yeah, that was the challenge when I did it originally in the recast resource... I could multithread the navmesh build but nothing else was threadsafe, so if I wanted to, for example, access the bins to parse collision geometry... well, here be dragons.Having learned a little more about concurrency since then and having implemented a tiled navmesh the process should be much easier. Now the main thread can parse collision geometry one tile at a time, and add those tiles to a dirty pool. The entire recast process can be performed in a separate thread for each tile (or even among a group of threads that all grab tiles from the pool), and then the data is dumped back into the navmesh in the main thread.
The idea is to do only Recast stuff in the separate thread, sidestepping all Torque's non-multithreadedness.
#9
To enable the "navigation" module as a selectable module in the Project Manager we'll need to modify the modules list in projects.xml to add a new entry:
07/23/2013 (9:00 am)
Daniel's Recast based pull requests have been merged into the Development branch.To enable the "navigation" module as a selectable module in the Project Manager we'll need to modify the modules list in projects.xml to add a new entry:
<module name="navigation">Recast Navigation</module>Once that is done Recast will show up in the list of module choices. Otherwise you'll need to manually add a line to buildFiles/config/project.conf for each project you want to use Recast with:
includeModule( 'navigation' );
#10
Is there a way to pause the AI updates on individual AI? I have a concept where I possess different AIs in game. I want to be able to have the AI pause when I take over an AI and resume when I leave the AI. I also want to train the AI while I am in possession of the AI and perhaps allow limited AI action. I know this is kind of application specific though.
07/23/2013 (1:02 pm)
@dB,Is there a way to pause the AI updates on individual AI? I have a concept where I possess different AIs in game. I want to be able to have the AI pause when I take over an AI and resume when I leave the AI. I also want to train the AI while I am in possession of the AI and perhaps allow limited AI action. I know this is kind of application specific though.
#11
07/23/2013 (1:18 pm)
Presently using a raw object-to-target distance comparision + script-based comparator callback (several, actually) for comparing weighted distances between multiple targets. If it isn't too heavy weight, might be a good idea to have something similar based on projected navpaths to shore up the one to many end of things.
#12
Demo: not sure what AI updates you're referring to. As in have them stop pathfinding? Just call .stop().
Azaezel: as in finding the shortest path distance to an object? You can do that with navigation by accessing NavPath's .length property for each path to your multiple destinations. But yeah, I've always wanted to add some sort of automatic way to do this.
07/23/2013 (4:05 pm)
Mike: so awesome to hear that :D. I've pull-requested the projects.xml change.Demo: not sure what AI updates you're referring to. As in have them stop pathfinding? Just call .stop().
Azaezel: as in finding the shortest path distance to an object? You can do that with navigation by accessing NavPath's .length property for each path to your multiple destinations. But yeah, I've always wanted to add some sort of automatic way to do this.
#13
I was hoping it was that simple. I am just not very familiar how the system works to begin with. I thought there was more to it.
07/23/2013 (4:40 pm)
@dB,I was hoping it was that simple. I am just not very familiar how the system works to begin with. I thought there was more to it.
#14
Bout freakin time (just kidding)! Grats on working it out. By the way.... Been adding recast to every build I have been making (it is MANY). This path finding solution (if you know how to use it) is AMAZING.
Just cuz not many people say it, and you deserve some recognition. Good work and thanks for your time, I know your time is precious (skilled programmer that you are, not gonna comment on that except for all the 'contact' stuff you have been getting) and honestly, having your skill level and professionalism involved in the MIT project is awesome! Guys like you and Mike and Dave and the new Committee guys will only make T3D a better engine.
Ron
07/23/2013 (4:55 pm)
Daniel,Bout freakin time (just kidding)! Grats on working it out. By the way.... Been adding recast to every build I have been making (it is MANY). This path finding solution (if you know how to use it) is AMAZING.
Just cuz not many people say it, and you deserve some recognition. Good work and thanks for your time, I know your time is precious (skilled programmer that you are, not gonna comment on that except for all the 'contact' stuff you have been getting) and honestly, having your skill level and professionalism involved in the MIT project is awesome! Guys like you and Mike and Dave and the new Committee guys will only make T3D a better engine.
Ron
#16
Demo: I think I understand what you're talking about now. It's honestly totally beyond the scope of navigation - currently T3D has no such thing as an 'AI update'. Pathfinding with this resource is done completely independently of the AIPlayer class, and the found path is followed by a character using the standard Torque AIPlayer scripts (or something similar). If you want your character to stop moving, call .stop() and delete the NavPath they were following. To resume, just find another path to the original destination and start following it.
This is all part of higher-level logic than my pull request provides.
07/24/2013 (1:16 am)
Aw shucks guys :).Demo: I think I understand what you're talking about now. It's honestly totally beyond the scope of navigation - currently T3D has no such thing as an 'AI update'. Pathfinding with this resource is done completely independently of the AIPlayer class, and the found path is followed by a character using the standard Torque AIPlayer scripts (or something similar). If you want your character to stop moving, call .stop() and delete the NavPath they were following. To resume, just find another path to the original destination and start following it.
This is all part of higher-level logic than my pull request provides.
#17
Thanks
Edit: @Azaezel: Yeah ... I maybe should have read the documentation better ... my bad. :)
"Should work out-of-the-box with Torque 3D MIT 3.0." -- *slaps self*
07/24/2013 (1:49 am)
@Daniel: Sorry to butt in here ... tried to mail you but I had some issues. Is Walkabout compatible with Torque 3D MIT? I am a license holder of Walkabout. :)Thanks
Edit: @Azaezel: Yeah ... I maybe should have read the documentation better ... my bad. :)
"Should work out-of-the-box with Torque 3D MIT 3.0." -- *slaps self*
#18
http://www.garagegames.com/community/forums/viewthread/132276
@Daniel: Ahh. Dunno how I overlooked that one. Thanks. Will see how that goes when we're talking upwards of 50-100 potential targets.
07/24/2013 (2:58 am)
@Quinton: It is. Just got a fix for compatibility with the latest, in fact. http://www.garagegames.com/community/forums/viewthread/132276
@Daniel: Ahh. Dunno how I overlooked that one. Thanks. Will see how that goes when we're talking upwards of 50-100 potential targets.
#19
Azaezel, yeah, 50-100 pathfinds in a single tick will push it... go for it though! I'd love to see a good and proper stress test of the system. Unfortunately, if it turns out to be infeasible, there's really not a lot to be done. We could reinstate sliced pathfinding, but that comes with its own issues like needing to write asynchronous code, which souynds like a pain in TS.
07/24/2013 (5:46 am)
For the record, questions about Walkabout should go to the dedicated thread in the addons forum. I'll probably mention Walkabout all the time in this thread because the work is related, but I'd like to keep a clear separation between MIT stuff and Walkabout. As much as is feasible.Azaezel, yeah, 50-100 pathfinds in a single tick will push it... go for it though! I'd love to see a good and proper stress test of the system. Unfortunately, if it turns out to be infeasible, there's really not a lot to be done. We could reinstate sliced pathfinding, but that comes with its own issues like needing to write asynchronous code, which souynds like a pain in TS.
#20
I was thinking there was some kind of AI think hook. I am sorry for the silly questions as I have not looked at the resource.
If you want examples of how to control an asynchronous thread using TS check out my Audio RTT resource. It does this and I believe is a good example of how to control threads processes from script.
07/24/2013 (10:58 am)
@dB,I was thinking there was some kind of AI think hook. I am sorry for the silly questions as I have not looked at the resource.
If you want examples of how to control an asynchronous thread using TS check out my Audio RTT resource. It does this and I believe is a good example of how to control threads processes from script.
Torque Owner Kory Imaginism
innovative imaginations