<commit_before>#include "scene/perspectivecamera.hpp"

#include "glload/gl_3_2.h"

#include <glm/gtc/matrix_transform.hpp>

#include "scene/scenegroup.hpp"

using namespace scene;

const glm::vec3 PerspectiveCamera::up(0.0f, 1.0f, 0.0f);

const float positionUpdate = 10;
const float directionUpdate = 1;

char PerspectiveCamera::keyPressed = NO_KEY_PRESSED;

PerspectiveCamera::PerspectiveCamera(SceneGroup* myWorld) : world(myWorld) {
}

void PerspectiveCamera::rescale(int width, int height) {
	glViewport(0, 0, width, height);

	//HOR+
	//The approximate field of view of a human eye is 95° out, 75° down, 60° in, 60° up
	projection = glm::perspective<float>(60.0f, static_cast<float>(width)/height, 0.3f, 200.0f);

	viewProjection = projection * view;
}

void PerspectiveCamera::changeCameraPosition(glm::vec3 position, glm::vec3 direction) {
	glm::vec3 lookAtCenter =  position + direction;

	view = glm::lookAt<float>(position, lookAtCenter, glm::vec3(0.0f, 1.0f, 0.0f));

	viewProjection = projection * view;
}

void PerspectiveCamera::render() {
	world->visitScene([this](std::unique_ptr<SceneItem>& child) {
		child->render(viewProjection);
	});
}

void PerspectiveCamera::update() {
	switch(keyPressed) {
		case UP_KEY_PRESSED:
			updateDirection(directionUpdate, 1, 0, 0);
			break;
		case DOWN_KEY_PRESSED:
			updateDirection(-directionUpdate, 1, 0, 0);
			break;
		case LEFT_KEY_PRESSED:
			updateDirection(directionUpdate, 0, 0, 1);
			break;
		case RIGHT_KEY_PRESSED:
			updateDirection(-directionUpdate, 0, 0, 1);
			break;
		case W_KEY_PRESSED:
			updatePosition(0, 0, -positionUpdate);
			break;
		case A_KEY_PRESSED:
			updatePosition(-positionUpdate, 0, 0);
			break;
		case S_KEY_PRESSED:
			updatePosition(0, 0, positionUpdate);
			break;
		case D_KEY_PRESSED:
			updatePosition(positionUpdate, 0, 0);
			break;
		case PAGEUP_KEY_PRESSED:
			updatePosition(0, positionUpdate, 0);
			break;
		case PAGEDOWN_KEY_PRESSED:
			updatePosition(0, -positionUpdate, 0);
			break;
		default:
			;
	}<commit_msg>Rotate around the y-axis on left/right instead of z... :P<commit_after>#include "scene/perspectivecamera.hpp"

#include "glload/gl_3_2.h"

#include <glm/gtc/matrix_transform.hpp>

#include "scene/scenegroup.hpp"

using namespace scene;

const glm::vec3 PerspectiveCamera::up(0.0f, 1.0f, 0.0f);

const float positionUpdate = 10;
const float directionUpdate = 1;

char PerspectiveCamera::keyPressed = NO_KEY_PRESSED;

PerspectiveCamera::PerspectiveCamera(SceneGroup* myWorld) : world(myWorld) {
}

void PerspectiveCamera::rescale(int width, int height) {
	glViewport(0, 0, width, height);

	//HOR+
	//The approximate field of view of a human eye is 95° out, 75° down, 60° in, 60° up
	projection = glm::perspective<float>(60.0f, static_cast<float>(width)/height, 0.3f, 200.0f);

	viewProjection = projection * view;
}

void PerspectiveCamera::changeCameraPosition(glm::vec3 position, glm::vec3 direction) {
	glm::vec3 lookAtCenter =  position + direction;

	view = glm::lookAt<float>(position, lookAtCenter, glm::vec3(0.0f, 1.0f, 0.0f));

	viewProjection = projection * view;
}

void PerspectiveCamera::render() {
	world->visitScene([this](std::unique_ptr<SceneItem>& child) {
		child->render(viewProjection);
	});
}

void PerspectiveCamera::update() {
	switch(keyPressed) {
		case UP_KEY_PRESSED:
			updateDirection(directionUpdate, 1, 0, 0);
			break;
		case DOWN_KEY_PRESSED:
			updateDirection(-directionUpdate, 1, 0, 0);
			break;
		case LEFT_KEY_PRESSED:
			updateDirection(directionUpdate, 0, 1, 0);
			break;
		case RIGHT_KEY_PRESSED:
			updateDirection(-directionUpdate, 0, 1, 0);
			break;
		case W_KEY_PRESSED:
			updatePosition(0, 0, -positionUpdate);
			break;
		case A_KEY_PRESSED:
			updatePosition(-positionUpdate, 0, 0);
			break;
		case S_KEY_PRESSED:
			updatePosition(0, 0, positionUpdate);
			break;
		case D_KEY_PRESSED:
			updatePosition(positionUpdate, 0, 0);
			break;
		case PAGEUP_KEY_PRESSED:
			updatePosition(0, positionUpdate, 0);
			break;
		case PAGEDOWN_KEY_PRESSED:
			updatePosition(0, -positionUpdate, 0);
			break;
		default:
			;
	}
{'fraction_non_alphanumeric': 0.1270772238514174, 'fraction_numerical': 0.03176930596285435, 'mean_word_length': 5.099850968703428, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2113283', 'n_tokens_mistral': 1683, 'n_tokens_neox': 1449, 'n_words': 323}