Exemplo n.º 1
0
	void DRBPointLightData::updateRange(const glm::mat4 &transformation)
	{
		float errorRate = 0.01f;
		glm::vec3 lightRange;
		glm::vec3 equation(_range.z, _range.y, _range.x);

		// if the value of equation.z + equation.y * dist + equation.x * dist * dist == 256
		// then the pixels are not lighted anymore (pxlColor = final_color / attenuation)
		equation.z -= 256;
		if (equation.x == 0) // first degree
		{
			// infinite range if there is no distance attenuation
			AGE_ASSERT(equation.y != 0);
			lightRange = glm::vec3(-equation.z / equation.y);
		}
		else // second degree
		{
			float d = Mathematic::secondDegreeDiscriminant(equation);
			glm::vec2 res = Mathematic::resolveSecondDegree(equation, d);
			lightRange = glm::vec3(glm::max(res.x, res.y));
		}
		AGE_ASSERT(lightRange.x > 0);
		_sphereTransform = glm::scale(transformation, lightRange + lightRange * errorRate);
		_positionLightProperty->autoSet(glm::vec3(_sphereTransform[3]));
		setTransformation(_sphereTransform);
	}
Exemplo n.º 2
0
	LFListBase::LFListBase(std::size_t nextPtrPadding)
		: _nextPtrPadding(nextPtrPadding)
	{
		AGE_ASSERT(nextPtrPadding != 0);
		AGE_ASSERT(nextPtrPadding % 8 == 0);
		_datas.head = nullptr;
		_datas.size = 0;
	}
Exemplo n.º 3
0
	void BFCBlock::deleteItem(ItemID itemId)
	{
		AGE_ASSERT(itemId < MaxItemID);

		_items[itemId].setDrawable(nullptr);
		_free.push(itemId);
	}
	void ComponentRegistrationManager::serializeBinary(ComponentBase *c, cereal::PortableBinaryOutputArchive &ar)
	{
		auto id = c->getType();
		auto find = _binarySaveMap.find(id);
		AGE_ASSERT(find != std::end(_binarySaveMap));
		find->second(c, ar);
	}
	void ComponentRegistrationManager::serializeJson(ComponentBase *c, cereal::JSONOutputArchive &ar)
	{
		auto id = c->getType();
		auto find = _jsonSaveMap.find(id);
		AGE_ASSERT(find != std::end(_jsonSaveMap));
		find->second(c, ar);
	}
Exemplo n.º 6
0
	void TextureBuffer::set(GLvoid const *data, GLsizeiptr count)
	{
		SCOPE_profile_cpu_function("TextureBuffer");
		AGE_ASSERT(count <= _count);
		bindBuffer();
		glBufferSubData(GL_TEXTURE_BUFFER, 0, _size * count, data);
	}
Exemplo n.º 7
0
	bool RenderThread::update()
	{
		/*
		- Tant qu'il n'y a pas de command
		-> je pop des task
		- Une fois que j'ai mes commandes
		-> pour chacunes d'elles
		-> je regarde si c'est a moi de les traiter (ex : changement de scene)
		-> si ca n'est pas a moi de les traiter
		-> je les passe au render context actif
		-> si il n'y a pas de render context actif, c'est que j'ai fait une erreur, et j'assert dans ta face :D
		*/

		_registerId();

		_run = true;
		_insideRun = true;
		DWORD threadId = GetThreadId(static_cast<HANDLE>(_threadHandle.native_handle()));
		SetThreadName(threadId, this->_name.c_str());

		TMQ::MessageBase *task = nullptr;

		while (_run && _insideRun)
		{
			SCOPE_profile_cpu_i("RenderTimer", "Update");

			if (TMQ::TaskManager::RenderThreadGetTask(task))
			{
				SCOPE_profile_cpu_i("RenderTimer", "Execute task");
				auto success = execute(task); // we receive a task that we cannot treat
				AGE_ASSERT(success);
			}
		}
		return true;
	}
Exemplo n.º 8
0
		void ArchetypeEditorManager::spawn(Entity &entity, const std::string &name)
		{
			auto it = _archetypesCollection.find(name);
			AGE_ASSERT(it != std::end(_archetypesCollection));
			loadFromFile(it->second);
			entity->getScene()->internalCopyEntity(it->second->root, entity, true, false);

			auto representation = entity->getComponent<EntityRepresentation>();

			representation->editorOnly = false;
			representation->_archetypeLinked = it->second;
			
			std::vector<Entity*> tmpEntitiesList;
			std::vector<const char*> tmpEntitiesNameList;
			listEntityTree(entity, tmpEntitiesNameList, tmpEntitiesList);
			
			it->second->entities.insert(entity);

			for (auto &en: tmpEntitiesList)
			{
				auto &e = *en;
				if (e->haveComponent<ArchetypeComponent>() == false)
				{
					e->addComponent<ArchetypeComponent>(name);
				}
				if (e != entity)
				{
					e->getComponent<ArchetypeComponent>()->parentIsAnArchetype = true;
				}
			}

		}
Exemplo n.º 9
0
	DepthMapHandle::DepthMapHandle(DepthMapManager *managerPtr, DepthMap *map, std::size_t index, DepthMapManager::Status status)
		: _manager(managerPtr)
		, _map(map)
		, _index(index)
		, _status(status)
	{
		AGE_ASSERT(_manager != nullptr);
	}
Exemplo n.º 10
0
	void BFCLinkTracker::removeLink(std::size_t index)
	{
		SCOPE_profile_cpu_function("BFC");

		AGE_ASSERT(index != -1 && index < _links.size());
		_links[index] = nullptr;
		_free.push(index);
	}
	ComponentBase *ComponentRegistrationManager::copyComponent(ComponentBase *src, AScene *scene)
	{
		AGE_ASSERT(scene != nullptr);
		AGE_ASSERT(src != nullptr);

		auto id = src->getType();
		auto find = _copyMap.find(id);
		if (find == std::end(_copyMap))
		{
#ifdef _DEBUG
			// can be normal for component who generates other components
			//std::cerr << "Component not copyable\n";
#endif // _DEBUG
			return nullptr;
		}
		auto voidCpt = scene->allocateComponent(id);
		find->second(voidCpt, src);
		return static_cast<ComponentBase*>(voidCpt);
	}
	ComponentBase *ComponentRegistrationManager::loadBinary(std::size_t componentHashId, Entity &e, cereal::PortableBinaryInputArchive &ar)
	{
		AGE_ASSERT(_typeIds.find(componentHashId) != std::end(_typeIds) && "Component type has not been registered. Use REGISTER_COMPONENT_TYPE");
		auto id = _typeIds[componentHashId];

		auto voidCpt = e->getScene()->allocateComponent(id);

		auto find = _binaryLoadMap.find(id);
		AGE_ASSERT(find != std::end(_binaryLoadMap));
		find->second(voidCpt, ar, e);

		auto cpt = (AGE::ComponentBase*)voidCpt;

		cpt->_typeId = id;
		cpt->entity = e;

		e->addComponentPtr(cpt);
		return cpt;
	}
Exemplo n.º 13
0
	void LFListBase::push(void *element)
	{
		void *elementNext = (void*)((std::size_t)element + _nextPtrPadding);

		while (true)
		{
			Data datas;
			while (true)
			{
				datas = _datas;
				__int64 cr[2];
				cr[0] = (__int64)datas.size; /* low */
				cr[1] = (__int64)datas.head; /* high */
				if (_InterlockedCompareExchange128(&_datas.size, (__int64)datas.head, datas.size, &cr[0]) == 1)
				{
					break;
				}
			}
			Data oldDatas = datas;

			*(std::size_t*)(elementNext) = (std::size_t)datas.head;
			AGE_ASSERT((std::size_t)(elementNext) % 8 == 0);
			AGE_ASSERT(datas.head != elementNext);

			datas.head = element;
			datas.size += 1;

			__int64 comparandResult[2];
			comparandResult[0] = (__int64)oldDatas.size; /* low */
			comparandResult[1] = (__int64)oldDatas.head; /* high */
			if (_InterlockedCompareExchange128(
				&_datas.size,
				(__int64)datas.head,
				datas.size,
				&comparandResult[0]
				) == 1)
			{
				return;
			}
		}
	}
Exemplo n.º 14
0
	void RenderThread::getCube(Key<Vertices> &v, Key<Painter> &p)
	{
		static const std::vector<glm::vec3> positions =
		{
			glm::vec3(-1.0f, 1.0f, 1.0f),
			glm::vec3(-1.0f, -1.0f, 1.0f),
			glm::vec3(1.0f, -1.0f, 1.0f),
			glm::vec3(1.0f, 1.0f, 1.0f),
			glm::vec3(-1.0f, 1.0f, -1.0f),
			glm::vec3(-1.0f, -1.0f, -1.0f),
			glm::vec3(1.0f, -1.0f, -1.0f),
			glm::vec3(1.0f, 1.0f, -1.0f)
		};
		static const std::vector<unsigned int> indices =
		{
			0, 1, 2, 3, 0, 3, 7, 4, 4, 7, 6, 5, 6, 5, 1, 2, 2, 3, 7, 6, 4, 0, 1, 5
		};

		// to be sure that this function is only called in render thread
		AGE_ASSERT(CurrentThread() == (AGE::Thread*)GetRenderThread());

		if (SimpleGeometry::cubeMesh.verticesKey.isValid() &&
			SimpleGeometry::cubeMesh.painterKey.isValid())
		{
			v = SimpleGeometry::cubeMesh.verticesKey;
			p = SimpleGeometry::cubeMesh.painterKey;
			return;
		}

		auto type = std::make_pair<GLenum, StringID>(GL_FLOAT_VEC3, StringID("position", 0x4cbf3a26fca1d74a));
		std::vector<std::pair < GLenum, StringID > > types;
		types.push_back(type);

		if (!paintingManager->has_painter(types))
		{
			SimpleGeometry::cubeMesh.painterKey = paintingManager->add_painter(std::move(types));
		}
		else
		{
			SimpleGeometry::cubeMesh.painterKey = paintingManager->get_painter(types);
		}
		auto &painterPtr = paintingManager->get_painter(SimpleGeometry::cubeMesh.painterKey);

		SimpleGeometry::cubeMesh.verticesKey = painterPtr->add_vertices(positions.size(), indices.size());
		auto vertices = painterPtr->get_vertices(SimpleGeometry::cubeMesh.verticesKey);

		vertices->set_data<glm::vec3>(positions, StringID("position", 0x4cbf3a26fca1d74a));
		vertices->set_indices(indices);

		v = SimpleGeometry::cubeMesh.verticesKey;
		p = SimpleGeometry::cubeMesh.painterKey;
	}
Exemplo n.º 15
0
	void RenderThread::_initPipelines()
	{
		// to be sure that this function is only called in render thread
		AGE_ASSERT(CurrentThread() == (AGE::Thread*)GetRenderThread());

		for (auto &e : pipelines)
		{
			if (!e)
			{
				continue;
			}
			e->init();
		}
	}
Exemplo n.º 16
0
	void Library::close(void)
	{
		AGE_ASSERT(handle && "Library not opened");
		if (handle)
		{
#if defined(AGE_PLATFORM_WINDOWS)
			FreeLibrary(handle);
#else
			dlclose(handle);
#endif
			handle = nullptr;
			pluginName.clear();
		}
	}
Exemplo n.º 17
0
		void ArchetypeEditorManager::loadFromFile(std::shared_ptr<ArchetypeEditorRepresentation> ptr)
		{
			AGE_ASSERT(ptr != nullptr);

			if (ptr->loaded == false)
			{
				auto path = _libraryFolder + "/" + ptr->name + ".raw_archetype";
				ReadableEntityPack pack;
				pack.scene = getScene();
				pack.loadFromFile(path);

				ptr->root = pack.entities.front().entity;
				ptr->loaded = true;

			}
		}
Exemplo n.º 18
0
	bool TextureBuffer::init(GLsizeiptr count, GLenum internal_format /*GL_R32F */, GLsizeiptr size, GLenum usage /* GL_STATIC_DRAW ...*/)
	{
		SCOPE_profile_cpu_function("TextureBuffer");
		AGE_ASSERT(_bufferHandle == -1 && _textureHandle == -1 && _count == 0 && _size == 0 && _buffer == nullptr);
		_count = count;
		_size = size;

		glGenBuffers(1, &_bufferHandle);
		bindBuffer();
		glBufferData(GL_TEXTURE_BUFFER, size * count, nullptr, usage);
		glGenTextures(1, &_textureHandle);
		bind();
		glTexBuffer(GL_TEXTURE_BUFFER, internal_format, _bufferHandle);
		_buffer = (char*)AGE_MALLOC(size * count);
		return true;
	}
Exemplo n.º 19
0
	void ArchetypeManager::spawn(Entity &entity, const std::string &name)
	{
		auto it = _archetypesCollection.find(name);
		if (it == std::end(_archetypesCollection))
		{
			load();
			it = _archetypesCollection.find(name);
		}
		AGE_ASSERT(it != std::end(_archetypesCollection));

		entity->getScene()->internalCopyEntity(it->second, entity, true, false);
		//if (entity->haveComponent<AGE::ArchetypeComponent>())
		//{
		//	entity->removeComponent<AGE::ArchetypeComponent>();
		//}
	}
Exemplo n.º 20
0
	bool Library::load(const std::string &name)
	{
		AGE_ASSERT(handle == nullptr && "Library is not closed");
		std::string libraryName = Library::GenerateName(name);
		if (libraryName.empty())
		{
#if defined(AGE_PLATFORM_WINDOWS)
			handle = GetModuleHandle(nullptr);
#else
			handle = dlopen(nullptr, 0);
#endif
		}
		else
		{
#if defined(AGE_PLATFORM_WINDOWS)
			handle = LoadLibrary(libraryName.c_str());
#else
			handle = dlopen(libraryName.c_str(), RTLD_LAZY);
#endif
			if (!handle)
			{
				libraryName = name;
#if defined(AGE_PLATFORM_WINDOWS)
				handle = LoadLibrary(libraryName.c_str());
#else
				handle = dlopen(libraryName.c_str(), RTLD_LAZY);
#endif
			}
		}
		if (handle != nullptr)
		{
			if (libraryName.empty())
			{
				pluginName = "CurrentProcess";
			}
			else
			{
				pluginName = libraryName;
			}
			return true;
		}
		else
		{
			AGE_ERROR("Impossible to load \"", libraryName, "\" library");
			return false;
		}
	}
Exemplo n.º 21
0
	DeferredShadowBuffering::DeferredShadowBuffering(glm::uvec2 const &screenSize, std::shared_ptr<PaintingManager> painterManager) :
		FrameBufferRender(screenSize.x, screenSize.y, painterManager)
	{
		// We dont want to take the skinned or transparent meshes
		_forbidden[AGE_SKINNED] = true;
		_forbidden[AGE_SEMI_TRANSPARENT] = true;
		_programs.resize(PROGRAM_NBR);
		auto confManager = GetEngine()->getInstance<ConfigurationManager>();
		auto shaderPath = confManager->getConfiguration<std::string>("ShadersPath");
		// you have to set shader directory in configuration path
		AGE_ASSERT(shaderPath != nullptr);
		auto vertexShaderPath = shaderPath->getValue() + DEFERRED_SHADING_SHADOW_BUFFERING_VERTEX;
		auto fragmentShaderPath = shaderPath->getValue() + DEFERRED_SHADING_SHADOW_BUFFERING_FRAG;
		_programs[PROGRAM_BUFFERING] = std::make_shared<Program>(Program(std::string("program_shadow_buffering"),
		{
			std::make_shared<UnitProg>(vertexShaderPath, GL_VERTEX_SHADER),
			std::make_shared<UnitProg>(fragmentShaderPath, GL_FRAGMENT_SHADER)
		}));
	}
Exemplo n.º 22
0
	void BinaryEntityPack::load(cereal::PortableBinaryInputArchive &ar, const std::uint32_t version)
	{
		AGE_ASSERT(scene != nullptr);
		std::size_t entityNumber;
		ar(componentsIdReferenceTable);
		ar(entityNumber);
		entities.resize(entityNumber);
		for (std::size_t i = 0; i < entities.size(); ++i)
		{
			entities[i].entity = scene->createEntity();
			entities[i].typesMap = &componentsIdReferenceTable;
			ar(entities[i]);
		}
		for (auto &e : entities)
		{
			for (auto &c : e.children)
			{
				e.entity->getLink().attachChild(entities[c].entity.getLinkPtr());
			}
		}
		for (auto &e : entities)
		{
			if (e.entity->getLink().hasChildren())
			{
				e.entity->getLink().isUserModified();
				e.entity->getLink().setTransform(e.entity->getLink().getLocalTransform(), true);
			}
		}
		for (auto &e : entities)
		{
			if (e.entity->getComponent<ArchetypeComponent>())
			{
				continue;
			}
			for (auto &c : e.entity->getComponentList())
			{
				if (c)
				{
					c->postUnserialization();
				}
			}
		}
	}
Exemplo n.º 23
0
	void BFCBlockManager::createItem(BFCCullableObject *object, BlockID &blockID, ItemID &itemId)
	{
		
		if (_blocksNotFull.empty() == false)
		{
			auto b = *(_blocksNotFull.begin());
			auto &block = _blocks[b];
			itemId = block->createItem(object);
			blockID = std::uint8_t(b);
			if (block->isFull())
			{
				_blocksNotFull.erase(_blocksNotFull.begin());
			}
			return;
		}
		_blocks.push_back(std::make_shared<BFCBlock>());
		AGE_ASSERT(_blocks.size() < MaxBlockID);
		_blocksNotFull.insert(_blocks.size() - 1);
		createItem(object, blockID, itemId);
	}
Exemplo n.º 24
0
		void ArchetypeEditorManager::load()
		{
			Directory dir;
			const bool success = dir.open(_libraryFolder.c_str());
			AGE_ASSERT(success);
			for (auto it = dir.recursive_begin(); it != dir.recursive_end(); ++it)
			{
				if (Directory::IsFile(*it))
				{
					auto extension = FileUtils::GetExtension(*it);

					if (extension != "raw_archetype")
					{
						continue;
					}
					loadOne(FileUtils::RemoveExtension(FileUtils::GetName(*it)));
				}
			}
			dir.close();
		}
Exemplo n.º 25
0
	void RenderThread::getIcoSphereGeometry(Key<Vertices> &v, Key<Painter> &p, uint32_t recursion)
	{
		std::vector<glm::vec3> positions;
		std::vector<unsigned int> indices;

		// to be sure that this function is only called in render thread
		AGE_ASSERT(CurrentThread() == (AGE::Thread*)GetRenderThread());

		if (SimpleGeometry::icosphereMeshes[recursion].verticesKey.isValid() &&
			SimpleGeometry::icosphereMeshes[recursion].painterKey.isValid())
		{
			v = SimpleGeometry::icosphereMeshes[recursion].verticesKey;
			p = SimpleGeometry::icosphereMeshes[recursion].painterKey;
			return;
		}

		SimpleGeometry::generateIcoSphere(recursion, positions, indices);

		auto type = std::make_pair<GLenum, StringID>(GL_FLOAT_VEC3, StringID("position", 0x4cbf3a26fca1d74a));
		std::vector<std::pair < GLenum, StringID > > types;
		types.push_back(type);

		if (!paintingManager->has_painter(types))
		{
			SimpleGeometry::icosphereMeshes[recursion].painterKey = paintingManager->add_painter(std::move(types));
		}
		else
		{
			SimpleGeometry::icosphereMeshes[recursion].painterKey = paintingManager->get_painter(types);
		}
		auto &painterPtr = paintingManager->get_painter(SimpleGeometry::icosphereMeshes[recursion].painterKey);

		SimpleGeometry::icosphereMeshes[recursion].verticesKey = painterPtr->add_vertices(positions.size(), indices.size());
		auto vertices = painterPtr->get_vertices(SimpleGeometry::icosphereMeshes[recursion].verticesKey);

		vertices->set_data<glm::vec3>(positions, StringID("position", 0x4cbf3a26fca1d74a));
		vertices->set_indices(indices);

		v = SimpleGeometry::icosphereMeshes[recursion].verticesKey;
		p = SimpleGeometry::icosphereMeshes[recursion].painterKey;
	}
Exemplo n.º 26
0
	void ReadableEntityPack::load(cereal::JSONInputArchive &ar, const std::uint32_t version)
	{
		AGE_ASSERT(scene != nullptr);
		std::size_t entityNumber;
		ar(componentsIdReferenceTable);
		ar(entityNumber);
		entities.resize(entityNumber);
		for (std::size_t i = 0; i < entities.size(); ++i)
		{
			entities[i].entity = scene->createEntity();
			entities[i].typesMap = &componentsIdReferenceTable;
			ar(entities[i]);
		}
		for (auto &e : entities)
		{
			for (auto &c : e.children)
			{
				e.entity->getLink().attachChild(entities[c].entity.getLinkPtr());
			}
		}
	}
Exemplo n.º 27
0
void BinaryEntity::load(cereal::PortableBinaryInputArchive &ar, const std::uint32_t version)
{
    ENTITY_FLAGS flags;

    AGE_ASSERT(typesMap != nullptr);

    ar(entity->getLink()
       , children
       , flags
       , componentTypes
       , archetypesDependency);

    auto archetypeManager = entity->getScene()->getInstance<AGE::IArchetypeManager>();

    // we load archetypes dependency
    if (!archetypesDependency.empty())
    {
        for (auto &dep : archetypesDependency)
        {
            archetypeManager->loadOne(dep);
        }
    }

    entity->getLink().setPosition(entity->getLink().getPosition());
    entity->getLink().setOrientation(entity->getLink().getOrientation());
    entity->getLink().setScale(entity->getLink().getScale());
    //entity.setFlags(f);
    for (auto &e : componentTypes)
    {
        auto hashType = (*typesMap)[e];
        auto newComponent = ComponentRegistrationManager::getInstance().loadBinary(hashType, entity, ar);
    }
    if (entity->haveComponent<ArchetypeComponent>())
    {
        auto archetypeName = entity->getComponent<ArchetypeComponent>()->archetypeName;
        archetypeManager->spawn(entity, archetypeName);
    }
}
Exemplo n.º 28
0
	DepthOfField::DepthOfField(glm::uvec2 const &screenSize, std::shared_ptr<PaintingManager> painterManager,
		std::shared_ptr<Texture2D> depth,
		std::shared_ptr<Texture2D> blurred1,
		std::shared_ptr<Texture2D> blurred2,
		std::shared_ptr<Texture2D> clean,
		std::shared_ptr<Texture2D> dst) :
		FrameBufferRender(screenSize.x, screenSize.y, painterManager)
	{
		push_storage_output(GL_COLOR_ATTACHMENT0, dst);

		_depth = depth;
		_clean = clean;
		_blurred1 = blurred1;
		_blurred2 = blurred2;

		_programs.resize(PROGRAM_NBR);

		auto confManager = GetEngine()->getInstance<ConfigurationManager>();

		auto shaderPath = confManager->getConfiguration<std::string>("ShadersPath");

		// you have to set shader directory in configuration path
		AGE_ASSERT(shaderPath != nullptr);

		auto vertexShaderPath = shaderPath->getValue() + PROGRAM_DOF_VERTEX;
		auto fragmentShaderPath = shaderPath->getValue() + PROGRAM_DOF_FRAG;

		_programs[PROGRAM_DEPTH_OF_FIELD] = std::make_shared<Program>(Program(std::string("depth_of_field"),
		{
			std::make_shared<UnitProg>(vertexShaderPath, GL_VERTEX_SHADER),
			std::make_shared<UnitProg>(fragmentShaderPath, GL_FRAGMENT_SHADER)
		}));
		Key<Painter> quadPainterKey;

		GetRenderThread()->getQuadGeometry(_quadVertices, quadPainterKey);
		_quadPainter = _painterManager->get_painter(quadPainterKey);
	}
Exemplo n.º 29
0
	void BFCBlockManager::deleteItem(BlockID &blockID, ItemID &itemId)
	{
		AGE_ASSERT(blockID < _blocks.size());
		_blocks[blockID]->deleteItem(itemId);
		_blocksNotFull.insert(blockID);
	}
Exemplo n.º 30
0
		void ArchetypeEditorManager::addOne(const std::string &name, Entity &entity)
		{
			if (_archetypesCollection.find(name) != std::end(_archetypesCollection))
			{
				return;
			}
			auto scene = entity->getScene();
			auto representation = std::make_shared<ArchetypeEditorRepresentation>();
			representation->name = name;
			representation->loaded = true;

			//we copy the original entity into the archetype entity
			//for that we set the ArchetypeScene as the current scene
			//so that messages will be not passed to the renderScene of the WE's scene
			//but to the ArchetypeScene.
			bool success = getScene()->copyEntity(entity, representation->root, true, false);

			AGE_ASSERT(success);

			representation->root->getComponent<EntityRepresentation>()->editorOnly = true;

			auto componentsCopy = entity->getComponentList();

			auto entityRepresentationComponent = entity->getComponent<EntityRepresentation>();
			AGE_ASSERT(entityRepresentationComponent != nullptr);

			//we remove original entity's components
			//replacing them by archetypes ones
			for (auto &e : componentsCopy)
			{
				if (e != nullptr && e != entityRepresentationComponent)
				{
					entity->copyComponent(representation->root->getComponent(e->getType()));
				}
			}

			std::vector<Entity*> tmpEntitiesList;
			std::vector<const char*> tmpEntitiesNameList;
			listEntityTree(entity, tmpEntitiesNameList, tmpEntitiesList);

			for (auto &entity : tmpEntitiesList)
			{
				auto &e = *entity;
				auto er = e->getComponent<EntityRepresentation>();
				e->addComponent<ArchetypeComponent>(name);
				e->getComponent<ArchetypeComponent>()->parentIsAnArchetype = false;
				if (er != entityRepresentationComponent)
				{
					e->getComponent<ArchetypeComponent>()->parentIsAnArchetype = true;
				}
			}

			tmpEntitiesList.clear(); tmpEntitiesNameList.clear();
			listEntityTree(representation->root, tmpEntitiesNameList, tmpEntitiesList);

			for (auto &entity : tmpEntitiesList)
			{
				auto &e = *entity;

				auto er = e->getComponent<EntityRepresentation>();
				er->_isArchetype = true;
			}

			entityRepresentationComponent->_archetypeLinked = representation;

			representation->entities.insert(entity);

			_archetypesCollection.insert(std::make_pair(name, representation));

			_regenerateImGuiNamesList();
		}