void Collision::Update(void) { int first,second; int g1,g2; Entity *e1,*e2; int a; for(a=0;a<m_collisions.size();a++) delete m_collisions[a]; m_collisions.clear(); for(a=0;a<m_comparegroups.size();a+=2) { g1 = m_comparegroups[a+SRC]; g2 = m_comparegroups[a+DST]; for(first=0;first<m_groups[g1].size();first++) { // Get the ptr to the entity itself e1 = m_groups[g1][first]; // Detect whether the entity is active or not if(e1->GetActive() == true){ CalculateBox(e1,SRC); for(second=0;second<m_groups[g2].size();second++) { // Get the ptr to the entity itself e2 = m_groups[g2][second]; // Detect whether the entity is active or not if(e2->GetActive() == true){ CalculateBox(e2,DST); // Collision detect both bb's against each other if(Intersect() == true){ CollisionPair *pair = new CollisionPair; pair->GroupID[SRC] = g1; pair->GroupID[DST] = g2; pair->entity[SRC] = e1; pair->entity[DST] = e2; m_collisions.push_back(pair); (this->*CorrectVectors)(e1,e2); } } } } } } }
//================================================================================================= void Terrain::Randomize() { assert(state > 0); RandomizeHeight(0.f, 8.f); RoundHeight(); RoundHeight(); RoundHeight(); CalculateBox(); //RandomizeTexture(); }