#include "DeerRender/Scene.h"

#include "DeerRender/Components.h"
#include "DeerRender/Enviroment.h"
#include "DeerRender/Render/RenderCommand.h"
#include "DeerRender/VoxelWorld.h"

namespace Deer {
	void Scene::render() {
		uint32_t mainCamera = environment.tryGetMainCamera();
		if (mainCamera == 0)
			return;

		Entity& m_cameraEntity = environment.getEntity(mainCamera);
		SceneCamera sceneCamera;
		sceneCamera.camera = m_cameraEntity.getComponent<CameraComponent>();
		sceneCamera.transform = m_cameraEntity.getComponent<TransformComponent>();

		Scene::render(sceneCamera);
	}

	void Scene::render(SceneCamera sceneCamera) {
		RenderCommand::setDepthBuffer(true);
		environment.render(sceneCamera);

		if (VoxelWorld::isInitialized())
			VoxelWorld::render(sceneCamera);

		RenderCommand::setDepthBuffer(false);
		gizmoRenderer.render(sceneCamera);
	}

} // namespace Deer
