<commit_before>#include <Components/CameraComponent.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <Threads/ThreadManager.hpp>
#include <Threads/MainThread.hpp>
#include <Threads/PrepareRenderThread.hpp>
#include <Context/SDL/SdlContext.hh>
#include <Core/AScene.hh>
#include <imgui/imgui.h>

namespace AGE
{
	CameraComponent::CameraComponent()
		: ComponentBase()
	{
	}

	CameraComponent::~CameraComponent(void)
	{
	}

	CameraComponent::CameraComponent(CameraComponent const &o)
		: _projection(1)
		, _key(o._key)
	{
	}

	CameraComponent	&CameraComponent::operator=(CameraComponent const &o)
	{
		_key = o._key;
		_projection = o._projection;
		return *this;
	}

	void CameraComponent::setProjection(const glm::mat4 &projection)
	{
		_projection = projection;

		AGE::GetPrepareThread()->setCameraInfos(_projection, _key, _pipelines);
	}

	void CameraComponent::addPipeline(RenderType pipeline)
	{
		auto haveIt = havePipeline(pipeline);
		if (haveIt == false)
		{
			_pipelines.insert(pipeline);
			AGE::GetPrepareThread()->setCameraInfos(_projection, _key, _pipelines);
		}
	}

	void CameraComponent::removePipeline(RenderType pipeline)
	{
		auto it = _pipelines.find(pipeline);
		if (it  != std::end(_pipelines))
		{
			_pipelines.erase(it);
			AGE::GetPrepareThread()->setCameraInfos(_projection, _key, _pipelines);
		}
	}

	bool CameraComponent::havePipeline(RenderType pipeline) const
	{
		auto it = _pipelines.find(pipeline);
		return (it != std::end(_pipelines));
	}


	const glm::mat4 &CameraComponent::getProjection() const
	{
		return _projection;
	}

	void CameraComponent::init()
	{
		auto scene = entity.getScene();
		_key = AGE::GetPrepareThread()->addCamera();
		entity.getLink().registerOctreeObject(_key);
		auto screenSize = entity.getScene()->getInstance<IRenderContext>()->getScreenSize();
		setProjection(glm::perspective(60.0f, (float)screenSize.x / (float)screenSize.y, 0.1f, 2000.0f));
	}

	void CameraComponent::reset()
	{
		if (_key.invalid())
		{
			entity.getLink().unregisterOctreeObject(_key);
		}
		_projection = glm::mat4(1);
	}

	void CameraComponent::postUnserialization()
	{
		init();
		setProjection(_projection);
	}

#ifdef EDITOR_ENABLED
	void CameraComponent::editorCreate(AScene *scene)
	{}

	void CameraComponent::editorDelete(AScene *scene)
	{}

	void CameraComponent::editorUpdate(AScene *scene)
	{
	}
#endif

};

<commit_msg>Camera deletion fixed<commit_after>#include <Components/CameraComponent.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <Threads/ThreadManager.hpp>
#include <Threads/MainThread.hpp>
#include <Threads/PrepareRenderThread.hpp>
#include <Context/SDL/SdlContext.hh>
#include <Core/AScene.hh>
#include <imgui/imgui.h>

namespace AGE
{
	CameraComponent::CameraComponent()
		: ComponentBase()
	{
	}

	CameraComponent::~CameraComponent(void)
	{
	}

	CameraComponent::CameraComponent(CameraComponent const &o)
		: _projection(1)
		, _key(o._key)
	{
	}

	CameraComponent	&CameraComponent::operator=(CameraComponent const &o)
	{
		_key = o._key;
		_projection = o._projection;
		return *this;
	}

	void CameraComponent::setProjection(const glm::mat4 &projection)
	{
		_projection = projection;

		AGE::GetPrepareThread()->setCameraInfos(_projection, _key, _pipelines);
	}

	void CameraComponent::addPipeline(RenderType pipeline)
	{
		auto haveIt = havePipeline(pipeline);
		if (haveIt == false)
		{
			_pipelines.insert(pipeline);
			AGE::GetPrepareThread()->setCameraInfos(_projection, _key, _pipelines);
		}
	}

	void CameraComponent::removePipeline(RenderType pipeline)
	{
		auto it = _pipelines.find(pipeline);
		if (it  != std::end(_pipelines))
		{
			_pipelines.erase(it);
			AGE::GetPrepareThread()->setCameraInfos(_projection, _key, _pipelines);
		}
	}

	bool CameraComponent::havePipeline(RenderType pipeline) const
	{
		auto it = _pipelines.find(pipeline);
		return (it != std::end(_pipelines));
	}


	const glm::mat4 &CameraComponent::getProjection() const
	{
		return _projection;
	}

	void CameraComponent::init()
	{
		auto scene = entity.getScene();
		_key = AGE::GetPrepareThread()->addCamera();
		entity.getLink().registerOctreeObject(_key);
		auto screenSize = entity.getScene()->getInstance<IRenderContext>()->getScreenSize();
		setProjection(glm::perspective(60.0f, (float)screenSize.x / (float)screenSize.y, 0.1f, 2000.0f));
	}

	void CameraComponent::reset()
	{
		if (!_key.invalid())
		{
			entity.getLink().unregisterOctreeObject(_key);
		}
		_projection = glm::mat4(1);
	}

	void CameraComponent::postUnserialization()
	{
		init();
		setProjection(_projection);
	}

#ifdef EDITOR_ENABLED
	void CameraComponent::editorCreate(AScene *scene)
	{}

	void CameraComponent::editorDelete(AScene *scene)
	{}

	void CameraComponent::editorUpdate(AScene *scene)
	{
	}
#endif

};


{'fraction_non_alphanumeric': 0.1420180406964548, 'fraction_numerical': 0.0062932662051604785, 'mean_word_length': 5.576551724137931, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 33, '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': '4737983', 'n_tokens_mistral': 1783, 'n_tokens_neox': 1656, 'n_words': 254}