<commit_before>#include "scene_view.h"
#include "editor/asset_browser.h"
#include "editor/gizmo.h"
#include "editor/ieditor_command.h"
#include "editor/log_ui.h"
#include "editor/platform_interface.h"
#include "editor/prefab_system.h"
#include "editor/render_interface.h"
#include "editor/settings.h"
#include "editor/studio_app.h"
#include "engine/crc32.h"
#include "engine/engine.h"
#include "engine/input_system.h"
#include "engine/json_serializer.h"
#include "engine/path.h"
#include "engine/path_utils.h"
#include "engine/plugin_manager.h"
#include "engine/profiler.h"
#include "engine/property_register.h"
#include "engine/resource_manager.h"
#include "engine/resource_manager_base.h"
#include "engine/string.h"
#include "engine/universe/component.h"
#include "engine/universe/universe.h"
#include "imgui/imgui.h"
#include "renderer/frame_buffer.h"
#include "renderer/model.h"
#include "renderer/pipeline.h"
#include "renderer/render_scene.h"
#include "renderer/renderer.h"
#include "renderer/shader.h"
#include "renderer/texture.h"
#include <SDL.h>


namespace Lumix
{


static const ComponentType MODEL_INSTANCE_TYPE = PropertyRegister::getComponentType("renderable");
static const ResourceType MODEL_TYPE("model");
static const ResourceType SHADER_TYPE("shader");
static const ResourceType TEXTURE_TYPE("texture");


SceneView::SceneView(StudioApp& app)
	: m_app(app)
	, m_drop_handlers(app.getWorldEditor()->getAllocator())
{
	m_camera_speed = 0.1f;
	m_is_mouse_captured = false;
	m_show_stats = false;

	m_log_ui = m_app.getLogUI();
	m_editor = m_app.getWorldEditor();
	auto& engine = m_editor->getEngine();
	auto& allocator = engine.getAllocator();
	auto* renderer = static_cast<Renderer*>(engine.getPluginManager().getPlugin("renderer"));
	m_is_opengl = renderer->isOpenGL();
	Path path("pipelines/main.lua");
	m_pipeline = Pipeline::create(*renderer, path, engine.getAllocator());
	m_pipeline->load();
	m_pipeline->addCustomCommandHandler("renderGizmos").callback.bind<SceneView, &SceneView::renderGizmos>(this);
	m_pipeline->addCustomCommandHandler("renderIcons").callback.bind<SceneView, &SceneView::renderIcons>(this);

	m_editor->universeCreated().bind<SceneView, &SceneView::onUniverseCreated>(this);
	m_editor->universeDestroyed().bind<SceneView, &SceneView::onUniverseDestroyed>(this);

	m_toggle_gizmo_step_action =
		LUMIX_NEW(allocator, Action)("Enable/disable gizmo step", "toggleGizmoStep");
	m_toggle_gizmo_step_action->is_global = false;
	m_app.addAction(m_toggle_gizmo_step_action);

	m_move_forward_action = LUMIX_NEW(allocator, Action)("Move forward", "moveForward");
	m_move_forward_action->is_global = false;
	m_app.addAction(m_move_forward_action);

	m_move_back_action = LUMIX_NEW(allocator, Action)("Move back", "moveBack");
	m_move_back_action->is_global = false;
	m_app.addAction(m_move_back_action);

	m_move_left_action = LUMIX_NEW(allocator, Action)("Move left", "moveLeft");
	m_move_left_action->is_global = false;
	m_app.addAction(m_move_left_action);

	m_move_right_action = LUMIX_NEW(allocator, Action)("Move right", "moveRight");
	m_move_right_action->is_global = false;
	m_app.addAction(m_move_right_action);

	m_move_up_action = LUMIX_NEW(allocator, Action)("Move up", "moveUp");
	m_move_up_action->is_global = false;
	m_app.addAction(m_move_up_action);

	m_move_down_action = LUMIX_NEW(allocator, Action)("Move down", "moveDown");
	m_move_down_action->is_global = false;
	m_app.addAction(m_move_down_action);

	m_camera_speed_action = LUMIX_NEW(allocator, Action)("Camera speed", "cameraSpeed");
	m_camera_speed_action->is_global = false;
	m_camera_speed_action->func.bind<SceneView, &SceneView::resetCameraSpeed>(this);
	m_app.addAction(m_camera_speed_action);

	m_app.getAssetBrowser()->resourceChanged().bind<SceneView, &SceneView::onResourceChanged>(this);
}


void SceneView::onResourceChanged(const Path& path, const char* /*ext*/)
{
	if (getPipeline()->getPath() == path) getPipeline()->load();
}


void SceneView::resetCameraSpeed()
{
	m_camera_speed = 0.1f;
}


SceneView::~SceneView()
{
	m_app.getAssetBrowser()->resourceChanged().bind<SceneView, &SceneView::onResourceChanged>(this);
	m_editor->universeCreated().unbind<SceneView, &SceneView::onUniverseCreated>(this);
	m_editor->universeDestroyed().unbind<SceneView, &SceneView::onUniverseDestroyed>(this);
	Pipeline::destroy(m_pipeline);
	m_pipeline = nullptr;
}


void SceneView::setScene(RenderScene* scene)
{
	m_pipeline->setScene(scene);
}


void SceneView::onUniverseCreated()
{
	auto* scene = m_editor->getUniverse()->getScene(crc32("renderer"));
	m_pipeline->setScene(static_cast<RenderScene*>(scene));
}


void SceneView::onUniverseDestroyed()
{
	m_pipeline->setScene(nullptr);
}


void SceneView::update(float)
{
	PROFILE_FUNCTION();<commit_msg>Update scene_view.cpp<commit_after>#include "scene_view.h"
#include "editor/asset_browser.h"
#include "editor/gizmo.h"
#include "editor/ieditor_command.h"
#include "editor/log_ui.h"
#include "editor/platform_interface.h"
#include "editor/prefab_system.h"
#include "editor/render_interface.h"
#include "editor/settings.h"
#include "editor/studio_app.h"
#include "engine/crc32.h"
#include "engine/engine.h"
#include "engine/input_system.h"
#include "engine/json_serializer.h"
#include "engine/path.h"
#include "engine/path_utils.h"
#include "engine/plugin_manager.h"
#include "engine/profiler.h"
#include "engine/property_register.h"
#include "engine/resource_manager.h"
#include "engine/resource_manager_base.h"
#include "engine/string.h"
#include "engine/universe/component.h"
#include "engine/universe/universe.h"
#include "imgui/imgui.h"
#include "renderer/frame_buffer.h"
#include "renderer/model.h"
#include "renderer/pipeline.h"
#include "renderer/render_scene.h"
#include "renderer/renderer.h"
#include "renderer/shader.h"
#include "renderer/texture.h"
#include <SDL.h>


namespace Lumix
{


static const ComponentType MODEL_INSTANCE_TYPE = PropertyRegister::getComponentType("renderable");
static const ResourceType MODEL_TYPE("model");
static const ResourceType SHADER_TYPE("shader");
static const ResourceType TEXTURE_TYPE("texture");


SceneView::SceneView(StudioApp& app)
	: m_app(app)
	, m_drop_handlers(app.getWorldEditor()->getAllocator())
{
	m_camera_speed = 0.1f;
	m_is_mouse_captured = false;
	m_show_stats = false;

	m_log_ui = m_app.getLogUI();
	m_editor = m_app.getWorldEditor();
	auto& engine = m_editor->getEngine();
	auto& allocator = engine.getAllocator();
	auto* renderer = static_cast<Renderer*>(engine.getPluginManager().getPlugin("renderer"));
	m_is_opengl = renderer->isOpenGL();
	Path path("pipelines/main.lua");
	m_pipeline = Pipeline::create(*renderer, path, engine.getAllocator());
	m_pipeline->load();
	m_pipeline->addCustomCommandHandler("renderGizmos").callback.bind<SceneView, &SceneView::renderGizmos>(this);
	m_pipeline->addCustomCommandHandler("renderIcons").callback.bind<SceneView, &SceneView::renderIcons>(this);

	m_editor->universeCreated().bind<SceneView, &SceneView::onUniverseCreated>(this);
	m_editor->universeDestroyed().bind<SceneView, &SceneView::onUniverseDestroyed>(this);

	m_toggle_gizmo_step_action =
		LUMIX_NEW(allocator, Action)("Enable/disable gizmo step", "toggleGizmoStep");
	m_toggle_gizmo_step_action->is_global = false;
	m_app.addAction(m_toggle_gizmo_step_action);

	m_move_forward_action = LUMIX_NEW(allocator, Action)("Move forward", "moveForward");
	m_move_forward_action->is_global = false;
	m_app.addAction(m_move_forward_action);

	m_move_back_action = LUMIX_NEW(allocator, Action)("Move back", "moveBack");
	m_move_back_action->is_global = false;
	m_app.addAction(m_move_back_action);

	m_move_left_action = LUMIX_NEW(allocator, Action)("Move left", "moveLeft");
	m_move_left_action->is_global = false;
	m_app.addAction(m_move_left_action);

	m_move_right_action = LUMIX_NEW(allocator, Action)("Move right", "moveRight");
	m_move_right_action->is_global = false;
	m_app.addAction(m_move_right_action);

	m_move_up_action = LUMIX_NEW(allocator, Action)("Move up", "moveUp");
	m_move_up_action->is_global = false;
	m_app.addAction(m_move_up_action);

	m_move_down_action = LUMIX_NEW(allocator, Action)("Move down", "moveDown");
	m_move_down_action->is_global = false;
	m_app.addAction(m_move_down_action);

	m_camera_speed_action = LUMIX_NEW(allocator, Action)("Camera speed", "cameraSpeed");
	m_camera_speed_action->is_global = false;
	m_camera_speed_action->func.bind<SceneView, &SceneView::resetCameraSpeed>(this);
	m_app.addAction(m_camera_speed_action);

	m_app.getAssetBrowser()->resourceChanged().bind<SceneView, &SceneView::onResourceChanged>(this);
}


void SceneView::onResourceChanged(const Path& path, const char* /*ext*/)
{
	if (getPipeline()->getPath() == path) getPipeline()->load();
}


void SceneView::resetCameraSpeed()
{
	m_camera_speed = 0.1f;
}


SceneView::~SceneView()
{
	m_app.getAssetBrowser()->resourceChanged().unbind<SceneView, &SceneView::onResourceChanged>(this);
	m_editor->universeCreated().unbind<SceneView, &SceneView::onUniverseCreated>(this);
	m_editor->universeDestroyed().unbind<SceneView, &SceneView::onUniverseDestroyed>(this);
	Pipeline::destroy(m_pipeline);
	m_pipeline = nullptr;
}


void SceneView::setScene(RenderScene* scene)
{
	m_pipeline->setScene(scene);
}


void SceneView::onUniverseCreated()
{
	auto* scene = m_editor->getUniverse()->getScene(crc32("renderer"));
	m_pipeline->setScene(static_cast<RenderScene*>(scene));
}


void SceneView::onUniverseDestroyed()
{
	m_pipeline->setScene(nullptr);
}


void SceneView::update(float)
{
	PROFILE_FUNCTION();
{'fraction_non_alphanumeric': 0.14682456508069588, 'fraction_numerical': 0.0016767973171242926, 'mean_word_length': 8.495522388059701, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 83, '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': '5982516', 'n_tokens_mistral': 3449, 'n_tokens_neox': 3426, 'n_words': 470}