<commit_before>#include "ModuleEditorCamera.h"
#include "Engine.h"
#include "ModuleInput.h"
#include <MathGeoLib/include/Math/Quat.h>

using namespace math;

ModuleEditorCamera::ModuleEditorCamera()
{
	Frustum.SetPos(float3::zero);
	Frustum.SetFront(-float3::unitZ);
	Frustum.SetUp(float3::unitY);

	SetPlaneDistances(0.1f, 1000.0f);
	
	Frustum.SetKind(FrustumSpaceGL, FrustumRightHanded);

	Frustum.SetVerticalFovAndAspectRatio(DegToRad(60), 1.f);
}

ModuleEditorCamera::~ModuleEditorCamera()
{
}

update_status ModuleEditorCamera::Update()
{
	float3 movement = float3::zero;
	
	float rotateUp = 0;
	float rotateRight = 0;

	if (App->input->GetKey(SDL_SCANCODE_UP))
		rotateUp += 1;
	if (App->input->GetKey(SDL_SCANCODE_DOWN))
		rotateUp -= 1;
	if (App->input->GetKey(SDL_SCANCODE_RIGHT))
		rotateRight -= 1;
	if (App->input->GetKey(SDL_SCANCODE_LEFT))
		rotateRight += 1;

	if (rotateRight != 0)
	{
		Quat rot = Quat::RotateY(DegToRad(rotateRight));

		Frustum.SetFront(rot.Mul(Frustum.Front()).Normalized());
		Frustum.SetUp(rot.Mul(Frustum.Up()).Normalized());
	}

	if (rotateUp != 0.f)
	{
		Quat rot = Quat::RotateAxisAngle(Frustum.WorldRight(), DegToRad(rotateUp));

		float3 up = rot.Mul(Frustum.Up()).Normalized();

		if (up.y > 0.f)
		{
			Frustum.SetFront(rot.Mul(Frustum.Front()).Normalized());
			Frustum.SetUp(up);
		}
	}

	if (App->input->GetKey(SDL_SCANCODE_Q))<commit_msg>Add simple camera movement with mouse<commit_after>#include "ModuleEditorCamera.h"
#include "Engine.h"
#include "ModuleInput.h"
#include <MathGeoLib/include/Math/Quat.h>

using namespace math;

ModuleEditorCamera::ModuleEditorCamera()
{
	Frustum.SetPos(float3::zero);
	Frustum.SetFront(-float3::unitZ);
	Frustum.SetUp(float3::unitY);

	SetPlaneDistances(0.1f, 1000.0f);
	
	Frustum.SetKind(FrustumSpaceGL, FrustumRightHanded);

	Frustum.SetVerticalFovAndAspectRatio(DegToRad(60), 1.f);
}

ModuleEditorCamera::~ModuleEditorCamera()
{
}

update_status ModuleEditorCamera::Update()
{
	float3 movement = float3::zero;
	
	float rotateUp = 0;
	float rotateRight = 0;

	if(App->input->GetMouseButtonDown(SDL_BUTTON_RIGHT))
	{
		iPoint mouse_movement = App->input->GetMouseMotion();
		float2 mouse_drag = { float(mouse_movement.x), float(mouse_movement.y) };

		if(!mouse_drag.IsZero())
			mouse_drag.Normalize();

		LOG("%d, %d", mouse_movement.x, mouse_movement.y);

		rotateUp += -mouse_drag.y;
		rotateRight += -mouse_drag.x;
	}

	if (App->input->GetKey(SDL_SCANCODE_UP))
		rotateUp += 1;
	if (App->input->GetKey(SDL_SCANCODE_DOWN))
		rotateUp -= 1;
	if (App->input->GetKey(SDL_SCANCODE_RIGHT))
		rotateRight -= 1;
	if (App->input->GetKey(SDL_SCANCODE_LEFT))
		rotateRight += 1;

	CLAMP(rotateUp, -1, 1);
	CLAMP(rotateRight, -1, 1);

	if (rotateRight != 0)
	{
		Quat rot = Quat::RotateY(DegToRad(rotateRight));

		Frustum.SetFront(rot.Mul(Frustum.Front()).Normalized());
		Frustum.SetUp(rot.Mul(Frustum.Up()).Normalized());
	}

	if (rotateUp != 0.f)
	{
		Quat rot = Quat::RotateAxisAngle(Frustum.WorldRight(), DegToRad(rotateUp));

		float3 up = rot.Mul(Frustum.Up()).Normalized();

		if (up.y > 0.f)
		{
			Frustum.SetFront(rot.Mul(Frustum.Front()).Normalized());
			Frustum.SetUp(up);
		}
	}

	if (App->input->GetKey(SDL_SCANCODE_Q))
{'fraction_non_alphanumeric': 0.16749533871970168, 'fraction_numerical': 0.01709136109384711, 'mean_word_length': 5.399602385685885, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '4798047', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1283, 'n_words': 176}