SDLPP: Scene - add visitCollisions function
This commit is contained in:
parent
5b96de0d9d
commit
7206dbf7c3
@ -126,7 +126,7 @@ std::vector< std::shared_ptr< RenderObject > > &RenderObject::getColidedWith() {
|
|||||||
void RenderObject::setId( uint64_t input_id ) {
|
void RenderObject::setId( uint64_t input_id ) {
|
||||||
id = input_id;
|
id = input_id;
|
||||||
}
|
}
|
||||||
uint64_t RenderObject::getId() {
|
uint64_t RenderObject::getId() const {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
void RenderObject::setHidden( bool hid ) {
|
void RenderObject::setHidden( bool hid ) {
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
void addColided( std::shared_ptr< RenderObject > &obj );
|
void addColided( std::shared_ptr< RenderObject > &obj );
|
||||||
std::vector< std::shared_ptr< RenderObject > > &getColidedWith();
|
std::vector< std::shared_ptr< RenderObject > > &getColidedWith();
|
||||||
void setId( uint64_t input_id );
|
void setId( uint64_t input_id );
|
||||||
uint64_t getId();
|
uint64_t getId() const;
|
||||||
void setHidden( bool hid );
|
void setHidden( bool hid );
|
||||||
bool getHidden() const;
|
bool getHidden() const;
|
||||||
void destroy();
|
void destroy();
|
||||||
|
@ -107,6 +107,11 @@ Scene::getCollisions( RenderObject &r ) {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
void Scene::visitCollisions( RenderObject &r, Visitor &v ) {
|
||||||
|
for(auto &collision : getCollisions(r)) {
|
||||||
|
collision->visit(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
std::vector< std::shared_ptr< RenderObject > >
|
std::vector< std::shared_ptr< RenderObject > >
|
||||||
Scene::getCollisions( RenderObject &r,
|
Scene::getCollisions( RenderObject &r,
|
||||||
const std::unordered_set< int > &objectIDs ) {
|
const std::unordered_set< int > &objectIDs ) {
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "sdlpp_common.hpp"
|
#include "sdlpp_common.hpp"
|
||||||
#include "sdlpp_renderer.hpp"
|
#include "sdlpp_renderer.hpp"
|
||||||
#include "sdlpp_renderobject.hpp"
|
#include "sdlpp_renderobject.hpp"
|
||||||
|
#include "sdlpp_visitor.hpp"
|
||||||
|
|
||||||
namespace SDLPP {
|
namespace SDLPP {
|
||||||
class SDLPPSCOPE Scene {
|
class SDLPPSCOPE Scene {
|
||||||
@ -28,6 +29,7 @@ public:
|
|||||||
void updateScene();
|
void updateScene();
|
||||||
std::vector< std::shared_ptr< RenderObject > >
|
std::vector< std::shared_ptr< RenderObject > >
|
||||||
getCollisions( RenderObject &r );
|
getCollisions( RenderObject &r );
|
||||||
|
void visitCollisions( RenderObject &r, Visitor &v );
|
||||||
std::vector< std::shared_ptr< RenderObject > >
|
std::vector< std::shared_ptr< RenderObject > >
|
||||||
getCollisions( RenderObject &r,
|
getCollisions( RenderObject &r,
|
||||||
const std::unordered_set< int > &objectIDs );
|
const std::unordered_set< int > &objectIDs );
|
||||||
|
@ -10,7 +10,7 @@ class SDLPPSCOPE RenderObject;
|
|||||||
class SDLPPSCOPE Visitor {
|
class SDLPPSCOPE Visitor {
|
||||||
public:
|
public:
|
||||||
Visitor() {}
|
Visitor() {}
|
||||||
virtual void visit( const RenderObject &obj );
|
virtual void visit( const RenderObject &obj ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace SDLPP
|
} // namespace SDLPP
|
||||||
|
Loading…
Reference in New Issue
Block a user