Jump to content
  • entries
    945
  • comments
    5,899
  • views
    930,073

Pathfinding


Josh

4,946 views

 Share

It doesn't happen to me much anymore but when I get stuck on a difficult problem, I get very restless and short-tempered. I guess that's the point where most programmers give up on a project. Since I can't physically wrestle code to the ground and give it a good beating Billy Batts style, the fight or flight response probably is not conducive to sitting in front of a piece of glass and figuring out code. On the other hand, I have a tendency to get difficult things done, no matter how hard they are. Maybe a more patient programmer in the same situation would be too patient to produce useful output under his own volition.

 

My understanding of how recast works is it turns upwards-facing triangles into a grid, then uses that grid to construct a navigation mesh. The results seem very robust, but the fundamental approach is an approximation. It is possible to construct a perfectly accurate navigation mesh out of CSG solids, because they have volumetric properties an arbitrary polygon soup does not. On the other hand, my instinct says people will prefer an approximation that works with any arbitrary geometry over a mathematically correct solution that requires constructive solid geometry.

 

Another approach is to simply let the user construct the navigation mesh in the editor. Since the pieces need to be convex, a CSG editor is ideal for this. This also has the possibility of adding more advanced functionality like climbing up walls and jumping. (This is how Left 4 Dead 2 works.) Still, I know people will value a pretty-good solution that works with arbitrary polygon geometry more, and that gets into a land of approximations I don't really have any experience with. I suspect it would involve a lot of adjustments and fine-tuning to get the desired results.

 

You can see here, the results are definitely an approximation, but they're a pretty good one:

blogentry-1-0-43372100-1314126154_thumb.jpg

 

So here are the options I am looking at:

1. Hire someone with existing knowledge of recast to write the implementation.

2. Find someone with existing knowledge of recast and work off their knowledge to write the implementation myself.

3. Stare at incomprehensible code for days on end and hope that somehow imparts knowledge of how to use the library. Maybe other people can understand this, but I am awful at deciphering other people's code.

4. Write my own polygon-based solution.

5. Write my own CSG-based solution.

 

I think the CSG-based solution is the best technical choice, but I think it would cause a lot of complaints. It's fine for Valve, but I think a lot of people would just get mad if I tried to explain why arbitrary triangle meshes have no volumetric properties.

 

Another frightening thing about recast is that from what I am reading, a lot of people are using the demo application as a tool to generate their navmesh data, and just loading the saved files that produces in their own game. That's completely unacceptable. We need to be able to generate this data in our own editor. I know it's possible, but the lack of people able to do this is an indication of the difficulty of the task.

 

The pathfinding stuff is actually the last bit of research I have to complete before I know how everything in Leadwerks3D works. The rest is just a matter of hard work, but all the unknown factors we started with will be resolved.

 

blogentry-1-0-28901500-1314122480_thumb.png

 Share

20 Comments


Recommended Comments

I would think that your time would be more valuable in getting other parts of the upcoming game engine polished.

 

Marley's Ghost and myself have both created reasonably solid libraries in a reasonable amount of time, both in C# and Lua varieties. I would think with your advanced knowledge, and the assistance of the community, you could create an entirely custom pathing system that is optimized for your engine!

Link to comment

I'd say get in touch with this guy: http://www.arongranberg.com/unity/a-pathfinding/ and see if he'd want to do it.

 

His Unity implementation is pretty nice, offers good performance and a bunch of features including grid based, point based, imported navmesh and recast based navmesh generation.

 

I like having the option of using different types, as navmeshes are very performant if you don't need to change it at runtime, but grid based is a lot faster to update if you need to dynamically add obstacles at runtime.

 

Multithreading is also a huge plus, since I usually don't care if a path takes a couple frames to solve, as long as it doesn't impact framerate while it's solving.

 

Anyways, just my two cents, which isn't worth much in this economy.

 

P.S. I *think* recast works by voxelizing the poly mesh then generating a navmesh that fits that. But that's just the impression I got from reading something somewhere and may be totally incorrect.

Link to comment

I vote a mix of 1 and 2. Hire someone to do it, but make sure they knowledge transfer to you so you can maintain it.

 

I would think that your time would be more valuable in getting other parts of the upcoming game engine polished.

 

I view pathfinding as a critical piece in any game engine. I'm using a grid based Lua library, you and Marley have libraries, Pixel wrote his own editor even, but think of the time you put into those. Would be so much easier (and cheaper if your time is worth money) if Josh has it in the new LE. If people did all that for learning purposes then that's cool, but I'd prefer to just use a library built into the engine myself.

Link to comment

P.S. I *think* recast works by voxelizing the poly mesh then generating a navmesh that fits that. But that's just the impression I got from reading something somewhere and may be totally incorrect.

Yeah, but 2D voxels are just a fancy way of saying a grid.

Link to comment

Yes, but those are all node or grid based, are they not?

 

 

A* is A* its an algorithm .. nothing more nothing less. Nodes, Waypoints, Grids, names and addresses, towns and roads and Navmeshes are just what can be used to create the data that makes up the graph that it uses. Recast makes a navmesh its Detour that does the pathfinding and spatial reasoning. A tile map is a collection of grids, waypoints are a collection of linked nodes and a navmesh is a collection of polygons. tile or waypoint or ploygon makes no difference essentially they are all just a collection of nodes with connection information. All I am doing currently is experimenting with different ways to assemble that graph data. The A* remains unchanged except for the interface between it and the data.

Link to comment

Okay, I have a large amount of navmesh generation code compiling. It's nowhere near working, but I have learned some things.

 

The most important thing to understand is that recast is NOT a library; It's an open-source program. The code doing the heavy lifting is very impressive, but this thing was not designed as a general library with commands to be called from an external program. You've got to extract the parts of the program you want, and try to comment out all the calls to things you don't want, like OpenGL rendering, the GUI, etc.

Link to comment

I can't assist on code but what I learned the last two years is that you can't do everything on your own. I used to try to do everything on my own too but at a certain point this is just unproductive. I COULD do high-poly trees for projects myself but its just more cost efficient if I buy a library and invest this free time in other things.

 

Same with outsourcing to freelancers. Before you get mad with recast hire someone if you can afford him and invest this time other LE3 work. Imagine what you can do in 6 months if you outsource this problem. :)

Link to comment

I vote a mix of 1 and 2. Hire someone to do it, but make sure they knowledge you and Marley have libraries, Pixel wrote his own editor even, but think of the time you put into those. Would be so much easier (and cheaper if your time is worth money) if Josh has it in the new LE. If people did all that for learning purposes then that's cool, but I'd prefer to just use a library built into the engine myself.

 

 

I assume Pix wrote his editor to be able to create the graph data for the pathfinding to work on, the A* is the easy bit. My solution in Bmax took a week, 2 days to write the A* as I had no idea what it was and the rest of the time to find a way to generate data from a test level on which it could chew. My Lua A* took a day to write from scratch, with most of that time spent learning Lua, I am now still finding ways to generate the data for a level on which it can chew. This time had to be spent, as LE has no inherent pathfinding. I'd prefer to just use a library built into the engine also, but until there is a version of LE that has that functionality there is not a lot of options.

Link to comment
Guest Red Ocktober

Posted

I would think that your time would be more valuable in getting other parts of the upcoming game engine polished.

 

i agree with Rekindled here... right now we have several options in the mill... this is something that definitely can be added later if you deem it necessary...

 

besides... what's wrong with some decent node based A* pathfinding anyways :)

 

 

--Mike

Link to comment

I'm focusing on the gameplay features first and foremost. Pathfinding and flowgraphs are more important than having another post-processing effect.

Link to comment
Guest Red Ocktober

Posted

I'm focusing on the gameplay features first and foremost. Pathfinding and flowgraphs are more important than having another post-processing effect.

 

not to somone who can add their own gameplay logic and not to someone who really has no interest in joining lines together...

 

and there are plenty of those people here...

 

 

gimme a good post processing effect though, (water was what you were jabbing at)... and, i'll be a sold pony!!!

 

 

but hey, i'll be content to leave all that up to you... seems like you've been making steady progress so far... so...

 

and after all, this is your baby... you know how you want her to turn out...

 

i was just adding my 2 cents to the discussion... as i thought that feedback from the peanut gallery was what this was all about...

 

sorrrrryyyyy... my mistake...

 

--Mike

Link to comment

Right, a lot of people can do that, but the problem is we then branch the code, and each programmer becomes an island. This causes the rate of collaboration to be pretty low.

 

With a built-in navigation system, we can share AI scripts and they will all work together. We can even write different AI scripts and make them battle.

 

In the past, I figured that my job is to provide the graphics and physics foundation on which gameplay is built, and then let the user take over. I don't think that approach has worked out very well, except for a few people who already know how to write games.

Link to comment

I don't think that approach has worked out very well, except for a few people who already know how to write games.

 

Making video games is an interesting thing because the reality is there are many common tasks that the majority of them have. Who plays a video game and thinks that the pathfinding in this game is amazing and really makes this game stand out from others? These tasks just have to not suck instead of being revolutionary.

 

People aren't redesigning entire car engines for each new car because there are parts that are tried and true. The same should be for game engines. It shouldn't be just about making drawing and physics easier, but to provide the tried and true parts of a game.

 

I wouldn't even consider pathfinding a gameplay feature honestly. It's as essential as physics in modern 3D games and generally physics isn't considered gameplay. Bullet time, combat systems, weapons and things of that nature is what I would classify as gameplay and those are the things that make games stand out from each other. Those are the things that I don't think you want to get into the business of making and those are the things that dreaming game designers think of first when they think of a new game. When you dream of your amazing game that you want to make you aren't dreaming about pathfinding or networking code, you are dreaming about the unique gameplay features like the cool kinds of guns you want or the different abilities you want your character to have access too

 

30 years ago maybe pathfinding would be considered a gameplay feature, but I think it's graduated to essential core engine feature.

Link to comment

Just realized this...

 

The pathfinding stuff is actually the last bit of research I have to complete before I know how everything in Leadwerks3D works.

Does this mean you know how to do water/ocean/river like you want to???? :blink: Because I think that was an unresolved challenge some months back, if I remember right and caught all the news.

 

Also, Rick, good point. Some things are simply expected of games, just as they are of engines. People don't notice if they work but they definitely notice if they don't.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...