SDLPP: add collider IDs

This commit is contained in:
2021-04-26 21:57:31 +02:00
parent 19e66bf34a
commit dd6f37264c
16 changed files with 112 additions and 41 deletions
+6 -4
View File
@@ -41,18 +41,20 @@ void RenderObject::setPos( const Vec2D< double > &vec ) {
Vec2D< double > RenderObject::getPos() const {
return original;
}
bool RenderObject::colidesWith( const RenderObject &other ) const {
std::vector< uint64_t >
RenderObject::colidesWith( const RenderObject &other ) const {
if ( !hasCollisions() || !other.hasCollisions() || getHidden() ||
other.getHidden() ) {
return false;
return {};
}
std::vector< uint64_t > ret = {};
for ( const auto &x : collisions ) {
for ( const auto &y : other.getCollisions() ) {
if ( x->colidesWith( *y ) )
return true;
ret.push_back( x->getId() );
}
}
return false;
return ret;
}
bool RenderObject::hasCollisions() const {
return !collisions.empty();