Wrestling with the compiler to pass these shared_ptr's
This commit is contained in:
@@ -210,10 +210,10 @@ void Hardware_Caster::create_viewport(int width, int height, float v_fov, float
|
||||
//
|
||||
//}
|
||||
|
||||
void Hardware_Caster::assign_lights(std::vector<LightController::PackedData> *data) {
|
||||
void Hardware_Caster::assign_lights(std::vector<char> *data) {
|
||||
|
||||
// Get a pointer to the packed light data
|
||||
this->lights = data;
|
||||
// this->lights = data;
|
||||
|
||||
light_count = static_cast<int>(lights->size());
|
||||
|
||||
@@ -223,8 +223,6 @@ void Hardware_Caster::assign_lights(std::vector<LightController::PackedData> *da
|
||||
|
||||
create_buffer("light_count", sizeof(int), &light_count);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Hardware_Caster::draw(sf::RenderWindow* window) {
|
||||
|
||||
@@ -1,60 +1,36 @@
|
||||
#pragma once
|
||||
#include "LightController.h"
|
||||
#include "Pub_Sub.h"
|
||||
|
||||
LightController::LightController(std::shared_ptr<RayCaster> raycaster) :
|
||||
raycaster(raycaster) {
|
||||
|
||||
|
||||
|
||||
//packed_index = packed_data.size() / packed_size;
|
||||
}
|
||||
//LightController::LightController(std::shared_ptr<RayCaster> raycaster) {
|
||||
// //:raycaster(raycaster) {
|
||||
//
|
||||
//
|
||||
//
|
||||
// //packed_index = packed_data.size() / packed_size;
|
||||
//}
|
||||
|
||||
LightController::~LightController() {
|
||||
}
|
||||
|
||||
//void LightController::create_light(LightController::PackedData light_data, std::string light_name) {
|
||||
//
|
||||
// //if (light_map.count(light_name) == 1) {
|
||||
// // // light already exists, TODO: error out
|
||||
// // return;
|
||||
// //}
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
//LightHandle LightController::get_light_handle(std::string light_name) {
|
||||
|
||||
//}
|
||||
|
||||
void LightController::set_position(sf::Vector3f position) {
|
||||
|
||||
}
|
||||
|
||||
int LightController::add_static_impulse(sf::Vector3f impulse) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int LightController::add_relative_impulse(DIRECTION impulse_direction, float speed) {
|
||||
|
||||
// No sense in doing fancy dot products, adding Pi's will suffice
|
||||
// Always add PI/2 to X initially to avoid negative case
|
||||
sf::Vector2f dir;
|
||||
|
||||
switch (impulse_direction) {
|
||||
|
||||
case DIRECTION::FORWARD:
|
||||
dir = sf::Vector2f(packed_data_array.at(packed_index).direction_cartesian.y, packed_data_array.at(packed_index).direction_cartesian.x);
|
||||
break;
|
||||
case DIRECTION::REARWARD:
|
||||
dir = sf::Vector2f(packed_data_array.at(packed_index).direction_cartesian.y, packed_data_array.at(packed_index).direction_cartesian.x + PI_F);
|
||||
break;
|
||||
case DIRECTION::LEFT:
|
||||
dir = sf::Vector2f(packed_data_array.at(packed_index).direction_cartesian.y + PI_F + PI_F / 2, PI_F / 2);
|
||||
break;
|
||||
case DIRECTION::RIGHT:
|
||||
dir = sf::Vector2f(packed_data_array.at(packed_index).direction_cartesian.y + PI_F / 2, PI_F / 2);
|
||||
break;
|
||||
case DIRECTION::UP:
|
||||
dir = sf::Vector2f(packed_data_array.at(packed_index).direction_cartesian.y, packed_data_array.at(packed_index).direction_cartesian.x + PI_F / 2);
|
||||
break;
|
||||
case DIRECTION::DOWN:
|
||||
dir = sf::Vector2f(packed_data_array.at(packed_index).direction_cartesian.y + PI_F, (packed_data_array.at(packed_index).direction_cartesian.x * -1) + PI_F / 2);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
//movement += SphereToCart(dir);
|
||||
//movement *= speed;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int LightController::update(double delta_time) {
|
||||
@@ -99,9 +75,9 @@ void LightController::erase_light() {
|
||||
//packed_data.emplace_back(PackedData(position, direction, rgbi));
|
||||
}
|
||||
|
||||
std::vector<LightController::PackedData>* LightController::get_lights() {
|
||||
return &packed_data;
|
||||
}
|
||||
//std::vector<LightController::PackedData>* LightController::get_lights() {
|
||||
// return &packed_data_array;
|
||||
//}
|
||||
|
||||
void LightController::look_at_center() {
|
||||
|
||||
|
||||
18
src/LightHandle.cpp
Normal file
18
src/LightHandle.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "LightHandle.h"
|
||||
|
||||
|
||||
LightHandle::LightHandle() {
|
||||
|
||||
// init an empty light
|
||||
LightController::PackedData data;
|
||||
data.direction_cartesian = sf::Vector3f(0, 0, 0);
|
||||
data.position = sf::Vector3f(0, 0, 0);
|
||||
data.rgbi = sf::Vector4f(0, 0, 0, 0);
|
||||
|
||||
//light_controller.create_light(data, light_name);
|
||||
}
|
||||
|
||||
LightHandle::~LightHandle() {
|
||||
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ void Software_Caster::create_viewport(int width, int height, float v_fov, float
|
||||
|
||||
}
|
||||
|
||||
void Software_Caster::assign_lights(std::vector<LightController::PackedData> *data) {
|
||||
void Software_Caster::assign_lights(std::vector<char> *data) {
|
||||
|
||||
this->lights = data;
|
||||
// this->lights = data;
|
||||
|
||||
int light_count = static_cast<int>(data->size());
|
||||
}
|
||||
|
||||
@@ -130,10 +130,11 @@ int main() {
|
||||
*/
|
||||
|
||||
// Light for the currently non functional Bling Phong shader
|
||||
LightController l(raycaster);
|
||||
std::shared_ptr<RayCaster> asdf;
|
||||
//LightController l(asdf);
|
||||
|
||||
// *links* the lights to the GPU
|
||||
raycaster->assign_lights();
|
||||
//raycaster->assign_lights();
|
||||
|
||||
|
||||
// Load in the spritesheet texture
|
||||
|
||||
Reference in New Issue
Block a user