Removed the class heirarchy for the raycaster. I was aiming for maximum compatability but realistically, this project will never run at any sort of acceptable speed on the cpu. Also in the previous commit fixed multiple longterm bugs as well as fixed bugs in the event system and made it much safer

This commit is contained in:
MitchellHansen
2017-04-15 01:50:01 -07:00
parent 334a375535
commit a40b5545e8
10 changed files with 5 additions and 454 deletions

View File

@@ -4,7 +4,6 @@
#include <numeric>
#include "util.hpp"
#include "Pub_Sub.h"
#include "raycaster/RayCaster.h"
#include "raycaster/Hardware_Caster.h"
#include "LightHandle.h"

View File

@@ -1,5 +1,4 @@
#pragma once
#include <raycaster/RayCaster.h>
#include <Vector4.hpp>
#include <vector>
#include <iostream>

View File

@@ -1,55 +0,0 @@
#pragma once
#include "Vector4.hpp"
#include <map/Map.h>
#include <SFML/Graphics.hpp>
class Old_Map;
class Camera;
struct PackedData;
class RayCaster {
public:
enum ERROR_CODES {
SHARING_NOT_SUPPORTED = 800,
OPENCL_NOT_SUPPORTED = 801,
OPENCL_ERROR = 802,
ERR = 803
};
RayCaster();
virtual ~RayCaster();
virtual int init() = 0;
virtual void assign_map(Old_Map *map) = 0;
virtual void assign_camera(Camera *camera) = 0;
virtual void create_viewport(int width, int height, float v_fov, float h_fov) = 0;
virtual void assign_lights(std::vector<PackedData> *data) = 0;
virtual void validate() = 0;
// draw will abstract the gl sharing and software rendering
// methods of retrieving the screen buffer
virtual void compute() = 0;
virtual void draw(sf::RenderWindow* window) = 0;
protected:
sf::Sprite viewport_sprite;
sf::Texture viewport_texture;
Old_Map * map = nullptr;
Camera *camera = nullptr;
// std::vector<LightController::PackedData> *lights;
std::vector<PackedData> *lights;
int light_count = 0;
sf::Uint8 *viewport_image = nullptr;
sf::Vector4f *viewport_matrix = nullptr;
sf::Vector2i viewport_resolution;
int error = 0;
};

View File

@@ -1,40 +0,0 @@
#pragma once
#include "raycaster/RayCaster.h"
#include <thread>
#include "map/Old_Map.h"
#include "Camera.h"
struct PackedData;
class Software_Caster : public RayCaster
{
public:
Software_Caster();
virtual ~Software_Caster();
int init() override;
// In interop mode, this will create a GL texture that we share
// Otherwise, it will create the pixel buffer and pass that in as an image, retrieving it each draw
// Both will create the view matrix, view res buffer
void create_viewport(int width, int height, float v_fov, float h_fov) override;
void assign_lights(std::vector<PackedData> *data) override;
void assign_map(Old_Map *map) override;
void assign_camera(Camera *camera) override;
void validate() override;
// draw will abstract the gl sharing and software rendering
// methods of retrieving the screen buffer
void compute() override;
void draw(sf::RenderWindow* window) override;
private:
void cast_viewport();
void cast_thread(int start_id, int end_id);
void cast_ray(int id);
void blit_pixel(sf::Color color, sf::Vector2i position, sf::Vector3i mask);
sf::Color global_light(sf::Color in, sf::Vector3i mask);
};