partway through some documentation and bug fixing

This commit is contained in:
2018-02-17 01:08:31 -08:00
parent 176d9f7a54
commit 51be54c964
11 changed files with 146 additions and 38 deletions

View File

@@ -30,22 +30,22 @@ bool Application::init_clcaster() {
abort();
map = std::make_shared<Map>(MAP_X);
sf::Image bitmap = map->GenerateHeightBitmap(sf::Vector3i(MAP_X, MAP_Y, MAP_Z));
// TODO: Implement this
sf::Image bitmap = map->GenerateHeightBitmap(sf::Vector3i(MAP_X, MAP_Y, MAP_Z));
map->ApplyHeightmap(bitmap);
map->octree.CastRayOctree(sf::Vector2f(1.57f, 0.0001f), sf::Vector3f(0.5f, 0.5f, 0.5f));
//map->octree.CastRayOctree(sf::Vector2f(1.57f, 0.0001f), sf::Vector3f(0.5f, 0.5f, 0.5f));
// TODO: Consolidate this to one call
raycaster->assign_octree(map);
raycaster->assign_map(map);
// Create a new camera with (starting position, direction)
camera = std::make_shared<Camera>(
sf::Vector3f(3.5f, 3.5f, 3.5f),
sf::Vector2f(1.57f, 0.0f),
sf::Vector3f(3.5f, 3.5f, 3.5f), // Starting position
sf::Vector2f(1.57f, 0.0f), // Direction
window.get()
);
// *link* the camera to the GPU
raycaster->assign_camera(camera);
// Generate and send the viewport to the GPU. Also creates the viewport texture
@@ -63,7 +63,6 @@ bool Application::init_clcaster() {
light_handle = light_controller->create_light(prototype);
// Load in the spritesheet texture
if (!spritesheet.loadFromFile("../assets/textures/minecraft_tiles.png"))
Logger::log("Failed to load spritesheet from file", Logger::LogLevel::WARN);
raycaster->create_texture_atlas(&spritesheet, sf::Vector2i(16, 16));

View File

@@ -8,11 +8,10 @@ CLCaster::~CLCaster() {
//release_camera();
//release_octree();
//clReleaseKernel(kernel_map.at("raycaster"));
// clReleaseProgram()
//clReleaseProgram()
//release_viewport();
delete[] viewport_matrix;
delete[] viewport_image;
delete[] viewport_image;
camera.reset();
@@ -720,13 +719,19 @@ bool CLCaster::compile_kernel(std::string kernel_source, bool is_path, std::stri
return false;
}
// Try and build the program
// "-cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations"
// need a ref to the oct dimensions
//std::string oct_dimensions = std::to_string(map->getDimensions().x);
std::string build_string = "-DOCTDIM=" + std::to_string(Application::MAP_X) + " -cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations";
std::stringstream build_string_stream;
// walk the settings index's and add them to the defines
for (auto i: settings_index_map){
build_string_stream << " -D" << i.first << "=" << std::to_string(i.second);
}
build_string_stream << "-DOCTDIM=" << std::to_string(Application::MAP_X);
build_string_stream << " -cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations";
std::string build_string = build_string_stream.str();
error = clBuildProgram(program, 1, &device_id, build_string.c_str(), NULL, NULL);
// Check to see if it error'd out

View File

@@ -65,11 +65,11 @@ int Camera::slew_camera(sf::Vector2f input) {
return 1;
}
void Camera::set_camera(sf::Vector2f input) {
void Camera::set_camera_direction(sf::Vector2f input) {
direction = input;
}
void Camera::set_camera(sf::Vector3f input) {
void Camera::set_camera_direction(sf::Vector3f input) {
direction = CartToNormalizedSphere(input);
}
@@ -101,10 +101,10 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
auto held_event = static_cast<vr::KeyHeld*>(event.get());
if (held_event->code == sf::Keyboard::LShift) {
default_impulse = 0.01f;
setSpeed(0.01f);
}
else if (held_event->code == sf::Keyboard::RShift) {
default_impulse = 1.0f;
setSpeed(0.3f);
}
else if (held_event->code == sf::Keyboard::C) {
look_at_center();
@@ -151,7 +151,6 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
vr::MouseMoved *mouse_event = static_cast<vr::MouseMoved*>(event.get());
//deltas = fixed - sf::Mouse::getPosition();
deltas = fixed - sf::Vector2i(mouse_event->x, mouse_event->y);
if (deltas != sf::Vector2i(0, 0) && mouse_enabled == true) {
@@ -271,7 +270,7 @@ sf::Vector2f Camera::get_direction() {
}
void Camera::setSpeed(float speed) {
default_impulse = speed;;
default_impulse = speed;
}
float Camera::getSpeed() {

View File

@@ -147,7 +147,6 @@ void Input::render_gui() {
for (int i = 0; i < 3; i++) {
float offset = ImGui::GetColumnWidth(i);
draw_list->AddLine(ImVec2(p.x + 0 + offset * i, p.y + 50), ImVec2(p.x + 100 + offset * i, p.y + 50), col32, 1.0);
@@ -284,8 +283,7 @@ void Input::transpose_sf_events(std::list<sf::Event> sf_event_queue) {
break;
};
default: {
std::cout << "Event not recognized";
abort();
Logger::log("Event not recognized", Logger::LogLevel::WARN);
break;
}
}

View File

@@ -3,14 +3,53 @@
#include "Pub_Sub.h"
/**
* Subscriber
*/
VrEventSubscriber::~VrEventSubscriber() {
// Cycles through the publishers we're subscribed to
for (auto const& publisher : subscriptions) {
// And one by one remove the EventTypes we're subscribed to
for (auto event_type: publisher.second) {
publisher.first->unsubscribe(this, event_type);
}
}
}
void VrEventSubscriber::subscribe_to_publisher(VrEventPublisher* publisher, vr::Event::EventType type) {
publisher->subscribe(this, type);
subscriptions[publisher].push_back(type);
}
void VrEventSubscriber::subscribe_to_publisher(VrEventPublisher* publisher, std::vector<vr::Event::EventType> type) {
publisher->subscribe(this, type);
subscriptions[publisher].insert(subscriptions[publisher].end(), type.begin(), type.end());
}
void VrEventSubscriber::unsubscribe(VrEventPublisher* publisher, vr::Event::EventType type){
}
/**
* Publisher
*/
VrEventPublisher::~VrEventPublisher() {
// Cycle through the subscribers that are listening to us
for (auto const& subscriber_bucket : subscribers) {
// And one by one remove the
for (auto subscriber: subscriber_bucket.second){
subscriber.
}
}
}
void VrEventPublisher::subscribe(VrEventSubscriber *subscriber, vr::Event::EventType type) {
@@ -42,3 +81,4 @@ void VrEventPublisher::notify_subscribers(std::unique_ptr<vr::Event> event) {
}
}