Open jfcameron opened 3 years ago
first idea that comes to mind is the standard function pointer + user pointer pattern. before doing that though try to think of more cppy way to do it. it would be nice to avoid a void*
but basically, camera would gain a set_cull_visitor
and entity would gain a set_cull_user_pointer
.
overall i feel like this would be out of place in this otherwise very safety oriented project
opportunity to use std::any?
entity std::any m_cull_data
camera std::function<void(std::any pCullData)> m_cull_functor
Dont add setters, the functor should be provided at construction time. I want to keep things as immutable as possible after construction, its easier to think about and provides opportunity to optimize.
Look into the cost of checking if an any has value and if an any has the expected type. if its expensive then this should be memoized when an entity is added to a scene. e.g: if the entity being added has cull_data then place it in a unordered_map<typeid, unordered_set<shared_ptr
drawing as little as possible is a good idea. I dont want this graphics project to depend on a 3d collision library just to provide culling options. its a different problem. plus there are valid reasons a user would want simpler culling rules. a visitor would allow the user to make their own decisions, they could even pull in a collision library themselves.