Lights are now working correctly. Need to update the kernel to account for multiple lights, and add sfEventSubscriber to the LightHandler

master
MitchellHansen 8 years ago
parent 6e0d5814e1
commit e364c5380d

@ -35,6 +35,7 @@ struct PackedData {
position(position), direction_cartesian(direction_cartesian), rgbi(rgbi) {
}
PackedData() {};
~PackedData() {};
sf::Vector4f rgbi;
sf::Vector3f position;
sf::Vector3f direction_cartesian;
@ -50,7 +51,7 @@ public:
LightController(std::shared_ptr<Hardware_Caster> raycaster);
~LightController();
std::unique_ptr<LightHandle> create_light(LightPrototype light_prototype);
std::shared_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;

@ -55,7 +55,7 @@ public:
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, PackedData *const data_reference);
// Reference to the LightController to handle deconstruction and removal using the light_id
LightController *const light_controller_ref;
@ -67,5 +67,5 @@ private:
sf::Vector3f movement;
// Reference to the packed data in the LightController
std::unique_ptr<PackedData> data_reference;
PackedData *const data_reference;
};

@ -1,6 +1,7 @@
#include "LightController.h"
#include "LightHandle.h"
#include <numeric>
#include <SFML/System/Time.hpp>
@ -9,20 +10,22 @@ LightController::LightController(std::shared_ptr<Hardware_Caster> raycaster) : p
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) {
std::shared_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.data()[index]);
PackedData* data = &packed_data_array.data()[index];
std::unique_ptr<LightHandle> handle(new LightHandle(this, index, light_prototype, std::move(data)));
std::shared_ptr<LightHandle> handle(new LightHandle(this, index, light_prototype, data));
return handle;

@ -2,10 +2,8 @@
#include "LightController.h"
LightHandle::LightHandle(LightController *const light_controller, unsigned int light_id, LightPrototype light_prototype, std::unique_ptr<PackedData> data_reference) :
light_controller_ref(light_controller), light_id(light_id) {
data_reference = std::move(data_reference);
LightHandle::LightHandle(LightController *const light_controller, unsigned int light_id, LightPrototype light_prototype, PackedData *const data_reference) :
light_controller_ref(light_controller), light_id(light_id), data_reference(data_reference) {
friction_coefficient = light_prototype.friction;
default_impulse = light_prototype.impulse;
@ -29,6 +27,7 @@ LightHandle::~LightHandle() {
}
void LightHandle::set_friction(float friction)
{

@ -132,17 +132,8 @@ int main() {
sf::Vector3f(-1.0f, -1.0f, -1.5f),
sf::Vector4f(1.0f, 1.0f, 1.0f, 1.0f)
);
std::unique_ptr<LightHandle> handle = light_controller.create_light(prototype);
// Light for the currently non functional Bling Phong shader
//std::unique_ptr<RayCaster> asdf(raycaster);
//LightController light_controller(std::move(raycaster));
// *links* the lights to the GPU
//raycaster->assign_lights();
std::shared_ptr<LightHandle> handle(light_controller.create_light(prototype));
// Load in the spritesheet texture
@ -191,7 +182,7 @@ int main() {
camera->subscribe_to_publisher(&input_handler, vr::Event::EventType::KeyHeld);
camera->subscribe_to_publisher(&input_handler, vr::Event::EventType::KeyPressed);
camera->subscribe_to_publisher(&input_handler, vr::Event::EventType::MouseMoved);
camera->subscribe_to_publisher(&ni, vr::Event::EventType::JoystickMoved);
//camera->subscribe_to_publisher(&ni, vr::Event::EventType::JoystickMoved);
WindowHandler win_hand(&window);
win_hand.subscribe_to_publisher(&input_handler, vr::Event::EventType::Closed);
@ -203,7 +194,7 @@ int main() {
input_handler.consume_sf_events(&window);
input_handler.handle_held_keys();
input_handler.dispatch_events();
ni.dispatch_events();
//ni.dispatch_events();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::F11)) {

Loading…
Cancel
Save