Did this work?
This commit is contained in:
@@ -34,9 +34,8 @@
|
|||||||
// Srsly people who macro error codes are the devil
|
// Srsly people who macro error codes are the devil
|
||||||
#undef ERROR
|
#undef ERROR
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "FrameWatcher.h"
|
|
||||||
|
|
||||||
class Application: private Gui {
|
class Application {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const int WINDOW_X = 1536;
|
const int WINDOW_X = 1536;
|
||||||
@@ -72,8 +71,6 @@ private:
|
|||||||
Input input_handler;
|
Input input_handler;
|
||||||
std::shared_ptr<WindowHandler> window_handler;
|
std::shared_ptr<WindowHandler> window_handler;
|
||||||
|
|
||||||
FrameWatcher frame_watcher;
|
|
||||||
|
|
||||||
// The sfml imgui wrapper I'm using requires Update be called with sf::Time
|
// The sfml imgui wrapper I'm using requires Update be called with sf::Time
|
||||||
// Might modify it to also accept seconds
|
// Might modify it to also accept seconds
|
||||||
sf::Clock sf_delta_clock;
|
sf::Clock sf_delta_clock;
|
||||||
@@ -93,9 +90,4 @@ private:
|
|||||||
delta_time = 0.0,
|
delta_time = 0.0,
|
||||||
accumulator_time = 0.0,
|
accumulator_time = 0.0,
|
||||||
current_time = 0.0;
|
current_time = 0.0;
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void render_gui() override;
|
|
||||||
virtual void update_gui() override;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -26,7 +26,7 @@ public:
|
|||||||
|
|
||||||
int update(double delta_time);
|
int update(double delta_time);
|
||||||
|
|
||||||
void look_at(sf::Vector3f position);
|
void look_at_center();
|
||||||
|
|
||||||
sf::Vector2f* get_direction_pointer();
|
sf::Vector2f* get_direction_pointer();
|
||||||
sf::Vector3f* get_position_pointer();
|
sf::Vector3f* get_position_pointer();
|
||||||
|
|||||||
@@ -57,12 +57,6 @@ namespace vr {
|
|||||||
NetworkJoystickMoved,
|
NetworkJoystickMoved,
|
||||||
NetworkJoystickConnected,
|
NetworkJoystickConnected,
|
||||||
NetworkJoystickDisconnected,
|
NetworkJoystickDisconnected,
|
||||||
Tick120Seconds,
|
|
||||||
Tick60Seconds,
|
|
||||||
Tick30Seconds,
|
|
||||||
Tick20Seconds,
|
|
||||||
Tick10Seconds,
|
|
||||||
Tick5Seconds,
|
|
||||||
Count
|
Count
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -78,6 +72,8 @@ namespace vr {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Closed : public Event {
|
class Closed : public Event {
|
||||||
public:
|
public:
|
||||||
Closed() : Event(vr::Event::EventType::Closed) {};
|
Closed() : Event(vr::Event::EventType::Closed) {};
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Pub_Sub.h"
|
|
||||||
|
|
||||||
class FrameWatcher : public VrEventPublisher{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
FrameWatcher();
|
|
||||||
~FrameWatcher();
|
|
||||||
|
|
||||||
void do_tick();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
float get_elapsed_time();
|
|
||||||
|
|
||||||
float step_size = 0.0166f;
|
|
||||||
double frame_time = 0.0;
|
|
||||||
double elapsed_time = 0.0;
|
|
||||||
double delta_time = 0.0;
|
|
||||||
double accumulator_time = 0.0;
|
|
||||||
double current_time = 0.0;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -42,7 +42,7 @@ private:
|
|||||||
static std::list<Gui*> renderable_container;
|
static std::list<Gui*> renderable_container;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool rendering = true;
|
bool rendering = false;
|
||||||
// Derived class will handle imgui calls
|
// Derived class will handle imgui calls
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public:
|
|||||||
void consume_vr_events();
|
void consume_vr_events();
|
||||||
|
|
||||||
void handle_held_keys();
|
void handle_held_keys();
|
||||||
|
void dispatch_events();
|
||||||
|
|
||||||
|
|
||||||
virtual void render_gui() override;
|
virtual void render_gui() override;
|
||||||
virtual void update_gui() override;
|
virtual void update_gui() override;
|
||||||
@@ -40,10 +42,6 @@ private:
|
|||||||
static const std::vector<std::string> key_strings;
|
static const std::vector<std::string> key_strings;
|
||||||
|
|
||||||
std::list<std::unique_ptr<vr::Event>> event_queue;
|
std::list<std::unique_ptr<vr::Event>> event_queue;
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void generate_events() override;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowHandler : public VrEventSubscriber {
|
class WindowHandler : public VrEventSubscriber {
|
||||||
|
|||||||
@@ -23,9 +23,13 @@ public:
|
|||||||
void stop_recieving_from_clients();
|
void stop_recieving_from_clients();
|
||||||
|
|
||||||
void generate_events();
|
void generate_events();
|
||||||
|
void dispatch_events();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
std::list<std::unique_ptr<vr::Event>> event_queue;
|
||||||
|
|
||||||
std::vector<sf::TcpSocket*> client_sockets;
|
std::vector<sf::TcpSocket*> client_sockets;
|
||||||
sf::SocketSelector socket_selector;
|
sf::SocketSelector socket_selector;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Event.hpp"
|
#include "Event.hpp"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <list>
|
|
||||||
|
|
||||||
|
|
||||||
class VrEventPublisher;
|
class VrEventPublisher;
|
||||||
@@ -23,19 +22,12 @@ class VrEventPublisher {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~VrEventPublisher() {};
|
virtual ~VrEventPublisher() {};
|
||||||
virtual void subscribe(VrEventSubscriber *subscriber, vr::Event::EventType type) final;
|
virtual void subscribe(VrEventSubscriber *subscriber, vr::Event::EventType type);
|
||||||
virtual void subscribe(VrEventSubscriber *subscriber, std::vector<vr::Event::EventType> type) final;
|
virtual void subscribe(VrEventSubscriber *subscriber, std::vector<vr::Event::EventType> type);
|
||||||
virtual void unsubscribe(VrEventSubscriber *s, vr::Event::EventType c) final;
|
virtual void unsubscribe(VrEventSubscriber *s, vr::Event::EventType c);
|
||||||
|
virtual void notify_subscribers(std::unique_ptr<vr::Event> event);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::map<vr::Event::EventType, std::vector<VrEventSubscriber*>> subscribers;
|
std::map<vr::Event::EventType, std::vector<VrEventSubscriber*>> subscribers;
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void notify_subscribers(std::unique_ptr<vr::Event> event) final;
|
|
||||||
virtual void dispatch_events() final;
|
|
||||||
virtual void generate_events() = 0;
|
|
||||||
std::list<std::unique_ptr<vr::Event>> event_queue;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ __kernel void raycaster(
|
|||||||
bool shadow_ray = false;
|
bool shadow_ray = false;
|
||||||
|
|
||||||
// Andrew Woo's raycasting algo
|
// Andrew Woo's raycasting algo
|
||||||
while (distance_traveled < max_distance && bounce_count < 4) {
|
while (distance_traveled < max_distance && bounce_count < 2) {
|
||||||
|
|
||||||
// Fancy no branch version of the logic step
|
// Fancy no branch version of the logic step
|
||||||
face_mask = intersection_t.xyz <= min(intersection_t.yzx, intersection_t.zxy);
|
face_mask = intersection_t.xyz <= min(intersection_t.yzx, intersection_t.zxy);
|
||||||
@@ -387,7 +387,6 @@ __kernel void raycaster(
|
|||||||
voxel_data = 5;
|
voxel_data = 5;
|
||||||
voxel.xyz -= voxel_step.xyz * face_mask.xyz;
|
voxel.xyz -= voxel_step.xyz * face_mask.xyz;
|
||||||
first_strike = mix(fog_color, voxel_color, 1.0 - max(distance_traveled / 700.0f, (float)0));
|
first_strike = mix(fog_color, voxel_color, 1.0 - max(distance_traveled / 700.0f, (float)0));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -538,10 +537,10 @@ __kernel void raycaster(
|
|||||||
texture_atlas,
|
texture_atlas,
|
||||||
convert_int2(tile_face_position * convert_float2(*atlas_dim / *tile_dim)) +
|
convert_int2(tile_face_position * convert_float2(*atlas_dim / *tile_dim)) +
|
||||||
convert_int2((float2)(3, 4) * convert_float2(*atlas_dim / *tile_dim))
|
convert_int2((float2)(3, 4) * convert_float2(*atlas_dim / *tile_dim))
|
||||||
).xyz/4;
|
).xyz/2;
|
||||||
|
|
||||||
voxel_color -= 0.3f;
|
voxel_color.w += 0.3f;
|
||||||
max_distance = 700;
|
max_distance = 500;
|
||||||
distance_traveled = 0;
|
distance_traveled = 0;
|
||||||
|
|
||||||
float3 hit_pos = convert_float3(voxel) + face_position;
|
float3 hit_pos = convert_float3(voxel) + face_position;
|
||||||
|
|||||||
@@ -110,43 +110,17 @@ bool Application::game_loop() {
|
|||||||
|
|
||||||
// Time keeping
|
// Time keeping
|
||||||
elapsed_time = elap_time();
|
elapsed_time = elap_time();
|
||||||
|
|
||||||
// time between this and the last frame
|
|
||||||
delta_time = elapsed_time - current_time;
|
delta_time = elapsed_time - current_time;
|
||||||
|
|
||||||
// Setup the time for the next tick
|
|
||||||
current_time = elapsed_time;
|
current_time = elapsed_time;
|
||||||
|
|
||||||
// If the delta exceeded 0.2f, then limit the max lag we'll allow
|
|
||||||
// 1 / float is how you get the fps. 0.2f == 5fps
|
|
||||||
if (delta_time > 0.2f)
|
if (delta_time > 0.2f)
|
||||||
delta_time = 0.2f;
|
delta_time = 0.2f;
|
||||||
|
|
||||||
// Add the the physics accumulator our delta
|
|
||||||
accumulator_time += delta_time;
|
accumulator_time += delta_time;
|
||||||
|
|
||||||
// We want to keep our physics at a constant step size but we have a variable frame rate.
|
|
||||||
// 0.016 == physics preferred timestep
|
|
||||||
// 0.030 == average 30 fps frame rate
|
|
||||||
// we must run the physics step ~twice every render frame to keep consistency
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
while ((accumulator_time - step_size) >= step_size) {
|
while ((accumulator_time - step_size) >= step_size) {
|
||||||
|
|
||||||
|
|
||||||
count++;
|
|
||||||
accumulator_time -= step_size;
|
accumulator_time -= step_size;
|
||||||
|
|
||||||
// do physics at step size rate
|
|
||||||
|
|
||||||
for (int i = 0; i < 1000; i++) {
|
|
||||||
int x = 9;
|
|
||||||
int r = i + x * 4;
|
|
||||||
current_time = elapsed_time;
|
|
||||||
}
|
|
||||||
// ==== DELTA TIME LOCKED ====
|
// ==== DELTA TIME LOCKED ====
|
||||||
}
|
}
|
||||||
std::cout << count << "\n";
|
|
||||||
// ==== FPS LOCKED ====
|
// ==== FPS LOCKED ====
|
||||||
|
|
||||||
window->clear(sf::Color::Black);
|
window->clear(sf::Color::Black);
|
||||||
@@ -172,6 +146,94 @@ bool Application::game_loop() {
|
|||||||
fps.draw();
|
fps.draw();
|
||||||
|
|
||||||
Gui::do_render();
|
Gui::do_render();
|
||||||
|
|
||||||
|
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar;
|
||||||
|
bool window_show = true;
|
||||||
|
|
||||||
|
|
||||||
|
if (ImGui::BeginMenuBar())
|
||||||
|
{
|
||||||
|
if (ImGui::BeginMenu("Menu"))
|
||||||
|
{
|
||||||
|
ImGui::Button("asdoifjasodif");
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Begin("Window");
|
||||||
|
ImGui::InputText("filename", screenshot_buf, 128);
|
||||||
|
if (ImGui::Button("Take Screen shot")) {
|
||||||
|
|
||||||
|
std::string path = "../assets/";
|
||||||
|
std::string filename(screenshot_buf);
|
||||||
|
filename += ".png";
|
||||||
|
|
||||||
|
sf::Texture window_texture;
|
||||||
|
window_texture.create(window->getSize().x, window->getSize().y);
|
||||||
|
window_texture.update(*window);
|
||||||
|
|
||||||
|
sf::Image image = window_texture.copyToImage();
|
||||||
|
image.saveToFile(path + filename);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::NextColumn();
|
||||||
|
|
||||||
|
if (ImGui::Button("Pause")) {
|
||||||
|
|
||||||
|
paused = !paused;
|
||||||
|
|
||||||
|
if (paused)
|
||||||
|
Logger::log("Pausing", Logger::LogLevel::INFO);
|
||||||
|
else
|
||||||
|
Logger::log("Unpausing", Logger::LogLevel::INFO);
|
||||||
|
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
|
||||||
|
|
||||||
|
ImGui::Begin("Controller debugger");
|
||||||
|
|
||||||
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
|
static ImVec4 col = ImVec4(1.0f, 0.0f, 1.0f, 1.0f);
|
||||||
|
const ImVec2 p = ImGui::GetCursorScreenPos();
|
||||||
|
const ImU32 col32 = ImColor(col);
|
||||||
|
|
||||||
|
std::vector<float> axis_values = {
|
||||||
|
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::X) / 2,
|
||||||
|
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::Y) / 2,
|
||||||
|
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::U) / 2,
|
||||||
|
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::R) / 2,
|
||||||
|
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::Z) / 2,
|
||||||
|
sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::V) / 2
|
||||||
|
};
|
||||||
|
|
||||||
|
ImGui::Columns(3, "Axis's"); // 4-ways, with border
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::Text("X Y"); ImGui::NextColumn();
|
||||||
|
ImGui::Text("U R"); ImGui::NextColumn();
|
||||||
|
ImGui::Text("Z V"); ImGui::NextColumn();
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
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);
|
||||||
|
draw_list->AddLine(ImVec2(p.x + 50 + offset * i, p.y + 0), ImVec2(p.x + 50 + offset * i, p.y + 100), col32, 1.0);
|
||||||
|
draw_list->AddCircleFilled(ImVec2(p.x + axis_values[2 * i] + 50 + offset * i, p.y + axis_values[2 * i + 1] + 50), 6, col32, 32);
|
||||||
|
|
||||||
|
ImGui::Dummy(ImVec2(100, 100));
|
||||||
|
ImGui::NextColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
|
||||||
|
//ImGui::ShowTestWindow();
|
||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
// ImGUI messes up somthing in the SFML GL state, so we need a single draw call to right things
|
// ImGUI messes up somthing in the SFML GL state, so we need a single draw call to right things
|
||||||
@@ -195,40 +257,3 @@ float Application::elap_time() {
|
|||||||
return static_cast<float>(elapsed_time.count());
|
return static_cast<float>(elapsed_time.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::render_gui() {
|
|
||||||
|
|
||||||
ImGui::Begin("Window");
|
|
||||||
ImGui::InputText("filename", screenshot_buf, 128);
|
|
||||||
if (ImGui::Button("Take Screen shot")) {
|
|
||||||
|
|
||||||
std::string path = "../assets/";
|
|
||||||
std::string filename(screenshot_buf);
|
|
||||||
filename += ".png";
|
|
||||||
|
|
||||||
sf::Texture window_texture;
|
|
||||||
window_texture.create(window->getSize().x, window->getSize().y);
|
|
||||||
window_texture.update(*window);
|
|
||||||
|
|
||||||
sf::Image image = window_texture.copyToImage();
|
|
||||||
image.saveToFile(path + filename);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::NextColumn();
|
|
||||||
|
|
||||||
if (ImGui::Button("Pause")) {
|
|
||||||
|
|
||||||
paused = !paused;
|
|
||||||
|
|
||||||
if (paused)
|
|
||||||
Logger::log("Pausing", Logger::LogLevel::INFO);
|
|
||||||
else
|
|
||||||
Logger::log("Unpausing", Logger::LogLevel::INFO);
|
|
||||||
|
|
||||||
}
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::update_gui() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
|
|||||||
default_impulse = 1.0f;
|
default_impulse = 1.0f;
|
||||||
}
|
}
|
||||||
else if (held_event->code == sf::Keyboard::C) {
|
else if (held_event->code == sf::Keyboard::C) {
|
||||||
look_at(sf::Vector3f(128, 128, 10));
|
look_at_center();
|
||||||
}
|
}
|
||||||
else if (held_event->code == sf::Keyboard::Q) {
|
else if (held_event->code == sf::Keyboard::Q) {
|
||||||
add_relative_impulse(Camera::DIRECTION::DOWN, default_impulse);
|
add_relative_impulse(Camera::DIRECTION::DOWN, default_impulse);
|
||||||
@@ -230,10 +230,9 @@ void Camera::update_gui() {
|
|||||||
rendering = true;
|
rendering = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::look_at(sf::Vector3f position)
|
void Camera::look_at_center() {
|
||||||
{
|
|
||||||
|
|
||||||
direction = CartToNormalizedSphere(position - this->position);
|
direction = CartToNormalizedSphere(sf::Vector3f(60, 60, 35) - position);
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Vector2f* Camera::get_direction_pointer() {
|
sf::Vector2f* Camera::get_direction_pointer() {
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
|
|
||||||
#include "FrameWatcher.h"
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
FrameWatcher::FrameWatcher() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameWatcher::~FrameWatcher()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void FrameWatcher::do_tick() {
|
|
||||||
|
|
||||||
|
|
||||||
elapsed_time = get_elapsed_time();
|
|
||||||
delta_time = elapsed_time - current_time;
|
|
||||||
current_time = elapsed_time;
|
|
||||||
|
|
||||||
if (delta_time > 0.2f)
|
|
||||||
delta_time = 0.2f;
|
|
||||||
|
|
||||||
accumulator_time += delta_time;
|
|
||||||
|
|
||||||
while ((accumulator_time - step_size) >= step_size) {
|
|
||||||
accumulator_time -= step_size;
|
|
||||||
|
|
||||||
// ==== DELTA TIME LOCKED ====
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
float FrameWatcher::get_elapsed_time() {
|
|
||||||
|
|
||||||
static std::chrono::time_point<std::chrono::system_clock> start;
|
|
||||||
static bool started = false;
|
|
||||||
|
|
||||||
if (!started) {
|
|
||||||
start = std::chrono::system_clock::now();
|
|
||||||
started = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now();
|
|
||||||
std::chrono::duration<double> elapsed_time = now - start;
|
|
||||||
return static_cast<float>(elapsed_time.count());
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -112,6 +112,16 @@ void Input::handle_held_keys() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Input::dispatch_events() {
|
||||||
|
|
||||||
|
while (event_queue.size() != 0) {
|
||||||
|
notify_subscribers(std::move(event_queue.front()));
|
||||||
|
event_queue.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Input::render_gui() {
|
void Input::render_gui() {
|
||||||
|
|
||||||
ImGui::Begin("Input Debugger");
|
ImGui::Begin("Input Debugger");
|
||||||
@@ -386,7 +396,4 @@ const std::vector<std::string> Input::key_strings = {
|
|||||||
"Pause"
|
"Pause"
|
||||||
};
|
};
|
||||||
|
|
||||||
void Input::generate_events() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,14 @@ void NetworkInput::recieve_from_clients()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkInput::dispatch_events()
|
||||||
|
{
|
||||||
|
while (event_queue.size() != 0) {
|
||||||
|
notify_subscribers(std::move(event_queue.front()));
|
||||||
|
event_queue.pop_front();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkInput::threaded_client_listener(int port) {
|
void NetworkInput::threaded_client_listener(int port) {
|
||||||
|
|
||||||
listener.listen(port);
|
listener.listen(port);
|
||||||
|
|||||||
@@ -42,10 +42,3 @@ void VrEventPublisher::notify_subscribers(std::unique_ptr<vr::Event> event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VrEventPublisher::dispatch_events() {
|
|
||||||
while (event_queue.size() != 0) {
|
|
||||||
notify_subscribers(std::move(event_queue.front()));
|
|
||||||
event_queue.pop_front();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ void Old_Map::generate_terrain() {
|
|||||||
|
|
||||||
for (int x = dimensions.x / 2; x < dimensions.x / 2 + dimensions.x / 64; x++) {
|
for (int x = dimensions.x / 2; x < dimensions.x / 2 + dimensions.x / 64; x++) {
|
||||||
for (int y = dimensions.x / 2; y < dimensions.y / 2 + dimensions.x / 64; y++) {
|
for (int y = dimensions.x / 2; y < dimensions.y / 2 + dimensions.x / 64; y++) {
|
||||||
for (int z = 5; z < 15; z++) {
|
for (int z = 0; z < 5; z++) {
|
||||||
|
|
||||||
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 6;
|
voxel_data[x + dimensions.x * (y + dimensions.z * z)] = 6;
|
||||||
}
|
}
|
||||||
@@ -249,63 +249,63 @@ void Old_Map::generate_terrain() {
|
|||||||
|
|
||||||
// Hand code in some constructions
|
// Hand code in some constructions
|
||||||
|
|
||||||
//std::vector<std::vector<int>> maze =
|
std::vector<std::vector<int>> maze =
|
||||||
// generate_maze(sf::Vector2i(8, 8), sf::Vector2i(0, 0));
|
generate_maze(sf::Vector2i(8, 8), sf::Vector2i(0, 0));
|
||||||
|
|
||||||
//for (int x = 0; x < maze.size(); x++) {
|
for (int x = 0; x < maze.size(); x++) {
|
||||||
// for (int y = 0; y < maze.at(0).size(); y++) {
|
for (int y = 0; y < maze.at(0).size(); y++) {
|
||||||
//
|
|
||||||
// switch(maze.at(x).at(y)) {
|
switch(maze.at(x).at(y)) {
|
||||||
//
|
|
||||||
// case 1: { // North
|
case 1: { // North
|
||||||
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
|
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
|
||||||
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
||||||
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 5;
|
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 5;
|
||||||
// //voxel_data[x * 3 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
|
//voxel_data[x * 3 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
|
||||||
// //voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
|
//voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// case 2: { // South
|
case 2: { // South
|
||||||
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + dimensions.z * 1)] = 5;
|
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + dimensions.z * 1)] = 5;
|
||||||
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
||||||
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
|
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
|
||||||
// //voxel_data[x * 3 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
|
//voxel_data[x * 3 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
|
||||||
// //voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
|
//voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// case 3: { // East
|
case 3: { // East
|
||||||
// voxel_data[x * 3 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
voxel_data[x * 3 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
||||||
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
||||||
// voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 5;
|
voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 5;
|
||||||
// //voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
|
//voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
|
||||||
// //voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
|
//voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// case 4: { // West
|
case 4: { // West
|
||||||
// voxel_data[x * 3 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 5;
|
voxel_data[x * 3 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 5;
|
||||||
// voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
voxel_data[x * 3 + 1 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
||||||
// voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
voxel_data[x * 3 + 2 + dimensions.x * (y * 3 + 1 + dimensions.z * 1)] = 6;
|
||||||
// //voxel_data[x * 3 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
|
//voxel_data[x * 3 + dimensions.x * (y * 3 + dimensions.z * 1)] = 6;
|
||||||
// //voxel_data[x * 3 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
|
//voxel_data[x * 3 + dimensions.x * (y * 3 + 2 + dimensions.z * 1)] = 6;
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//for (int x = 0; x < dimensions.x; x++) {
|
||||||
|
// for (int y = 0; y < dimensions.y; y++) {
|
||||||
|
// voxel_data[x + dimensions.x * (y + dimensions.z * 1)] = 6;
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
set_voxel(sf::Vector3i(45, 70, 6), 6);
|
||||||
////for (int x = 0; x < dimensions.x; x++) {
|
set_voxel(sf::Vector3i(47, 70, 6), 6);
|
||||||
//// for (int y = 0; y < dimensions.y; y++) {
|
set_voxel(sf::Vector3i(100, 100, 50), 1);
|
||||||
//// voxel_data[x + dimensions.x * (y + dimensions.z * 1)] = 6;
|
|
||||||
//// }
|
|
||||||
////}
|
|
||||||
|
|
||||||
//set_voxel(sf::Vector3i(45, 70, 6), 6);
|
|
||||||
//set_voxel(sf::Vector3i(47, 70, 6), 6);
|
|
||||||
//set_voxel(sf::Vector3i(100, 100, 50), 1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user