Lights are now working correctly. Need to update the kernel to account for multiple lights, and add sfEventSubscriber to the LightHandler
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
|
||||
15
src/main.cpp
15
src/main.cpp
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user