[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/worldmap path_graph.cxx,1.14,1.15 pat
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/worldmap path_graph.cxx,1.14,1.15 path_graph.hxx,1.6,1.7 pathfinder.hxx,1.10,1.11 |
Date: |
16 Oct 2002 09:14:47 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/worldmap
In directory dark:/tmp/cvs-serv32403/worldmap
Modified Files:
path_graph.cxx path_graph.hxx pathfinder.hxx
Log Message:
- added pathfinding cache for worldmap
- put some stuff in the blitter class where it belongs
Index: path_graph.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/path_graph.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- path_graph.cxx 15 Oct 2002 23:56:17 -0000 1.14
+++ path_graph.cxx 16 Oct 2002 09:14:45 -0000 1.15
@@ -56,6 +56,12 @@
cur = cur->next;
cur = XMLhelper::skip_blank(cur);
}
+
+ // Init the pathfinder cache
+ pathfinder_cache.resize(graph.max_node_handler_value());
+ for(PFinderCache::iterator i = pathfinder_cache.begin();
+ i != pathfinder_cache.end(); ++i)
+ *i = 0;
}
void
@@ -187,9 +193,14 @@
PathfinderResult
PathGraph::get_path(NodeId start_id, NodeId end_id)
{
- // FIXME: This could get cached by the node
- Pathfinder<Dot*, Path*> pathfinder(graph, start_id);
- return pathfinder.get_result(end_id);
+ Pathfinder<Dot*,Path*>*& pfinder = pathfinder_cache[start_id];
+
+ if (!pfinder)
+ {
+ pfinder = new Pathfinder<Dot*, Path*>(graph, start_id);
+ }
+
+ return pfinder->get_result(end_id);
}
EdgeId
Index: path_graph.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/path_graph.hxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- path_graph.hxx 15 Oct 2002 19:13:33 -0000 1.6
+++ path_graph.hxx 16 Oct 2002 09:14:45 -0000 1.7
@@ -45,6 +45,8 @@
Graph<Dot*, Path*> graph;
std::vector<Dot*> dots;
+ typedef std::vector<Pathfinder<Dot*, Path*>* > PFinderCache;
+ PFinderCache pathfinder_cache;
private:
// FIXME: This could/should probally be moved inside the graph (or not?!)
Index: pathfinder.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/pathfinder.hxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- pathfinder.hxx 15 Oct 2002 21:58:50 -0000 1.10
+++ pathfinder.hxx 16 Oct 2002 09:14:45 -0000 1.11
@@ -76,6 +76,7 @@
std::vector<NodeStat> stat_graph;
public:
+ /** Find pathes to all other nodes, by starting from the node \a s */
Pathfinder (Graph<T, C>& g, NodeId s)
: graph (g), start (s), open_nodes(CostComp(*this))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/worldmap path_graph.cxx,1.14,1.15 path_graph.hxx,1.6,1.7 pathfinder.hxx,1.10,1.11,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src blitter.cxx,1.16,1.17 blitter.hxx,1.8,1.9 pingus_resource.cxx,1.18,1.19 smallmap.cxx,1.24,1.25
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src blitter.cxx,1.17,1.18 indexed_canvas.cxx,1.1,1.2 indexed_canvas.hxx,1.1,1.2
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src blitter.cxx,1.16,1.17 blitter.hxx,1.8,1.9 pingus_resource.cxx,1.18,1.19 smallmap.cxx,1.24,1.25
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src blitter.cxx,1.17,1.18 indexed_canvas.cxx,1.1,1.2 indexed_canvas.hxx,1.1,1.2
- Index(es):