18#include <rapidjson/filereadstream.h>
19#include <rapidjson/document.h>
20#include <rapidjson/error/en.h>
21#include <rapidjson/rapidjson.h>
22#include <rapidjson/stringbuffer.h>
23#include <rapidjson/writer.h>
27 std::uint32_t Scene::s_nextRegistryId = 1;
33 m_registryId = s_nextRegistryId;
35 GetRegistryMap()[m_registryId] = std::make_unique<entt::registry>();
37 EE_TRACE(
"Created scene '{}' with registry id: {}", m_name.c_str(), m_registryId);
57 for (std::shared_ptr<GameObject> obj : m_rootObjects)
79 m_cubemap->SetViewMatrix(view);
96 for (std::shared_ptr<GameObject> obj : m_rootObjects)
112 obj->RenderInEditor();
125 for (std::shared_ptr<GameObject> obj : m_rootObjects)
131 void Scene::AddObject(std::shared_ptr<GameObject> newObject, std::shared_ptr<GameObject> parent)
138 AddRootObject(newObject);
142 if (newObject->GetScene() == parent->GetScene())
144 newObject->SetParent(parent);
148 EE_CORE_ERROR(
"Cannot add a child object from a different scene.");
155 ScenePtr scene = std::make_shared<Scene>(name, type);
171 void Scene::RemoveFromRoot(std::shared_ptr<GameObject>
object)
173 m_rootObjects.erase(
object);
176 void Scene::AddRootObject(std::shared_ptr<GameObject> newRootObject)
178 newRootObject->m_parent =
nullptr;
179 newRootObject->m_scene =
this;
180 m_rootObjects.insert(newRootObject);
static const GameContextState & GetGameState()
static Camera * GetCurrent()
const glm::mat4 & GetProjectionMatrix() const
glm::mat4 GenViewMatrix() const
static Cubemap * CreateFromFile(const std::string &filePath)
static void LoadScene(ScenePtr scene)
void Notify(Event &event)
static ScenePtr Create(std::string name, SceneType type=SceneType::RuntimeScene)
void AddObject(std::shared_ptr< GameObject > newObject, std::shared_ptr< GameObject > parent)
void RenderScene(Camera *cam=nullptr)
void SetSkybox(const std::string &skyboxFilePath)
std::weak_ptr< Cubemap > GetSkybox()
std::string Serialize() const override
std::unordered_map< uint32_t, std::unique_ptr< entt::registry > > & GetRegistryMap()
std::shared_ptr< Scene > ScenePtr