@ -4,14 +4,28 @@
# include <memory>
# include <memory>
// We need to be able to :
// Light Handle :
// - Allow lights to exist outside the context of a LightController
// - Contains data relating to movement, and a reference to the rbgi, direction, and position
// - i.e we can have a prototype light or similar
// elements in the LightController.
// - Preserve the existence of lights upon object destruction
// - Resultant of the use of LightController.create_light(LightPrototype). Cannot be self instantiated.
// - No need to keep track of an object only used upon special use cases
// - On deconstruction, light data is removed from the LightController and the light disappears
// - Maintain an X*N byte array, X = size of packed data, N = Light number
// - But still allow classes of size Y bytes
// LightPrototype :
// - Preserve X packed bytes in an array which are pointed to by an array of shared pointers
// - Contains the desired starting values for the light. The LightHandler object will then be
// instantiated using this data
// PackedData :
// - We need to single out the data that the GPU needs into a single contiguous
// array. PackedData holds the values for position, direction, and rgbi
// LightController :
// - Contains the PackedData array in a static sized array.
// Empty light slots are set to 0 and still sent over the line
// TODO: This introduces light limits and inefficiencies
// - Contains a factory that takes LightPrototypes and generates unique ptr LightHandles.
// Each light handle is given a light index enabling light removal.
struct LightPrototype ;
struct LightPrototype ;
class LightController ;
class LightController ;
@ -21,29 +35,37 @@ class LightHandle {
public :
public :
// Allow LightController to access this objects constructor for a factory style pattern
friend class LightController ;
friend class LightController ;
~ LightHandle ( ) ;
~ LightHandle ( ) ;
// Functions for movement
void set_friction ( float friction ) ;
void set_friction ( float friction ) ;
void set_impulse ( float impulse ) ;
void set_impulse ( float impulse ) ;
void set_movement ( sf : : Vector3f movement ) ;
void set_movement ( sf : : Vector3f movement ) ;
void add_movement ( sf : : Vector3f movement ) ;
void add_movement ( sf : : Vector3f movement ) ;
// Functions modifying the pointed to data
void set_position ( sf : : Vector3f position ) ;
void set_position ( sf : : Vector3f position ) ;
void set_direction ( sf : : Vector3f direction ) ;
void set_direction ( sf : : Vector3f direction ) ;
void set_rgbi ( sf : : Vector4f rgbi ) ;
void set_rgbi ( sf : : Vector4f rgbi ) ;
// void update(double delta_time);
private :
private :
LightHandle ( LightController * const light_controller , unsigned int light_id , LightPrototype light_prototype , std : : unique_ptr < PackedData > data_reference ) ;
LightHandle ( LightController * const light_controller , unsigned int light_id , LightPrototype light_prototype , std : : unique_ptr < PackedData > data_reference ) ;
// Reference to the LightController to handle deconstruction and removal using the light_id
LightController * const light_controller_ref ;
LightController * const light_controller_ref ;
unsigned int light_id ;
const unsigned int light_id ;
// Movement values provided by the prototype
float friction_coefficient = 0.1f ;
float friction_coefficient = 0.1f ;
float default_impulse = 1.0f ;
float default_impulse = 1.0f ;
sf : : Vector3f movement ;
sf : : Vector3f movement ;
// Reference to the packed data in the LightController
std : : unique_ptr < PackedData > data_reference ;
std : : unique_ptr < PackedData > data_reference ;
} ;
} ;