61 lines
1.8 KiB
C++
61 lines
1.8 KiB
C++
|
|
#include "CScene.hpp"
|
||
|
|
#include "nlohmann/json_fwd.hpp"
|
||
|
|
#include "../Component/Graphics/CTestRenderer.hpp"
|
||
|
|
//#include "../../Controller/Exception/CRuntimeException.hpp"
|
||
|
|
//#include "Components/CAbstractScript.hpp"
|
||
|
|
|
||
|
|
namespace CosmicCore {
|
||
|
|
|
||
|
|
CScene::CScene(std::string name) : CSerializable(),
|
||
|
|
m_name(std::move(name)) {
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
std::string CScene::getName(void) const {
|
||
|
|
return m_name;
|
||
|
|
}
|
||
|
|
|
||
|
|
unsigned int CScene::getNumEntity(void) const {
|
||
|
|
return this->m_ecManager.view<CMetaData>()->size();
|
||
|
|
}
|
||
|
|
|
||
|
|
void CScene::removeEntity(unsigned int index, bool destroy)
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void CScene::render(){
|
||
|
|
auto renderers = m_ecManager.view<CTestRenderer>();
|
||
|
|
for(auto beg = renderers->begin(); beg != renderers->end(); ++beg)
|
||
|
|
{
|
||
|
|
beg->render();
|
||
|
|
}
|
||
|
|
//std::chrono::steady_clock::time_point begin1 = std::chrono::steady_clock::now();
|
||
|
|
//auto eh = m_ecManager.create();
|
||
|
|
//m_ecManager.emplace<CTestRenderer>(eh, nullptr);
|
||
|
|
//std::chrono::steady_clock::time_point end1 = std::chrono::steady_clock::now();
|
||
|
|
//std::cout << "added entity and comptest : " <<std::chrono::duration_cast<std::chrono::seconds>(end1 - begin1).count() << std::endl;
|
||
|
|
//static unsigned int entitynb = 0;
|
||
|
|
//entitynb++;
|
||
|
|
//std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
|
||
|
|
//m_ecManager.view<CTestRenderer>().each([](auto e, CTestRenderer& comp){comp.render();});
|
||
|
|
//std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
|
||
|
|
//std::cout << "render func : " << std::chrono::duration_cast<std::chrono::seconds>(end - begin).count() << std::endl;
|
||
|
|
//std::cout << "nb : " << entitynb << std::endl;
|
||
|
|
}
|
||
|
|
|
||
|
|
// void CScene::setMask(unsigned int mask)
|
||
|
|
// {
|
||
|
|
// m_maskLayer = mask;
|
||
|
|
// }
|
||
|
|
|
||
|
|
// unsigned int CScene::getMask(void)
|
||
|
|
// {
|
||
|
|
// return m_maskLayer;
|
||
|
|
// }
|
||
|
|
|
||
|
|
nlohmann::json CScene::to_json()
|
||
|
|
{
|
||
|
|
return nlohmann::json();
|
||
|
|
}
|
||
|
|
}
|