Surface.hpp
This file defines a templated class to represent a 2D suface capable of maintaining data about which 2D bodies are currently on that surface and rapidly identifying if they are overlapping.
BODY_TYPE is the class that represents the body geometry.
Developer Notes:
Should add enums to control boundary conditions (INFINITE, TOROIDAL, BOUNDED)
Incorporate physics? Can have various plug-in modules.
-
template<typename ...BODY_TYPES>
class Surface - #include <Surface.hpp>
Public Functions
-
inline ~Surface()
-
inline double GetWidth() const
-
inline double GetHeight() const
-
inline bool IsActive(size_t id) const
Determine if an id represents an active body on a surface.
-
template<typename ORIGINAL_T>
inline Ptr<ORIGINAL_T> GetPtr(size_t id) const
-
inline double GetRadius(size_t id) const
-
inline size_t GetColor(size_t id) const
-
inline void SetRadius(size_t id, double _in)
-
inline void ScaleRadius(size_t id, double scale)
-
inline void SetColor(size_t id, size_t _in)
-
inline void RemoveBody(size_t id)
-
template<typename BODY_T>
inline size_t AddBody(Ptr<BODY_T> _body, Point _center, double _radius, size_t _color = 0) Add a single body; return its unique ID.
-
template<typename BODY_T>
inline size_t AddBody(BODY_T *_body, Point _center, double _radius, size_t _color = 0) Allow bodies to be provided as raw pointers as well.
-
template<typename BODY1_T, typename BODY2_T>
inline void AddOverlapFun(const std::function<void(BODY1_T&, BODY2_T&)> &overlap_fun) Add a function to call in the case of overlaps (using an std::function object)
-
template<typename BODY1_T, typename BODY2_T>
inline void AddOverlapFun(void (*overlap_fun)(BODY1_T&, BODY2_T&)) Add a function to call in the case of overlaps (using a function pointer)
-
template<typename LAMBDA_T>
inline void AddOverlapFun(const LAMBDA_T &fun) Add a to call a lambda function in the case of overlaps (using a function pointer)
-
inline void FindOverlaps()
-
inline void FindOverlap(BodyInfo &body)
Determine if there are any overlaps with a single provided body (that may or may not be on surface).
-
inline void FindOverlap(size_t body_id)
Public Static Functions
Protected Functions
-
inline void InitSectors()
-
inline void RefreshBodySize()
-
inline void Activate()
Protected Attributes
-
TypeTracker<Ptr<BODY_TYPES>...> type_tracker
The TypeTracker manages pointers to arbitrary surface objects.
-
bool data_active
Are we trying to keep data up-to-date?
-
double max_radius
Largest radius of any body.
-
size_t num_cols
How many cols of sectors are there?
-
size_t num_rows
How many rows of sectors are there?
-
size_t num_sectors
How many total sectors are there?
-
double sector_width
How wide is each sector?
-
double sector_height
How tall is each sector?
-
class BodyInfo
- #include <Surface.hpp>
Public Functions
-
inline BodyInfo(TrackedVar &&_ptr, size_t _id, Point _center, double _radius, size_t _color = 0)
-
inline TrackedVar &GetBodyPtr()
-
inline size_t GetID() const
-
inline double GetRadius() const
-
inline size_t GetColor() const
-
inline void SetRadius(double _in)
-
inline void SetColor(size_t _in)
-
inline bool IsActive() const
-
inline void Deactivate()
-
inline BodyInfo(TrackedVar &&_ptr, size_t _id, Point _center, double _radius, size_t _color = 0)
-
inline ~Surface()