Remove object from collisions as well when killing it
This commit is contained in:
parent
5f275081fe
commit
aaaf668616
@ -577,14 +577,21 @@ private:
|
|||||||
void checkKilled() {
|
void checkKilled() {
|
||||||
render_mutex.lock();
|
render_mutex.lock();
|
||||||
std::vector< int > killed;
|
std::vector< int > killed;
|
||||||
|
std::vector< int > killed_collisions;
|
||||||
for ( long unsigned int i = 0; i < renderObjects.size(); i++ ) {
|
for ( long unsigned int i = 0; i < renderObjects.size(); i++ ) {
|
||||||
if ( renderObjects[i]->getKilled() )
|
if ( renderObjects[i]->getKilled() )
|
||||||
killed.push_back( i );
|
killed.push_back( i );
|
||||||
|
if ( i < collisionObjects.size() && collisionObjects[i]->getKilled() )
|
||||||
|
killed_collisions.push_back( i );
|
||||||
}
|
}
|
||||||
std::reverse( killed.begin(), killed.end() );
|
std::reverse( killed.begin(), killed.end() );
|
||||||
|
std::reverse( killed_collisions.begin(), killed_collisions.end() );
|
||||||
for ( auto &index : killed ) {
|
for ( auto &index : killed ) {
|
||||||
renderObjects.erase( renderObjects.begin() + index );
|
renderObjects.erase( renderObjects.begin() + index );
|
||||||
}
|
}
|
||||||
|
for ( auto &index : killed_collisions ) {
|
||||||
|
collisionObjects.erase( collisionObjects.begin() + index );
|
||||||
|
}
|
||||||
render_mutex.unlock();
|
render_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user