#include <id_table.h>
Collaboration diagram for IdTable< T >:

Public Methods | |
| void | eraseAll () |
| int | add (const T &s) |
| Adds a T to the universe. More... | |
| void | kill (int id) |
| Pushes a T onto the delete queue for future deletion. More... | |
| T * | getById (int id) |
| Returns the ID of this T given the name. More... | |
| void | updateDeleteList () |
| Removes all units on the delete queue and kills them foreverer. More... | |
| void | draw () |
| Goes through the mesh-sorted draw list in order and renders the Ts to screen. More... | |
| void | update () |
| Gets the command from each AI and attempts to follow said command if possible (obstacles/other Ts willing). More... | |
| template<class Coll> void | collideWithOther (Coll *coll, int surface, double minRadius, double maxRadius) |
| Goes through bolt list and checks them against each mesh. FIXME combine somehow with update. More... | |
| void | collideWithBolts () |
| Goes through bolt list and checks them against each mesh. FIXME combine somehow with update. More... | |
| void | fixCollideOrder () |
| void | collideWithSame () |
| Goes through all other T s ( Spectre or Bolt )s inside of this table and Collides them against each other. More... | |
Protected Methods | |
| bool | del (int id) |
| Erases a T from the maps, freeing all memory do not do this during list traversal. More... | |
Private Types | |
| typedef MutableSet< T, MeshIdLess > | MeshMapClass |
| A map that will store each T in texture-sorted, mesh-sorted order. More... | |
| typedef KeyMutableSet< typename T::CollideKey, T, CollideKeyLess > | CollideMapClass |
| typedef Hashtable< int, T *, 65535 > | IdMap |
Private Methods | |
| void | incrementAndCheck (typename CollideMapClass::iterator &iter) |
Private Attributes | |
| std::vector< int > | deleteQueue |
| MeshMapClass | meshMap |
| This class has the physical copy of the memory itself, stored in mesh-sorted order. More... | |
| IdMap | idMap |
| A pointer to the mesh that is stored previously hashed on the ID int. More... | |
| CollideMapClass | collideMap |
| A pointer to the T sorted by surface then by radius. More... | |
|
|||||
|
|
|
|||||
|
|
|
|||||
|
A map that will store each T in texture-sorted, mesh-sorted order.
|
|
||||||||||
|
Adds a T to the universe.
00076 {
00077 static int numgen=0;
00078 typename MeshMapClass::iterator iter= meshMap.insert(s);
00079 T *collidableToInsert=&(*iter).get();
00080 collideMap.insert(collidableToInsert);
00081 collidableToInsert->setId(numgen++);
00082 idMap.Put(collidableToInsert->getId(),collidableToInsert);
00083 return collidableToInsert->getId();
00084 }
|
|
|||||||||
|
Goes through bolt list and checks them against each mesh. FIXME combine somehow with update.
00124 {
00125 //lower_bound!!!
00126 IdTable<Bolt> *btable=&world->surfaces[0]->boltField;//Just in case.
00127 typename CollideMapClass::iterator thisiter=collideMap.begin();
00128 for (;
00129 thisiter!=collideMap.end();
00130 ++thisiter) {
00131 const typename T::CollideKey &collideKey = ((*thisiter)->getCollideKey());
00132 int surface=collideKey.surface;
00133 btable=&world->surfaces[surface]->boltField;
00134 T * c = (*thisiter);
00135 float cRadius=c->getRadius();
00136 btable->collideWithOther(c,surface,collideKey.radius-fudgeFactor-cRadius,collideKey.radius+fudgeFactor+cRadius);
00137 }
00138 }
|
|
||||||||||||||||||||||||||||
|
Goes through bolt list and checks them against each mesh. FIXME combine somehow with update.
00114 {
00115 typename CollideMapClass::iterator othiter;
00116 typename T::CollideKey collideKey (surface,minRadius);
00117 othiter=this->collideMap.lower_bound(collideKey);
00118 while (othiter!=this->collideMap.end()&&(*othiter)->getCollideKey().radius<=maxRadius) {
00119 (*othiter)->collide(coll);
00120 ++othiter;
00121 }
00122 }
|
|
|||||||||
|
Goes through all other T s ( Spectre or Bolt )s inside of this table and Collides them against each other.
00145 {
00146 for (typename CollideMapClass::iterator thisiter=collideMap.begin();
00147 thisiter!=collideMap.end();
00148 ++thisiter) {
00149 const typename T::CollideKey &collideKey = ((*thisiter)->getCollideKey());
00150 for (typename CollideMapClass::iterator backward=thisiter;;) {
00151 if (backward==collideMap.begin())
00152 break;
00153 --backward;
00154 const typename T::CollideKey &backCollideKey = ((*backward)->getCollideKey());
00155 if ((backCollideKey.radius<(collideKey.radius-fudgeFactor-(2 * (*thisiter)->getRadius())))||(backCollideKey.surface!=collideKey.surface)) {
00156 break;
00157 }
00158 (*thisiter)->collide(*backward);
00159 }
00160 bool reachedthisiter=false;
00161 typename CollideMapClass::iterator otheriter=thisiter;
00162 ++otheriter;
00163 for (;otheriter!=collideMap.end();++otheriter) {
00164 const typename T::CollideKey &forwardCollideKey = ((*otheriter)->getCollideKey());
00165 if (forwardCollideKey.radius>(collideKey.radius+fudgeFactor+(2 * (*thisiter )->getRadius()))||forwardCollideKey.surface!=collideKey.surface) {
00166 break;
00167 }
00168 (*thisiter)->collide(*otheriter);
00169 }
00170 }
00171 }
|
|
||||||||||
|
Erases a T from the maps, freeing all memory do not do this during list traversal.
00045 {
00046 using std::vector;
00047 T *spec=idMap.Get(id);
00048 if (!spec) {
00049 return false;
00050 }
00051 idMap.Delete(id);
00052 {
00053 typename CollideMapClass::iterator iter=collidemap.find(spec->getCollideKey());
00054 while (iter!=collidemap.end()) {
00055 if (spec==(*iter).second) {
00056 collidemap.erase(iter);
00057 }
00058 iter++;
00059 }
00060 }
00061 typename MeshMapClass::iterator iter=meshmap.find(spec);
00062 if (&(*iter)==spec) {
00063 meshmap.erase(iter);
00064 break;
00065 }
00066 return true;
00067 }
|
|
|||||||||
|
Goes through the mesh-sorted draw list in order and renders the Ts to screen.
|
|
|||||||||
|
00069 {
00070 meshMap.clear();
00071 // idMap=IdMap(); //Does not work :-(
00072 collideMap.clear();
00073 deleteQueue.clear();
00074 }
|
|
|||||||||
|
00139 {
00140 for (typename CollideMapClass::iterator thisiter=collideMap.begin();
00141 thisiter!=collideMap.end();
00142 incrementAndCheck(thisiter)) {}
00143 }
|
|
||||||||||
|
Returns the ID of this T given the name.
00090 {
00091 typename IdMap::iterator iter = idMap.find(id);
00092 if (iter!=iter.end()) {
00093 return (*iter).second;
00094 } else {
00095 return NULL;
00096 }
00097 }
|
|
||||||||||
|
00040 {
00041 iter=collideMap.changeKey(iter,(*iter)->recalculateCollideKey());
00042 }
|
|
||||||||||
|
Pushes a T onto the delete queue for future deletion.
00086 {
00087 deleteQueue.push_back (id);
00088 }
|
|
|||||||||
|
Gets the command from each AI and attempts to follow said command if possible (obstacles/other Ts willing).
|
|
|||||||||
|
Removes all units on the delete queue and kills them foreverer.
00103 {
00104 while (!deleteQueue.empty()){
00105 Del (deleteQueue.back());
00106 deleteQueue.pop_back();
00107 }
00108 }
|
|
|||||
|
A pointer to the T sorted by surface then by radius.
|
|
|||||
|
|
|
|||||
|
A pointer to the mesh that is stored previously hashed on the ID int.
|
|
|||||
|
This class has the physical copy of the memory itself, stored in mesh-sorted order.
|
1.2.15