Working on lights, I'm conceeding and just using a fixed array. I think it will be faster in the long run, as I won't have to rebind the lights when I add/remove one. Also wrestling with really lame compiler erros with these templated pointers
This commit is contained in:
@@ -4,56 +4,55 @@
|
||||
#include "util.hpp"
|
||||
#include "Pub_Sub.h"
|
||||
#include "raycaster/RayCaster.h"
|
||||
#include "LightHandle.h"
|
||||
#include <list>
|
||||
#include "raycaster/Hardware_Caster.h"
|
||||
|
||||
struct LightPrototype {
|
||||
|
||||
sf::Vector3f position;
|
||||
sf::Vector3f direction_cartesian;
|
||||
sf::Vector4f rgbi;
|
||||
|
||||
sf::Vector3f movement;
|
||||
float impulse = 1.0f;
|
||||
float friction = 1.0f;
|
||||
|
||||
};
|
||||
|
||||
// Packed data structure for passing raw light data to the caster
|
||||
struct PackedData {
|
||||
PackedData(sf::Vector3f position, sf::Vector3f direction_cartesian, sf::Vector4f rgbi) :
|
||||
position(position), direction_cartesian(direction_cartesian), rgbi(rgbi) {
|
||||
}
|
||||
PackedData() {};
|
||||
sf::Vector3f position;
|
||||
sf::Vector3f direction_cartesian;
|
||||
sf::Vector4f rgbi;
|
||||
};
|
||||
|
||||
class LightHandle;
|
||||
class Hardware_Caster;
|
||||
|
||||
class LightController : public VrEventSubscriber {
|
||||
public:
|
||||
|
||||
enum DIRECTION { FORWARD, REARWARD, LEFT, RIGHT, UP, DOWN };
|
||||
|
||||
// Packed data structure for passing raw light data to the caster
|
||||
struct PackedData {
|
||||
PackedData(sf::Vector3f position, sf::Vector3f direction_cartesian, sf::Vector4f rgbi) :
|
||||
position(position), direction_cartesian(direction_cartesian), rgbi(rgbi) {
|
||||
}
|
||||
PackedData() {};
|
||||
sf::Vector3f position;
|
||||
sf::Vector3f direction_cartesian;
|
||||
sf::Vector4f rgbi;
|
||||
};
|
||||
|
||||
// LightController(std::shared_ptr<RayCaster> raycaster);
|
||||
LightController();
|
||||
LightController(std::shared_ptr<Hardware_Caster> raycaster);
|
||||
~LightController();
|
||||
|
||||
//void create_light(LightController::PackedData light_data, std::string light_name);
|
||||
// LightHandle get_light_handle(std::string light_name);
|
||||
|
||||
void set_position(sf::Vector3f position);
|
||||
|
||||
|
||||
int update(double delta_time);
|
||||
|
||||
void look_at_center();
|
||||
std::unique_ptr<LightHandle> create_light(LightPrototype light_prototype);
|
||||
void remove_light(unsigned int light_index);
|
||||
|
||||
void recieve_event(VrEventPublisher* p, std::unique_ptr<vr::Event> event) override;
|
||||
|
||||
void erase_light();
|
||||
//std::vector<LightController::PackedData>* get_lights();
|
||||
private:
|
||||
|
||||
// Set the static arrays size
|
||||
int reserved_count = 8;
|
||||
|
||||
//// Need to allow N byte light class to be packed into 10 byte packets
|
||||
//int packed_size = sizeof(PackedData);
|
||||
|
||||
// Indices available in the light array
|
||||
std::list<unsigned int> open_list;
|
||||
|
||||
std::vector<PackedData> packed_data_array;
|
||||
//
|
||||
//
|
||||
std::unordered_map<std::string, LightHandle> light_map;
|
||||
//
|
||||
//std::shared_ptr<RayCaster> raycaster;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user