Fixed LNK2019
This commit is contained in:
parent
e8919dbe86
commit
bed8eef97c
@ -1,68 +0,0 @@
|
|||||||
#include "KeyInput.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
std::vector<KeyInput*> KeyInput::instances;
|
|
||||||
glm::vec2 KeyInput::cursorPos;
|
|
||||||
glm::vec2 KeyInput::mouseScroll;
|
|
||||||
|
|
||||||
KeyInput::KeyInput(const std::vector<int>& keysToMonitor)
|
|
||||||
{
|
|
||||||
for (int key : keysToMonitor)
|
|
||||||
keys[key] = false;
|
|
||||||
// Add this instance to the list of instances
|
|
||||||
KeyInput::instances.push_back(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyInput::~KeyInput()
|
|
||||||
{
|
|
||||||
// Remove this instance from the list of instances
|
|
||||||
instances.erase(std::remove(instances.begin(), instances.end(), this), instances.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool KeyInput::isKeyDown(int key)
|
|
||||||
{
|
|
||||||
std::map<int, bool>::iterator it = keys.find(key);
|
|
||||||
if (it != keys.end())
|
|
||||||
return keys[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyInput::setKeyDown(int key, bool isDown)
|
|
||||||
{
|
|
||||||
std::map<int, bool>::iterator it = keys.find(key);
|
|
||||||
if (it != keys.end())
|
|
||||||
keys[key] = isDown;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyInput::setupCallbacks(GLFWwindow*& window)
|
|
||||||
{
|
|
||||||
glfwSetKeyCallback(window, KeyInput::keyCallback);
|
|
||||||
glfwSetCursorPosCallback(window, KeyInput::cursorPosCallback);
|
|
||||||
glfwSetMouseButtonCallback(window, KeyInput::mouseButtonCallBack);
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyInput::keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
|
||||||
{
|
|
||||||
// Send key event to all KeyInput instances
|
|
||||||
for (KeyInput* keyInput : instances)
|
|
||||||
keyInput->setKeyDown(key, action != GLFW_RELEASE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyInput::mouseButtonCallBack(GLFWwindow* window, int button, int action, int mods)
|
|
||||||
{
|
|
||||||
// Send key event to all KeyInput instances
|
|
||||||
for (KeyInput* keyInput : instances)
|
|
||||||
keyInput->setKeyDown(button, action != GLFW_RELEASE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyInput::cursorPosCallback(GLFWwindow* window, double xpos, double ypos)
|
|
||||||
{
|
|
||||||
cursorPos.x = xpos;
|
|
||||||
cursorPos.y = ypos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyInput::scrollCallback(GLFWwindow* window, double xoffset, double yoffset)
|
|
||||||
{
|
|
||||||
mouseScroll.x = xoffset;
|
|
||||||
mouseScroll.y = yoffset;
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
// The naming conventions of this project do not seems to be 100% clear
|
|
||||||
// but I guess that member functions start with a uppercase letters and
|
|
||||||
// functions with lowercase
|
|
||||||
class KeyInput
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::map<int, bool> keys;
|
|
||||||
static std::vector<KeyInput*> instances;
|
|
||||||
public:
|
|
||||||
static glm::vec2 cursorPos;
|
|
||||||
static glm::vec2 mouseScroll;
|
|
||||||
public:
|
|
||||||
/// This takes in a vector containing all keys that should be monitord by this instance
|
|
||||||
KeyInput(const std::vector<int>& keysToMonitor);
|
|
||||||
~KeyInput();
|
|
||||||
bool isKeyDown(int key);
|
|
||||||
// This function should only be called once after OpenGL and glfw are all set up and ready to go
|
|
||||||
static void setupCallbacks(GLFWwindow*& window);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setKeyDown(int key, bool isDown);
|
|
||||||
static void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
|
||||||
static void mouseButtonCallBack(GLFWwindow* window, int button, int action, int mods);
|
|
||||||
static void cursorPosCallback(GLFWwindow* window, double xpos, double ypos);
|
|
||||||
static void scrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
|
||||||
};
|
|
@ -6,8 +6,10 @@ Physics::RaycastResult Physics::Raycast(const glm::vec3 startPos, const glm::vec
|
|||||||
{
|
{
|
||||||
float currentDistance = 0;
|
float currentDistance = 0;
|
||||||
|
|
||||||
while (currentDistance < maxDistance)
|
std::cout << "Start raycast" << std::endl;
|
||||||
|
while (currentDistance < maxDistance) // This needs optinazion asap I will chnage this to do a dda traversal
|
||||||
{
|
{
|
||||||
|
std::cout << "Step" << std::endl;
|
||||||
currentDistance += Physics::RAY_STEP;
|
currentDistance += Physics::RAY_STEP;
|
||||||
if (currentDistance > maxDistance)
|
if (currentDistance > maxDistance)
|
||||||
currentDistance = maxDistance;
|
currentDistance = maxDistance;
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
#include "NoiseSettings.h"
|
#include "NoiseSettings.h"
|
||||||
#include "SurfaceFeature.h"
|
#include "SurfaceFeature.h"
|
||||||
#include "ChunkData.h"
|
#include "ChunkData.h"
|
||||||
#include "glm/glm.hpp"
|
|
||||||
|
|
||||||
namespace WorldGen
|
namespace WorldGen
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user