You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.8 KiB

#include "LightController.h"
#include "LightHandle.h"
#include <numeric>
LightController::LightController(std::shared_ptr<Hardware_Caster> raycaster) : packed_data_array(reserved_count), open_list(reserved_count) {
std::iota(open_list.begin(), open_list.end(), 0);
raycaster->assign_lights(&packed_data_array);
}
LightController::~LightController() {
}
std::unique_ptr<LightHandle> LightController::create_light(LightPrototype light_prototype) {
unsigned int index = open_list.front();
open_list.pop_front();
std::unique_ptr<PackedData> data(&packed_data_array.at(index));
std::unique_ptr<LightHandle> handle(new LightHandle(this, index, light_prototype, std::move(data)));
return handle;
}
void LightController::remove_light(unsigned int light_index) {
// Sanitization is currently handled by the light handler
open_list.push_front(light_index);
}
void LightController::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) {
if (event.get()->type == vr::Event::KeyHeld) {}
else if (event->type == vr::Event::KeyPressed) {}
else if (event->type == vr::Event::MouseMoved) {}
else if (event->type == vr::Event::JoystickMoved) {
vr::JoystickMoved *joystick_event = static_cast<vr::JoystickMoved*>(event.get());
if (joystick_event->axis == sf::Joystick::Axis::X) {
//movement.x -= joystick_event->position / 5;
//add_relative_impulse(Camera::DIRECTION::FORWARD, joystick_event->position);
}
else if (joystick_event->axis == sf::Joystick::Axis::Y) {
//movement.y += joystick_event->position / 5;
//add_relative_impulse(Camera::DIRECTION::RIGHT, joystick_event->position);
}
//else if (joystick_event->axis == sf::Joystick::Axis::Z) {
// add_relative_impulse(Camera::DIRECTION::DOWN, joystick_event->position);
//}
}
}