About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Cloning PathWorld
Author Message
fatcoder Offline
Member

Post: #1
Cloning PathWorld
Is there anyway to clone a PathWorld to make an exact duplicate, or is it possible to add a clone method to PathWorld that returns an exact copy. This is useful for maintaining multiple states of the pathing and obstacles for the world.
11-28-2011 06:04 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Cloning PathWorld
can't you use:
"PathWorld a,b;" ?
11-28-2011 07:52 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #3
RE: Cloning PathWorld
Not sure I follow you there?

What I mean is, when the world loads, you have the default PathWorld for the world. i.e. Game::World.path()

I want to be able to make a clone of this default PathWorld, so I can make changes to the clone (obstacles) without effecting the default PathWorld.

I thought I could do something like this to try and clone the default PathWorld, but I can't seem to get it to work correctly. See two comments in code below.

Code:
PathWorld pw;
pw.create(Game::World.path().areaSize() );
PathSettings ps; // CAN'T ACCESS Game::World.path() PathSettings TO CLONE FROM
for(int x = -10; x <= 10; ++x)
   for(int z = -10; z <= 10; ++z)
   {
      Game::Area* grid = Game::World.areaActive(VecI2(x,z));
      if(!grid) continue;
      Game::Area::Data *data = grid->data();
      PathMesh* pm = new PathMesh;
      pm->create(..., VecI2(x,z),ps); // WHAT DO I USE AS THE TERRAIN MESH
      pw.set(pm,VecI2(x,z));
   }

If you can add a clone() method to PathWorld that does the above correctly and returns the cloned PathWorld, that would be great.
11-29-2011 12:19 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Cloning PathWorld
why do you need this?
11-29-2011 12:26 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #5
RE: Cloning PathWorld
In order to maintain different states of the PathWorld.

For example, in my current project, the user can place objects on the terrain that create an obstacle. However the obstacle only blocks movement for some types of agents. Other types of agents ignore it. So you need two PathWorlds, one with the obstacle and one without. This is the exact problem I'm facing right now.

Another example is when you have different sized agents. For example, the default PathWorld can handle your small agents, but then you might have a larger type of agent as well that cannot fit through some places, so you need a different nav mesh for it. If we can clone the PathWorld using a modified PathSettings we can then path for the larger agent as well.
11-29-2011 12:54 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Cloning PathWorld
1st example, the proper way would be to add obstacles with special flag, and do pathfinding including that flag or not - no clone method needed

2nd example won't go, because path meshes with path settings are generated in world building process - clone method is not enough, secondary PathWorld with all PathMesh'es would need to be created

I will add 1st to the roadmap
12-01-2011 12:00 PM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #7
RE: Cloning PathWorld
OK. The first problem is the one I'm facing right now. I have obstacles that block movement for some agents but not for other types. I have no way to solve this problem at the moment. I didn't know that flags for obstacles would be an option. I look forward to this feature being added. Hopefully sooner rather than later. grin Thanks.
12-01-2011 12:42 PM
Find all posts by this user Quote this message in a reply
Post Reply