<commit_before>#include "Crown.h"
#include "Terrain.h"
#include <cstdlib>
#include <GL/glew.h>
#include <GL/glu.h>
#include "OS.h"

using namespace crown;

class WndCtrl: public KeyboardListener
{
public:

	WndCtrl()
	{
		GetInputManager()->RegisterKeyboardListener(this);
	}

	void KeyReleased(const KeyboardEvent& event)
	{
		if (event.key == KC_ESCAPE)
		{
			GetDevice()->StopRunning();
		}
	}
};

void DrawCircle(const Vec3& pos, float radius);

class MainScene: public KeyboardListener, public MouseListener
{

public:

	MainScene() :
		optShowSkybox(true),
		optShowCrate(true),
		optShowTerrain(true)
	{
		GetInputManager()->RegisterKeyboardListener(this);
		GetInputManager()->RegisterMouseListener(this);
		mouseRightPressed = false;
		mouseLeftPressed = false;
	}

	~MainScene()
	{
	}

	void KeyReleased(const KeyboardEvent& event)
	{
		if (event.key == '1')
		{
			terrain.PlotCircle(2, 2, 2, 2);
		}

		if (event.key == '2')
		{
			terrain.PlotCircle(4, 4, 4, 2);
		}

		if (event.key == '3')
		{		
			terrain.PlotCircle(8, 8, 8, 2);
		}

		if (event.key == KC_F5)
		{
			terrain.SaveAsBmp("blah.bmp");
		}

		if (event.key == KC_SPACE)
		{
			if (cam)
			{
				cam->SetActive(!cam->IsActive());
			}
		}
	}

	void ButtonPressed(const MouseEvent& event)
	{
		if (event.button == MB_LEFT)
		{
			mouseLeftPressed = true;

			GLint view[4];
			GLdouble proj[16], model[16];

			glGetDoublev(GL_MODELVIEW_MATRIX, model);
			glGetDoublev(GL_PROJECTION_MATRIX, proj);
			glGetIntegerv(GL_VIEWPORT, view);

			int x = event.x;
			int y = event.y;

			// Adjust y wndCoord
			y = (625 - y);

			double sX, sY, sZ;
			double eX, eY, eZ;

			gluUnProject(x, y, 0.0f, model, proj, view, &sX, &sY, &sZ);
			gluUnProject(x, y, 1.0f, model, proj, view, &eX, &eY, &eZ);

			Vec3 dir = Vec3(eX, eY, eZ) - Vec3(sX, sY, sZ);

			dir.normalize();

			//ray.origin = cam->GetPosition();
			ray.direction = dir;

			//std::cout << x << " " << y << std::endl;
			//std::cout << "Ori: " << ray.origin.ToStr().c_str() << std::endl;
			//std::cout << "Dir: " << ray.direction.ToStr().c_str() << std::endl;
		}
		else if (event.button == MB_RIGHT)
		{
			mouseRightPressed = true;
		}
		wheel += event.wheel * 0.25;
	}

	void ButtonReleased(const MouseEvent& event)
	{
		if (event.button == MB_LEFT)
		{
			mouseLeftPressed = false;
		}
		else if (event.button == MB_RIGHT)
		{
			mouseRightPressed = false;
		}
		wheel -= event.wheel * 0.25;
	}
		

	void OnLoad()
	{
		crown::Renderer* renderer = crown::GetDevice()->GetRenderer();
		renderer->SetClearColor(Color4::LIGHTBLUE);

		// Add a movable camera
		cam = new MovableCamera(Vec3::ZERO, Angles::ZERO, true, 90.0f, 1.6f, true, 0.1, 2.5);

		if (cam)
		{
			cam->SetActive(true);
			cam->SetSpeed(0.1);
			cam->SetFarClipDistance(1000.0f);
		}

		// Add a skybox
		skybox = new Skybox(Vec3::ZERO, Angles::ZERO, true);

		if (skybox)
		{
			skybox->SetFace(SF_NORTH,	GetTextureManager()->Load("res/red_north.tga"));
			skybox->SetFace(SF_SOUTH,	GetTextureManager()->Load("res/red_south.tga"));
			skybox->SetFace(SF_EAST,	GetTextureManager()->Load("res/red_east.tga"));
			skybox->SetFace(SF_WEST,	GetTextureManager()->Load("res/red_west.tga"));
			skybox->SetFace(SF_UP,		GetTextureManager()->Load("res/red_up.tga"));
			skybox->SetFace(SF_DOWN,	GetTextureManager()->Load("res/red_down.tga"));
		}

		terrain.CreateTerrain(64, 64, 1, 0.0f);

		grass = GetTextureManager()->Load("res/grass.tga");
		grass->SetFilter(TF_TRILINEAR);

		terrain.PlotCircle(4, 4, 4, 2);

		//terrain.ApplyBrush(32, 32, 1.25f);
		terrain.UpdateVertexBuffer(true);
	}

	void RenderScene()
	{
		Renderer* renderer = GetDevice()->GetRenderer();
<commit_msg>Update terrain sample<commit_after>#include "Crown.h"
#include "Terrain.h"
#include <cstdlib>
#include <GL/glew.h>
#include <GL/glu.h>
#include "OS.h"

using namespace crown;

class WndCtrl: public KeyboardListener
{
public:

	WndCtrl()
	{
		GetInputManager()->RegisterKeyboardListener(this);
	}

	void KeyReleased(const KeyboardEvent& event)
	{
		if (event.key == KC_ESCAPE)
		{
			GetDevice()->StopRunning();
		}
	}
};

void DrawCircle(const Vec3& pos, float radius);

class MainScene: public KeyboardListener, public MouseListener
{

public:

	MainScene() :
		optShowSkybox(true),
		optShowCrate(true),
		optShowTerrain(true)
	{
		GetInputManager()->RegisterKeyboardListener(this);
		GetInputManager()->RegisterMouseListener(this);
		mouseRightPressed = false;
		mouseLeftPressed = false;
	}

	~MainScene()
	{
	}

	void KeyReleased(const KeyboardEvent& event)
	{
		if (event.key == '1')
		{
			terrain.PlotCircle(2, 2, 2, 2);
		}

		if (event.key == '2')
		{
			terrain.PlotCircle(4, 4, 4, 2);
		}

		if (event.key == '3')
		{		
			terrain.PlotCircle(8, 8, 8, 2);
		}

		if (event.key == KC_F5)
		{
			terrain.SaveAsBmp("blah.bmp");
		}

		if (event.key == KC_SPACE)
		{
			if (cam)
			{
				cam->SetActive(!cam->IsActive());
			}
		}
	}

	void ButtonPressed(const MouseEvent& event)
	{
		if (event.button == MB_LEFT)
		{
			mouseLeftPressed = true;

			GLint view[4];
			GLdouble proj[16], model[16];

			glGetDoublev(GL_MODELVIEW_MATRIX, model);
			glGetDoublev(GL_PROJECTION_MATRIX, proj);
			glGetIntegerv(GL_VIEWPORT, view);

			int x = event.x;
			int y = event.y;

			// Adjust y wndCoord
			y = (625 - y);

			double sX, sY, sZ;
			double eX, eY, eZ;

			gluUnProject(x, y, 0.0f, model, proj, view, &sX, &sY, &sZ);
			gluUnProject(x, y, 1.0f, model, proj, view, &eX, &eY, &eZ);

			Vec3 dir = Vec3(eX, eY, eZ) - Vec3(sX, sY, sZ);

			dir.normalize();

			//ray.origin = cam->GetPosition();
			ray.direction = dir;

			//std::cout << x << " " << y << std::endl;
			//std::cout << "Ori: " << ray.origin.ToStr().c_str() << std::endl;
			//std::cout << "Dir: " << ray.direction.ToStr().c_str() << std::endl;
		}
		else if (event.button == MB_RIGHT)
		{
			mouseRightPressed = true;
		}
		wheel += event.wheel * 0.25;
	}

	void ButtonReleased(const MouseEvent& event)
	{
		if (event.button == MB_LEFT)
		{
			mouseLeftPressed = false;
		}
		else if (event.button == MB_RIGHT)
		{
			mouseRightPressed = false;
		}
		wheel -= event.wheel * 0.25;
	}
		

	void OnLoad()
	{
		crown::Renderer* renderer = crown::GetDevice()->GetRenderer();
		renderer->SetClearColor(Color4::LIGHTBLUE);

		// Add a movable camera
		cam = new MovableCamera(Vec3::ZERO, true, 90.0f, 1.6f, true, 0.1, 2.5);

		if (cam)
		{
			cam->SetActive(true);
			cam->SetSpeed(0.1);
			cam->SetFarClipDistance(1000.0f);
		}

		// Add a skybox
		skybox = new Skybox(Vec3::ZERO, true);

		if (skybox)
		{
			skybox->SetFace(SF_NORTH,	GetTextureManager()->Load("res/red_north.tga"));
			skybox->SetFace(SF_SOUTH,	GetTextureManager()->Load("res/red_south.tga"));
			skybox->SetFace(SF_EAST,	GetTextureManager()->Load("res/red_east.tga"));
			skybox->SetFace(SF_WEST,	GetTextureManager()->Load("res/red_west.tga"));
			skybox->SetFace(SF_UP,		GetTextureManager()->Load("res/red_up.tga"));
			skybox->SetFace(SF_DOWN,	GetTextureManager()->Load("res/red_down.tga"));
		}

		terrain.CreateTerrain(64, 64, 1, 0.0f);

		grass = GetTextureManager()->Load("res/grass.tga");
		grass->SetFilter(TF_TRILINEAR);

		terrain.PlotCircle(4, 4, 4, 2);

		//terrain.ApplyBrush(32, 32, 1.25f);
		terrain.UpdateVertexBuffer(true);
	}

	void RenderScene()
	{
		Renderer* renderer = GetDevice()->GetRenderer();

{'fraction_non_alphanumeric': 0.1765829694323144, 'fraction_numerical': 0.02046943231441048, 'mean_word_length': 3.6533333333333333, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 63, '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': '7219853', 'n_tokens_mistral': 3437, 'n_tokens_neox': 2952, 'n_words': 532}