diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..e5d2d0db3c --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,52 @@ +Checks: '-*,readability-identifier-naming' +CheckOptions: + # Namespace: lowercase + - { key: readability-identifier-naming.NamespaceCase, value: lower_case } + + # Class/Struct: strip C/S prefix, snake_case + - { key: readability-identifier-naming.ClassCase, value: lower_case } + - { key: readability-identifier-naming.ClassPrefix, value: 'C' } + - { key: readability-identifier-naming.StructCase, value: lower_case } + - { key: readability-identifier-naming.StructPrefix, value: 'S' } + - { key: readability-identifier-naming.UnionCase, value: lower_case } + - { key: readability-identifier-naming.EnumCase, value: lower_case } + - { key: readability-identifier-naming.ScopedEnumCase, value: lower_case } + - { key: readability-identifier-naming.EnumPrefix, value: 'E' } + - { key: readability-identifier-naming.TypedefCase, value: lower_case } + - { key: readability-identifier-naming.TypeAliasCase, value: lower_case } + - { key: readability-identifier-naming.TemplateParameterCase, value: lower_case } + + # Function/Method: snake_case + - { key: readability-identifier-naming.FunctionCase, value: lower_case } + - { key: readability-identifier-naming.GlobalFunctionCase, value: lower_case } + - { key: readability-identifier-naming.MethodCase, value: lower_case } + + # Variables: snake_case + - { key: readability-identifier-naming.VariableCase, value: lower_case } + - { key: readability-identifier-naming.GlobalVariableCase, value: lower_case } + - { key: readability-identifier-naming.MemberCase, value: lower_case } + - { key: readability-identifier-naming.PrivateMemberCase, value: lower_case } + - { key: readability-identifier-naming.ProtectedMemberCase, value: lower_case } + - { key: readability-identifier-naming.PublicMemberCase, value: lower_case } + - { key: readability-identifier-naming.ConstantCase, value: lower_case } + - { key: readability-identifier-naming.ConstantMemberCase, value: lower_case } + - { key: readability-identifier-naming.StaticConstantCase, value: lower_case } + + # Members: strip m prefix, add trailing _ + - { key: readability-identifier-naming.MemberPrefix, value: 'm' } + - { key: readability-identifier-naming.MemberSuffix, value: '_' } + - { key: readability-identifier-naming.PrivateMemberPrefix, value: 'm' } + - { key: readability-identifier-naming.PrivateMemberSuffix, value: '_' } + - { key: readability-identifier-naming.ProtectedMemberPrefix, value: 'm' } + - { key: readability-identifier-naming.ProtectedMemberSuffix, value: '_' } + + # Parameter: strip p prefix, snake_case + - { key: readability-identifier-naming.ParameterCase, value: lower_case } + - { key: readability-identifier-naming.ParameterPrefix, value: 'p' } + - { key: readability-identifier-naming.ParameterPackCase, value: lower_case } + + # Enum values: snake_case + - { key: readability-identifier-naming.EnumConstantCase, value: lower_case } + + # Macro: keep UPPER_CASE + - { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE } diff --git a/ARC-Editor/src/EditorApp.cpp b/ARC-Editor/src/EditorApp.cpp index 58d3ded2f3..abd2d9ac49 100644 --- a/ARC-Editor/src/EditorApp.cpp +++ b/ARC-Editor/src/EditorApp.cpp @@ -5,14 +5,14 @@ #include "EditorApp.h" #include "EditorLayer.h" -namespace ARC { - CApplication* CreateApplication() +namespace arc { + application* create_application() { - return new CEditorApp(); + return new editor_app(); } - CEditorApp::CEditorApp() : - CApplication("ARC-Editor") + editor_app::editor_app() : + application("ARC-Editor") { - PushLayer(new CEditorLayer()); + push_layer(new editor_layer()); } } \ No newline at end of file diff --git a/ARC-Editor/src/EditorApp.h b/ARC-Editor/src/EditorApp.h index 8576278050..fe79047b8a 100644 --- a/ARC-Editor/src/EditorApp.h +++ b/ARC-Editor/src/EditorApp.h @@ -1,13 +1,13 @@ #pragma once #include "ARC/Core/Application.h" -namespace ARC { - class CEditorApp : public ARC::CApplication +namespace arc { + class editor_app : public arc::application { public: - CEditorApp(); - ~CEditorApp() {}; + editor_app(); + ~editor_app() {}; - inline virtual std::string GetAppName() override { return "ARC-Editor"; }; + inline virtual std::string get_app_name() override { return "ARC-Editor"; }; }; } \ No newline at end of file diff --git a/ARC-Editor/src/EditorLayer.cpp b/ARC-Editor/src/EditorLayer.cpp index 99a283f240..7ea5cfbea4 100644 --- a/ARC-Editor/src/EditorLayer.cpp +++ b/ARC-Editor/src/EditorLayer.cpp @@ -16,13 +16,13 @@ #include "ARC/Events/MouseEvent.h" #include "ARC/Events/KeyEvent.h" -namespace ARC { - static CEntity ESquare; - static CEntity ECamera; +namespace arc { + static entity ESquare; + static entity ECamera; - CEditorLayer::CEditorLayer() : - CLayer("EditorLayer"), - mCameraController(1280.f / 780.f, true) + editor_layer::editor_layer() : + layer("EditorLayer"), + camera_controller_(1280.f / 780.f, true) #ifdef ARC_DRAW_DEBUG_SHAPES , DrawDebugShapes(1u) #endif // ARC_DRAW_DEBUG_SHAPES @@ -30,135 +30,135 @@ namespace ARC { { } - void CEditorLayer::OnAttach() + void editor_layer::on_attach() { - mPlayButtonTexture = CTexture2D::Create(std::filesystem::path("resources/icons/PlayButton.png")); - mStopButtonTexture = CTexture2D::Create(std::filesystem::path("resources/icons/StopButton.png")); - mPauseButtonTexture = CTexture2D::Create(std::filesystem::path("resources/icons/PauseButton.png")); - mSimulateButtonTexture = CTexture2D::Create(std::filesystem::path("resources/icons/SimulateButton.png")); + play_button_texture_ = texture_2d::create(std::filesystem::path("resources/icons/PlayButton.png")); + stop_button_texture_ = texture_2d::create(std::filesystem::path("resources/icons/StopButton.png")); + pause_button_texture_ = texture_2d::create(std::filesystem::path("resources/icons/PauseButton.png")); + simulate_button_texture_ = texture_2d::create(std::filesystem::path("resources/icons/SimulateButton.png")); - SFrameBufferSpecification frame_buffer_specs; + frame_buffer_specification frame_buffer_specs; frame_buffer_specs.Width = 1280; frame_buffer_specs.Height = 720; - frame_buffer_specs.Attachments = { EFrameBufferTextureFormat::RGBA8, EFrameBufferTextureFormat::RED_INTEGER, EFrameBufferTextureFormat::DEPTH24STENCIL8 }; - mFrameBuffer = CFrameBuffer::Create(frame_buffer_specs); + frame_buffer_specs.Attachments = { frame_buffer_texture_format::RGBA8, frame_buffer_texture_format::RED_INTEGER, frame_buffer_texture_format::DEPTH24STENCIL8 }; + frame_buffer_ = framebuffer::create(frame_buffer_specs); - mActiveScene = CreateRef(); + active_scene_ = create_ref(); - mEditorScene = mActiveScene; + editor_scene_ = active_scene_; - mLifeSim2D = CreateRef(); - mSceneHierachyPanel.SetContext(mActiveScene); - mEditorCamera = CEditorCamera(30.0f, 1.778f, 0.1f, 1000.0f); + life_sim2_d_ = create_ref(); + scene_hierachy_panel_.set_context(active_scene_); + editor_camera_ = editor_camera(30.0f, 1.778f, 0.1f, 1000.0f); - mLifeSim2D->OnAttach(mActiveScene); + life_sim2_d_->on_attach(active_scene_); } - void CEditorLayer::OnDetach() + void editor_layer::on_detach() { - mLifeSim2D->OnDetach(); + life_sim2_d_->on_detach(); } - void CEditorLayer::OnUpdate(float _DeltaTime) + void editor_layer::on_update(float delta_time) { - if (SFrameBufferSpecification spec = mFrameBuffer->GetSpecifications(); - mViewportSize.x > 0.0f && mViewportSize.y > 0.0f && // zero sized framebuffer is invalid - (spec.Width != mViewportSize.x || spec.Height != mViewportSize.y)) + if (frame_buffer_specification spec = frame_buffer_->get_specifications(); + viewport_size_.x > 0.0f && viewport_size_.y > 0.0f && // zero sized framebuffer is invalid + (spec.Width != viewport_size_.x || spec.Height != viewport_size_.y)) { - mFrameBuffer->Resize({ (TUInt32)mViewportSize.x, (TUInt32)mViewportSize.y }); - mCameraController.OnResize(mViewportSize.x, mViewportSize.y); - mEditorCamera.SetViewportSize(mViewportSize.x, mViewportSize.y); - mActiveScene->OnViewportResize({ (TUInt32)mViewportSize.x, (TUInt32)mViewportSize.y }); + frame_buffer_->resize({ (u32)viewport_size_.x, (u32)viewport_size_.y }); + camera_controller_.OnResize(viewport_size_.x, viewport_size_.y); + editor_camera_.set_viewport_size(viewport_size_.x, viewport_size_.y); + active_scene_->on_viewport_resize({ (u32)viewport_size_.x, (u32)viewport_size_.y }); } - if (mIsViewportHovered && mIsViewportFocused) mCameraController.OnUpdate(_DeltaTime); + if (is_viewport_hovered_ && is_viewport_focused_) camera_controller_.on_update(delta_time); - SRenderer2D::ResetStats(); + renderer_2d::ResetStats(); - mFrameBuffer->Bind(); + frame_buffer_->bind(); - CRenderCommand::SetClearColour({ .1f, .1f, .1f, 1.f }); - CRenderCommand::Clear(); + render_command::set_clear_colour({ .1f, .1f, .1f, 1.f }); + render_command::clear(); - mFrameBuffer->ClearColorAttachment(1, -1); + frame_buffer_->ClearColorAttachment(1, -1); - switch (mSceneState) { - case ESceneState::Edit: - mActiveScene->OnUpdateEditor(_DeltaTime, mEditorCamera); - mLifeSim2D->OnUpdateEditor(_DeltaTime); + switch (scene_state_) { + case scene_state::Edit: + active_scene_->on_update_editor(delta_time, editor_camera_); + life_sim2_d_->on_update_editor(delta_time); break; - case ESceneState::Play: - mActiveScene->OnUpdateRuntime(_DeltaTime); - mLifeSim2D->OnUpdateRuntime(_DeltaTime); + case scene_state::Play: + active_scene_->on_update_runtime(delta_time); + life_sim2_d_->on_update_runtime(delta_time); break; - case ESceneState::Simulate: - mActiveScene->OnUpdateSimulation(_DeltaTime, mEditorCamera); + case scene_state::Simulate: + active_scene_->on_update_simulation(delta_time, editor_camera_); break; } - auto viewportSize = mViewportMaxBound-mViewportMinBound; - auto MousePos = (FVec2&)ImGui::GetMousePos() - mViewportMinBound; + auto viewportSize = viewport_max_bound_-viewport_min_bound_; + auto MousePos = (vec2&)ImGui::get_mouse_pos() - viewport_min_bound_; MousePos.y = viewportSize.y - MousePos.y; if (MousePos.x >= 0 && MousePos.y >= 0 && MousePos.x < viewportSize.x && MousePos.y < viewportSize.y) { - auto readPixel = mFrameBuffer->ReadPixel(1, MousePos.x, MousePos.y); - mHoveredEntity = readPixel == -1 ? CEntity{} : CEntity{ TEntityID(readPixel), mActiveScene.get() }; + auto readPixel = frame_buffer_->read_pixel(1, MousePos.x, MousePos.y); + hovered_entity_ = readPixel == -1 ? entity{} : entity{ entity_id(readPixel), active_scene_.get() }; } OnOverlayRender(); - mFrameBuffer->UnBind(); + frame_buffer_->UnBind(); - mEditorCamera.OnUpdate(_DeltaTime); + editor_camera_.on_update(delta_time); } - void CEditorLayer::OnEvent(CEvent& _Event) + void editor_layer::on_event(event& event) { - mEditorCamera.OnEvent(_Event); - CEventDispatcher dispatcher(_Event); - dispatcher.Dispatch(BIND_FN(&CEditorLayer::OnKeyPressed)); - dispatcher.Dispatch(BIND_FN(&CEditorLayer::OnMousePressedEvent)); + editor_camera_.on_event(event); + event_dispatcher dispatcher(event); + dispatcher.Dispatch(BIND_FN(&editor_layer::on_key_pressed)); + dispatcher.Dispatch(BIND_FN(&editor_layer::OnMousePressedEvent)); } - bool CEditorLayer::OnKeyPressed(CKeyPressedEvent& pE) + bool editor_layer::on_key_pressed(key_pressed_event& pE) { - if (pE.GetRepeatCount() > 0) + if (pE.get_repeat_count() > 0) return false; - bool control = SInput::IsKeyPressed(EKey::LeftControl) || SInput::IsKeyPressed(EKey::RightControl); - bool shift = SInput::IsKeyPressed(EKey::LeftShift) || SInput::IsKeyPressed(EKey::RightShift); + bool control = input::is_key_pressed(key::LeftControl) || input::is_key_pressed(key::RightControl); + bool shift = input::is_key_pressed(key::LeftShift) || input::is_key_pressed(key::RightShift); - switch (pE.GetKeyCode()) + switch (pE.get_key_code()) { // Scene - case EKey::N: + case key::N: { if (control) - NewScene(); + new_scene(); break; } - case EKey::O: + case key::O: { if (control) - OpenScene(); + open_scene(); break; } - case EKey::S: + case key::S: { if (control) { if (shift) - SaveSceneAs(); + save_scene_as(); else - SaveScene(); + save_scene(); } break; } // Editor - case EKey::D: + case key::D: { - switch (mSceneState) { - case ESceneState::Edit: - if (control && mSceneHierachyPanel.GetSelectedEntity()) - mSceneHierachyPanel.GetSelectedEntity().Duplicate(); // @TODO: Rename + switch (scene_state_) { + case scene_state::Edit: + if (control && scene_hierachy_panel_.get_selected_entity()) + scene_hierachy_panel_.get_selected_entity().Duplicate(); // @TODO: Rename break; }; @@ -166,41 +166,41 @@ namespace ARC { } // Gizmos - case EKey::Q: + case key::Q: { - if (!ImGuizmo::IsUsing()) - mGuizmoType = -1; + if (!ImGuizmo::is_using()) + guizmo_type_ = -1; break; } - case EKey::W: + case key::W: { - if (!ImGuizmo::IsUsing()) - mGuizmoType = ImGuizmo::OPERATION::TRANSLATE; + if (!ImGuizmo::is_using()) + guizmo_type_ = ImGuizmo::OPERATION::TRANSLATE; break; } - case EKey::E: + case key::E: { - if (!ImGuizmo::IsUsing()) - mGuizmoType = ImGuizmo::OPERATION::ROTATE; + if (!ImGuizmo::is_using()) + guizmo_type_ = ImGuizmo::OPERATION::ROTATE; break; } - case EKey::R: + case key::R: { - if (!ImGuizmo::IsUsing()) - mGuizmoType = ImGuizmo::OPERATION::SCALE; + if (!ImGuizmo::is_using()) + guizmo_type_ = ImGuizmo::OPERATION::SCALE; break; } } } - bool CEditorLayer::OnMousePressedEvent(CMouseButtonPressedEvent& pE) + bool editor_layer::OnMousePressedEvent(mouse_button_pressed_event& pE) { - if (pE.GetMouseButton() == EMouse::ButtonLeft) - if (mIsViewportHovered && !ImGuizmo::IsOver() && !SInput::IsKeyPressed(EKey::LeftAlt)) - mSceneHierachyPanel.SetSelectedEntity(mHoveredEntity); + if (pE.get_mouse_button() == mouse::ButtonLeft) + if (is_viewport_hovered_ && !ImGuizmo::is_over() && !input::is_key_pressed(key::LeftAlt)) + scene_hierachy_panel_.set_selected_entity(hovered_entity_); return false; } - void CEditorLayer::OnGuiRender() + void editor_layer::on_gui_render() { ARC_PROFILE_FUNCTION(); // Note: Switch this to true to enable dockspace @@ -217,37 +217,37 @@ namespace ARC { ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking; if (opt_fullscreen) { - ImGuiViewport* viewport = ImGui::GetMainViewport(); - ImGui::SetNextWindowPos(viewport->Pos); - ImGui::SetNextWindowSize(viewport->Size); - ImGui::SetNextWindowViewport(viewport->ID); + ImGuiViewport* viewport = ImGui::get_main_viewport(); + ImGui::set_next_window_pos(viewport->Pos); + ImGui::set_next_window_size(viewport->size); + ImGui::set_next_window_viewport(viewport->ID); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus; } - // When using ImGuiDockNodeFlags_PassthruCentralNode, DockSpace() will render our background and handle the pass-thru hole, so we ask Begin() to not render a background. + // When using ImGuiDockNodeFlags_PassthruCentralNode, DockSpace() will render our background and handle the pass-thru hole, so we ask begin() to not render a background. if (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode) window_flags |= ImGuiWindowFlags_NoBackground; - // Important: note that we proceed even if Begin() returns false (aka window is collapsed). + // Important: note that we proceed even if begin() returns false (aka window is collapsed). // This is because we want to keep our DockSpace() active. If a DockSpace() is inactive, // all active windows docked into it will lose their parent and become undocked. // We cannot preserve the docking relationship between an active window and an inactive docking, otherwise // any change of dockspace/settings would lead to windows being stuck in limbo and never being visible. ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); - ImGui::Begin("DockSpace Demo", &dockspaceOpen, window_flags); + ImGui::begin("DockSpace Demo", &dockspaceOpen, window_flags); ImGui::PopStyleVar(); if (opt_fullscreen) ImGui::PopStyleVar(2); // DockSpace - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO& io = ImGui::get_io(); if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable) { - ImGuiID dockspace_id = ImGui::GetID("MyDockSpace"); + ImGuiID dockspace_id = ImGui::get_id("MyDockSpace"); ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags); } @@ -262,39 +262,39 @@ namespace ARC { if (ImGui::MenuItem("Save")) {} if (ImGui::MenuItem("Open...", "Ctrl+O")) { - auto filepath = SFileDialogs::OpenFile("ARC-Engine Scene (*.arc)\0*.arc\0"); + auto filepath = file_dialogs::open_file("ARC-Engine Scene (*.arc)\0*.arc\0"); if (!filepath.empty()) - OpenScene(filepath); + open_scene(filepath); } if (ImGui::MenuItem("Save As...", "Ctrl+Shift+S")) { - auto filepath = SFileDialogs::SaveFile("ARC-Engine Scene (*.arc)\0*.arc\0"); + auto filepath = file_dialogs::save_file("ARC-Engine Scene (*.arc)\0*.arc\0"); if (!filepath.empty()) - mActiveScene->SerializeToText(filepath); + active_scene_->serialize_to_text(filepath); } - if (ImGui::MenuItem("Exit")) CApplication::Get().Shutdown(); + if (ImGui::MenuItem("Exit")) application::Get().shutdown(); ImGui::EndMenu(); } ImGui::EndMenuBar(); } - mSceneHierachyPanel.OnImGuiRender(); - mContentBrowserPanel.OnImGuiRender(); + scene_hierachy_panel_.on_imgui_render(); + content_browser_panel_.on_imgui_render(); - ImGui::Begin("Settings"); + ImGui::begin("set_tings"); - auto stats = SRenderer2D::GetStats(); + auto stats = renderer_2d::get_stats(); ImGui::Text("Renderer2D Stats:"); ImGui::Text("Draw Calls: %d", stats.DrawCalls); ImGui::Text("Quads: %d", stats.QuadCount); - ImGui::Text("Vertices: %d", stats.GetTotalVertexCount()); - ImGui::Text("Indices: %d", stats.GetTotalIndexCount()); + ImGui::Text("Vertices: %d", stats.get_total_vertex_count()); + ImGui::Text("Indices: %d", stats.get_total_index_count()); - TString name = "None"; + string name = "None"; - if (mHoveredEntity && mHoveredEntity.HasComponent()) - name = mHoveredEntity.GetComponent().Name; + if (hovered_entity_ && hovered_entity_.has_component()) + name = hovered_entity_.get_component().Name; ImGui::Text("Hovered Entity: %s", name.c_str()); @@ -318,203 +318,203 @@ namespace ARC { ImGui::TreePop(); } - ImGui::End(); + ImGui::end(); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 5, 5 }); - ImGui::Begin("Viewport"); - auto viewportMinRegion = (FVec2&)ImGui::GetWindowContentRegionMin(); - auto viewportMaxRegion = (FVec2&)ImGui::GetWindowContentRegionMax(); - auto viewportOffset = (FVec2&)ImGui::GetWindowPos(); + ImGui::begin("Viewport"); + auto viewportMinRegion = (vec2&)ImGui::get_window_content_region_min(); + auto viewportMaxRegion = (vec2&)ImGui::get_window_content_region_max(); + auto viewportOffset = (vec2&)ImGui::get_window_pos(); - mViewportMinBound = viewportMinRegion + viewportOffset; - mViewportMaxBound = viewportMaxRegion + viewportOffset; + viewport_min_bound_ = viewportMinRegion + viewportOffset; + viewport_max_bound_ = viewportMaxRegion + viewportOffset; - mIsViewportFocused = ImGui::IsWindowFocused(); - mIsViewportHovered = ImGui::IsWindowHovered(); + is_viewport_focused_ = ImGui::is_window_focused(); + is_viewport_hovered_ = ImGui::is_window_hovered(); - CApplication::Get().GetImGuiLayer()->SetBlockEvents(!mIsViewportFocused || !mIsViewportHovered); - ImVec2 viewportPanelSize = ImGui::GetContentRegionAvail(); - mViewportSize = { viewportPanelSize.x, viewportPanelSize.y }; - TUInt64 textureID = mFrameBuffer->GetColorAttachmentRendererID(); + application::Get().get_imgui_layer()->set_block_events(!is_viewport_focused_ || !is_viewport_hovered_); + ImVec2 viewportPanelSize = ImGui::get_content_region_avail(); + viewport_size_ = { viewportPanelSize.x, viewportPanelSize.y }; + u64 textureID = frame_buffer_->get_color_attachment_renderer_id(); - ImGui::Image((void*)textureID, ImVec2{ mViewportSize.x, mViewportSize.y }, ImVec2{ 0, 1 }, ImVec2{ 1, 0 }); + ImGui::Image((void*)textureID, ImVec2{ viewport_size_.x, viewport_size_.y }, ImVec2{ 0, 1 }, ImVec2{ 1, 0 }); if (ImGui::BeginDragDropTarget()) { if (const auto* payload = ImGui::AcceptDragDropPayload("CONTENT_BROWSER_ITEM")) { const auto* path = (const wchar_t*)payload->Data; - OpenScene(std::filesystem::path("assets")/std::filesystem::path(path)); + open_scene(std::filesystem::path("assets")/std::filesystem::path(path)); } ImGui::EndDragDropTarget(); } // Gizmos - CEntity selectedEntity = mSceneHierachyPanel.GetSelectedEntity(); - if (selectedEntity && mGuizmoType != -1) + entity selectedEntity = scene_hierachy_panel_.get_selected_entity(); + if (selectedEntity && guizmo_type_ != -1) { - ImGuizmo::SetOrthographic(false); - ImGuizmo::SetDrawlist(); - ImGuizmo::SetRect(mViewportMinBound.x, mViewportMinBound.y, mViewportMaxBound.x-mViewportMinBound.x, mViewportMaxBound.y - mViewportMinBound.y); + ImGuizmo::set_orthographic(false); + ImGuizmo::set_drawlist(); + ImGuizmo::set_rect(viewport_min_bound_.x, viewport_min_bound_.y, viewport_max_bound_.x-viewport_min_bound_.x, viewport_max_bound_.y - viewport_min_bound_.y); - if (selectedEntity.HasComponent()) + if (selectedEntity.has_component()) { // Snapping - bool snap = SInput::IsKeyPressed(EKey::LeftControl); + bool snap = input::is_key_pressed(key::LeftControl); float snapValue = 0.5f; // Snap to 0.5m for translation/scale // Snap to 45 degrees for rotation - if (mGuizmoType == ImGuizmo::OPERATION::ROTATE) + if (guizmo_type_ == ImGuizmo::OPERATION::ROTATE) snapValue = 45.0f; float snapValues[3] = { snapValue, snapValue, snapValue }; - auto& entityTransform = selectedEntity.GetComponent().Transform; - auto entityTransformMatrix = SConvert::Conv(entityTransform); + auto& entityTransform = selectedEntity.get_component().Transform; + auto entityTransformMatrix = convert::Conv(entityTransform); ImGuizmo::Manipulate( - glm::value_ptr(mEditorCamera.GetViewMatrix()), - glm::value_ptr(mEditorCamera.GetProjection()), - (ImGuizmo::OPERATION)mGuizmoType, + glm::value_ptr(editor_camera_.get_view_matrix()), + glm::value_ptr(editor_camera_.get_projection()), + (ImGuizmo::OPERATION)guizmo_type_, ImGuizmo::LOCAL, glm::value_ptr(entityTransformMatrix), nullptr, snap ? snapValues : nullptr ); - if (ImGuizmo::IsUsing()) - entityTransform = SConvert::Conv(entityTransformMatrix); + if (ImGuizmo::is_using()) + entityTransform = convert::Conv(entityTransformMatrix); } } - ImGui::End(); + ImGui::end(); ImGui::PopStyleVar(); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 2)); ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(0, 2)); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0,0,0,0.1)); - const auto& tmp = ImGui::GetStyle().Colors[ImGuiCol_ButtonHovered]; + const auto& tmp = ImGui::get_style().Colors[ImGuiCol_ButtonHovered]; ImGui::PushStyleColor(ImGuiCol_ButtonHovered, { tmp.x,tmp.y,tmp.z,tmp.w / 2 }); - const auto& tmp2 = ImGui::GetStyle().Colors[ImGuiCol_ButtonHovered]; + const auto& tmp2 = ImGui::get_style().Colors[ImGuiCol_ButtonHovered]; ImGui::PushStyleColor(ImGuiCol_ButtonActive, { tmp2.x,tmp2.y,tmp2.z,tmp2.w / 2 }); - ImGui::Begin("##toolbar", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoScrollWithMouse); - auto buttonSize = ImGui::GetWindowHeight()-10; - switch (mSceneState) { - case ESceneState::Edit: - ImGui::SetCursorPosX((ImGui::GetContentRegionMax().x) * 0.5f - buttonSize); - - if (ImGui::ImageButton((ImTextureID)(uint64_t)mPlayButtonTexture->GetRendererID(), ImVec2(buttonSize, buttonSize), ImVec2(0, 0), ImVec2(1, 1), 0)) { - SetSceneState(ESceneState::Play); + ImGui::begin("##toolbar", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoScrollWithMouse); + auto buttonSize = ImGui::get_window_height()-10; + switch (scene_state_) { + case scene_state::Edit: + ImGui::set_cursor_pos_x((ImGui::get_content_region_max().x) * 0.5f - buttonSize); + + if (ImGui::ImageButton((ImTextureID)(uint64_t)play_button_texture_->get_renderer_id(), ImVec2(buttonSize, buttonSize), ImVec2(0, 0), ImVec2(1, 1), 0)) { + set_scene_state(scene_state::Play); } ImGui::SameLine(); - if (ImGui::ImageButton((ImTextureID)(uint64_t)mSimulateButtonTexture->GetRendererID(), ImVec2(buttonSize, buttonSize), ImVec2(0, 0), ImVec2(1, 1), 0)) { - SetSceneState(ESceneState::Simulate); + if (ImGui::ImageButton((ImTextureID)(uint64_t)simulate_button_texture_->get_renderer_id(), ImVec2(buttonSize, buttonSize), ImVec2(0, 0), ImVec2(1, 1), 0)) { + set_scene_state(scene_state::Simulate); } break; - case ESceneState::Play: case ESceneState::Simulate: - ImGui::SetCursorPosX((ImGui::GetContentRegionMax().x - buttonSize) * 0.5f); - if (ImGui::ImageButton((ImTextureID)(uint64_t)mStopButtonTexture->GetRendererID(), ImVec2(buttonSize, buttonSize), ImVec2(0, 0), ImVec2(1, 1), 0)) { - SetSceneState(ESceneState::Edit); + case scene_state::Play: case scene_state::Simulate: + ImGui::set_cursor_pos_x((ImGui::get_content_region_max().x - buttonSize) * 0.5f); + if (ImGui::ImageButton((ImTextureID)(uint64_t)stop_button_texture_->get_renderer_id(), ImVec2(buttonSize, buttonSize), ImVec2(0, 0), ImVec2(1, 1), 0)) { + set_scene_state(scene_state::Edit); } break; } - ImGui::End(); + ImGui::end(); ImGui::PopStyleVar(2); ImGui::PopStyleColor(3); - mLifeSim2D->OnGuiRender(); - ImGui::End(); + life_sim2_d_->on_gui_render(); + ImGui::end(); } } - void CEditorLayer::NewScene() + void editor_layer::new_scene() { - mActiveScene = CreateRef(); - mActiveScene->OnViewportResize(TVec2(mViewportSize.x, mViewportSize.y)); - mSceneHierachyPanel.SetContext(mActiveScene); - mEditorScenePath = std::filesystem::path(); + active_scene_ = create_ref(); + active_scene_->on_viewport_resize(vec2(viewport_size_.x, viewport_size_.y)); + scene_hierachy_panel_.set_context(active_scene_); + editor_scene_path_ = std::filesystem::path(); } - void CEditorLayer::OpenScene() + void editor_layer::open_scene() { - OpenScene(SFileDialogs::OpenFile("ARC-Engine Scene (*.arc)\0*.arc\0")); + open_scene(file_dialogs::open_file("ARC-Engine Scene (*.arc)\0*.arc\0")); } - void CEditorLayer::OpenScene(const std::filesystem::path& pFilepath) + void editor_layer::open_scene(const std::filesystem::path& pFilepath) { if (pFilepath.empty()) return; if (pFilepath.extension().string() != ".arc") return; - mEditorScene = CreateRef(); - mEditorScene->OnViewportResize(TVec2(mViewportSize.x, mViewportSize.y)); - mEditorScene->DeserializeFromText(pFilepath); + editor_scene_ = create_ref(); + editor_scene_->on_viewport_resize(vec2(viewport_size_.x, viewport_size_.y)); + editor_scene_->deserialize_from_text(pFilepath); - SetSceneState(ESceneState::Edit); + set_scene_state(scene_state::Edit); - mEditorScenePath = pFilepath; + editor_scene_path_ = pFilepath; } - void CEditorLayer::SaveSceneAs() + void editor_layer::save_scene_as() { - auto filepath = SFileDialogs::SaveFile("ARC-Engine Scene (*.arc)\0*.arc\0"); + auto filepath = file_dialogs::save_file("ARC-Engine Scene (*.arc)\0*.arc\0"); if (filepath.empty()) return; - mEditorScenePath = filepath; - mActiveScene->SerializeToText(filepath); + editor_scene_path_ = filepath; + active_scene_->serialize_to_text(filepath); } - void CEditorLayer::SaveScene() + void editor_layer::save_scene() { - if (mEditorScenePath.empty()) SaveSceneAs(); - else mActiveScene->SerializeToText(mEditorScenePath); + if (editor_scene_path_.empty()) save_scene_as(); + else active_scene_->serialize_to_text(editor_scene_path_); } - void CEditorLayer::SetSceneState(ESceneState pNewState) + void editor_layer::set_scene_state(scene_state pNewState) { - if (mSceneState == ESceneState::Play || mSceneState == ESceneState::Simulate) { - mActiveScene->OnSetSceneState((TUInt8)mSceneState, 0); + if (scene_state_ == scene_state::Play || scene_state_ == scene_state::Simulate) { + active_scene_->on_set_scene_state((u8)scene_state_, 0); } - mActiveScene = pNewState == ESceneState::Edit ? mEditorScene : CScene::Copy(mEditorScene); + active_scene_ = pNewState == scene_state::Edit ? editor_scene_ : scene::copy(editor_scene_); - mLifeSim2D->SetScene(mActiveScene); - mActiveScene->OnSetSceneState(0, (TUInt8)pNewState); - mSceneState = pNewState; + life_sim2_d_->set_scene(active_scene_); + active_scene_->on_set_scene_state(0, (u8)pNewState); + scene_state_ = pNewState; - mSceneHierachyPanel.SetContext(mActiveScene); + scene_hierachy_panel_.set_context(active_scene_); } - void CEditorLayer::OnOverlayRender() + void editor_layer::OnOverlayRender() { #ifdef ARC_DRAW_DEBUG_SHAPES - SRenderer2D::EndScene(); - switch (mSceneState) { - case ESceneState::Edit: case ESceneState::Simulate: - SRenderer2D::BeginScene(mEditorCamera); + renderer_2d::end_scene(); + switch (scene_state_) { + case scene_state::Edit: case scene_state::Simulate: + renderer_2d::begin_scene(editor_camera_); break; - case ESceneState::Play: - if (auto e = mActiveScene->GetPrimaryCameraEntity()) - SRenderer2D::BeginScene(e.GetComponent().Camera, e.GetComponent().Transform); + case scene_state::Play: + if (auto e = active_scene_->get_primary_camera_entity()) + renderer_2d::begin_scene(e.get_component().Camera, e.get_component().Transform); break; } - mActiveScene->FilterByComponents().each([&](auto e, auto& transformComponent, auto& circleColliderComponent) { + active_scene_->FilterByComponents().each([&](auto e, auto& transformComponent, auto& circleColliderComponent) { if (DrawDebugShapes) { - SRenderer2D::DrawCircle(transformComponent.Transform.Location+FVec3(circleColliderComponent.Offset.x, circleColliderComponent.Offset.y, 0.001), transformComponent.Transform.Rotation, FVec2(circleColliderComponent.Radius) * transformComponent.Transform.Scale.x * 2.f, DebugCircleColliderColor, DebugCircleColliderThickness, 0.995, (int)e); + renderer_2d::draw_circle(transformComponent.Transform.Location+vec3(circleColliderComponent.Offset.x, circleColliderComponent.Offset.y, 0.001), transformComponent.Transform.Rotation, vec2(circleColliderComponent.Radius) * transformComponent.Transform.Scale.x * 2.f, DebugCircleColliderColor, DebugCircleColliderThickness, 0.995, (int)e); } }); - mActiveScene->FilterByComponents().each([&](auto e, auto& transformComponent, auto& boxColliderComponent) { + active_scene_->FilterByComponents().each([&](auto e, auto& transformComponent, auto& boxColliderComponent) { if (DrawDebugShapes) { - float lT = SRenderer2D::GetLineThickness(); - SRenderer2D::SetLineThickness(DebugBoxColliderThickness); - SRenderer2D::DrawRect( - transformComponent.Transform.Location + FVec3(boxColliderComponent.Offset.x, boxColliderComponent.Offset.y, 0.001), + float lT = renderer_2d::get_line_thickness(); + renderer_2d::set_line_thickness(DebugBoxColliderThickness); + renderer_2d::DrawRect( + transformComponent.Transform.Location + vec3(boxColliderComponent.Offset.x, boxColliderComponent.Offset.y, 0.001), transformComponent.Transform.Rotation, - boxColliderComponent.Size * transformComponent.Transform.Scale * 2.f, + boxColliderComponent.size * transformComponent.Transform.Scale * 2.f, DebugBoxColliderColor, (int)e); - SRenderer2D::SetLineThickness(lT); + renderer_2d::set_line_thickness(lT); } }); - SRenderer2D::EndScene(); + renderer_2d::end_scene(); #endif // ARC_DRAW_DEBUG_SHAPES } diff --git a/ARC-Editor/src/EditorLayer.h b/ARC-Editor/src/EditorLayer.h index 20a48c965d..42ad8e9c48 100644 --- a/ARC-Editor/src/EditorLayer.h +++ b/ARC-Editor/src/EditorLayer.h @@ -7,44 +7,44 @@ #include "ARC/Scene/EditorCamera.h" #include "ARC/Core/Macros.h" -namespace ARC { class CLifeSim2D; } -namespace ARC { class CFrameBuffer; } -namespace ARC { class CScene; } -namespace ARC { class CKeyPressedEvent; } -namespace ARC { class CMouseButtonPressedEvent; } -namespace ARC { class CMouseButtonReleasedEvent; } +namespace arc { class life_sim_2d; } +namespace arc { class framebuffer; } +namespace arc { class scene; } +namespace arc { class key_pressed_event; } +namespace arc { class mouse_button_pressed_event; } +namespace arc { class mouse_button_released_event; } -namespace ARC { - enum class ESceneState : TUInt8 { +namespace arc { + enum class scene_state : u8 { None = 0, Edit=1, Play=2, Simulate=3 }; - class CEditorLayer : public CLayer + class editor_layer : public layer { public: - CEditorLayer(); - virtual ~CEditorLayer() = default; - virtual void OnGuiRender() override; + editor_layer(); + virtual ~editor_layer() = default; + virtual void on_gui_render() override; - virtual void OnAttach() override; - virtual void OnDetach() override; + virtual void on_attach() override; + virtual void on_detach() override; - virtual void OnUpdate(float pDeltaTime) override; - virtual void OnEvent(CEvent& pEvent) override; + virtual void on_update(float pDeltaTime) override; + virtual void on_event(event& pEvent) override; - bool OnKeyPressed(CKeyPressedEvent& pE); - bool OnMousePressedEvent(CMouseButtonPressedEvent& pE); + bool on_key_pressed(key_pressed_event& pE); + bool OnMousePressedEvent(mouse_button_pressed_event& pE); - void NewScene(); - void OpenScene(); - void OpenScene(const std::filesystem::path& pFilepath); - void SaveSceneAs(); - void SaveScene(); + void new_scene(); + void open_scene(); + void open_scene(const std::filesystem::path& pFilepath); + void save_scene_as(); + void save_scene(); - void SetSceneState(ESceneState pNewState); + void set_scene_state(scene_state pNewState); void OnOverlayRender(); @@ -53,37 +53,37 @@ namespace ARC { #ifdef ARC_DRAW_DEBUG_SHAPES bool DrawDebugShapes; float DebugCircleColliderThickness = 0.1f; - FColor4 DebugCircleColliderColor = FColor4::Green(); + color4 DebugCircleColliderColor = color4::Green(); float DebugBoxColliderThickness = 0.1f; - FColor4 DebugBoxColliderColor = FColor4::Green(); + color4 DebugBoxColliderColor = color4::Green(); #endif protected: private: - TUInt8 mIsViewportFocused : 1; - TUInt8 mIsViewportHovered : 1; - FVec2 mViewportSize; - FVec2 mViewportMinBound; - FVec2 mViewportMaxBound; + u8 is_viewport_focused_ : 1; + u8 is_viewport_hovered_ : 1; + vec2 viewport_size_; + vec2 viewport_min_bound_; + vec2 viewport_max_bound_; - int mGuizmoType = -1; - CEntity mHoveredEntity; - TRef mFrameBuffer; - TRef mActiveScene; - TRef mEditorScene; - TRef mLifeSim2D; + int guizmo_type_ = -1; + entity hovered_entity_; + ref frame_buffer_; + ref active_scene_; + ref editor_scene_; + ref life_sim2_d_; - std::filesystem::path mEditorScenePath; + std::filesystem::path editor_scene_path_; - CEditorCamera mEditorCamera; - COrthographicCameraController mCameraController; - CSceneHierarchyPanel mSceneHierachyPanel; - CContentBrowserPanel mContentBrowserPanel; + editor_camera editor_camera_; + orthographic_camera_controller camera_controller_; + scene_hierarchy_panel scene_hierachy_panel_; + content_browser_panel content_browser_panel_; - ESceneState mSceneState = ESceneState::Edit; - TRef mPlayButtonTexture; - TRef mStopButtonTexture; - TRef mSimulateButtonTexture; - TRef mPauseButtonTexture; + scene_state scene_state_ = scene_state::Edit; + ref play_button_texture_; + ref stop_button_texture_; + ref simulate_button_texture_; + ref pause_button_texture_; }; } \ No newline at end of file diff --git a/ARC-Editor/src/LifeSim2D/LifeSim2D.cpp b/ARC-Editor/src/LifeSim2D/LifeSim2D.cpp index b9b9363a46..5ff4af4df3 100644 --- a/ARC-Editor/src/LifeSim2D/LifeSim2D.cpp +++ b/ARC-Editor/src/LifeSim2D/LifeSim2D.cpp @@ -10,17 +10,17 @@ #include "ARC/Renderer/Renderer2D.h" #include "imgui/imgui_internal.h" -namespace ARC { +namespace arc { // 2d only static bool bPause = false; - static FVec3 FindClosestPointOnLine(FVec3 pLB, FVec3 pLE, FVec3 pP) + static vec3 FindClosestPointOnLine(vec3 pLB, vec3 pLE, vec3 pP) { - float LineLength = SMath::Dist(pLB, pLE); - FVec3 Vector = pP - pLB; - FVec3 LineDirection = (pLE - pLB) / LineLength; + float LineLength = math::Dist(pLB, pLE); + vec3 Vector = pP - pLB; + vec3 LineDirection = (pLE - pLB) / LineLength; - FVec3 tmp(Vector * LineDirection); + vec3 tmp(Vector * LineDirection); float Distance = tmp.x + tmp.y; if (Distance <= 0.f) return pLB; @@ -28,27 +28,27 @@ namespace ARC { return pLB + LineDirection * Distance; } - static bool IsColliding(FVec3 p1, FVec3 p2, float pR1, float pR2) { return SMath::DistSqr(p1, p2) < SMath::Sqr(pR1+pR2); } + static bool is_colliding(vec3 p1, vec3 p2, float pR1, float pR2) { return math::DistSqr(p1, p2) < math::Sqr(pR1+pR2); } // basic simple light based organism simulator - void CEnergyComponent::DrawPropertiesUI(CEntity & pEntity) + void energy_component::draw_properties_ui(entity & pEntity) { ImGui::DragFloat("Energy", &Energy); } - void CEnergyComponent::Serialize(YAML::Emitter& pOut) + void energy_component::serialize(YAML::Emitter& pOut) { pOut << YAML::Key << "Energy" << YAML::Value << Energy; } - void CEnergyComponent::Deserialize(YAML::Node& pData) + void energy_component::deserialize(YAML::Node& pData) { Energy = pData["Energy"].as(); } - void COrganismComponent::DrawPropertiesUI(CEntity& pEntity) + void organism_component::draw_properties_ui(entity& pEntity) { if (ImGui::CollapsingHeader("Data")) { ImGui::DragFloat("Health", &Data.Health, 0.01 * Data.MaxHealth, 0, Data.MaxHealth); @@ -67,13 +67,13 @@ namespace ARC { } } - void COrganismComponent::Serialize(YAML::Emitter& pOut) + void organism_component::serialize(YAML::Emitter& pOut) { pOut << YAML::Key << "Health" << YAML::Value << Data.Health; pOut << YAML::Key << "Speed" << YAML::Value << Data.Speed; } - void COrganismComponent::Deserialize(YAML::Node& pData) + void organism_component::deserialize(YAML::Node& pData) { Data.Health = pData["Health"].as(); Data.Speed = pData["Speed"].as(); @@ -82,7 +82,7 @@ namespace ARC { struct SResourceManager { static float Consume(float pAmt, float& pResource, float pReserve=0.f) { - auto rval = SMath::Min(pResource-pReserve, pAmt); + auto rval = math::Min(pResource-pReserve, pAmt); pResource -= rval; return rval; } @@ -91,8 +91,8 @@ namespace ARC { */ static float Convert(float& pResourceFrom, float& pResourceTo, float pAmt, float pConversionFactor=1.f, float pResourceToCap=std::numeric_limits::infinity()) { - auto deltaTo = SMath::Min( - SMath::Min(pResourceFrom, pAmt) * pConversionFactor, + auto deltaTo = math::Min( + math::Min(pResourceFrom, pAmt) * pConversionFactor, pResourceToCap - pResourceTo ); pResourceTo += deltaTo; @@ -107,65 +107,65 @@ namespace ARC { // @TODO add basic color schemeing and name bars for organisms - CEntity CLifeSim2D::MakeOrganism(const TString& pName) + entity life_sim_2d::MakeOrganism(const string& pName) { - static auto CircleTex = CTexture2D::Create("assets/textures/circle-64.png"); - - CEntity oE = mActiveScene->CreateEntity(pName == "##Default" ? "Organism#" + std::to_string(mEIndex++) : pName); - auto& trans = oE.AddComponent(); - oE.AddComponent().Texture=CircleTex; - auto& organism = oE.AddComponent(); - auto& energy = oE.AddComponent().Energy = organism.Data.InitialEnergy; - auto& velocity = oE.AddComponent().Velocity = FVec2::ZeroVector(); + static auto CircleTex = texture_2d::create("assets/textures/circle-64.png"); + + entity oE = active_scene_->create_entity(pName == "##Default" ? "Organism#" + std::to_string(e_index_++) : pName); + auto& trans = oE.add_component(); + oE.add_component().Texture=CircleTex; + auto& organism = oE.add_component(); + auto& energy = oE.add_component().Energy = organism.Data.InitialEnergy; + auto& velocity = oE.add_component().Velocity = vec2::ZeroVector(); return oE; } - float CLifeSim2D::HealthToSize(float pHealth) + float life_sim_2d::HealthToSize(float pHealth) { - return SMath::Max(pHealth*pHealth/8000, mMinSize); + return math::Max(pHealth*pHealth/8000, min_size_); } - float CLifeSim2D::LightToRadiation(float pLight) + float life_sim_2d::LightToRadiation(float pLight) { return pLight*0.68; } - CLifeSim2D::CWorldGeoData& CLifeSim2D::GetGeoDataFromLocation(FVec3 pLoc) + life_sim_2d::world_geo_data& life_sim_2d::get_geo_data_from_location(vec3 pLoc) { - if (pLoc.x > mWorldMaxBounds.x || pLoc.x < -mWorldMaxBounds.x || pLoc.y > mWorldMaxBounds.y || pLoc.y < -mWorldMaxBounds.y) return mEmptySpace; + if (pLoc.x > world_max_bounds_.x || pLoc.x < -world_max_bounds_.x || pLoc.y > world_max_bounds_.y || pLoc.y < -world_max_bounds_.y) return empty_space_; - float nearestX = float(std::floor((mWorldMaxBounds.x + pLoc.x) * mGridDensity)); - float nearestY = float(std::floor((mWorldMaxBounds.y - pLoc.y) * mGridDensity)); + float nearestX = float(std::floor((world_max_bounds_.x + pLoc.x) * grid_density_)); + float nearestY = float(std::floor((world_max_bounds_.y - pLoc.y) * grid_density_)); - return mWorldGeoData[int(nearestX + 2 * mWorldMaxBounds.x * mGridDensity * nearestY)];; + return world_geo_data_[int(nearestX + 2 * world_max_bounds_.x * grid_density_ * nearestY)];; } - const CLifeSim2D::CWorldGeoData& CLifeSim2D::GetGeoDataFromLocation(FVec3 pLoc) const + const life_sim_2d::world_geo_data& life_sim_2d::get_geo_data_from_location(vec3 pLoc) const { - if (pLoc.x > mWorldMaxBounds.x || pLoc.x < -mWorldMaxBounds.x || pLoc.y > mWorldMaxBounds.y || pLoc.y < -mWorldMaxBounds.y) return mEmptySpace; + if (pLoc.x > world_max_bounds_.x || pLoc.x < -world_max_bounds_.x || pLoc.y > world_max_bounds_.y || pLoc.y < -world_max_bounds_.y) return empty_space_; - float nearestX = float(std::floor((mWorldMaxBounds.x + pLoc.x) * mGridDensity)); - float nearestY = float(std::floor((mWorldMaxBounds.y - pLoc.y) * mGridDensity)); + float nearestX = float(std::floor((world_max_bounds_.x + pLoc.x) * grid_density_)); + float nearestY = float(std::floor((world_max_bounds_.y - pLoc.y) * grid_density_)); - auto _ = int(nearestX + 2 * mWorldMaxBounds.x * mGridDensity * nearestY); + auto _ = int(nearestX + 2 * world_max_bounds_.x * grid_density_ * nearestY); - return mWorldGeoData[_]; + return world_geo_data_[_]; } - void CLifeSim2D::OnAttach(TRef pActiveScene) + void life_sim_2d::on_attach(ref pActiveScene) { - SetScene(pActiveScene); + set_scene(pActiveScene); - SSceneRegistry::SetupComponent(); - SSceneRegistry::SetupComponent(); - SSceneRegistry::SetupComponent(); + scene_registry::setup_component(); + scene_registry::setup_component(); + scene_registry::setup_component(); { - auto camE = mActiveScene->CreateEntity("Camera"); - auto& trans = camE.AddComponent(); - auto& cam = camE.AddComponent(); + auto camE = active_scene_->create_entity("Camera"); + auto& trans = camE.add_component(); + auto& cam = camE.add_component(); cam.Primary = true; - cam.Camera.SetOrthographicSize((mWorldMaxBounds.MaxComponent()*2.f)); + cam.Camera.set_orthographic_size((world_max_bounds_.MaxComponent()*2.f)); } for (int i = 0; i<1000; i++) @@ -173,112 +173,112 @@ namespace ARC { } - void CLifeSim2D::OnDetach() + void life_sim_2d::on_detach() { } - void CLifeSim2D::OnUpdateEditor(float pDeltaTime) + void life_sim_2d::on_update_editor(float pDeltaTime) { if (bPause) return; - static const FVec3 Mask = FVec3(1, 1, 0); + static const vec3 Mask = vec3(1, 1, 0); } - void CLifeSim2D::OnUpdateRuntime(float pDeltaTime) + void life_sim_2d::on_update_runtime(float pDeltaTime) { if (bPause) return; - static const FVec3 Mask = FVec3(1, 1, 0); + static const vec3 Mask = vec3(1, 1, 0); - pDeltaTime*= mTimeMultiplier; - mTime += pDeltaTime; + pDeltaTime*= time_multiplier_; + time_ += pDeltaTime; - std::set DeathRow; + std::set DeathRow; - if (auto E = mActiveScene->GetPrimaryCameraEntity()) + if (auto E = active_scene_->get_primary_camera_entity()) { static bool itrlDO2 = true; - SRenderer2D::BeginScene(E.GetComponent().Camera, E.GetComponent().Transform); - SRenderer2D::DrawRect(FVec3::ZeroVector(), 0.f, mWorldMaxBounds * 2.f, FColor4::Yellow()*0.7f); - SRenderer2D::DrawRect(FVec3::ZeroVector(), 0.f, (mWorldMaxBounds * 2.f) + 1, FColor4::Blue() * 0.9f); + renderer_2d::begin_scene(E.get_component().Camera, E.get_component().Transform); + renderer_2d::DrawRect(vec3::ZeroVector(), 0.f, world_max_bounds_ * 2.f, color4::Yellow()*0.7f); + renderer_2d::DrawRect(vec3::ZeroVector(), 0.f, (world_max_bounds_ * 2.f) + 1, color4::Blue() * 0.9f); { - auto view = mActiveScene->FilterByComponents(); + auto view = active_scene_->FilterByComponents(); std::for_each(std::execution::par_unseq, view.begin(), view.end(), [&](auto e) { - auto& transformComponent = view.get(e); - auto& velocityComponent = view.get(e); + auto& transformComponent = view.get(e); + auto& velocityComponent = view.get(e); - (FVec2&)transformComponent.Transform.Location += velocityComponent.Velocity*pDeltaTime; + (vec2&)transformComponent.Transform.Location += velocityComponent.Velocity*pDeltaTime; }); } static float savedDT = 0; savedDT += pDeltaTime; { - auto view= mActiveScene->FilterByComponents(); + auto view= active_scene_->FilterByComponents(); std::for_each(std::execution::par_unseq, view.begin(), view.end(), [&](auto e) { - auto& transformComponent = view.get(e); - auto& organism = view.get(e); - if (transformComponent.Transform.Location.x > mWorldMaxBounds.x) transformComponent.Transform.Location.x = -mWorldMaxBounds.x; - if (transformComponent.Transform.Location.x < -mWorldMaxBounds.x) transformComponent.Transform.Location.x = mWorldMaxBounds.x; - if (transformComponent.Transform.Location.y > mWorldMaxBounds.y) transformComponent.Transform.Location.y = -mWorldMaxBounds.y; - if (transformComponent.Transform.Location.y < -mWorldMaxBounds.y) transformComponent.Transform.Location.y = mWorldMaxBounds.y; - - if (savedDT > SRandom::Float(1, 1.5)) { - transformComponent.Transform.Scale = FVec2(HealthToSize(organism.Data.Health)); - - auto E = CEntity(e, mActiveScene.get()); - auto& energy = E.GetComponent(); + auto& transformComponent = view.get(e); + auto& organism = view.get(e); + if (transformComponent.Transform.Location.x > world_max_bounds_.x) transformComponent.Transform.Location.x = -world_max_bounds_.x; + if (transformComponent.Transform.Location.x < -world_max_bounds_.x) transformComponent.Transform.Location.x = world_max_bounds_.x; + if (transformComponent.Transform.Location.y > world_max_bounds_.y) transformComponent.Transform.Location.y = -world_max_bounds_.y; + if (transformComponent.Transform.Location.y < -world_max_bounds_.y) transformComponent.Transform.Location.y = world_max_bounds_.y; + + if (savedDT > random::Float(1, 1.5)) { + transformComponent.Transform.Scale = vec2(HealthToSize(organism.Data.Health)); + + auto E = entity(e, active_scene_.get()); + auto& energy = E.get_component(); float speed = 0.f; - SRM::Convert(energy.Energy, speed, energy.Energy, mSpeedPerEnergy, organism.Data.Speed); + SRM::Convert(energy.Energy, speed, energy.Energy, speed_per_energy_, organism.Data.Speed); - E.GetComponent().Velocity = FVec2(SMath::Sin(SRandom::Float(-1, 1) * PIf), SMath::Cos(SRandom::Float(-1, 1) * PIf)) * speed; + E.get_component().Velocity = vec2(math::Sin(random::Float(-1, 1) * PIf), math::Cos(random::Float(-1, 1) * PIf)) * speed; if (0.01f > energy.Energy) DeathRow.emplace(E); } }); } if (savedDT>=1.2f) savedDT = 0.f; - if (fmodf(mTime, 10.f) < 0.1f) { + if (fmodf(time_, 10.f) < 0.1f) { if (itrlDO2) { - std::for_each(std::execution::par_unseq, mWorldGeoData, mWorldGeoData+mGridCount, [&](auto&& i) { - auto lI = SRandom::Float(mMinLight, 5); - i = CLifeSim2D::CWorldGeoData(lI); + std::for_each(std::execution::par_unseq, world_geo_data_, world_geo_data_+grid_count_, [&](auto&& i) { + auto lI = random::Float(min_light_, 5); + i = life_sim_2d::world_geo_data(lI); }); itrlDO2 = false; } } else itrlDO2 = true; -// for (int i = 0; i < mGridCount; i++) { -// auto xScale = mWorldMaxBounds.x / (mWorldMaxBounds.x + mWorldMaxBounds.y); -// SRenderer2D::DrawQuad( -// FVec3( -// (i % int(mWorldMaxBounds.x * 2 * mGridDensity) - mWorldMaxBounds.x), -// xScale*(i / int(mWorldMaxBounds.y * 2 * mGridDensity)) - mWorldMaxBounds.y, +// for (int i = 0; i < grid_count_; i++) { +// auto xScale = world_max_bounds_.x / (world_max_bounds_.x + world_max_bounds_.y); +// renderer_2d::draw_quad( +// vec3( +// (i % int(world_max_bounds_.x * 2 * grid_density_) - world_max_bounds_.x), +// xScale*(i / int(world_max_bounds_.y * 2 * grid_density_)) - world_max_bounds_.y, // -0.1), // // 0, -// FVec2(1, 1-xScale) / mGridDensity, -// ETransparencyType::Opaque, -// FColor4::Yellow() * mWorldGeoData[i].LightIntensity / 5); +// vec2(1, 1-xScale) / grid_density_, +// transparency_type::Opaque, +// color4::Yellow() * world_geo_data_[i].LightIntensity / 5); // } - auto view = mActiveScene->FilterByComponents(); + auto view = active_scene_->FilterByComponents(); std::for_each(std::execution::par_unseq, view.begin(), view.end(), [&](auto e) { // Photosynthesis - auto& organism = view.get(e); - auto& energy = view.get(e); - float photoAbsorb = GetLightIntensityAtLocation(E.GetComponent().Transform.Location); - energy.Energy = SMath::Clamp(energy.Energy + (photoAbsorb * organism.Data.PhotoSynthRate * pDeltaTime), 0.f, energy.MaxEnergy); + auto& organism = view.get(e); + auto& energy = view.get(e); + float photoAbsorb = get_light_intensity_at_location(E.get_component().Transform.Location); + energy.Energy = math::Clamp(energy.Energy + (photoAbsorb * organism.Data.PhotoSynthRate * pDeltaTime), 0.f, energy.MaxEnergy); // @TODO release appropriate energy amt //if (0.01f > energy.Energy) ARC_CORE_INFO("death {}", int(e)); DeathRow.emplace(E); //energy leak SRM::Consume( - SMath::Interp>( + math::Interp>( 0.f, - energy.MaxEnergy * mEnergyLeakMultiplier, + energy.MaxEnergy * energy_leak_multiplier_, organism.Data.Health / organism.Data.MaxHealth) * pDeltaTime, energy.Energy ); @@ -289,13 +289,13 @@ namespace ARC { energy.Energy, organism.Data.Health, energy.Energy * organism.Data.HealRate * pDeltaTime, - mHealthPerEnergy, + health_per_energy_, organism.Data.MaxHealth ); //if (0.01f > energy.Energy) ARC_CORE_INFO("death {}", int(e)); DeathRow.emplace(E); }); - auto iter = mActiveScene->FilterByComponents().each(); + auto iter = active_scene_->FilterByComponents().each(); for (auto i=iter.begin(); i!=iter.end(); i++) { @@ -311,45 +311,45 @@ namespace ARC { // reproduction { - auto view = mActiveScene->FilterByComponents(); + auto view = active_scene_->FilterByComponents(); std::for_each(std::execution::par_unseq, view.begin(), view.end(), [&](auto e) { // Photosynthesis - auto& organism = view.get(e); - auto& energy = view.get(e); auto E = CEntity(e, mActiveScene.get()); - if (energy.Energy == energy.MaxEnergy && energy.Energy >= mMinReproductionEnergyCost) // does not reproduce until max energy + auto& organism = view.get(e); + auto& energy = view.get(e); auto E = entity(e, active_scene_.get()); + if (energy.Energy == energy.MaxEnergy && energy.Energy >= min_reproduction_energy_cost_) // does not reproduce until max energy { // reproduce - auto EChild = MakeOrganism(E.GetName()+"_child" + std::to_string(organism.NextChildsIndex++)); - auto& ec_organismComp = EChild.GetComponent(); - auto& ec_energyComp = EChild.GetComponent(); + auto EChild = MakeOrganism(E.get_name()+"_child" + std::to_string(organism.NextChildsIndex++)); + auto& ec_organismComp = EChild.get_component(); + auto& ec_energyComp = EChild.get_component(); - EChild.GetComponent().Transform.Location = E.GetComponent().Transform.Location; - EChild.GetComponent().Transform.Location.y += E.GetComponent().Transform.Scale.MaxComponent() + EChild.GetComponent().Transform.Scale.MaxComponent() + 0.1f; - - float RadiationFactor = LightToRadiation(GetLightIntensityAtLocation(E.GetComponent().Transform.Location)); - - ec_organismComp.Data.MaxHealth += SRandom::Float(-ec_organismComp.MutationData.MaxHealth, ec_organismComp.MutationData.MaxHealth)*RadiationFactor; - ec_organismComp.Data.Speed += SRandom::Float(-ec_organismComp.MutationData.Speed, ec_organismComp.MutationData.Speed) * RadiationFactor; - ec_organismComp.Data.PhotoSynthRate += SRandom::Float(-ec_organismComp.MutationData.PhotoSynthRate, ec_organismComp.MutationData.PhotoSynthRate) * RadiationFactor; - ec_organismComp.Data.HealRate += SRandom::Float(-ec_organismComp.MutationData.HealRate, ec_organismComp.MutationData.HealRate) * RadiationFactor; - ec_organismComp.Data.InitialEnergy += SRandom::Float(-ec_organismComp.MutationData.InitialEnergy, ec_organismComp.MutationData.InitialEnergy) * RadiationFactor; - ec_organismComp.Data.PostReproductionEnergyReserve += SRandom::Float(-ec_organismComp.MutationData.PostReproductionEnergyReserve, ec_organismComp.MutationData.PostReproductionEnergyReserve) * RadiationFactor; - ec_energyComp.MaxEnergy += SRandom::Float(-ec_organismComp.MutationData.MaxEnergy, ec_organismComp.MutationData.MaxEnergy) * RadiationFactor; - - ec_organismComp.Data.MaxHealth = SMath::Max(0.f, ec_organismComp.Data.MaxHealth); - ec_organismComp.Data.Speed = SMath::Max(0.f, ec_organismComp.Data.Speed); - ec_organismComp.Data.PhotoSynthRate = SMath::Max(0.f, ec_organismComp.Data.PhotoSynthRate); - ec_organismComp.Data.HealRate = SMath::Max(0.f, ec_organismComp.Data.HealRate); - ec_organismComp.Data.InitialEnergy = SMath::Max(0.f, ec_organismComp.Data.InitialEnergy); - ec_organismComp.Data.PostReproductionEnergyReserve = SMath::Max(0.f, ec_organismComp.Data.PostReproductionEnergyReserve); - ec_energyComp.MaxEnergy = SMath::Max(0.f, ec_energyComp.MaxEnergy); + EChild.get_component().Transform.Location = E.get_component().Transform.Location; + EChild.get_component().Transform.Location.y += E.get_component().Transform.Scale.MaxComponent() + EChild.get_component().Transform.Scale.MaxComponent() + 0.1f; + + float RadiationFactor = LightToRadiation(get_light_intensity_at_location(E.get_component().Transform.Location)); + + ec_organismComp.Data.MaxHealth += random::Float(-ec_organismComp.MutationData.MaxHealth, ec_organismComp.MutationData.MaxHealth)*RadiationFactor; + ec_organismComp.Data.Speed += random::Float(-ec_organismComp.MutationData.Speed, ec_organismComp.MutationData.Speed) * RadiationFactor; + ec_organismComp.Data.PhotoSynthRate += random::Float(-ec_organismComp.MutationData.PhotoSynthRate, ec_organismComp.MutationData.PhotoSynthRate) * RadiationFactor; + ec_organismComp.Data.HealRate += random::Float(-ec_organismComp.MutationData.HealRate, ec_organismComp.MutationData.HealRate) * RadiationFactor; + ec_organismComp.Data.InitialEnergy += random::Float(-ec_organismComp.MutationData.InitialEnergy, ec_organismComp.MutationData.InitialEnergy) * RadiationFactor; + ec_organismComp.Data.PostReproductionEnergyReserve += random::Float(-ec_organismComp.MutationData.PostReproductionEnergyReserve, ec_organismComp.MutationData.PostReproductionEnergyReserve) * RadiationFactor; + ec_energyComp.MaxEnergy += random::Float(-ec_organismComp.MutationData.MaxEnergy, ec_organismComp.MutationData.MaxEnergy) * RadiationFactor; + + ec_organismComp.Data.MaxHealth = math::Max(0.f, ec_organismComp.Data.MaxHealth); + ec_organismComp.Data.Speed = math::Max(0.f, ec_organismComp.Data.Speed); + ec_organismComp.Data.PhotoSynthRate = math::Max(0.f, ec_organismComp.Data.PhotoSynthRate); + ec_organismComp.Data.HealRate = math::Max(0.f, ec_organismComp.Data.HealRate); + ec_organismComp.Data.InitialEnergy = math::Max(0.f, ec_organismComp.Data.InitialEnergy); + ec_organismComp.Data.PostReproductionEnergyReserve = math::Max(0.f, ec_organismComp.Data.PostReproductionEnergyReserve); + ec_energyComp.MaxEnergy = math::Max(0.f, ec_energyComp.MaxEnergy); ec_organismComp.Data.Health = 0.f; - SRM::Consume(mMinReproductionEnergyCost, energy.Energy, organism.Data.PostReproductionEnergyReserve); + SRM::Consume(min_reproduction_energy_cost_, energy.Energy, organism.Data.PostReproductionEnergyReserve); SRM::Consume(ec_organismComp.Data.InitialEnergy, energy.Energy, organism.Data.PostReproductionEnergyReserve); - SRM::Convert(energy.Energy, ec_organismComp.Data.Health, energy.Energy - organism.Data.PostReproductionEnergyReserve, mHealthPerEnergy, ec_organismComp.Data.MaxHealth); + SRM::Convert(energy.Energy, ec_organismComp.Data.Health, energy.Energy - organism.Data.PostReproductionEnergyReserve, health_per_energy_, ec_organismComp.Data.MaxHealth); } if (0.01f > energy.Energy) { ARC_CORE_INFO("reproduction death{}", int(e)); DeathRow.emplace(E); @@ -362,71 +362,71 @@ namespace ARC { } - SRenderer2D::EndScene(); + renderer_2d::end_scene(); } } - void CLifeSim2D::OnGuiRender() + void life_sim_2d::on_gui_render() { - ImGui::Begin("LS2D"); + ImGui::begin("LS2D"); - static FVec3 tmp = FVec3::ZeroVector(); - float tmp2 = LightToRadiation(GetLightIntensityAtLocation(tmp)) / 5; - float tmp3 = GetLightIntensityAtLocation(tmp); + static vec3 tmp = vec3::ZeroVector(); + float tmp2 = LightToRadiation(get_light_intensity_at_location(tmp)) / 5; + float tmp3 = get_light_intensity_at_location(tmp); ImGui::DragFloat3("Rad@Loc", tmp.Data()); ImGui::DragFloat("Light@Loc", &tmp3, ImGuiSliderFlags_ReadOnly); ImGui::DragFloat("LightTmp", &tmp2, ImGuiSliderFlags_ReadOnly); - ImGui::DragFloat("Time Multiplier", &mTimeMultiplier); - ImGui::DragFloat("World Time", &mTime); + ImGui::DragFloat("Time Multiplier", &time_multiplier_); + ImGui::DragFloat("World Time", &time_); float abcd = TimeToTimeOfDay(); ImGui::DragFloat("Time of day", &abcd); - abcd = GetLightIntensity(); + abcd = get_light_intensity(); ImGui::DragFloat("LightIntensity", &abcd); - abcd = LightToRadiation(GetLightIntensity()); + abcd = LightToRadiation(get_light_intensity()); ImGui::DragFloat("Radiation", &abcd); - TString timeofday = abcd > 0.2f ? "Morning" : "Night"; + string timeofday = abcd > 0.2f ? "Morning" : "Night"; ImGui::Text(timeofday.c_str()); - ImGui::End(); + ImGui::end(); } - void CLifeSim2D::OnEvent(CEvent& pEvent) + void life_sim_2d::on_event(event& pEvent) { } - void CLifeSim2D::SetScene(TRef pScene) + void life_sim_2d::set_scene(ref pScene) { - mActiveScene = pScene; - mTime = 0.f; - delete[] mWorldGeoData; - mGridCount = int(4.f * mWorldMaxBounds.x* (mWorldMaxBounds.y+0.5) * mGridDensity)+1; - mWorldGeoData = new CWorldGeoData[mGridCount]; + active_scene_ = pScene; + time_ = 0.f; + delete[] world_geo_data_; + grid_count_ = int(4.f * world_max_bounds_.x* (world_max_bounds_.y+0.5) * grid_density_)+1; + world_geo_data_ = new world_geo_data[grid_count_]; - for (int i = 0; i < mGridCount; i++) - mWorldGeoData[i] = CLifeSim2D::CWorldGeoData(SRandom::Float(mMinLight, 5)); + for (int i = 0; i < grid_count_; i++) + world_geo_data_[i] = life_sim_2d::world_geo_data(random::Float(min_light_, 5)); } - float CLifeSim2D::TimeToTimeOfDay() const + float life_sim_2d::TimeToTimeOfDay() const { - return fmodf(mTime, mDayLength); + return fmodf(time_, day_length_); } - float CLifeSim2D::GetLightIntensity() const + float life_sim_2d::get_light_intensity() const { - auto _ = SMath::Clamp( - (SMath::Sin(SMath::Interp(0.f, 1.2f * PIf, TimeToTimeOfDay() / mDayLength))) * mLightMultiplier, - mMinLight, - mLightMultiplier + auto _ = math::Clamp( + (math::Sin(math::Interp(0.f, 1.2f * PIf, TimeToTimeOfDay() / day_length_))) * light_multiplier_, + min_light_, + light_multiplier_ ); return _; } - float CLifeSim2D::GetLightIntensityAtLocation(FVec3 pLoc) const + float life_sim_2d::get_light_intensity_at_location(vec3 pLoc) const { - return GetLightIntensity()* GetGeoDataFromLocation(pLoc).LightIntensity; + return get_light_intensity()* get_geo_data_from_location(pLoc).LightIntensity; } } \ No newline at end of file diff --git a/ARC-Editor/src/LifeSim2D/LifeSim2D.h b/ARC-Editor/src/LifeSim2D/LifeSim2D.h index f2857b378f..2a8c0a523d 100644 --- a/ARC-Editor/src/LifeSim2D/LifeSim2D.h +++ b/ARC-Editor/src/LifeSim2D/LifeSim2D.h @@ -2,27 +2,27 @@ #include "ARC/Renderer/Layer.h" #include "ARC/Scene/Component.h" -namespace ARC { class CScene; } -namespace ARC { class CEvent; } +namespace arc { class scene; } +namespace arc { class event; } -namespace ARC +namespace arc { - struct CEnergyComponent : public CComponentBase + struct energy_component : public component_base { float Energy = 10.f; float MaxEnergy = 100.f; - virtual void DrawPropertiesUI(CEntity& pEntity) override; - virtual void Serialize(YAML::Emitter& pOut) override; - virtual void Deserialize(YAML::Node& pData) override; - virtual TUInt32 GetFlags() override { return Flags; }; + virtual void draw_properties_ui(entity& pEntity) override; + virtual void serialize(YAML::Emitter& pOut) override; + virtual void deserialize(YAML::Node& pData) override; + virtual u32 get_flags() override { return Flags; }; - static inline TUInt32 Flags = ECF::DefaultComponentFlags | ECF::Serializable; + static inline u32 Flags = ecf::DefaultComponentFlags | ecf::Serializable; }; - struct COrganismComponent : public CComponentBase + struct organism_component : public component_base { - struct COrganismData { + struct organism_data { float MaxHealth = 100; float Health = MaxHealth; // energy leak multiplier = 1 - health float Speed = 1.f; // defines how fast can organism move// acceleration consumes energy// unused @@ -34,7 +34,7 @@ namespace ARC float InitialEnergy = 10; }; - struct COrganismMutationData { + struct organism_mutation_data { float MaxHealth = 1; float Speed = 0.1; float PhotoSynthRate = 0.1; @@ -44,75 +44,75 @@ namespace ARC float MaxEnergy = 1; // @TODO - //COrganismData InitialDataMultiplier= COrganismData(0.2f, 0.2f, 1.2f, 1.5f, 0.2f, 1.f); + //organism_data InitialDataMultiplier= organism_data(0.2f, 0.2f, 1.2f, 1.5f, 0.2f, 1.f); //float TimeTillFullGrowth = 2.f; // in days }; - COrganismData Data; - COrganismMutationData MutationData; + organism_data Data; + organism_mutation_data MutationData; - TUInt32 NextChildsIndex = 0; // next name of child && reward + u32 NextChildsIndex = 0; // next name of child && reward - virtual void DrawPropertiesUI(CEntity& pEntity) override; - virtual void Serialize(YAML::Emitter& pOut) override; - virtual void Deserialize(YAML::Node& pData) override; - virtual TUInt32 GetFlags() override { return Flags; }; + virtual void draw_properties_ui(entity& pEntity) override; + virtual void serialize(YAML::Emitter& pOut) override; + virtual void deserialize(YAML::Node& pData) override; + virtual u32 get_flags() override { return Flags; }; - static inline TUInt32 Flags = ECF::DefaultComponentFlags | ECF::Serializable; + static inline u32 Flags = ecf::DefaultComponentFlags | ecf::Serializable; }; - struct CVelocityComponent : public CComponentBase { - FVec2 Velocity; - virtual TUInt32 GetFlags() override { return Flags; }; - static inline TUInt32 Flags = 0; + struct velocity_component : public component_base { + vec2 Velocity; + virtual u32 get_flags() override { return Flags; }; + static inline u32 Flags = 0; }; - class CLifeSim2D + class life_sim_2d { public: - void OnAttach(TRef pActiveScene); - void OnDetach(); - void OnUpdateEditor(float pDeltaTime); - void OnUpdateRuntime(float pDeltaTime); - void OnGuiRender(); - void OnEvent(CEvent& pEvent); + void on_attach(ref pActiveScene); + void on_detach(); + void on_update_editor(float pDeltaTime); + void on_update_runtime(float pDeltaTime); + void on_gui_render(); + void on_event(event& pEvent); - void SetScene(TRef pScene); + void set_scene(ref pScene); float TimeToTimeOfDay() const; - float GetLightIntensity() const; - float GetLightIntensityAtLocation(FVec3 pLoc) const; + float get_light_intensity() const; + float get_light_intensity_at_location(vec3 pLoc) const; - CEntity MakeOrganism(const TString& pName = "##Default"); + entity MakeOrganism(const string& pName = "##Default"); float HealthToSize(float pHealth); float LightToRadiation(float pLight); - struct CWorldGeoData { float LightIntensity = 1.f; }; + struct world_geo_data { float LightIntensity = 1.f; }; - CWorldGeoData& GetGeoDataFromLocation(FVec3 pLoc); - const CWorldGeoData& GetGeoDataFromLocation(FVec3 pLoc) const; + world_geo_data& get_geo_data_from_location(vec3 pLoc); + const world_geo_data& get_geo_data_from_location(vec3 pLoc) const; private: - static inline CWorldGeoData mEmptySpace = CWorldGeoData(0.f); - CWorldGeoData* mWorldGeoData; - int mGridDensity = 1; // grid per unit area - int mGridCount = 0; // grid per unit area - FVec2 mWorldMaxBounds= FVec2(60.f, 40.f); - - float mTime = 0.f; - float mTimeMultiplier = 1.f; - float mDayLength = 100.f; // length of 1 day - float mLightMultiplier = 1.f; - float mMinLight = 0.01; - float mEnergyLeakMultiplier = 0.01f; - float mHealthPerEnergy = 2.f; - float mMinReproductionEnergyCost = 15.f; - float mSpeedPerEnergy = 10.f; - float mMinSize = 0.35f; - - TUInt32 mEIndex = 0; - - TRef mActiveScene; + static inline world_geo_data empty_space_ = world_geo_data(0.f); + world_geo_data* world_geo_data_; + int grid_density_ = 1; // grid per unit area + int grid_count_ = 0; // grid per unit area + vec2 world_max_bounds_= vec2(60.f, 40.f); + + float time_ = 0.f; + float time_multiplier_ = 1.f; + float day_length_ = 100.f; // length of 1 day + float light_multiplier_ = 1.f; + float min_light_ = 0.01; + float energy_leak_multiplier_ = 0.01f; + float health_per_energy_ = 2.f; + float min_reproduction_energy_cost_ = 15.f; + float speed_per_energy_ = 10.f; + float min_size_ = 0.35f; + + u32 e_index_ = 0; + + ref active_scene_; }; } diff --git a/ARC-Editor/src/Panels/ContentBrowserPanel.cpp b/ARC-Editor/src/Panels/ContentBrowserPanel.cpp index 378422e78d..7152e042c2 100644 --- a/ARC-Editor/src/Panels/ContentBrowserPanel.cpp +++ b/ARC-Editor/src/Panels/ContentBrowserPanel.cpp @@ -6,52 +6,52 @@ static const std::filesystem::path sAssetsDirectoryPath = "assets"; -namespace ARC { - CContentBrowserPanel::CContentBrowserPanel() : - mCurrentDir(sAssetsDirectoryPath) +namespace arc { + content_browser_panel::content_browser_panel() : + current_dir_(sAssetsDirectoryPath) { - mDirectoryIcon = CTexture2D::Create("resources/icons/directory icon.png"); - mFileIcon = CTexture2D::Create("resources/icons/file icon.png"); + directory_icon_ = texture_2d::create("resources/icons/directory icon.png"); + file_icon_ = texture_2d::create("resources/icons/file icon.png"); } - void CContentBrowserPanel::OnImGuiRender() + void content_browser_panel::on_imgui_render() { - ImGui::Begin("Content Browser Panel"); + ImGui::begin("Content Browser Panel"); - if (mCurrentDir != sAssetsDirectoryPath) { + if (current_dir_ != sAssetsDirectoryPath) { if (ImGui::Button("<-")) - mCurrentDir = mCurrentDir.parent_path(); + current_dir_ = current_dir_.parent_path(); } static auto padding = 16.0f; static auto thumbnailSize = 120.0f; - auto panelWidth = ImGui::GetContentRegionAvail().x; + auto panelWidth = ImGui::get_content_region_avail().x; int columnCount = int(panelWidth/(padding+thumbnailSize)); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.0f); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.15f,0.17f,0.16f,1.f)); - ImGui::Columns(SMath::Max(columnCount, 1), 0, false); + ImGui::Columns(math::Max(columnCount, 1), 0, false); - for (auto& i : std::filesystem::directory_iterator(mCurrentDir)) + for (auto& i : std::filesystem::directory_iterator(current_dir_)) { const auto& path = i.path(); auto relativePath = std::filesystem::relative(path, sAssetsDirectoryPath); auto filename = relativePath.filename().string(); ImGui::PushID(filename.c_str()); - auto icon = i.is_directory() ? mDirectoryIcon : mFileIcon; + auto icon = i.is_directory() ? directory_icon_ : file_icon_; - ImGui::ImageButton((ImTextureID)(TUInt64)icon->GetRendererID(), ImVec2(thumbnailSize, thumbnailSize), {0,1}, {1,0}); + ImGui::ImageButton((ImTextureID)(u64)icon->get_renderer_id(), ImVec2(thumbnailSize, thumbnailSize), {0,1}, {1,0}); if (ImGui::BeginDragDropSource()) { const wchar_t* relativePathCStr = relativePath.c_str(); - ImGui::SetDragDropPayload("CONTENT_BROWSER_ITEM", relativePathCStr, (std::wcslen(relativePathCStr) + 1) * sizeof(wchar_t)); + ImGui::set_drag_drop_payload("CONTENT_BROWSER_ITEM", relativePathCStr, (std::wcslen(relativePathCStr) + 1) * sizeof(wchar_t)); ImGui::EndDragDropSource(); } - if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { + if (ImGui::is_item_hovered() && ImGui::is_mouse_double_clicked(ImGuiMouseButton_Left)) { if (i.is_directory()) - mCurrentDir /= path.filename(); + current_dir_ /= path.filename(); else {} } @@ -60,10 +60,10 @@ namespace ARC { ImGui::PopID(); } ImGui::Columns(1); - ImGui::SliderFloat("Thumbnail Size", &thumbnailSize, 16, 512); + ImGui::SliderFloat("Thumbnail size", &thumbnailSize, 16, 512); ImGui::SliderFloat("Padding", &padding, 0, 64); ImGui::PopStyleVar(); ImGui::PopStyleColor(); - ImGui::End(); + ImGui::end(); } } \ No newline at end of file diff --git a/ARC-Editor/src/Panels/ContentBrowserPanel.h b/ARC-Editor/src/Panels/ContentBrowserPanel.h index 25b7226e26..580e5cb161 100644 --- a/ARC-Editor/src/Panels/ContentBrowserPanel.h +++ b/ARC-Editor/src/Panels/ContentBrowserPanel.h @@ -2,19 +2,19 @@ #include #include "ARC/Types/Pointer.h" -namespace ARC { class CTexture2D; } +namespace arc { class texture_2d; } -namespace ARC { - class CContentBrowserPanel +namespace arc { + class content_browser_panel { public: - CContentBrowserPanel(); + content_browser_panel(); - void OnImGuiRender(); + void on_imgui_render(); private: - std::filesystem::path mCurrentDir; - TRef mDirectoryIcon; - TRef mFileIcon; + std::filesystem::path current_dir_; + ref directory_icon_; + ref file_icon_; }; } \ No newline at end of file diff --git a/ARC-Editor/src/Panels/SceneHierarchyPanel.cpp b/ARC-Editor/src/Panels/SceneHierarchyPanel.cpp index 05c588ff09..9fad8a39dc 100644 --- a/ARC-Editor/src/Panels/SceneHierarchyPanel.cpp +++ b/ARC-Editor/src/Panels/SceneHierarchyPanel.cpp @@ -9,90 +9,90 @@ #include "ARC\Scene\BasicComponents.h" #include "ARC\Scene\SceneRegistry.h" -namespace ARC { - CSceneHierarchyPanel::CSceneHierarchyPanel(const TRef& pScene) +namespace arc { + scene_hierarchy_panel::scene_hierarchy_panel(const ref& pScene) { - SetContext(pScene); + set_context(pScene); } - void CSceneHierarchyPanel::SetContext(const TRef& pScene) + void scene_hierarchy_panel::set_context(const ref& pScene) { - mContext = pScene; - mSelectedEntity = {}; + context_ = pScene; + selected_entity_ = {}; } - void CSceneHierarchyPanel::OnImGuiRender() + void scene_hierarchy_panel::on_imgui_render() { static bool bDraw = true; ImGui::ShowDemoWindow(&bDraw); - ImGui::Begin("Scene Hierarchy"); + ImGui::begin("Scene Hierarchy"); - mContext->GetManager().each([&](auto pID) { - DrawEntityNode(CEntity(pID, mContext.get())); + context_->get_manager().each([&](auto pID) { + DrawEntityNode(entity(pID, context_.get())); }); - if (ImGui::IsMouseDown(0) && ImGui::IsWindowHovered()) - mSelectedEntity = {}; + if (ImGui::is_mouse_down(0) && ImGui::is_window_hovered()) + selected_entity_ = {}; // right click on a blank space if (ImGui::BeginPopupContextWindow(nullptr)) { - if (ImGui::MenuItem("Create Empty Entity")) - mContext->CreateEntity("Empty Entity"); + if (ImGui::MenuItem("create Empty Entity")) + context_->create_entity("Empty Entity"); ImGui::EndPopup(); } - ImGui::End(); + ImGui::end(); - ImGui::Begin("Properties"); + ImGui::begin("Properties"); - if(mSelectedEntity) + if(selected_entity_) { - if (CComponentBase* comp = SSceneRegistry::GetMetaComponents()[SComponentTraits::GetID()].GetComponent(mSelectedEntity)) { + if (component_base* comp = scene_registry::get_meta_components()[component_traits::get_id()].get_component(selected_entity_)) { ImGui::Text("Name:"); ImGui::SameLine(100.f, 20.f); - comp->DrawPropertiesUI(mSelectedEntity); + comp->draw_properties_ui(selected_entity_); } bool bNameCompFound = false; - for(auto& _ : SSceneRegistry::GetMetaComponents()) { - if (auto* comp = _.second.GetComponent(mSelectedEntity)) { + for(auto& _ : scene_registry::get_meta_components()) { + if (auto* comp = _.second.get_component(selected_entity_)) { bool bDeleteComponent = false; - if (!bNameCompFound && _.first == SComponentTraits::GetID()) { + if (!bNameCompFound && _.first == component_traits::get_id()) { bNameCompFound = true; continue; } - if (comp->GetFlags() & ECF::EComponentFlags::ShowInPropertiesPanel - && ImGui::TreeNodeEx(_.second.GetName().c_str(), ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_FramePadding | ImGuiTreeNodeFlags_SpanAvailWidth, _.second.GetName().c_str())) { + if (comp->get_flags() & ecf::component_flags::ShowInPropertiesPanel + && ImGui::TreeNodeEx(_.second.get_name().c_str(), ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_FramePadding | ImGuiTreeNodeFlags_SpanAvailWidth, _.second.get_name().c_str())) { if (ImGui::BeginPopupContextItem()) { if (ImGui::MenuItem("Delete Component")) bDeleteComponent = true; ImGui::EndPopup(); } - comp->DrawPropertiesUI(mSelectedEntity); + comp->draw_properties_ui(selected_entity_); ImGui::TreePop(); } if (bDeleteComponent) - _.second.RemoveComponent(mSelectedEntity); + _.second.remove_component(selected_entity_); } } if (ImGui::Button("Add Component")) - ImGui::OpenPopup("AddComponent"); + ImGui::OpenPopup("add_component"); - if (ImGui::BeginPopup("AddComponent")) + if (ImGui::BeginPopup("add_component")) { - for(auto& compMeta : SSceneRegistry::GetMetaComponents()) + for(auto& compMeta : scene_registry::get_meta_components()) { - if (!compMeta.second.GetComponent(mSelectedEntity) && ImGui::MenuItem(compMeta.second.GetName().c_str())) + if (!compMeta.second.get_component(selected_entity_) && ImGui::MenuItem(compMeta.second.get_name().c_str())) { - compMeta.second.AddComponent(mSelectedEntity); + compMeta.second.add_component(selected_entity_); ImGui::CloseCurrentPopup(); } } @@ -100,10 +100,10 @@ namespace ARC { } } - ImGui::End(); + ImGui::end(); - ImGui::Begin("Style"); - auto& colors = ImGui::GetStyle().Colors; + ImGui::begin("Style"); + auto& colors = ImGui::get_style().Colors; #define ColorStuff(xx) ImGui::ColorEdit4(#xx, &colors[xx].x) @@ -153,24 +153,24 @@ namespace ARC { ColorStuff(ImGuiCol_ModalWindowDimBg); #undef ColorStuff - ImGui::End(); + ImGui::end(); } - void CSceneHierarchyPanel::DrawEntityNode(CEntity pEntity) + void scene_hierarchy_panel::DrawEntityNode(entity pEntity) { - if (!pEntity.HasComponent()) return; + if (!pEntity.has_component()) return; - auto& name = pEntity.GetComponent(); + auto& name = pEntity.get_component(); ImGuiTreeNodeFlags TreeFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_OpenOnDoubleClick - | ((mSelectedEntity == pEntity) ? ImGuiTreeNodeFlags_Selected : 0); - bool bOpened = ImGui::TreeNodeEx((void*)(uint64_t)pEntity.GetID(), TreeFlags, name.Name.c_str()); + | ((selected_entity_ == pEntity) ? ImGuiTreeNodeFlags_Selected : 0); + bool bOpened = ImGui::TreeNodeEx((void*)(uint64_t)pEntity.get_id(), TreeFlags, name.Name.c_str()); - if (ImGui::IsItemClicked()) - mSelectedEntity = pEntity; + if (ImGui::is_item_clicked()) + selected_entity_ = pEntity; bool bDeleteEntity = false; @@ -179,7 +179,7 @@ namespace ARC { if (ImGui::MenuItem("Delete Entity")) bDeleteEntity = true; if (ImGui::MenuItem("Duplicate Entity")) - mSelectedEntity = mSelectedEntity.Duplicate(); + selected_entity_ = selected_entity_.Duplicate(); ImGui::EndPopup(); } @@ -187,8 +187,8 @@ namespace ARC { ImGui::TreePop(); if (bDeleteEntity) { - mContext->RemoveEntity(pEntity); - mSelectedEntity = {}; + context_->remove_entity(pEntity); + selected_entity_ = {}; } } } \ No newline at end of file diff --git a/ARC-Editor/src/Panels/SceneHierarchyPanel.h b/ARC-Editor/src/Panels/SceneHierarchyPanel.h index 5c8f7bc307..6d26b7c59e 100644 --- a/ARC-Editor/src/Panels/SceneHierarchyPanel.h +++ b/ARC-Editor/src/Panels/SceneHierarchyPanel.h @@ -2,26 +2,26 @@ #include "ARC\Types\Pointer.h" #include "ARC\Scene\Entity.h" -namespace ARC { class CScene; } +namespace arc { class scene; } -namespace ARC { - class CSceneHierarchyPanel +namespace arc { + class scene_hierarchy_panel { public: - CSceneHierarchyPanel()=default; - CSceneHierarchyPanel(const TRef& pScene); + scene_hierarchy_panel()=default; + scene_hierarchy_panel(const ref& pScene); - void SetContext(const TRef& pScene); - void OnImGuiRender(); + void set_context(const ref& pScene); + void on_imgui_render(); - CEntity GetSelectedEntity() const { return mSelectedEntity; } - void SetSelectedEntity(CEntity p) { mSelectedEntity = p; } + entity get_selected_entity() const { return selected_entity_; } + void set_selected_entity(entity p) { selected_entity_ = p; } private: - void DrawEntityNode(CEntity pEntity); + void DrawEntityNode(entity pEntity); private: - TRef mContext; - CEntity mSelectedEntity; + ref context_; + entity selected_entity_; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Core/Application.cpp b/ARC-Engine/src/ARC/Core/Application.cpp index b08058fe7e..26f14202bc 100644 --- a/ARC-Engine/src/ARC/Core/Application.cpp +++ b/ARC-Engine/src/ARC/Core/Application.cpp @@ -12,96 +12,96 @@ #include "ARC/GUI/ImGuiLayer.h" #include "ARC/Helpers/Math.h" -namespace ARC +namespace arc { - CApplication* CApplication::s_Instance=nullptr; - CApplication::CApplication(const TString& _Name /*= "ARC-Engine"*/) : - mbRunning(1u) + application* application::instance=nullptr; + application::application(const string& name /*= "ARC-Engine"*/) : + running_(1u) { ARC_PROFILE_FUNCTION(); - ARC_CORE_ASSERT(!s_Instance, "Application already exists"); + ARC_CORE_ASSERT(!instance, "Application already exists"); - s_Instance= this; + instance= this; - mWindow = std::unique_ptr(CWindow::Create(_Name)); + window_ = std::unique_ptr(window::create(name)); - CRenderer::Init(); + renderer::init(); - mImGuiLayer = new CImGuiLayer(); - PushOverlay(mImGuiLayer); + imgui_layer_ = new imgui_layer(); + push_overlay(imgui_layer_); - mWindow->SetEventCallback(BIND_FN(&CApplication::OnEvent)); + window_->set_event_callback(BIND_FN(&application::on_event)); } - CApplication::~CApplication() {} + application::~application() {} - void CApplication::Run() + void application::run() { ARC_PROFILE_FUNCTION(); - while (mbRunning) + while (running_) { //@TEMP auto time = (float)glfwGetTime(); - mDeltaTime = time - mLastFrameTime; - mLastFrameTime = time; + delta_time_ = time - last_frame_time_; + last_frame_time_ = time; - if(!mbMinimized) { - for (CLayer* layer : mLayerStack) - layer->OnUpdate(mDeltaTime); + if(!minimized_) { + for (layer* layer : layer_stack_) + layer->on_update(delta_time_); } - mImGuiLayer->Begin(); - for (CLayer* layer : mLayerStack) - layer->OnGuiRender(); - mImGuiLayer->End(); - mWindow->OnUpdate(); + imgui_layer_->begin(); + for (layer* layer : layer_stack_) + layer->on_gui_render(); + imgui_layer_->end(); + window_->on_update(); } } - void CApplication::OnEvent(CEvent& _e) + void application::on_event(event& _e) { - CEventDispatcher dispatcher(_e); - dispatcher.Dispatch(BIND_FN(&CApplication::OnWindowClose)); - dispatcher.Dispatch(BIND_FN(&CApplication::OnWindowResize)); + event_dispatcher dispatcher(_e); + dispatcher.Dispatch(BIND_FN(&application::on_window_close)); + dispatcher.Dispatch(BIND_FN(&application::on_window_resize)); - for (auto it = mLayerStack.end(); it!= mLayerStack.begin();) + for (auto it = layer_stack_.end(); it!= layer_stack_.begin();) { - (*--it)->OnEvent(_e); + (*--it)->on_event(_e); if (_e.bHandled) break; } } - void CApplication::PushLayer(CLayer* _layer) + void application::push_layer(layer* _layer) { - mLayerStack.PushLayer(_layer); - _layer->OnAttach(); + layer_stack_.push_layer(_layer); + _layer->on_attach(); } - void CApplication::PushOverlay(CLayer* _overlay) + void application::push_overlay(layer* _overlay) { - mLayerStack.PushOverlay(_overlay); - _overlay->OnAttach(); + layer_stack_.push_overlay(_overlay); + _overlay->on_attach(); } - void CApplication::Shutdown() + void application::shutdown() { - mbRunning=false; + running_=false; } - bool CApplication::OnWindowClose(CWindowCloseEvent& _e) + bool application::on_window_close(window_close_event& _e) { - mbRunning = false; + running_ = false; return true; } - bool CApplication::OnWindowResize(CWindowResizeEvent& _e) + bool application::on_window_resize(window_resize_event& _e) { - if(_e.GetX() == 0 || _e.GetY() == 0){ - mbMinimized = true; + if(_e.get_x() == 0 || _e.get_y() == 0){ + minimized_ = true; return false; } - mbMinimized = false; - GetWindow().SetWidth(_e.GetX()); - GetWindow().SetHeight(_e.GetY()); - CRenderer::OnWindowResize(TVec2(_e.GetX(), _e.GetY())); + minimized_ = false; + get_window().set_width(_e.get_x()); + get_window().set_height(_e.get_y()); + renderer::on_window_resize(vec2(_e.get_x(), _e.get_y())); return false; } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Core/Application.h b/ARC-Engine/src/ARC/Core/Application.h index 013ed87524..0d3e57ad13 100644 --- a/ARC-Engine/src/ARC/Core/Application.h +++ b/ARC-Engine/src/ARC/Core/Application.h @@ -2,61 +2,61 @@ #include "Core.h" -#include "ARC/Renderer/LayerStack.h" +#include "ARC/Renderer/layer_stack.h" #include #include #include "../Types/vector.h" -namespace ARC { class CLayer; } -namespace ARC { class CImGuiLayer; } +namespace arc { class layer; } +namespace arc { class imgui_layer; } -namespace ARC { class CWindowCloseEvent; } -namespace ARC { class CWindowResizeEvent; } -namespace ARC { class CEvent; } +namespace arc { class window_close_event; } +namespace arc { class window_resize_event; } +namespace arc { class event; } -namespace ARC{ - class CWindow; - class ARC_API CApplication +namespace arc{ + class window; + class ARC_API application { public: - CApplication(const TString& _Name = "ARC-Engine"); - virtual ~CApplication(); + application(const string& name = "ARC-Engine"); + virtual ~application(); - void Run(); - void OnEvent(CEvent& _e); + void run(); + void on_event(event& _e); - void PushLayer(CLayer* _layer); - void PushOverlay(CLayer* _overlay); + void push_layer(layer* _layer); + void push_overlay(layer* _overlay); - inline CWindow& GetWindow() const { return *mWindow; } + inline window& get_window() const { return *window_; } - void Shutdown(); - CImGuiLayer* GetImGuiLayer() { return mImGuiLayer; }; + void shutdown(); + imgui_layer* get_imgui_layer() { return imgui_layer_; }; - inline static CApplication& Get() { return *s_Instance; } - inline virtual TString GetAppName() =0; - inline const TString& GetEngineName() { static TString rval = "ARC_Engine"; return rval; }; - inline float GetDeltaTime() const { return mDeltaTime; } + inline static application& Get() { return *instance; } + inline virtual string get_app_name() =0; + inline const string& get_engine_name() { static string rval = "ARC_Engine"; return rval; }; + inline float get_delta_time() const { return delta_time_; } private: - bool OnWindowClose(CWindowCloseEvent& pE); - bool OnWindowResize(CWindowResizeEvent& pE); + bool on_window_close(window_close_event& pE); + bool on_window_resize(window_resize_event& pE); private: - float mDeltaTime; - float mLastFrameTime = 0; + float delta_time_; + float last_frame_time_ = 0; - std::unique_ptr mWindow; + std::unique_ptr window_; - CImGuiLayer* mImGuiLayer; - TUInt8 mbRunning : 1; - TUInt8 mbMinimized: 1; - LayerStack mLayerStack; - static CApplication* s_Instance; + imgui_layer* imgui_layer_; + u8 running_ : 1; + u8 minimized_: 1; + layer_stack layer_stack_; + static application* instance; }; //Defined in client - CApplication* CreateApplication(); + application* create_application(); } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Core/Constants.h b/ARC-Engine/src/ARC/Core/Constants.h index 95988d4366..c18c4ffd52 100644 --- a/ARC-Engine/src/ARC/Core/Constants.h +++ b/ARC-Engine/src/ARC/Core/Constants.h @@ -1,7 +1,7 @@ #pragma once -namespace ARC { - struct SConstants { +namespace arc { + struct constants { }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Core/EntryPoint.h b/ARC-Engine/src/ARC/Core/EntryPoint.h index 462a92511e..95bb2eb04b 100644 --- a/ARC-Engine/src/ARC/Core/EntryPoint.h +++ b/ARC-Engine/src/ARC/Core/EntryPoint.h @@ -8,41 +8,41 @@ #ifdef ARC_PLATFORM_WINDOWS -extern ARC::CApplication* ARC::CreateApplication(); +extern arc::application* arc::create_application(); -int main(int p_ArgA, char** p_ArgB) +int main(int arg_a, char** arg_b) { printf("Starting-ARC----\n"); - //-------------------Log-Init-------------------// - ARC_PROFILE_BEGIN_SESSION("CSandBox2D::Log::Init", "logs/CSandBox2D-Log-Init.json"); + //-------------------Log-init-------------------// + ARC_PROFILE_BEGIN_SESSION("CSandBox2D::Log::init", "logs/CSandBox2D-Log-init.json"); printf("Initializing-Logger----\n"); - bool bInitLogger = ARC::CLog::Init(); + bool bInitLogger = arc::CLog::init(); if(!bInitLogger) return -1; else ARC_CORE_INFO("Logger-Initialized-Successfully"); ARC_PROFILE_END_SESSION(); - //-----------------Log-Init-End-----------------// + //-----------------Log-init-end-----------------// - //--------------Create-Application--------------// - ARC_PROFILE_BEGIN_SESSION("CSandBox2D::Create::Application", "logs/CSandBox2D-Create-Application.json"); + //--------------create-Application--------------// + ARC_PROFILE_BEGIN_SESSION("CSandBox2D::create::Application", "logs/CSandBox2D-create-Application.json"); ARC_CORE_INFO("Creating-Application"); - ARC::CApplication* App = ARC::CreateApplication(); - ARC_CORE_INFO("Application:[{0}]-Created-Successfully", App->GetAppName()); + arc::application* App = arc::create_application(); + ARC_CORE_INFO("Application:[{0}]-Created-Successfully", App->get_app_name()); ARC_PROFILE_END_SESSION(); //--------------Application-Created-------------// //----------------RunLoop-Started---------------// ARC_PROFILE_BEGIN_SESSION("CSandBox2D::RunLoop", "logs/CSandBox2D-RunLoop.json"); - ARC_CORE_INFO("Run-Loop-Started"); - App->Run(); - ARC_CORE_INFO("Run-Loop-Ended"); + ARC_CORE_INFO("run-Loop-Started"); + App->run(); + ARC_CORE_INFO("run-Loop-Ended"); ARC_PROFILE_END_SESSION(); //-----------------RunLoop-Ended----------------// //-------------Application-Deleting-------------// - ARC_PROFILE_BEGIN_SESSION("CSandBox2D::End", "logs/CSandBox2D-End.json"); + ARC_PROFILE_BEGIN_SESSION("CSandBox2D::end", "logs/CSandBox2D-end.json"); ARC_CORE_INFO("Destroying-Application-[]"); delete App; ARC_CORE_INFO("Application-Destroyed-Successfully"); diff --git a/ARC-Engine/src/ARC/Core/Ini.h b/ARC-Engine/src/ARC/Core/Ini.h index 2bce43da2f..18b7e6be9f 100644 --- a/ARC-Engine/src/ARC/Core/Ini.h +++ b/ARC-Engine/src/ARC/Core/Ini.h @@ -1,7 +1,7 @@ #pragma once #include "inicpp.h" -namespace ARC { +namespace arc { using CIniFile = ini::IniFile; using CIniFileCaseInsensitive = ini::IniFileCaseInsensitive; using CIniField = ini::IniField; diff --git a/ARC-Engine/src/ARC/Core/Log.cpp b/ARC-Engine/src/ARC/Core/Log.cpp index 67b4a314eb..1869eee8f8 100644 --- a/ARC-Engine/src/ARC/Core/Log.cpp +++ b/ARC-Engine/src/ARC/Core/Log.cpp @@ -2,18 +2,18 @@ #include "Log.h" #include "spdlog/sinks/stdout_color_sinks.h" -namespace ARC +namespace arc { - std::shared_ptr CLog::mCoreLogger; - std::shared_ptr CLog::mClientLogger; + std::shared_ptr CLog::core_logger_; + std::shared_ptr CLog::client_logger_; - int CLog::Init() + int CLog::init() { spdlog::set_pattern("%^[%T]-%n[%l]: %v%$"); - mCoreLogger = spdlog::stdout_color_mt("CORE"); - mCoreLogger->set_level(spdlog::level::trace); - mClientLogger = spdlog::stdout_color_mt("APP"); - mClientLogger->set_level(spdlog::level::trace); + core_logger_ = spdlog::stdout_color_mt("CORE"); + core_logger_->set_level(spdlog::level::trace); + client_logger_ = spdlog::stdout_color_mt("APP"); + client_logger_->set_level(spdlog::level::trace); return 1; } diff --git a/ARC-Engine/src/ARC/Core/Log.h b/ARC-Engine/src/ARC/Core/Log.h index 092d28d2c0..54dc306e2b 100644 --- a/ARC-Engine/src/ARC/Core/Log.h +++ b/ARC-Engine/src/ARC/Core/Log.h @@ -7,30 +7,30 @@ #include "ARC/Helpers/helpers.h" #include "Macros.h" -namespace ARC +namespace arc { class ARC_API CLog { public: - static int Init(); + static int init(); //inline static void SetPattern(std::string& newPattern, pattern_time_type newTimeType = pattern_time_type::local ){ spdlog::set_pattern(newPattern, newTimeType);}; public: - static std::shared_ptr& GetCoreLogger() { return mCoreLogger; }; - static std::shared_ptr& GetClientLogger() { return mClientLogger; }; + static std::shared_ptr& get_core_logger() { return core_logger_; }; + static std::shared_ptr& get_client_logger() { return client_logger_; }; private: - static std::shared_ptr mCoreLogger; - static std::shared_ptr mClientLogger; + static std::shared_ptr core_logger_; + static std::shared_ptr client_logger_; }; } -#define ARC_CORE_TRACE(...) ::ARC::CLog::GetCoreLogger()->trace(__VA_ARGS__) -#define ARC_CORE_INFO(...) ::ARC::CLog::GetCoreLogger()->info(__VA_ARGS__) -#define ARC_CORE_WARN(...) ::ARC::CLog::GetCoreLogger()->warn(__VA_ARGS__) -#define ARC_CORE_ERROR(...) ::ARC::CLog::GetCoreLogger()->error(__VA_ARGS__) -#define ARC_CORE_CRITICAL(...) ::ARC::CLog::GetCoreLogger()->critical(__VA_ARGS__) +#define ARC_CORE_TRACE(...) ::arc::CLog::get_core_logger()->trace(__VA_ARGS__) +#define ARC_CORE_INFO(...) ::arc::CLog::get_core_logger()->info(__VA_ARGS__) +#define ARC_CORE_WARN(...) ::arc::CLog::get_core_logger()->warn(__VA_ARGS__) +#define ARC_CORE_ERROR(...) ::arc::CLog::get_core_logger()->error(__VA_ARGS__) +#define ARC_CORE_CRITICAL(...) ::arc::CLog::get_core_logger()->critical(__VA_ARGS__) -#define ARC_TRACE(...) ::ARC::CLog::GetClientLogger()->trace(__VA_ARGS__) -#define ARC_INFO(...) ::ARC::CLog::GetClientLogger()->info(__VA_ARGS__) -#define ARC_WARN(...) ::ARC::CLog::GetClientLogger()->warn(__VA_ARGS__) -#define ARC_ERROR(...) ::ARC::CLog::GetClientLogger()->error(__VA_ARGS__) -#define ARC_CRITICAL(...) ::ARC::CLog::GetClientLogger()->critical(__VA_ARGS__) \ No newline at end of file +#define ARC_TRACE(...) ::arc::CLog::get_client_logger()->trace(__VA_ARGS__) +#define ARC_INFO(...) ::arc::CLog::get_client_logger()->info(__VA_ARGS__) +#define ARC_WARN(...) ::arc::CLog::get_client_logger()->warn(__VA_ARGS__) +#define ARC_ERROR(...) ::arc::CLog::get_client_logger()->error(__VA_ARGS__) +#define ARC_CRITICAL(...) ::arc::CLog::get_client_logger()->critical(__VA_ARGS__) \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Core/Macros.h b/ARC-Engine/src/ARC/Core/Macros.h index fbcbaf1b8f..10cbb60cc6 100644 --- a/ARC-Engine/src/ARC/Core/Macros.h +++ b/ARC-Engine/src/ARC/Core/Macros.h @@ -28,15 +28,15 @@ #define BIND_FN(x) std::bind(x, this, std::placeholders::_1) -#define LIKELY(mCondition) __builtin_expect(!!(mCondition), 1) -#define UNLIKELY(mCondition) __builtin_expect(!!(mCondition), 0) +#define LIKELY(condition_) __builtin_expect(!!(condition_), 1) +#define UNLIKELY(condition_) __builtin_expect(!!(condition_), 0) #define ARC_PROFILE #ifdef ARC_PROFILE -#define ARC_PROFILE_SCOPE(name) ::ARC::CTimer COMBINE2(ARC_timer, __LINE__)(name, true, true) +#define ARC_PROFILE_SCOPE(name) ::arc::timer COMBINE2(ARC_timer, __LINE__)(name, true, true) #define ARC_PROFILE_FUNCTION() ARC_PROFILE_SCOPE(__FUNCSIG__) -#define ARC_PROFILE_BEGIN_SESSION(name, filepath) ::ARC::CInstrumentor::Get().BeginSession(name, filepath) -#define ARC_PROFILE_END_SESSION() ::ARC::CInstrumentor::Get().EndSession() +#define ARC_PROFILE_BEGIN_SESSION(name, filepath) ::arc::instrumentor::Get().begin_session(name, filepath) +#define ARC_PROFILE_END_SESSION() ::arc::instrumentor::Get().end_session() #else #define ARC_PROFILE_SCOPE(name) #define ARC_PROFILE_FUNCTION() diff --git a/ARC-Engine/src/ARC/Core/PlatformDetection.h b/ARC-Engine/src/ARC/Core/PlatformDetection.h index 6ea10e6b32..9075012615 100644 --- a/ARC-Engine/src/ARC/Core/PlatformDetection.h +++ b/ARC-Engine/src/ARC/Core/PlatformDetection.h @@ -1,6 +1,6 @@ #pragma once -#ifdef _WIN32 - #ifdef _WIN64 +#ifdef win32 + #ifdef win64 #define ARC_PLATFORM_WINDOWS #else #error "x86 Builds are not supported!" diff --git a/ARC-Engine/src/ARC/Core/PlatformUtils.h b/ARC-Engine/src/ARC/Core/PlatformUtils.h index ac36cf31d5..4098548b15 100644 --- a/ARC-Engine/src/ARC/Core/PlatformUtils.h +++ b/ARC-Engine/src/ARC/Core/PlatformUtils.h @@ -1,12 +1,12 @@ #pragma once -namespace ARC +namespace arc { - struct SFileDialogs + struct file_dialogs { [[nodiscard]] - static std::filesystem::path OpenFile(const char* _Filter); + static std::filesystem::path open_file(const char* filter); [[nodiscard]] - static std::filesystem::path SaveFile(const char* _Filter); + static std::filesystem::path save_file(const char* filter); }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Core/UUID.cpp b/ARC-Engine/src/ARC/Core/UUID.cpp index 93e337bda8..ae4a6f7af9 100644 --- a/ARC-Engine/src/ARC/Core/UUID.cpp +++ b/ARC-Engine/src/ARC/Core/UUID.cpp @@ -2,12 +2,12 @@ #include "UUID.h" -namespace ARC { +namespace arc { static std::random_device sRandomDevice; static std::mt19937_64 sEngine(sRandomDevice()); - static std::uniform_int_distribution sUniformDistribution; // @TODO move to SRandom + static std::uniform_int_distribution sUniformDistribution; // @TODO move to random - TUUID SUUID::Generate() + uuid uuid::generate() { return sUniformDistribution(sEngine); } diff --git a/ARC-Engine/src/ARC/Core/UUID.h b/ARC-Engine/src/ARC/Core/UUID.h index aeb6074a1b..8e6ccbe75e 100644 --- a/ARC-Engine/src/ARC/Core/UUID.h +++ b/ARC-Engine/src/ARC/Core/UUID.h @@ -1,9 +1,9 @@ #pragma once -namespace ARC { - using TUUID = TUInt64; +namespace arc { + using uuid = u64; - struct SUUID { - static TUUID Generate(); + struct uuid { + static uuid generate(); }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Core/Window.h b/ARC-Engine/src/ARC/Core/Window.h index 8bff1e6d10..fbbc4ee289 100644 --- a/ARC-Engine/src/ARC/Core/Window.h +++ b/ARC-Engine/src/ARC/Core/Window.h @@ -2,35 +2,35 @@ #include -namespace ARC { class CEvent; } +namespace arc { class event; } -namespace ARC { - struct SWindowProps { - TString Title; +namespace arc { + struct window_props { + string Title; uint32_t Width; uint32_t Height; - SWindowProps(const TString& _title = "ARC-Engine", uint32_t _width = 1280, uint32_t _height = 720) : Title(_title), Width(_width), Height(_height){} + window_props(const string& _title = "ARC-Engine", uint32_t _width = 1280, uint32_t _height = 720) : Title(_title), Width(_width), Height(_height){} }; - class CWindow { + class window { public: - using EventCallbackFn = std::function; + using event_callback_fn = std::function; - virtual ~CWindow() {} - virtual void OnUpdate() = 0; + virtual ~window() {} + virtual void on_update() = 0; - virtual uint32_t GetWidth() const = 0; - virtual uint32_t GetHeight() const = 0; - virtual void SetWidth(uint32_t _) = 0; - virtual void SetHeight(uint32_t _) = 0; + virtual uint32_t get_width() const = 0; + virtual uint32_t get_height() const = 0; + virtual void set_width(uint32_t _) = 0; + virtual void set_height(uint32_t _) = 0; - virtual void SetEventCallback(const EventCallbackFn& _callback) = 0; - virtual void SetVSync(bool _bEnabled) = 0; - virtual bool IsVSync() const = 0; + virtual void set_event_callback(const event_callback_fn& _callback) = 0; + virtual void set_vsync(bool _bEnabled) = 0; + virtual bool is_vsync() const = 0; - virtual void* GetNativeWindow() const = 0; + virtual void* get_native_window() const = 0; - static CWindow* Create(const SWindowProps& _props = SWindowProps()); + static window* create(const window_props& _props = window_props()); }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Core/Yaml.h b/ARC-Engine/src/ARC/Core/Yaml.h index c36dc1b763..68bf0f7ff6 100644 --- a/ARC-Engine/src/ARC/Core/Yaml.h +++ b/ARC-Engine/src/ARC/Core/Yaml.h @@ -8,18 +8,18 @@ namespace YAML { template<> - struct convert + struct convert { - static Node encode(const ARC::FVec2& rhs) { + static Node encode(const arc::vec2& rhs) { Node node; node.push_back(rhs.x); node.push_back(rhs.y); - node.SetStyle(EmitterStyle::Flow); + node.set_style(EmitterStyle::Flow); return node; } - static bool decode(const Node& node, ARC::FVec2& rhs) { - if (!node.IsSequence() || node.size() != 2) + static bool decode(const Node& node, arc::vec2& rhs) { + if (!node.is_sequence() || node.size() != 2) return false; rhs.x = node[0].as(); @@ -28,19 +28,19 @@ namespace YAML } }; template<> - struct convert + struct convert { - static Node encode(const ARC::FVec3& rhs) { + static Node encode(const arc::vec3& rhs) { Node node; node.push_back(rhs.x); node.push_back(rhs.y); node.push_back(rhs.z); - node.SetStyle(EmitterStyle::Flow); + node.set_style(EmitterStyle::Flow); return node; } - static bool decode(const Node& node, ARC::FVec3& rhs) { - if (!node.IsSequence() || node.size() != 3) + static bool decode(const Node& node, arc::vec3& rhs) { + if (!node.is_sequence() || node.size() != 3) return false; rhs.x = node[0].as(); @@ -50,20 +50,20 @@ namespace YAML } }; template<> - struct convert + struct convert { - static Node encode(const ARC::FVec4& rhs) { + static Node encode(const arc::vec4& rhs) { Node node; node.push_back(rhs.x); node.push_back(rhs.y); node.push_back(rhs.z); node.push_back(rhs.w); - node.SetStyle(EmitterStyle::Flow); + node.set_style(EmitterStyle::Flow); return node; } - static bool decode(const Node& node, ARC::FVec4& rhs) { - if (!node.IsSequence() || node.size() != 4) + static bool decode(const Node& node, arc::vec4& rhs) { + if (!node.is_sequence() || node.size() != 4) return false; rhs.x = node[0].as(); @@ -75,20 +75,20 @@ namespace YAML }; template<> - struct convert + struct convert { - static Node encode(const ARC::FColor4& rhs) { + static Node encode(const arc::color4& rhs) { Node node; node.push_back(rhs.r); node.push_back(rhs.g); node.push_back(rhs.b); node.push_back(rhs.a); - node.SetStyle(EmitterStyle::Flow); + node.set_style(EmitterStyle::Flow); return node; } - static bool decode(const Node& node, ARC::FColor4& rhs) { - if (!node.IsSequence() || node.size() != 4) + static bool decode(const Node& node, arc::color4& rhs) { + if (!node.is_sequence() || node.size() != 4) return false; rhs.r = node[0].as(); @@ -99,7 +99,7 @@ namespace YAML } }; } -namespace ARC { +namespace arc { template inline YAML::Emitter& operator<<(YAML::Emitter& out, const T_& rhs) { out << YAML::convert::encode(rhs); diff --git a/ARC-Engine/src/ARC/Events/ApplicationEvent.h b/ARC-Engine/src/ARC/Events/ApplicationEvent.h index a4ac880a40..b2d08556d3 100644 --- a/ARC-Engine/src/ARC/Events/ApplicationEvent.h +++ b/ARC-Engine/src/ARC/Events/ApplicationEvent.h @@ -2,22 +2,22 @@ #include "Event.h" #include "../Types/vector.h" -namespace ARC { - class ARC_API CWindowResizeEvent : public CEvent +namespace arc { + class ARC_API window_resize_event : public event { public: - CWindowResizeEvent(TVec2& p_Dimentions) : - mDimentions(p_Dimentions) {} - CWindowResizeEvent(int p_DimentionsX, int p_DimentionsY) : - mDimentions(TVec2(p_DimentionsX, p_DimentionsY)) {} + window_resize_event(vec2& dimentions) : + dimentions_(dimentions) {} + window_resize_event(int dimentions_x, int dimentions_y) : + dimentions_(vec2(dimentions_x, dimentions_y)) {} - inline TVec2 GetDimentions() const { return mDimentions; }; - inline int GetX() const { return GetDimentions().x; }; - inline int GetY() const { return GetDimentions().y; }; + inline vec2 get_dimentions() const { return dimentions_; }; + inline int get_x() const { return get_dimentions().x; }; + inline int get_y() const { return get_dimentions().y; }; - virtual TString ToString() const override { + virtual string to_string() const override { std::stringstream ss; - ss << GetName() << ": " << GetX() << ", " << GetY(); + ss << get_name() << ": " << get_x() << ", " << get_y(); return ss.str(); } @@ -25,19 +25,19 @@ namespace ARC { EVENT_CLASS_TYPE(WindowResize) private: - TVec2 mDimentions; + vec2 dimentions_; }; - class ARC_API CWindowCloseEvent : public CEvent + class ARC_API window_close_event : public event { public: - CWindowCloseEvent(){} + window_close_event(){} EVENT_CLASS_CATEGORY(EventCategoryApplication) EVENT_CLASS_TYPE(WindowClose) }; - class ARC_API CAppTick : public CEvent + class ARC_API CAppTick : public event { public: CAppTick(){} @@ -46,7 +46,7 @@ namespace ARC { EVENT_CLASS_TYPE(AppTick) }; - class ARC_API CAppUpdate : public CEvent + class ARC_API CAppUpdate : public event { public: CAppUpdate(){} @@ -55,7 +55,7 @@ namespace ARC { EVENT_CLASS_TYPE(AppUpdate) }; - class ARC_API CAppRender : public CEvent + class ARC_API CAppRender : public event { public: CAppRender(){} diff --git a/ARC-Engine/src/ARC/Events/Event.h b/ARC-Engine/src/ARC/Events/Event.h index 3ac2265067..27e5e4d177 100644 --- a/ARC-Engine/src/ARC/Events/Event.h +++ b/ARC-Engine/src/ARC/Events/Event.h @@ -9,8 +9,8 @@ #include #include "ARC/Core/Macros.h" -namespace ARC { - enum class EEventType +namespace arc { + enum class event_type { None = 0, WindowClose, @@ -32,69 +32,69 @@ namespace ARC { MouseMoved, MouseScrolled }; - enum EEventCategory + enum event_category { None = 0, - EventCategoryApplication = SBIT(0), - EventCategoryInput = SBIT(1), - EventCategoryKeyboard = SBIT(2), - EventCategoryMouse = SBIT(3), - EventCategoryMouseButton = SBIT(4) + EventCategoryApplication = sbit(0), + EventCategoryInput = sbit(1), + EventCategoryKeyboard = sbit(2), + EventCategoryMouse = sbit(3), + EventCategoryMouseButton = sbit(4) }; #define EVENT_CLASS_TYPE(type) \ - static EEventType GetStaticType() {return COMBINE2(EEventType::, type);}\ - virtual EEventType GetEventType() const override {return GetStaticType();}\ - virtual const char* GetName() const override {return #type;} + static event_type get_static_type() {return COMBINE2(event_type::, type);}\ + virtual event_type get_event_type() const override {return get_static_type();}\ + virtual const char* get_name() const override {return #type;} - #define EVENT_CLASS_CATEGORY(category) virtual TUInt GetCategoryFlags() const override { return category; } + #define EVENT_CLASS_CATEGORY(category) virtual uint get_category_flags() const override { return category; } - class ARC_API CEvent + class ARC_API event { - friend class CEventDispatcher; + friend class event_dispatcher; public: - CEvent() : bHandled(0) {} - virtual ~CEvent() = default; + event() : bHandled(0) {} + virtual ~event() = default; - virtual EEventType GetEventType() const = 0; - virtual TUInt GetCategoryFlags() const = 0; + virtual event_type get_event_type() const = 0; + virtual uint get_category_flags() const = 0; // get event name - virtual const char* GetName() const = 0; + virtual const char* get_name() const = 0; // converts event to string - virtual TString ToString() const { return TString(GetName()); }; + virtual string to_string() const { return string(get_name()); }; - inline bool IsInCategory(EEventCategory category) { - return GetCategoryFlags() & category; + inline bool is_in_category(event_category category) { + return get_category_flags() & category; } - TUInt bHandled : 1; + uint bHandled : 1; }; - class CEventDispatcher + class event_dispatcher { template using EventFn = std::function; public: - CEventDispatcher(CEvent& p_Event) : mEvent(p_Event) {} + event_dispatcher(event& event) : event_(event) {} template - bool Dispatch(const F& _Func) + bool Dispatch(const F& func) { - if (mEvent.GetEventType() == T::GetStaticType()) + if (event_.get_event_type() == T::get_static_type()) { - mEvent.bHandled |= _Func(static_cast(mEvent)); + event_.bHandled |= func(static_cast(event_)); return true; } return false; } private: - CEvent& mEvent; + event& event_; }; - inline std::ostream& operator<<(std::ostream& os, const CEvent& e) { - return os << e.ToString(); + inline std::ostream& operator<<(std::ostream& os, const event& e) { + return os << e.to_string(); } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Events/KeyEvent.h b/ARC-Engine/src/ARC/Events/KeyEvent.h index 97d5ee319f..7c6be8c6b0 100644 --- a/ARC-Engine/src/ARC/Events/KeyEvent.h +++ b/ARC-Engine/src/ARC/Events/KeyEvent.h @@ -1,65 +1,65 @@ #pragma once #include "Event.h" -namespace ARC { +namespace arc { // abstract - class ARC_API CKeyEvent : public CEvent + class ARC_API CKeyEvent : public event { public: - inline int GetKeyCode() const { return mKeyCode; } + inline int get_key_code() const { return key_code_; } EVENT_CLASS_CATEGORY(EventCategoryKeyboard | EventCategoryInput) protected: - CKeyEvent() : mKeyCode(0) {} - int mKeyCode = 0; + CKeyEvent() : key_code_(0) {} + int key_code_ = 0; }; - class ARC_API CKeyPressedEvent : public CKeyEvent + class ARC_API key_pressed_event : public CKeyEvent { public: - CKeyPressedEvent(int p_KeyCode, TUInt p_RepeatCount) : - mRepeatCount() { - mKeyCode = p_KeyCode; + key_pressed_event(int key_code, uint repeat_count) : + repeat_count_() { + key_code_ = key_code; } - virtual TString ToString() const override { + virtual string to_string() const override { std::stringstream ss; - ss << GetName() << " [" << mKeyCode << "]: Repeated Count= " << mRepeatCount; + ss << get_name() << " [" << key_code_ << "]: Repeated Count= " << repeat_count_; return ss.str(); } - auto GetRepeatCount() const { return mRepeatCount; } + auto get_repeat_count() const { return repeat_count_; } EVENT_CLASS_TYPE(KeyPressed); private: - TUInt mRepeatCount = 0; + uint repeat_count_ = 0; }; - class ARC_API CKeyReleasedEvent : public CKeyEvent + class ARC_API key_released_event : public CKeyEvent { public: - CKeyReleasedEvent(int p_KeyCode) + key_released_event(int key_code) { - mKeyCode = p_KeyCode; + key_code_ = key_code; } - virtual TString ToString() const override { + virtual string to_string() const override { std::stringstream ss; - ss << GetName() << " [" << mKeyCode << "]"; + ss << get_name() << " [" << key_code_ << "]"; return ss.str(); } EVENT_CLASS_TYPE(KeyReleased); }; - class ARC_API CKeyTypedEvent : public CKeyEvent + class ARC_API key_typed_event : public CKeyEvent { public: - CKeyTypedEvent(int p_KeyCode) + key_typed_event(int key_code) { - mKeyCode = p_KeyCode; + key_code_ = key_code; } - virtual TString ToString() const override { + virtual string to_string() const override { std::stringstream ss; - ss << GetName() << " [" << mKeyCode << "]"; + ss << get_name() << " [" << key_code_ << "]"; return ss.str(); } EVENT_CLASS_TYPE(KeyTyped); diff --git a/ARC-Engine/src/ARC/Events/MouseEvent.h b/ARC-Engine/src/ARC/Events/MouseEvent.h index 634859b09b..c4186b114e 100644 --- a/ARC-Engine/src/ARC/Events/MouseEvent.h +++ b/ARC-Engine/src/ARC/Events/MouseEvent.h @@ -2,21 +2,21 @@ #include "Event.h" #include "..\Types\vector.h" -namespace ARC { - class ARC_API CMouseMovedEvent : public CEvent +namespace arc { + class ARC_API mouse_moved_event : public event { public: - CMouseMovedEvent(FVec2 p_MouseXY) : - mMousePos(p_MouseXY) {} - CMouseMovedEvent(float p_MouseX, float p_MouseY) : - mMousePos(FVec2(p_MouseX, p_MouseY)) { + mouse_moved_event(vec2 mouse_xy) : + mouse_pos_(mouse_xy) {} + mouse_moved_event(float mouse_x, float mouse_y) : + mouse_pos_(vec2(mouse_x, mouse_y)) { } - inline FVec2 GetPos() const {return mMousePos;}; + inline vec2 get_pos() const {return mouse_pos_;}; - virtual TString ToString() const { + virtual string to_string() const { std::stringstream ss; - ss << GetName() << "[" << GetPos().x << "," << GetPos().y << "]"; + ss << get_name() << "[" << get_pos().x << "," << get_pos().y << "]"; return ss.str(); } @@ -24,66 +24,66 @@ namespace ARC { EVENT_CLASS_TYPE(MouseMoved) private: - FVec2 mMousePos; + vec2 mouse_pos_; }; - class ARC_API CMouseScrolledEvent : public CEvent + class ARC_API mouse_scrolled_event : public event { public: - CMouseScrolledEvent(FVec2 p_Offset) : - mOffset(p_Offset) {} - CMouseScrolledEvent(float p_OffsetX, float p_OffsetY) : - mOffset(FVec2(p_OffsetY, p_OffsetY)) {} + mouse_scrolled_event(vec2 offset) : + offset_(offset) {} + mouse_scrolled_event(float offset_x, float offset_y) : + offset_(vec2(offset_y, offset_y)) {} - virtual TString ToString() const override { + virtual string to_string() const override { std::stringstream ss; - ss << GetName() << "[" << GetXOffset() << "," << GetYOffset() << "]"; + ss << get_name() << "[" << get_x_offset() << "," << get_y_offset() << "]"; return ss.str(); } - inline FVec2 GetOffset() const { return mOffset; } - inline float GetXOffset() const { return mOffset[0]; } - inline float GetYOffset() const { return mOffset[1]; } + inline vec2 get_offset() const { return offset_; } + inline float get_x_offset() const { return offset_[0]; } + inline float get_y_offset() const { return offset_[1]; } EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput) EVENT_CLASS_TYPE(MouseScrolled) private: - FVec2 mOffset; + vec2 offset_; }; - class ARC_API CMouseButtonEvent : public CEvent + class ARC_API CMouseButtonEvent : public event { public: - inline TUInt GetMouseButton() const { return mMouseButton; } + inline uint get_mouse_button() const { return mouse_button_; } EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput | EventCategoryMouseButton) protected: - CMouseButtonEvent(TUInt p_Button) : mMouseButton(p_Button) {} - TUInt mMouseButton; + CMouseButtonEvent(uint button) : mouse_button_(button) {} + uint mouse_button_; }; - class ARC_API CMouseButtonPressedEvent : public CMouseButtonEvent + class ARC_API mouse_button_pressed_event : public CMouseButtonEvent { public: - CMouseButtonPressedEvent(TUInt p_Button) : CMouseButtonEvent(p_Button) {} + mouse_button_pressed_event(uint button) : CMouseButtonEvent(button) {} - virtual TString ToString() const override { + virtual string to_string() const override { std::stringstream ss; - ss << GetName() << " [" << mMouseButton << "]"; + ss << get_name() << " [" << mouse_button_ << "]"; return ss.str(); } EVENT_CLASS_TYPE(MouseButtonPressed) }; - class ARC_API CMouseButtonReleasedEvent : public CMouseButtonEvent + class ARC_API mouse_button_released_event : public CMouseButtonEvent { public: - CMouseButtonReleasedEvent(TUInt p_Button) : CMouseButtonEvent(p_Button) {} + mouse_button_released_event(uint button) : CMouseButtonEvent(button) {} - virtual TString ToString() const override { + virtual string to_string() const override { std::stringstream ss; - ss << GetName() << " [" << mMouseButton << "]"; + ss << get_name() << " [" << mouse_button_ << "]"; return ss.str(); } diff --git a/ARC-Engine/src/ARC/GUI/ImGuiHelper.cpp b/ARC-Engine/src/ARC/GUI/ImGuiHelper.cpp index 8464e500d3..1083052414 100644 --- a/ARC-Engine/src/ARC/GUI/ImGuiHelper.cpp +++ b/ARC-Engine/src/ARC/GUI/ImGuiHelper.cpp @@ -3,17 +3,17 @@ #include "imgui.h" #include "imgui_internal.h" -namespace ARC { +namespace arc { - void SGuiHelper::DrawGuiControl(FVec1& pVec, const char* pID, float pColumnWidth, const FVec1& pDefaults) + void gui_helper::draw_gui_control(vec1& pVec, const char* pID, float pColumnWidth, const vec1& pDefaults) { - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO& io = ImGui::get_io(); auto BoldFont = io.Fonts->Fonts[0]; ImGui::PushID(pID); ImGui::Columns(2); - ImGui::SetColumnWidth(0, pColumnWidth); + ImGui::set_column_width(0, pColumnWidth); ImGui::Text(pID); ImGui::NextColumn(); @@ -40,15 +40,15 @@ namespace ARC { ImGui::Columns(1); } - void SGuiHelper::DrawGuiControl(FVec2& pVec, const char* pID, float pColumnWidth, const FVec2& pDefaults) + void gui_helper::draw_gui_control(vec2& pVec, const char* pID, float pColumnWidth, const vec2& pDefaults) { - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO& io = ImGui::get_io(); auto BoldFont = io.Fonts->Fonts[0]; ImGui::PushID(pID); ImGui::Columns(2); - ImGui::SetColumnWidth(0, pColumnWidth); + ImGui::set_column_width(0, pColumnWidth); ImGui::Text(pID); ImGui::NextColumn(); @@ -91,15 +91,15 @@ namespace ARC { ImGui::Columns(1); } - void SGuiHelper::DrawGuiControl(FVec3& pVec, const char* pID, float pColumnWidth, const FVec3& pDefaults) + void gui_helper::draw_gui_control(vec3& pVec, const char* pID, float pColumnWidth, const vec3& pDefaults) { - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO& io = ImGui::get_io(); auto BoldFont = io.Fonts->Fonts[0]; ImGui::PushID(pID); ImGui::Columns(2); - ImGui::SetColumnWidth(0, pColumnWidth); + ImGui::set_column_width(0, pColumnWidth); ImGui::Spacing(); ImGui::Text(pID); ImGui::NextColumn(); @@ -159,15 +159,15 @@ namespace ARC { ImGui::Columns(1); } - void SGuiHelper::DrawGuiControl(FVec4 & pVec, const char* pID, float pColumnWidth, const FVec4& pDefaults) + void gui_helper::draw_gui_control(vec4 & pVec, const char* pID, float pColumnWidth, const vec4& pDefaults) { - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO& io = ImGui::get_io(); auto BoldFont = io.Fonts->Fonts[0]; ImGui::PushID(pID); ImGui::Columns(2); - ImGui::SetColumnWidth(0, pColumnWidth); + ImGui::set_column_width(0, pColumnWidth); ImGui::Spacing(); ImGui::Text(pID); ImGui::NextColumn(); @@ -242,15 +242,15 @@ namespace ARC { ImGui::Columns(1); } - void SGuiHelper::DrawGuiControl(FColor4& pColor, const char* pID, float pColumnWidth, const FColor4& pDefaults /*= FColor4::White()*/) + void gui_helper::draw_gui_control(color4& pColor, const char* pID, float pColumnWidth, const color4& pDefaults /*= color4::White()*/) { - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO& io = ImGui::get_io(); auto BoldFont = io.Fonts->Fonts[0]; ImGui::PushID(pID); ImGui::Columns(2); - ImGui::SetColumnWidth(0, pColumnWidth); + ImGui::set_column_width(0, pColumnWidth); ImGui::Spacing(); ImGui::Text(pID); ImGui::NextColumn(); diff --git a/ARC-Engine/src/ARC/GUI/ImGuiHelper.h b/ARC-Engine/src/ARC/GUI/ImGuiHelper.h index 1d42951586..7d966f9996 100644 --- a/ARC-Engine/src/ARC/GUI/ImGuiHelper.h +++ b/ARC-Engine/src/ARC/GUI/ImGuiHelper.h @@ -1,11 +1,11 @@ #pragma once -namespace ARC { - struct SGuiHelper { - static void DrawGuiControl(FVec1& pVec, const char* pID, float pColumnWidth, const FVec1& pDefaults = FVec1::ZeroVector()); - static void DrawGuiControl(FVec2& pVec, const char* pID, float pColumnWidth, const FVec2& pDefaults = FVec2::ZeroVector()); - static void DrawGuiControl(FVec3& pVec, const char* pID, float pColumnWidth, const FVec3& pDefaults = FVec3::ZeroVector()); - static void DrawGuiControl(FVec4& pVec, const char* pID, float pColumnWidth, const FVec4& pDefaults = FVec4::ZeroVector()); - static void DrawGuiControl(FColor4& pVec, const char* pID, float pColumnWidth, const FColor4& pDefaults = FColor4::White()); +namespace arc { + struct gui_helper { + static void draw_gui_control(vec1& pVec, const char* pID, float pColumnWidth, const vec1& pDefaults = vec1::ZeroVector()); + static void draw_gui_control(vec2& pVec, const char* pID, float pColumnWidth, const vec2& pDefaults = vec2::ZeroVector()); + static void draw_gui_control(vec3& pVec, const char* pID, float pColumnWidth, const vec3& pDefaults = vec3::ZeroVector()); + static void draw_gui_control(vec4& pVec, const char* pID, float pColumnWidth, const vec4& pDefaults = vec4::ZeroVector()); + static void draw_gui_control(color4& pVec, const char* pID, float pColumnWidth, const color4& pDefaults = color4::White()); }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/GUI/ImGuiLayer.cpp b/ARC-Engine/src/ARC/GUI/ImGuiLayer.cpp index cd4690e3af..2ae648dac0 100644 --- a/ARC-Engine/src/ARC/GUI/ImGuiLayer.cpp +++ b/ARC-Engine/src/ARC/GUI/ImGuiLayer.cpp @@ -16,18 +16,18 @@ #include "ImGuizmo.h" -namespace ARC { - CImGuiLayer::CImGuiLayer() : CLayer("ImGuiLayer"), mbBlockEvents(1u) {} - CImGuiLayer::~CImGuiLayer() {} +namespace arc { + imgui_layer::imgui_layer() : layer("ImGuiLayer"), block_events_(1u) {} + imgui_layer::~imgui_layer() {} - void CImGuiLayer::OnAttach() + void imgui_layer::on_attach() { ARC_PROFILE_FUNCTION(); IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGui::StyleColorsClassic(); - ImGuiIO& io = ImGui::GetIO(); + ImGuiIO& io = ImGui::get_io(); io.IniFilename = "config/imgui.ini"; io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; @@ -39,23 +39,23 @@ namespace ARC { io.Fonts->AddFontFromFileTTF("assets/fonts/MavenPro-Bold.ttf", 16.f); io.FontDefault = io.Fonts->AddFontFromFileTTF("assets/fonts/MavenPro-Regular.ttf", 16.f); - ImGuiStyle& style = ImGui::GetStyle(); + ImGuiStyle& style = ImGui::get_style(); if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { style.WindowRounding=0.0f; style.Colors[ImGuiCol_WindowBg].w=1.0f; } - SetDarkThemeColors(); + set_dark_theme_colors(); ImGui::StyleColorsDark(); - auto& app = CApplication::Get(); - GLFWwindow* window = static_cast(app.GetWindow().GetNativeWindow()); + auto& app = application::Get(); + GLFWwindow* window = static_cast(app.get_window().get_native_window()); ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 410"); } - void CImGuiLayer::OnDetach() + void imgui_layer::on_detach() { ARC_PROFILE_FUNCTION(); ImGui_ImplOpenGL3_Shutdown(); @@ -63,15 +63,15 @@ namespace ARC { ImGui::DestroyContext(); } - void CImGuiLayer::OnEvent(CEvent& _e) + void imgui_layer::on_event(event& _e) { - if (!mbBlockEvents) return; - ImGuiIO& io = ImGui::GetIO(); - _e.bHandled |= _e.IsInCategory(EventCategoryMouse) & io.WantCaptureMouse; - _e.bHandled |= _e.IsInCategory(EventCategoryKeyboard) & io.WantCaptureKeyboard; + if (!block_events_) return; + ImGuiIO& io = ImGui::get_io(); + _e.bHandled |= _e.is_in_category(EventCategoryMouse) & io.WantCaptureMouse; + _e.bHandled |= _e.is_in_category(EventCategoryKeyboard) & io.WantCaptureKeyboard; } - void CImGuiLayer::Begin() + void imgui_layer::begin() { ARC_PROFILE_FUNCTION(); ImGui_ImplOpenGL3_NewFrame(); @@ -80,14 +80,14 @@ namespace ARC { ImGuizmo::BeginFrame(); } - void CImGuiLayer::End() + void imgui_layer::end() { ARC_PROFILE_FUNCTION(); - ImGuiIO& io = ImGui::GetIO(); - io.DisplaySize = ImVec2((float)CApplication::Get().GetWindow().GetWidth(), (float)CApplication::Get().GetWindow().GetHeight()); + ImGuiIO& io = ImGui::get_io(); + io.DisplaySize = ImVec2((float)application::Get().get_window().get_width(), (float)application::Get().get_window().get_height()); ImGui::Render(); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::get_draw_data()); if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { @@ -98,9 +98,9 @@ namespace ARC { } } - void CImGuiLayer::SetDarkThemeColors() + void imgui_layer::set_dark_theme_colors() { - auto& colors = ImGui::GetStyle().Colors; + auto& colors = ImGui::get_style().Colors; // colors[ImGuiCol_WindowBg] = ImVec4(.01, .012, .031, 1); // colors[ImGuiCol_PopupBg] = ImVec4(0.2, 0.2, 0.2, 1); // colors[ImGuiCol_Border] = ImVec4(1, 1, 1, 0.8); @@ -147,7 +147,7 @@ namespace ARC { // colors[ImGuiCol_ModalWindowDimBg] = ImVec4(.165, .212, .231, 1); } - void CImGuiLayer::OnGuiRender() + void imgui_layer::on_gui_render() { //static bool show = true; //ImGui::ShowDemoWindow(&show); diff --git a/ARC-Engine/src/ARC/GUI/ImGuiLayer.h b/ARC-Engine/src/ARC/GUI/ImGuiLayer.h index 061f9346fb..e8a914f827 100644 --- a/ARC-Engine/src/ARC/GUI/ImGuiLayer.h +++ b/ARC-Engine/src/ARC/GUI/ImGuiLayer.h @@ -1,25 +1,25 @@ #pragma once #include "ARC\Renderer\Layer.h" -namespace ARC { - class ARC_API CImGuiLayer : public CLayer +namespace arc { + class ARC_API imgui_layer : public layer { public: - CImGuiLayer(); - ~CImGuiLayer(); + imgui_layer(); + ~imgui_layer(); - virtual void OnAttach() override; - virtual void OnDetach() override; - virtual void OnGuiRender() override; - virtual void OnEvent(CEvent& _e) override; + virtual void on_attach() override; + virtual void on_detach() override; + virtual void on_gui_render() override; + virtual void on_event(event& _e) override; - void Begin(); - void End(); + void begin(); + void end(); - void SetBlockEvents(bool _) {mbBlockEvents = _; }; - void SetDarkThemeColors(); + void set_block_events(bool _) {block_events_ = _; }; + void set_dark_theme_colors(); private: - uint8_t mbBlockEvents : 1; - float mTime = 0.f; + uint8_t block_events_ : 1; + float time_ = 0.f; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Helpers/Conversions.h b/ARC-Engine/src/ARC/Helpers/Conversions.h index e24270adbd..23fc4d300d 100644 --- a/ARC-Engine/src/ARC/Helpers/Conversions.h +++ b/ARC-Engine/src/ARC/Helpers/Conversions.h @@ -1,10 +1,10 @@ #pragma once -namespace ARC +namespace arc { // treated as a static class template - struct SConvert + struct convert { static inline bool CanConv(const From& p) diff --git a/ARC-Engine/src/ARC/Helpers/Enum.h b/ARC-Engine/src/ARC/Helpers/Enum.h index 4fefb0d1be..1c0a7f4ce9 100644 --- a/ARC-Engine/src/ARC/Helpers/Enum.h +++ b/ARC-Engine/src/ARC/Helpers/Enum.h @@ -1,3 +1,3 @@ #pragma once -#define SBIT(x) (1 << x) +#define sbit(x) (1 << x) #define ARC_ENUM() \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Helpers/Helpers.cpp b/ARC-Engine/src/ARC/Helpers/Helpers.cpp index 4e28aa950a..ea1dfd5438 100644 --- a/ARC-Engine/src/ARC/Helpers/Helpers.cpp +++ b/ARC-Engine/src/ARC/Helpers/Helpers.cpp @@ -4,28 +4,28 @@ #include #include "inicpp.h" -namespace ARC { - static std::unordered_map> IniFiles; +namespace arc { + static std::unordered_map> IniFiles; - TString SHPR::ReadFile(const TString& _Path) + string shpr::ReadFile(const string& path) { - std::ifstream is(_Path.c_str(), std::ios::in | std::ios::binary); - ARC_CORE_ASSERT(is.is_open(), "Could not find the file \"{0}\"", _Path.c_str()); - TString str((std::istreambuf_iterator(is)), std::istreambuf_iterator()); + std::ifstream is(path.c_str(), std::ios::in | std::ios::binary); + ARC_CORE_ASSERT(is.is_open(), "Could not find the file \"{0}\"", path.c_str()); + string str((std::istreambuf_iterator(is)), std::istreambuf_iterator()); is.close(); return str; } - TString SHPR::ExtractFileNameFromPath(const TString& _Path, bool _bRemoveExtention /*= true*/) + string shpr::ExtractFileNameFromPath(const string& path, bool _bRemoveExtention /*= true*/) { - auto lastSlash = _Path.find_last_of("/\\"); + auto lastSlash = path.find_last_of("/\\"); - lastSlash = lastSlash == TString::npos ? 0 : lastSlash + 1; - if(!_bRemoveExtention) return _Path.substr(lastSlash); + lastSlash = lastSlash == string::npos ? 0 : lastSlash + 1; + if(!_bRemoveExtention) return path.substr(lastSlash); - auto lastDot = _Path.rfind('.'); - auto count = (lastDot == TString::npos ? _Path.length() - lastSlash : lastDot - lastSlash); + auto lastDot = path.rfind('.'); + auto count = (lastDot == string::npos ? path.length() - lastSlash : lastDot - lastSlash); - return _Path.substr(lastSlash, count); + return path.substr(lastSlash, count); } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Helpers/Helpers.h b/ARC-Engine/src/ARC/Helpers/Helpers.h index e12012e4e4..859a1051d5 100644 --- a/ARC-Engine/src/ARC/Helpers/Helpers.h +++ b/ARC-Engine/src/ARC/Helpers/Helpers.h @@ -13,25 +13,25 @@ #if defined(__GNUC__) || defined(__GNUG__) #include #endif -namespace ARC { namespace Core { class CApplication; } } +namespace arc { namespace Core { class application; } } -namespace ARC { class CEvent; } +namespace arc { class event; } #define OUT struct CounterId {}; -enum class EQuadCorner { +enum class quad_corner { TopLeft, TopRight, BottomLeft, BottomRight }; -namespace ARC { - struct SHPR { +namespace arc { + struct shpr { template static - TString GetClassName() + string get_class_name() { // @TODO Test code #if defined(__GNUC__) || defined(__GNUG__) @@ -41,7 +41,7 @@ namespace ARC { realname.reset(abi::__cxa_demangle(ti.name(), 0, 0, &status)); assert(status == 0); return std::string(realname.get()); - #elif defined(_MSC_VER) + #elif defined(msc_ver) auto rval = std::string(typeid(T).name()); std::size_t pos=0; @@ -59,37 +59,37 @@ namespace ARC { template static constexpr - size_t GetDataMemberOffset(U T::* member) + size_t get_data_member_offset(U T::* member) { return (char*)&((T*)nullptr->*member) - (char*)nullptr; } [[nodiscard]] static - TString ReadFile(const TString& _Path); + string ReadFile(const string& path); [[nodiscard]] static - TString ExtractFileNameFromPath(const TString& _Path, bool _bRemoveExtention = true); + string ExtractFileNameFromPath(const string& path, bool _bRemoveExtention = true); - template + template static - FVec2 GetScaledCorner(const FTransform2D& pTrans) { - GetScaledCorner(pTrans, SMath::Sin(pTrans.Rotation), SMath::Cos(pTrans.Rotation)); + vec2 get_scaled_corner(const transform_2d& pTrans) { + get_scaled_corner(pTrans, math::Sin(pTrans.Rotation), math::Cos(pTrans.Rotation)); } - template + template static - FVec2 GetScaledCorner(const FTransform2D& pTrans, float pSin, float pCos) { + vec2 get_scaled_corner(const transform_2d& pTrans, float pSin, float pCos) { switch (T1) { - case EQuadCorner::TopRight: return { + case quad_corner::TopRight: return { pTrans.Location.x + ((pTrans.Scale.x / 2) * pCos) - ((pTrans.Scale.y / 2) * pSin), pTrans.Location.y + ((pTrans.Scale.x / 2) * pSin) + ((pTrans.Scale.y / 2) * pCos) }; - case EQuadCorner::BottomLeft: return { + case quad_corner::BottomLeft: return { pTrans.Location.x - ((pTrans.Scale.x / 2) * pCos) + ((pTrans.Scale.y / 2) * pSin), pTrans.Location.y - ((pTrans.Scale.x / 2) * pSin) - ((pTrans.Scale.y / 2) * pCos) }; - case EQuadCorner::TopLeft: return { + case quad_corner::TopLeft: return { pTrans.Location.x - ((pTrans.Scale.x / 2) * pCos) - ((pTrans.Scale.y / 2) * pSin), pTrans.Location.y - ((pTrans.Scale.x / 2) * pSin) + ((pTrans.Scale.y / 2) * pCos) }; - case EQuadCorner::BottomRight: return { + case quad_corner::BottomRight: return { pTrans.Location.x + ((pTrans.Scale.x / 2) * pCos) + ((pTrans.Scale.y / 2) * pSin), pTrans.Location.y + ((pTrans.Scale.x / 2) * pSin) - ((pTrans.Scale.y / 2) * pCos) }; } @@ -98,7 +98,7 @@ namespace ARC { template static To Conv(const From& p) { - return SConvert::Conv(p); + return convert::Conv(p); }; template diff --git a/ARC-Engine/src/ARC/Helpers/Math.h b/ARC-Engine/src/ARC/Helpers/Math.h index aa30c701f1..269cb36bd7 100644 --- a/ARC-Engine/src/ARC/Helpers/Math.h +++ b/ARC-Engine/src/ARC/Helpers/Math.h @@ -5,11 +5,11 @@ #define PI 3.14159265358979323 #define PIf 3.14159265358979323f -enum class ERotType : uint8_t{ +enum class rot_type : uint8_t{ Degrees, Radians }; -enum class ETimeType : int8_t{ +enum class time_type : int8_t{ Day = -10, Hour = -2, Minute = -1, @@ -19,55 +19,55 @@ enum class ETimeType : int8_t{ Nano = 19 }; -namespace ARC { struct SMath; } +namespace arc { struct math; } -struct LerpingFunction { template inline constexpr static T Calculate(T _1, T _2, T1 _Alpha) { return 0; } }; +struct lerping_function { template inline constexpr static T calculate(T _1, T _2, T1 alpha) { return 0; } }; -struct Linear : LerpingFunction { +struct Linear : lerping_function { template inline constexpr static - T Calculate(T _1, T _2, T1 _Alpha) { - return _1 + (_2 - _1) * _Alpha; + T calculate(T _1, T _2, T1 alpha) { + return _1 + (_2 - _1) * alpha; } }; template -struct Flip : LerpingFunction { +struct Flip : lerping_function { template inline constexpr static - T Calculate(T _1, T _2, T1 _Alpha) { - return T0::Calculate(_1, _2, 1 - _Alpha); + T calculate(T _1, T _2, T1 alpha) { + return T0::calculate(_1, _2, 1 - alpha); } }; template -struct EaseIn : LerpingFunction { +struct ease_in : lerping_function { template inline constexpr static - T Calculate(T _1, T _2, T1 _Alpha) { - return Linear::Calculate(_1, _2, ARC::SMath::Pow(_Alpha, Exponent)); + T calculate(T _1, T _2, T1 alpha) { + return Linear::calculate(_1, _2, arc::math::Pow(alpha, Exponent)); } }; template -struct EaseInOut : LerpingFunction { +struct ease_in_out : lerping_function { template inline constexpr static - T Calculate(T _1, T _2, T1 _Alpha) { - return Linear::Calculate(_1, _2, Linear::Calculate( - EaseIn::Calculate(_1, _2, _Alpha), - Flip>::Calculate(_1, _2, _Alpha), - _Alpha + T calculate(T _1, T _2, T1 alpha) { + return Linear::calculate(_1, _2, Linear::calculate( + ease_in::calculate(_1, _2, alpha), + Flip>::calculate(_1, _2, alpha), + alpha )); } }; template -using EaseOut = Flip>; +using EaseOut = Flip>; -using Quadratic = EaseIn<2>; -using Cubic = EaseIn<3>; +using Quadratic = ease_in<2>; +using Cubic = ease_in<3>; -namespace ARC { - struct SMath { +namespace arc { + struct math { template [[nodiscard]] inline constexpr static decltype(auto) Dot(const T& _1, const T& _2) { @@ -112,14 +112,14 @@ namespace ARC { template [[nodiscard]] inline constexpr static decltype(auto) DistSqr(const T& _1, const T& _2) { - auto tmp = SMath::Sqr(_1 - _2); + auto tmp = math::Sqr(_1 - _2); return std::accumulate(tmp.begin(), tmp.end(), 0.f); } template [[nodiscard]] inline constexpr static decltype(auto) Dist(const T& _1, const T& _2) { - return SMath::Sqrt(DistSqr(_1, _2)); + return math::Sqrt(DistSqr(_1, _2)); } template @@ -152,9 +152,9 @@ namespace ARC { template [[nodiscard]] inline constexpr static - decltype(auto) Clamp(T _, T _Min, T _Max) { + decltype(auto) Clamp(T _, T min, T max) { static_assert(std::is_arithmetic_v); - return Min(Max(_, _Min), _Max) ; + return Min(Max(_, min), max) ; } template [[nodiscard]] inline constexpr static @@ -164,65 +164,65 @@ namespace ARC { } template [[nodiscard]] inline constexpr static - decltype(auto) IsEqual(const T& _1, const T& _2, T _Tollerance) { - return SMath::Abs(_1 - _2) <= _Tollerance; + decltype(auto) is_equal(const T& _1, const T& _2, T tollerance) { + return math::Abs(_1 - _2) <= tollerance; } /* * @todo Add Curved Interp Support */ template [[nodiscard]] inline constexpr static - decltype(auto) InterpF(T _1, T _2, float _Alpha) { - return TLerpingFunction::template Calculate(_1, _2, _Alpha); + decltype(auto) InterpF(T _1, T _2, float alpha) { + return TLerpingFunction::template calculate(_1, _2, alpha); } template [[nodiscard]] inline constexpr static - decltype(auto) Interp(T _1, T _2, T _Alpha) { - return TLerpingFunction::template Calculate(_1, _2, _Alpha); + decltype(auto) Interp(T _1, T _2, T alpha) { + return TLerpingFunction::template calculate(_1, _2, alpha); } template [[nodiscard]] inline constexpr static - decltype(auto) IsInRange(T _, T _Low, T _High) { - return (_Low <= _ && _ <= _High); + decltype(auto) is_in_range(T _, T low, T high) { + return (low <= _ && _ <= high); } - template + template [[nodiscard]] inline constexpr static decltype(auto) Conv(float _) { - if constexpr (From == ERotType::Degrees && To == ERotType::Radians) { + if constexpr (From == rot_type::Degrees && To == rot_type::Radians) { _ = (float)fmod(_, 360.f); if (_ < 0) _ += 360.f; return float(_ * PIf / 180.f); } - if constexpr (From == ERotType::Radians && To == ERotType::Degrees){ + if constexpr (From == rot_type::Radians && To == rot_type::Degrees){ _ = (float)fmod(_, PIf*2.f); if (_ < 0.f) _ += PIf * 2.f; return float(_ / (PIf / 180.f)); } } - template + template [[nodiscard]] inline constexpr static - decltype(auto) Conv(T _Time) { - if constexpr (From == To) return _Time; - if constexpr (To == ETimeType::Day) return Conv(_Time) / 24.f; - if constexpr (From == ETimeType::Day) return Conv(_Time * 24.f); + decltype(auto) Conv(T time) { + if constexpr (From == To) return time; + if constexpr (To == time_type::Day) return Conv(time) / 24.f; + if constexpr (From == time_type::Day) return Conv(time * 24.f); auto FromI = int8_t(From); auto ToI = int8_t(To); if (FromI >= 1) { - if (ToI >= 10) return _Time * Pow(T(10.f), ToI - FromI);// convert to seconds - else if(ToI <= 0) return Conv(_Time) / Pow(T(60.f), 0 - ToI); + if (ToI >= 10) return time * Pow(T(10.f), ToI - FromI);// convert to seconds + else if(ToI <= 0) return Conv(time) / Pow(T(60.f), 0 - ToI); } - return Conv(_Time * Pow(T(60.f), 0 - FromI)); + return Conv(time * Pow(T(60.f), 0 - FromI)); } [[nodiscard]] inline constexpr static - decltype(auto) Radians(float _) { return Conv(_); } + decltype(auto) Radians(float _) { return Conv(_); } [[nodiscard]] inline constexpr static - decltype(auto) Degrees(float _) { return Conv(_); } + decltype(auto) Degrees(float _) { return Conv(_); } }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Helpers/Random.h b/ARC-Engine/src/ARC/Helpers/Random.h index 08406531a6..8aa1aba686 100644 --- a/ARC-Engine/src/ARC/Helpers/Random.h +++ b/ARC-Engine/src/ARC/Helpers/Random.h @@ -1,42 +1,42 @@ #pragma once -namespace ARC { - struct SRandom +namespace arc { + struct random { public: using randclass = std::mt19937; - static void Init() + static void init() { - s_RandomEngine32.seed(std::random_device()()); + random_engine32.seed(std::random_device()()); } template - static void Init(const T* _Seed) + static void init(const T* seed) { - if constexpr (_Seed == nullptr) - Init(); + if constexpr (seed == nullptr) + init(); else - s_RandomEngine32.seed(*_Seed); + random_engine32.seed(*seed); } template static T Get() { - return (T)s_Distribution(s_RandomEngine32); + return (T)distribution(random_engine32); } template - static T Get(T _Min, T _Max) { - return _Min + ((T)s_Distribution(s_RandomEngine32) / ((T)randclass::max() / (_Max - _Min))); + static T Get(T min, T max) { + return min + ((T)distribution(random_engine32) / ((T)randclass::max() / (max - min))); } - static inline float Float() { return SRandom::Get(); } - static inline float Float(float _Min, float _Max) { return SRandom::Get(_Min, _Max); } + static inline float Float() { return random::Get(); } + static inline float Float(float min, float max) { return random::Get(min, max); } - static inline int Int() { return SRandom::Get(); } - static inline int Int(int _Min, int _Max) { return SRandom::Get(_Min, _Max); } + static inline int Int() { return random::Get(); } + static inline int Int(int min, int max) { return random::Get(min, max); } private: - static inline std::mt19937 s_RandomEngine32; - static inline std::uniform_int_distribution s_Distribution; + static inline std::mt19937 random_engine32; + static inline std::uniform_int_distribution distribution; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Input/Input.h b/ARC-Engine/src/ARC/Input/Input.h index 7046b2281d..1c7af5337c 100644 --- a/ARC-Engine/src/ARC/Input/Input.h +++ b/ARC-Engine/src/ARC/Input/Input.h @@ -3,12 +3,12 @@ #include "ARC/Types/vector.h" -namespace ARC { - class ARC_API SInput { +namespace arc { + class ARC_API input { public: - static bool IsKeyPressed(int _keycode); - static bool IsMouseButtonPressed(int _button); - static int GetKey(int _keycode); - static FVec2 GetMouseXY(); + static bool is_key_pressed(int _keycode); + static bool is_mouse_button_pressed(int _button); + static int get_key(int _keycode); + static vec2 get_mouse_xy(); }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Input/KeyCodes.h b/ARC-Engine/src/ARC/Input/KeyCodes.h index 0e50951c46..be236d04bf 100644 --- a/ARC-Engine/src/ARC/Input/KeyCodes.h +++ b/ARC-Engine/src/ARC/Input/KeyCodes.h @@ -1,9 +1,9 @@ #pragma once -namespace ARC { - namespace EKey +namespace arc { + namespace key { - enum EKey : TUInt16 + enum key : u16 { // From glfw3.h Space = 32, @@ -76,7 +76,7 @@ namespace ARC { PageUp = 266, PageDown = 267, Home = 268, - End = 269, + end = 269, CapsLock = 280, ScrollLock = 281, NumLock = 282, @@ -139,9 +139,9 @@ namespace ARC { }; } - namespace EMouse + namespace mouse { - enum EMouse : TUInt16 + enum mouse : u16 { // From glfw3.h Button0 = 0, diff --git a/ARC-Engine/src/ARC/Objects/Object.cpp b/ARC-Engine/src/ARC/Objects/Object.cpp index f425901d9c..aee6b95a47 100644 --- a/ARC-Engine/src/ARC/Objects/Object.cpp +++ b/ARC-Engine/src/ARC/Objects/Object.cpp @@ -1,6 +1,6 @@ #include "arc_pch.h" #include "Object.h" -namespace ARC { +namespace arc { } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Objects/Object.h b/ARC-Engine/src/ARC/Objects/Object.h index ddbef39813..d90f91030e 100644 --- a/ARC-Engine/src/ARC/Objects/Object.h +++ b/ARC-Engine/src/ARC/Objects/Object.h @@ -1,7 +1,7 @@ #pragma once -namespace ARC { - class CObject +namespace arc { + class object { }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Objects/Primitive2D.cpp b/ARC-Engine/src/ARC/Objects/Primitive2D.cpp index baff0ec050..4d9ddd98fa 100644 --- a/ARC-Engine/src/ARC/Objects/Primitive2D.cpp +++ b/ARC-Engine/src/ARC/Objects/Primitive2D.cpp @@ -1,6 +1,6 @@ #include "arc_pch.h" #include "Primitive2D.h" -namespace ARC { +namespace arc { } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Objects/Primitive2D.h b/ARC-Engine/src/ARC/Objects/Primitive2D.h index 7f626a52cc..2fb4fb7d58 100644 --- a/ARC-Engine/src/ARC/Objects/Primitive2D.h +++ b/ARC-Engine/src/ARC/Objects/Primitive2D.h @@ -5,31 +5,31 @@ #include "ARC/Types/Transform2D.h" #include "ARC/Types/Pointer.h" -namespace ARC { class CSubTexture2D; } -namespace ARC { class CTexture2D; } +namespace arc { class sub_texture_2d; } +namespace arc { class texture_2d; } -namespace ARC { - class CPrimitive2D : - public CObject +namespace arc { + class primitive_2d : + public object { public: - inline const FVec3& GetLocation() const { return Transform.Location; } - inline FVec3 GetLocation() { return Transform.Location; } + inline const vec3& get_location() const { return Transform.Location; } + inline vec3 get_location() { return Transform.Location; } - inline const float& GetRotation() const { return Transform.Rotation; } - inline float GetRotation() { return Transform.Rotation; } + inline const float& get_rotation() const { return Transform.Rotation; } + inline float get_rotation() { return Transform.Rotation; } - inline const FVec2& GetScale() const { return Transform.Scale; } - inline FVec2 GetScale() { return Transform.Scale; } + inline const vec2& get_scale() const { return Transform.Scale; } + inline vec2 get_scale() { return Transform.Scale; } - inline const FTransform2D& GetTransform() const { return Transform; } - inline FTransform2D GetTransform() { return Transform; } + inline const transform_2d& get_transform() const { return Transform; } + inline transform_2d get_transform() { return Transform; } public: - FTransform2D Transform; - TTransparencyType TransparencyLevel; - FColor4 Color = FColor4::White(); - TRef Texture = nullptr; - FVec2 TextureScaling = FVec2::OneVector(); + transform_2d Transform; + transparency_type TransparencyLevel; + color4 Color = color4::White(); + ref Texture = nullptr; + vec2 TextureScaling = vec2::OneVector(); }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/Buffer.cpp b/ARC-Engine/src/ARC/Renderer/Buffer.cpp index 92ae272d45..09365611eb 100644 --- a/ARC-Engine/src/ARC/Renderer/Buffer.cpp +++ b/ARC-Engine/src/ARC/Renderer/Buffer.cpp @@ -4,47 +4,47 @@ #include "Platform\OpenGl\OpenGLBuffer.h" #include "..\Core\Core.h" -namespace ARC { +namespace arc { - TRef CVertexBuffer::Create(float* _Vertices, uint32_t _Size) + ref vertex_buffer::create(float* vertices, uint32_t size) { - switch (CRenderer::GetCurrentAPI()) + switch (renderer::get_current_api()) { - case CRendererAPI::ERendererAPI::None: - ARC_CORE_ASSERT(false, "Selected renderer API is not supported (ERendererAPI::None)"); + case renderer_api::renderer_api::None: + ARC_CORE_ASSERT(false, "Selected renderer API is not supported (renderer_api::None)"); return nullptr; - case CRendererAPI::ERendererAPI::OpenGL: - return std::make_shared(_Vertices, _Size); + case renderer_api::renderer_api::OpenGL: + return std::make_shared(vertices, size); } ARC_CORE_ASSERT(false, "Unknown renderer API"); return nullptr; } - TRef CVertexBuffer::Create(uint32_t _Size) + ref vertex_buffer::create(uint32_t size) { - switch (CRenderer::GetCurrentAPI()) + switch (renderer::get_current_api()) { - case CRendererAPI::ERendererAPI::None: - ARC_CORE_ASSERT(false, "Selected renderer API is not supported (ERendererAPI::None)"); + case renderer_api::renderer_api::None: + ARC_CORE_ASSERT(false, "Selected renderer API is not supported (renderer_api::None)"); return nullptr; - case CRendererAPI::ERendererAPI::OpenGL: - return std::make_shared(_Size); + case renderer_api::renderer_api::OpenGL: + return std::make_shared(size); } ARC_CORE_ASSERT(false, "Unknown renderer API"); return nullptr; } - TRef CIndexBuffer::Create(uint32_t* _Indices, uint32_t _Count) + ref index_buffer::create(uint32_t* indices, uint32_t count) { - switch (CRenderer::GetCurrentAPI()) + switch (renderer::get_current_api()) { - case CRendererAPI::ERendererAPI::None: - ARC_CORE_ASSERT(false, "Selected renderer API is not supported (ERendererAPI::None)"); + case renderer_api::renderer_api::None: + ARC_CORE_ASSERT(false, "Selected renderer API is not supported (renderer_api::None)"); return nullptr; - case CRendererAPI::ERendererAPI::OpenGL: - return std::make_shared(_Indices, _Count); + case renderer_api::renderer_api::OpenGL: + return std::make_shared(indices, count); } ARC_CORE_ASSERT(false, "Unknown renderer API"); diff --git a/ARC-Engine/src/ARC/Renderer/Buffer.h b/ARC-Engine/src/ARC/Renderer/Buffer.h index 5de7c5767b..498b395bf8 100644 --- a/ARC-Engine/src/ARC/Renderer/Buffer.h +++ b/ARC-Engine/src/ARC/Renderer/Buffer.h @@ -3,48 +3,48 @@ #include #include "..\Core\Core.h" -namespace ARC { - enum class EShaderDataType : uint8_t +namespace arc { + enum class shader_data_type : uint8_t { None = 0, Float, Float2, Float3, Float4, Mat3, Mat4, Int, Int2, Int3, Int4, Bool }; - struct SShaderHelper { - static uint32_t GetSize(EShaderDataType _Type) + struct shader_helper { + static uint32_t get_size(shader_data_type type) { - switch (_Type) + switch (type) { - case EShaderDataType::Float: return 4u; - case EShaderDataType::Float2: return 4u * 2u; - case EShaderDataType::Float3: return 4u * 3u; - case EShaderDataType::Float4: return 4u * 4u; - case EShaderDataType::Mat3: return 4u * 3u * 3u; - case EShaderDataType::Mat4: return 4u * 4u * 4u; - case EShaderDataType::Int: return 4u; - case EShaderDataType::Int2: return 4u * 2u; - case EShaderDataType::Int3: return 4u * 3u; - case EShaderDataType::Int4: return 4u * 4u; - case EShaderDataType::Bool: return 1u; + case shader_data_type::Float: return 4u; + case shader_data_type::Float2: return 4u * 2u; + case shader_data_type::Float3: return 4u * 3u; + case shader_data_type::Float4: return 4u * 4u; + case shader_data_type::Mat3: return 4u * 3u * 3u; + case shader_data_type::Mat4: return 4u * 4u * 4u; + case shader_data_type::Int: return 4u; + case shader_data_type::Int2: return 4u * 2u; + case shader_data_type::Int3: return 4u * 3u; + case shader_data_type::Int4: return 4u * 4u; + case shader_data_type::Bool: return 1u; } ARC_CORE_ASSERT(false, "UnknownShaderDataType"); return 0; } - static uint32_t GetComponentCount(EShaderDataType _Type) + static uint32_t get_component_count(shader_data_type type) { - switch (_Type) + switch (type) { - case EShaderDataType::Float: return 1u; - case EShaderDataType::Float2: return 2u; - case EShaderDataType::Float3: return 3u; - case EShaderDataType::Float4: return 4u; - case EShaderDataType::Mat3: return 3u * 3u; - case EShaderDataType::Mat4: return 4u * 4u; - case EShaderDataType::Int: return 1u; - case EShaderDataType::Int2: return 2u; - case EShaderDataType::Int3: return 3u; - case EShaderDataType::Int4: return 4u; - case EShaderDataType::Bool: return 1u; + case shader_data_type::Float: return 1u; + case shader_data_type::Float2: return 2u; + case shader_data_type::Float3: return 3u; + case shader_data_type::Float4: return 4u; + case shader_data_type::Mat3: return 3u * 3u; + case shader_data_type::Mat4: return 4u * 4u; + case shader_data_type::Int: return 1u; + case shader_data_type::Int2: return 2u; + case shader_data_type::Int3: return 3u; + case shader_data_type::Int4: return 4u; + case shader_data_type::Bool: return 1u; } ARC_CORE_ASSERT(false, "UnknownShaderDataType"); @@ -52,84 +52,84 @@ namespace ARC { } }; - struct CBufferElement + struct buffer_element { std::string Name; - EShaderDataType Type; + shader_data_type Type; uint32_t Offset; - uint32_t Size; + uint32_t size; uint8_t bNormalized : 1; - CBufferElement(EShaderDataType _Type, const std::string& _Name, bool _bNormalized = false) - : Name(_Name), Type(_Type), Offset(0u), Size(SShaderHelper::GetSize(_Type)), bNormalized(_bNormalized) + buffer_element(shader_data_type type, const std::string& name, bool _bNormalized = false) + : Name(name), Type(type), Offset(0u), size(shader_helper::get_size(type)), bNormalized(_bNormalized) { } }; - class CBufferLayout + class buffer_layout { public: - CBufferLayout(){}; - CBufferLayout(const std::initializer_list& _Elem) - : mBufferElements(_Elem) + buffer_layout(){}; + buffer_layout(const std::initializer_list& elem) + : buffer_elements_(elem) { CalculateOffsetAndStride(); }; [[nodiscard]] inline const - std::vector& GetElements() const { return mBufferElements; } + std::vector& get_elements() const { return buffer_elements_; } [[nodiscard]] inline - uint32_t GetStride() const { return mStride; } + uint32_t get_stride() const { return stride_; } - std::vector::iterator begin() { return mBufferElements.begin(); } - std::vector::iterator end() { return mBufferElements.end(); } + std::vector::iterator begin() { return buffer_elements_.begin(); } + std::vector::iterator end() { return buffer_elements_.end(); } - std::vector::const_iterator begin() const { return mBufferElements.begin(); } - std::vector::const_iterator end() const { return mBufferElements.end(); } + std::vector::const_iterator begin() const { return buffer_elements_.begin(); } + std::vector::const_iterator end() const { return buffer_elements_.end(); } private: void CalculateOffsetAndStride() { uint32_t offset=0; - mStride = 0; - for (auto& elem : mBufferElements) + stride_ = 0; + for (auto& elem : buffer_elements_) { elem.Offset=offset; - offset+=elem.Size; - mStride+=elem.Size; + offset+=elem.size; + stride_+=elem.size; } } private: - std::vector mBufferElements; - uint32_t mStride=0; + std::vector buffer_elements_; + uint32_t stride_=0; }; - class CVertexBuffer + class vertex_buffer { public: - virtual ~CVertexBuffer() {}; - static TRef Create(float* _Vertices, uint32_t _Size); - static TRef Create(uint32_t _Size); + virtual ~vertex_buffer() {}; + static ref create(float* vertices, uint32_t size); + static ref create(uint32_t size); - virtual void SetLayout(const CBufferLayout& _Layout) = 0; - virtual const CBufferLayout& GetLayout() const = 0; + virtual void set_layout(const buffer_layout& layout) = 0; + virtual const buffer_layout& get_layout() const = 0; - virtual void SetData(const void* _Data, uint32_t _Size) = 0; + virtual void set_data(const void* data, uint32_t size) = 0; - virtual void Bind() const = 0; + virtual void bind() const = 0; virtual void UnBind() const = 0; }; - class CIndexBuffer + class index_buffer { public: - virtual ~CIndexBuffer() {}; - static TRef Create(uint32_t* _Indices, uint32_t _Count); + virtual ~index_buffer() {}; + static ref create(uint32_t* indices, uint32_t count); - virtual void Bind() const = 0; + virtual void bind() const = 0; virtual void UnBind() const = 0; - virtual uint32_t GetCount() const = 0; + virtual uint32_t get_count() const = 0; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/Camera.h b/ARC-Engine/src/ARC/Renderer/Camera.h index 26ea5024bf..2e76f6de76 100644 --- a/ARC-Engine/src/ARC/Renderer/Camera.h +++ b/ARC-Engine/src/ARC/Renderer/Camera.h @@ -2,17 +2,17 @@ #include "ARC/Wrappers/Glm.h" -namespace ARC +namespace arc { - class CCamera + class camera { public: - CCamera() = default; - CCamera(const FGLMMat4& pProjection) : mProjection(pProjection){}; + camera() = default; + camera(const mat4& pProjection) : projection_(pProjection){}; - const FGLMMat4& GetProjection() const { return mProjection; } + const mat4& get_projection() const { return projection_; } protected: - FGLMMat4 mProjection = FGLMMat4(1.0f); + mat4 projection_ = mat4(1.0f); }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/FrameBuffer.cpp b/ARC-Engine/src/ARC/Renderer/FrameBuffer.cpp index 0c9949df75..01ebb18749 100644 --- a/ARC-Engine/src/ARC/Renderer/FrameBuffer.cpp +++ b/ARC-Engine/src/ARC/Renderer/FrameBuffer.cpp @@ -2,17 +2,17 @@ #include "FrameBuffer.h" #include "Platform\OpenGl\OpenGLFrameBuffer.h" -namespace ARC { +namespace arc { - TRef CFrameBuffer::Create(const SFrameBufferSpecification& spec) + ref framebuffer::create(const frame_buffer_specification& spec) { - switch (CRenderer::GetCurrentAPI()) + switch (renderer::get_current_api()) { - case CRendererAPI::ERendererAPI::None: - ARC_CORE_ASSERT(false, "Selected renderer API is not supported (ERendererAPI::None)"); + case renderer_api::renderer_api::None: + ARC_CORE_ASSERT(false, "Selected renderer API is not supported (renderer_api::None)"); return nullptr; - case CRendererAPI::ERendererAPI::OpenGL: - return CreateRef(spec); + case renderer_api::renderer_api::OpenGL: + return create_ref(spec); } ARC_CORE_ASSERT(false, "Unknown renderer API"); diff --git a/ARC-Engine/src/ARC/Renderer/FrameBuffer.h b/ARC-Engine/src/ARC/Renderer/FrameBuffer.h index f63a34e243..26748f156d 100644 --- a/ARC-Engine/src/ARC/Renderer/FrameBuffer.h +++ b/ARC-Engine/src/ARC/Renderer/FrameBuffer.h @@ -2,9 +2,9 @@ #include "ARC.h" -namespace ARC { +namespace arc { - enum class EFrameBufferTextureFormat : TUInt32 + enum class frame_buffer_texture_format : u32 { None=0, @@ -19,34 +19,34 @@ namespace ARC { Depth = DEPTH24STENCIL8 }; - struct SFrameBufferSpecification + struct frame_buffer_specification { - TUInt32 Width, Height; - TUInt32 Samples=1; + u32 Width, Height; + u32 Samples=1; - std::vector Attachments; // EFrameBufferTextureFormat + std::vector Attachments; // frame_buffer_texture_format - TUInt8 bSwapChainTarget : 1; + u8 bSwapChainTarget : 1; }; - class CFrameBuffer + class framebuffer { public: - virtual ~CFrameBuffer() = default; + virtual ~framebuffer() = default; - virtual void Bind()=0; + virtual void bind()=0; virtual void UnBind()=0; - virtual void Resize(const TVec2& p)=0; - virtual int ReadPixel(TUInt32 pAttachmentIndex, int pX, int pY) = 0; + virtual void resize(const vec2& p)=0; + virtual int read_pixel(u32 pAttachmentIndex, int pX, int pY) = 0; - virtual const SFrameBufferSpecification& GetSpecifications() const = 0; - virtual TUInt32 GetColorAttachmentRendererID(TUInt32 pIndex = 0) const =0; + virtual const frame_buffer_specification& get_specifications() const = 0; + virtual u32 get_color_attachment_renderer_id(u32 pIndex = 0) const =0; - virtual void ClearColorAttachment(TUInt32 pAttachmentIndex, const int pValue) = 0; - virtual void ClearColorAttachment(TUInt32 pAttachmentIndex, const float pValue) = 0; + virtual void ClearColorAttachment(u32 pAttachmentIndex, const int pValue) = 0; + virtual void ClearColorAttachment(u32 pAttachmentIndex, const float pValue) = 0; - static TRef Create(const SFrameBufferSpecification& pSpec); + static ref create(const frame_buffer_specification& pSpec); }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/GraphicsContext.h b/ARC-Engine/src/ARC/Renderer/GraphicsContext.h index 0d9248f321..91869e71e4 100644 --- a/ARC-Engine/src/ARC/Renderer/GraphicsContext.h +++ b/ARC-Engine/src/ARC/Renderer/GraphicsContext.h @@ -1,11 +1,11 @@ #pragma once -namespace ARC { - class CGraphicsContext +namespace arc { + class graphics_context { public: - virtual ~CGraphicsContext() = default; - virtual void Init()=0; - virtual void SwapBuffers()=0; + virtual ~graphics_context() = default; + virtual void init()=0; + virtual void swap_buffers()=0; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/Layer.cpp b/ARC-Engine/src/ARC/Renderer/Layer.cpp index e9c2097552..4646ca1676 100644 --- a/ARC-Engine/src/ARC/Renderer/Layer.cpp +++ b/ARC-Engine/src/ARC/Renderer/Layer.cpp @@ -1,12 +1,12 @@ #include "arc_pch.h" #include "Layer.h" -namespace ARC { - CLayer::CLayer(const std::string& _name/*="Layer"*/) : mDebugName(_name) +namespace arc { + layer::layer(const std::string& _name/*="Layer"*/) : debug_name_(_name) { } - CLayer::~CLayer() + layer::~layer() { } diff --git a/ARC-Engine/src/ARC/Renderer/Layer.h b/ARC-Engine/src/ARC/Renderer/Layer.h index 96fe67a9bb..945ccaf131 100644 --- a/ARC-Engine/src/ARC/Renderer/Layer.h +++ b/ARC-Engine/src/ARC/Renderer/Layer.h @@ -1,23 +1,23 @@ #pragma once #include -namespace ARC { - class CEvent; +namespace arc { + class event; - class ARC_API CLayer + class ARC_API layer { public: - CLayer(const std::string& _name="Layer"); - virtual ~CLayer(); + layer(const std::string& _name="Layer"); + virtual ~layer(); - virtual void OnAttach(){} - virtual void OnDetach(){} - virtual void OnUpdate(float _DeltaTime){} - virtual void OnGuiRender(){} - virtual void OnEvent(CEvent& _event){} + virtual void on_attach(){} + virtual void on_detach(){} + virtual void on_update(float delta_time){} + virtual void on_gui_render(){} + virtual void on_event(event& _event){} - inline const std::string& GetName() const { return mDebugName; } + inline const std::string& get_name() const { return debug_name_; } protected: - std::string mDebugName; + std::string debug_name_; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/LayerStack.cpp b/ARC-Engine/src/ARC/Renderer/LayerStack.cpp index 27578ebf79..e8e124faff 100644 --- a/ARC-Engine/src/ARC/Renderer/LayerStack.cpp +++ b/ARC-Engine/src/ARC/Renderer/LayerStack.cpp @@ -1,45 +1,45 @@ #include "arc_pch.h" -#include "LayerStack.h" +#include "layer_stack.h" #include "Layer.h" -namespace ARC { - LayerStack::LayerStack() +namespace arc { + layer_stack::layer_stack() { } - LayerStack::~LayerStack() + layer_stack::~layer_stack() { - for(CLayer* layer : mLayers){ - layer->OnDetach(); + for(layer* layer : layers_){ + layer->on_detach(); delete layer; } } - void LayerStack::PushLayer(CLayer* _layer) + void layer_stack::push_layer(layer* _layer) { - mLayers.emplace(mLayers.begin() + mLayerInsertIndex, _layer); - ++mLayerInsertIndex; + layers_.emplace(layers_.begin() + layer_insert_index_, _layer); + ++layer_insert_index_; } - void LayerStack::PushOverlay(CLayer* _overlay) + void layer_stack::push_overlay(layer* _overlay) { - mLayers.emplace_back(_overlay); + layers_.emplace_back(_overlay); } - void LayerStack::PopLayer(CLayer* _layer) + void layer_stack::PopLayer(layer* _layer) { - auto it = std::find(mLayers.begin(), mLayers.end(), _layer); - if (it != mLayers.end()) { - mLayers.erase(it); - --mLayerInsertIndex; + auto it = std::find(layers_.begin(), layers_.end(), _layer); + if (it != layers_.end()) { + layers_.erase(it); + --layer_insert_index_; } } - void LayerStack::PopOverlay(CLayer* _overlay) + void layer_stack::PopOverlay(layer* _overlay) { - auto it = std::find(mLayers.begin(), mLayers.end(), _overlay); - if (it != mLayers.end()) { - mLayers.erase(it); + auto it = std::find(layers_.begin(), layers_.end(), _overlay); + if (it != layers_.end()) { + layers_.erase(it); } } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/LayerStack.h b/ARC-Engine/src/ARC/Renderer/LayerStack.h index f7a4b3a4bd..b0f95e71be 100644 --- a/ARC-Engine/src/ARC/Renderer/LayerStack.h +++ b/ARC-Engine/src/ARC/Renderer/LayerStack.h @@ -2,22 +2,22 @@ #include #include "Layer.h" -namespace ARC { - class ARC_API LayerStack +namespace arc { + class ARC_API layer_stack { public: - LayerStack(); - ~LayerStack(); + layer_stack(); + ~layer_stack(); - void PushLayer(CLayer* _layer); - void PushOverlay(CLayer* _overlay); - void PopLayer(CLayer* _layer); - void PopOverlay(CLayer* _overlay); + void push_layer(layer* _layer); + void push_overlay(layer* _overlay); + void PopLayer(layer* _layer); + void PopOverlay(layer* _overlay); - std::vector::iterator begin() { return mLayers.begin(); } - std::vector::iterator end() { return mLayers.end(); } + std::vector::iterator begin() { return layers_.begin(); } + std::vector::iterator end() { return layers_.end(); } private: - std::vector mLayers; - unsigned int mLayerInsertIndex=0; + std::vector layers_; + unsigned int layer_insert_index_=0; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/OrthographicCamera.cpp b/ARC-Engine/src/ARC/Renderer/OrthographicCamera.cpp index cd4fe114e3..b9fb41ef68 100644 --- a/ARC-Engine/src/ARC/Renderer/OrthographicCamera.cpp +++ b/ARC-Engine/src/ARC/Renderer/OrthographicCamera.cpp @@ -3,27 +3,27 @@ #include -namespace ARC { - COrthographicCamera::COrthographicCamera(float _Left, float _Right, float _Bottom, float _Top) : - mProjectionMatrix(glm::ortho(_Left, _Right, _Bottom, _Top, -1.0f, 1.0f)), - mViewMatrix(1.0f) +namespace arc { + orthographic_camera::orthographic_camera(float left, float right, float bottom, float top) : + projection_matrix_(glm::ortho(left, right, bottom, top, -1.0f, 1.0f)), + view_matrix_(1.0f) { - mViewProjectionMatrix = mProjectionMatrix * mViewMatrix; + view_projection_matrix_ = projection_matrix_ * view_matrix_; } - void COrthographicCamera::SetProjection(float _Left, float _Right, float _Bottom, float _Top) + void orthographic_camera::set_projection(float left, float right, float bottom, float top) { - mProjectionMatrix = glm::ortho(_Left, _Right, _Bottom, _Top, -1.0f, 1.0f); + projection_matrix_ = glm::ortho(left, right, bottom, top, -1.0f, 1.0f); - mViewProjectionMatrix = mProjectionMatrix * mViewMatrix; + view_projection_matrix_ = projection_matrix_ * view_matrix_; } - void COrthographicCamera::RecalculateViewProjectionMatrix() + void orthographic_camera::RecalculateViewProjectionMatrix() { - FGLMMat4 transform = glm::translate(FGLMMat4(1.0f), Position) * - glm::rotate(FGLMMat4(1.0f), glm::radians(Rotation), glm::vec3(0, 0, 1)); + mat4 transform = glm::translate(mat4(1.0f), Position) * + glm::rotate(mat4(1.0f), glm::radians(Rotation), glm::vec3(0, 0, 1)); - mViewMatrix = glm::inverse(transform); - mViewProjectionMatrix = mProjectionMatrix * mViewMatrix; + view_matrix_ = glm::inverse(transform); + view_projection_matrix_ = projection_matrix_ * view_matrix_; } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/OrthographicCamera.h b/ARC-Engine/src/ARC/Renderer/OrthographicCamera.h index 74fc6bdc82..6a915d38d3 100644 --- a/ARC-Engine/src/ARC/Renderer/OrthographicCamera.h +++ b/ARC-Engine/src/ARC/Renderer/OrthographicCamera.h @@ -1,15 +1,15 @@ #pragma once #include "ARC/Wrappers/Glm.h" -namespace ARC { - class COrthographicCamera +namespace arc { + class orthographic_camera { public: - COrthographicCamera(float _Left, float _Right, float _Bottom, float _Top); - void SetProjection(float _Left, float _Right, float _Bottom, float _Top); + orthographic_camera(float left, float right, float bottom, float top); + void set_projection(float left, float right, float bottom, float top); - inline const FGLMMat4& GetViewMatrix() const { return mViewMatrix; } - inline const FGLMMat4& GetViewProjectionMatrix() const { return mViewProjectionMatrix; } + inline const mat4& get_view_matrix() const { return view_matrix_; } + inline const mat4& get_view_projection_matrix() const { return view_projection_matrix_; } void RecalculateViewProjectionMatrix(); public: @@ -17,8 +17,8 @@ namespace ARC { glm::vec3 Scale = { 1.0f, 1.0f, 1.0f }; float Rotation = 0.0f; private: - FGLMMat4 mProjectionMatrix; - FGLMMat4 mViewMatrix; - FGLMMat4 mViewProjectionMatrix; + mat4 projection_matrix_; + mat4 view_matrix_; + mat4 view_projection_matrix_; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/OrthographicCameraController.cpp b/ARC-Engine/src/ARC/Renderer/OrthographicCameraController.cpp index da8c425749..a92c11dbc0 100644 --- a/ARC-Engine/src/ARC/Renderer/OrthographicCameraController.cpp +++ b/ARC-Engine/src/ARC/Renderer/OrthographicCameraController.cpp @@ -9,119 +9,119 @@ #include "ARC/Core/Macros.h" #include "ARC/Profiling/Timer.h" #include "glm/trigonometric.hpp" -namespace ARC { - COrthographicCameraController::COrthographicCameraController(float _AspectRatio, bool _bCanRotate) : - mAspectRatio(_AspectRatio), - mCamera(-mAspectRatio * mZoomLevel, mAspectRatio * mZoomLevel, -mZoomLevel, mZoomLevel), - mbCanRotate(_bCanRotate) +namespace arc { + orthographic_camera_controller::orthographic_camera_controller(float aspect_ratio, bool _bCanRotate) : + aspect_ratio_(aspect_ratio), + camera_(-aspect_ratio_ * zoom_level_, aspect_ratio_ * zoom_level_, -zoom_level_, zoom_level_), + can_rotate_(_bCanRotate) { } - void COrthographicCameraController::OnUpdate(float _DeltaTime) + void orthographic_camera_controller::on_update(float delta_time) { ARC_PROFILE_FUNCTION(); - if (SInput::IsKeyPressed(EKey::A)) + if (input::is_key_pressed(key::A)) { - mCamera.Position.x -= cos(glm::radians(mCamera.Rotation)) * mCamMoveSpeed * _DeltaTime; - mCamera.Position.y -= sin(glm::radians(mCamera.Rotation)) * mCamMoveSpeed * _DeltaTime; - mbNeedsRecalculation = 1u; + camera_.Position.x -= cos(glm::radians(camera_.Rotation)) * cam_move_speed_ * delta_time; + camera_.Position.y -= sin(glm::radians(camera_.Rotation)) * cam_move_speed_ * delta_time; + needs_recalculation_ = 1u; } - else if (SInput::IsKeyPressed(EKey::D)) + else if (input::is_key_pressed(key::D)) { - mCamera.Position.x += cos(glm::radians(mCamera.Rotation)) * mCamMoveSpeed * _DeltaTime; - mCamera.Position.y += sin(glm::radians(mCamera.Rotation)) * mCamMoveSpeed * _DeltaTime; - mbNeedsRecalculation = 1u; + camera_.Position.x += cos(glm::radians(camera_.Rotation)) * cam_move_speed_ * delta_time; + camera_.Position.y += sin(glm::radians(camera_.Rotation)) * cam_move_speed_ * delta_time; + needs_recalculation_ = 1u; } - if (SInput::IsKeyPressed(EKey::W)) + if (input::is_key_pressed(key::W)) { - mCamera.Position.x += -sin(glm::radians(mCamera.Rotation)) * mCamMoveSpeed * _DeltaTime; - mCamera.Position.y += cos(glm::radians(mCamera.Rotation)) * mCamMoveSpeed * _DeltaTime; - mbNeedsRecalculation = 1u; + camera_.Position.x += -sin(glm::radians(camera_.Rotation)) * cam_move_speed_ * delta_time; + camera_.Position.y += cos(glm::radians(camera_.Rotation)) * cam_move_speed_ * delta_time; + needs_recalculation_ = 1u; } - else if (SInput::IsKeyPressed(EKey::S)) + else if (input::is_key_pressed(key::S)) { - mCamera.Position.x -= -sin(glm::radians(mCamera.Rotation)) * mCamMoveSpeed * _DeltaTime; - mCamera.Position.y -= cos(glm::radians(mCamera.Rotation)) * mCamMoveSpeed * _DeltaTime; - mbNeedsRecalculation = 1u; + camera_.Position.x -= -sin(glm::radians(camera_.Rotation)) * cam_move_speed_ * delta_time; + camera_.Position.y -= cos(glm::radians(camera_.Rotation)) * cam_move_speed_ * delta_time; + needs_recalculation_ = 1u; } - if (SInput::IsKeyPressed(EKey::A)) + if (input::is_key_pressed(key::A)) { - mCamera.Position.x -= mCamMoveSpeed * _DeltaTime; - mbNeedsRecalculation = 1u; + camera_.Position.x -= cam_move_speed_ * delta_time; + needs_recalculation_ = 1u; } - if (SInput::IsKeyPressed(EKey::D)) + if (input::is_key_pressed(key::D)) { - mCamera.Position.x += mCamMoveSpeed * _DeltaTime; - mbNeedsRecalculation = 1u; + camera_.Position.x += cam_move_speed_ * delta_time; + needs_recalculation_ = 1u; } - if (SInput::IsKeyPressed(EKey::W)) + if (input::is_key_pressed(key::W)) { - mCamera.Position.y += mCamMoveSpeed * _DeltaTime; - mbNeedsRecalculation = 1u; + camera_.Position.y += cam_move_speed_ * delta_time; + needs_recalculation_ = 1u; } - if (SInput::IsKeyPressed(EKey::S)) + if (input::is_key_pressed(key::S)) { - mCamera.Position.y -= mCamMoveSpeed * _DeltaTime; - mbNeedsRecalculation = 1u; + camera_.Position.y -= cam_move_speed_ * delta_time; + needs_recalculation_ = 1u; } - if(mbCanRotate) { - if (SInput::IsKeyPressed(EKey::Q)) + if(can_rotate_) { + if (input::is_key_pressed(key::Q)) { - mCamera.Rotation += mCamRotSpeed * _DeltaTime; - mbNeedsRecalculation = 1u; + camera_.Rotation += cam_rot_speed_ * delta_time; + needs_recalculation_ = 1u; } - if (SInput::IsKeyPressed(EKey::E)) + if (input::is_key_pressed(key::E)) { - mCamera.Rotation -= mCamRotSpeed * _DeltaTime; - mbNeedsRecalculation = 1u; + camera_.Rotation -= cam_rot_speed_ * delta_time; + needs_recalculation_ = 1u; } } - mCamMoveSpeed = mZoomLevel; + cam_move_speed_ = zoom_level_; - if (mbNeedsRecalculation) + if (needs_recalculation_) { - mCamera.RecalculateViewProjectionMatrix(); + camera_.RecalculateViewProjectionMatrix(); } } - void COrthographicCameraController::OnEvent(CEvent& _Event) + void orthographic_camera_controller::on_event(event& event) { ARC_PROFILE_FUNCTION(); - CEventDispatcher dispatcher(_Event); - dispatcher.Dispatch(BIND_FN(&COrthographicCameraController::OnMouseScrolledEvent)); - dispatcher.Dispatch(BIND_FN(&COrthographicCameraController::OnWindowResized)); + event_dispatcher dispatcher(event); + dispatcher.Dispatch(BIND_FN(&orthographic_camera_controller::OnMouseScrolledEvent)); + dispatcher.Dispatch(BIND_FN(&orthographic_camera_controller::OnWindowResized)); } - void COrthographicCameraController::OnResize(float width, float height) + void orthographic_camera_controller::OnResize(float width, float height) { - mAspectRatio = width / height; + aspect_ratio_ = width / height; CalculateView(); } - void COrthographicCameraController::CalculateView() + void orthographic_camera_controller::CalculateView() { - mCamera.SetProjection(-mAspectRatio * mZoomLevel, mAspectRatio * mZoomLevel, -mZoomLevel, mZoomLevel); + camera_.set_projection(-aspect_ratio_ * zoom_level_, aspect_ratio_ * zoom_level_, -zoom_level_, zoom_level_); } - bool COrthographicCameraController::OnMouseScrolledEvent(CMouseScrolledEvent& _Event) + bool orthographic_camera_controller::OnMouseScrolledEvent(mouse_scrolled_event& event) { ARC_PROFILE_FUNCTION(); - mZoomLevel -= _Event.GetYOffset() * 0.25f; - mZoomLevel = std::max(mZoomLevel, 0.25f); + zoom_level_ -= event.get_y_offset() * 0.25f; + zoom_level_ = std::max(zoom_level_, 0.25f); CalculateView(); return false; } - bool COrthographicCameraController::OnWindowResized(CWindowResizeEvent& _Event) + bool orthographic_camera_controller::OnWindowResized(window_resize_event& event) { ARC_PROFILE_FUNCTION(); - OnResize((float)_Event.GetX(), (float)_Event.GetY()); + OnResize((float)event.get_x(), (float)event.get_y()); return false; } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/OrthographicCameraController.h b/ARC-Engine/src/ARC/Renderer/OrthographicCameraController.h index 3d83d27dd5..163e9e96a5 100644 --- a/ARC-Engine/src/ARC/Renderer/OrthographicCameraController.h +++ b/ARC-Engine/src/ARC/Renderer/OrthographicCameraController.h @@ -2,41 +2,41 @@ #include "ARC/Renderer/OrthographicCamera.h" #include "ARC/Objects/Object.h" -namespace ARC { class CMouseScrolledEvent; } -namespace ARC { class CWindowResizeEvent; } -namespace ARC { class CEvent; } +namespace arc { class mouse_scrolled_event; } +namespace arc { class window_resize_event; } +namespace arc { class event; } -namespace ARC { - class COrthographicCameraController : public CObject +namespace arc { + class orthographic_camera_controller : public object { public: - COrthographicCameraController(float _AspectRatio, bool _bCanRotate); + orthographic_camera_controller(float aspect_ratio, bool _bCanRotate); - void OnUpdate(float _DeltaTime); - void OnEvent(CEvent& _Event); + void on_update(float delta_time); + void on_event(event& event); void OnResize(float width, float height); - COrthographicCamera& GetCamera() { return mCamera; } - const COrthographicCamera& GetCamera() const { return mCamera; } - inline float GetZoomLevel() const { return mZoomLevel; } - inline void SetZoomLevel(float _val) { - mZoomLevel = _val; + orthographic_camera& get_camera() { return camera_; } + const orthographic_camera& get_camera() const { return camera_; } + inline float get_zoom_level() const { return zoom_level_; } + inline void set_zoom_level(float _val) { + zoom_level_ = _val; CalculateView(); } private: void CalculateView(); - bool OnMouseScrolledEvent(CMouseScrolledEvent& _Event); - bool OnWindowResized(CWindowResizeEvent& _Event); + bool OnMouseScrolledEvent(mouse_scrolled_event& event); + bool OnWindowResized(window_resize_event& event); private: - uint8_t mbCanRotate : 1; - uint8_t mbNeedsRecalculation : 1; + uint8_t can_rotate_ : 1; + uint8_t needs_recalculation_ : 1; - float mCamMoveSpeed = 10.f; - float mCamRotSpeed = 180.f; + float cam_move_speed_ = 10.f; + float cam_rot_speed_ = 180.f; - float mAspectRatio; - float mZoomLevel = 1; - COrthographicCamera mCamera; + float aspect_ratio_; + float zoom_level_ = 1; + orthographic_camera camera_; }; } diff --git a/ARC-Engine/src/ARC/Renderer/ParticleModifier2D.h b/ARC-Engine/src/ARC/Renderer/ParticleModifier2D.h index 65772c783d..a2eadf0f01 100644 --- a/ARC-Engine/src/ARC/Renderer/ParticleModifier2D.h +++ b/ARC-Engine/src/ARC/Renderer/ParticleModifier2D.h @@ -1,88 +1,88 @@ #pragma once #include "../Helpers/Random.h" -namespace ARC { class CParticle2D; } +namespace arc { class particle_2d; } -namespace ARC { - class CParticleModifier2D { +namespace arc { + class particle_modifier_2d { public: - virtual void ApplyModifier(CParticle2D& _Particle) = 0; - virtual void ApplyInitialModifier(CParticle2D& _Particle) { - ApplyModifier(_Particle); + virtual void ApplyModifier(particle_2d& particle) = 0; + virtual void ApplyInitialModifier(particle_2d& particle) { + ApplyModifier(particle); }; }; template - class CParticleVariationModifier2D : public CParticleModifier2D { + class particle_variation_modifier_2d : public particle_modifier_2d { public: - CParticleVariationModifier2D(T CParticle2D::* _MemberProperty, const T _Variation) : MemberProperty(_MemberProperty), Variation(_Variation) {}; - T CParticle2D::* MemberProperty; + particle_variation_modifier_2d(T particle_2d::* member_property, const T variation) : MemberProperty(member_property), Variation(variation) {}; + T particle_2d::* MemberProperty; T Variation; - virtual inline void ApplyModifier(CParticle2D& _Particle) override; + virtual inline void ApplyModifier(particle_2d& particle) override; }; - template - class CParticleLifetimeModifier2D : public CParticleModifier2D { + template + class particle_lifetime_modifier_2d : public particle_modifier_2d { public: - CParticleLifetimeModifier2D(T CParticle2D::* _MemberProperty, const T _End) : MemberProperty(_MemberProperty), EndVal(_End) {}; - T CParticle2D::* MemberProperty; + particle_lifetime_modifier_2d(T particle_2d::* member_property, const T end) : MemberProperty(member_property), EndVal(end) {}; + T particle_2d::* MemberProperty; T InitialVal; T EndVal; float Scaling; - virtual inline void ApplyModifier(CParticle2D& _Particle) override; - virtual inline void ApplyInitialModifier(CParticle2D& _Particle) override; + virtual inline void ApplyModifier(particle_2d& particle) override; + virtual inline void ApplyInitialModifier(particle_2d& particle) override; }; template - void CParticleVariationModifier2D::ApplyModifier(CParticle2D& _Particle) + void particle_variation_modifier_2d::ApplyModifier(particle_2d& particle) { - _Particle.*MemberProperty += (SRandom::Float() - 0.5f) * Variation; + particle.*MemberProperty += (random::Float() - 0.5f) * Variation; } template<> - void CParticleVariationModifier2D::ApplyModifier(CParticle2D& _Particle) + void particle_variation_modifier_2d::ApplyModifier(particle_2d& particle) { - _Particle.*MemberProperty += (SRandom::Float() - 0.5f) * Variation; + particle.*MemberProperty += (random::Float() - 0.5f) * Variation; } template<> - void CParticleVariationModifier2D::ApplyModifier(CParticle2D& _Particle) + void particle_variation_modifier_2d::ApplyModifier(particle_2d& particle) { - (_Particle.*MemberProperty).x += (SRandom::Float() - 0.5f) * Variation.x; - (_Particle.*MemberProperty).y += (SRandom::Float() - 0.5f) * Variation.y; + (particle.*MemberProperty).x += (random::Float() - 0.5f) * Variation.x; + (particle.*MemberProperty).y += (random::Float() - 0.5f) * Variation.y; } template<> - void CParticleVariationModifier2D::ApplyModifier(CParticle2D& _Particle) + void particle_variation_modifier_2d::ApplyModifier(particle_2d& particle) { - (_Particle.*MemberProperty).x += (SRandom::Float() - 0.5f) * Variation.x; - (_Particle.*MemberProperty).y += (SRandom::Float() - 0.5f) * Variation.y; - (_Particle.*MemberProperty).z += (SRandom::Float() - 0.5f) * Variation.z; + (particle.*MemberProperty).x += (random::Float() - 0.5f) * Variation.x; + (particle.*MemberProperty).y += (random::Float() - 0.5f) * Variation.y; + (particle.*MemberProperty).z += (random::Float() - 0.5f) * Variation.z; } template<> - void CParticleVariationModifier2D::ApplyModifier(CParticle2D& _Particle) + void particle_variation_modifier_2d::ApplyModifier(particle_2d& particle) { - (_Particle.*MemberProperty).x += (SRandom::Float() - 0.5f) * Variation.x; - (_Particle.*MemberProperty).y += (SRandom::Float() - 0.5f) * Variation.y; - (_Particle.*MemberProperty).z += (SRandom::Float() - 0.5f) * Variation.z; - (_Particle.*MemberProperty).w += (SRandom::Float() - 0.5f) * Variation.w; + (particle.*MemberProperty).x += (random::Float() - 0.5f) * Variation.x; + (particle.*MemberProperty).y += (random::Float() - 0.5f) * Variation.y; + (particle.*MemberProperty).z += (random::Float() - 0.5f) * Variation.z; + (particle.*MemberProperty).w += (random::Float() - 0.5f) * Variation.w; } template<> - void CParticleVariationModifier2D::ApplyModifier(CParticle2D& _Particle) + void particle_variation_modifier_2d::ApplyModifier(particle_2d& particle) { - (_Particle.*MemberProperty).x += (SRandom::Float() - 0.5f) * Variation.x; - (_Particle.*MemberProperty).y += (SRandom::Float() - 0.5f) * Variation.y; - (_Particle.*MemberProperty).z += (SRandom::Float() - 0.5f) * Variation.z; - (_Particle.*MemberProperty).w += (SRandom::Float() - 0.5f) * Variation.w; + (particle.*MemberProperty).x += (random::Float() - 0.5f) * Variation.x; + (particle.*MemberProperty).y += (random::Float() - 0.5f) * Variation.y; + (particle.*MemberProperty).z += (random::Float() - 0.5f) * Variation.z; + (particle.*MemberProperty).w += (random::Float() - 0.5f) * Variation.w; } - template - void CParticleLifetimeModifier2D::ApplyModifier(CParticle2D& _Particle) + template + void particle_lifetime_modifier_2d::ApplyModifier(particle_2d& particle) { - (_Particle.*MemberProperty) = SMath::InterpF(InitialVal, EndVal, _Particle.Life/Scaling); + (particle.*MemberProperty) = math::InterpF(InitialVal, EndVal, particle.Life/Scaling); } - template - void CParticleLifetimeModifier2D::ApplyInitialModifier(CParticle2D& _Particle) + template + void particle_lifetime_modifier_2d::ApplyInitialModifier(particle_2d& particle) { - InitialVal = (_Particle.*MemberProperty); - Scaling = _Particle.Life; - ApplyModifier(_Particle); + InitialVal = (particle.*MemberProperty); + Scaling = particle.Life; + ApplyModifier(particle); } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/ParticleSystem2D.cpp b/ARC-Engine/src/ARC/Renderer/ParticleSystem2D.cpp index 1609ea37d0..19d97e5a46 100644 --- a/ARC-Engine/src/ARC/Renderer/ParticleSystem2D.cpp +++ b/ARC-Engine/src/ARC/Renderer/ParticleSystem2D.cpp @@ -3,36 +3,36 @@ #include "ARC/Renderer/ParticleModifier2D.h" #include "ARC/Objects/Primitive2D.h" -namespace ARC { - CParticleSystem2D::CParticleSystem2D(uint32_t _PoolSize) +namespace arc { + particle_system_2d::particle_system_2d(uint32_t pool_size) { - mParticlePool.resize(_PoolSize); + particle_pool_.resize(pool_size); - mPoolIndex = _PoolSize-1; + pool_index_ = pool_size-1; } - CParticleSystem2D::~CParticleSystem2D() + particle_system_2d::~particle_system_2d() { - mModifiers.clear(); + modifiers_.clear(); } - void CParticleSystem2D::Emit() + void particle_system_2d::Emit() { - CParticle2D& particle = mParticlePool[mPoolIndex]; + particle_2d& particle = particle_pool_[pool_index_]; particle = Defaults; particle.bIsActive = true; particle.bInitial = true; - for (auto& i : mModifiers[EVariationApplicationTime::OnEmit]) + for (auto& i : modifiers_[variation_application_time::OnEmit]) { i->ApplyModifier(particle); } - mPoolIndex = --mPoolIndex % mParticlePool.size(); + pool_index_ = --pool_index_ % particle_pool_.size(); } - void CParticleSystem2D::OnUpdate(float _DeltaTime) + void particle_system_2d::on_update(float delta_time) { - for (auto& particle : mParticlePool) + for (auto& particle : particle_pool_) { if (!particle.bIsActive) continue; @@ -45,7 +45,7 @@ namespace ARC { if (particle.bInitial) { - for (auto& i : mModifiers[EVariationApplicationTime::OnUpdate]) + for (auto& i : modifiers_[variation_application_time::on_update]) { i->ApplyInitialModifier(particle); } @@ -53,35 +53,35 @@ namespace ARC { } else { - for (auto& i : mModifiers[EVariationApplicationTime::OnUpdate]) + for (auto& i : modifiers_[variation_application_time::on_update]) { i->ApplyModifier(particle); } } - particle.Location += particle.Velocity * _DeltaTime; - particle.Life -= _DeltaTime; + particle.Location += particle.Velocity * delta_time; + particle.Life -= delta_time; } } - void CParticleSystem2D::OnRender() + void particle_system_2d::OnRender() { - for (auto& particle : mParticlePool) + for (auto& particle : particle_pool_) { if (!particle.bIsActive) continue; - CPrimitive2D Quad; + primitive_2d Quad; Quad.Transform.Location = particle.Location; Quad.Transform.Rotation = particle.Rotation; Quad.Transform.Scale = particle.Scale; Quad.Color = particle.Color; Quad.Texture = particle.Texture; Quad.TextureScaling = { 1.f, 1.f }; - Quad.Transform.Rotation = SMath::Radians(particle.Rotation); + Quad.Transform.Rotation = math::Radians(particle.Rotation); - SRenderer2D::DrawQuad(Quad); + renderer_2d::draw_quad(Quad); } } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/ParticleSystem2D.h b/ARC-Engine/src/ARC/Renderer/ParticleSystem2D.h index 575fb7eecb..5f1884aecc 100644 --- a/ARC-Engine/src/ARC/Renderer/ParticleSystem2D.h +++ b/ARC-Engine/src/ARC/Renderer/ParticleSystem2D.h @@ -7,52 +7,52 @@ #include #include -namespace ARC { class CParticleModifier2D; } -namespace ARC { class CParticle2D; } +namespace arc { class particle_modifier_2d; } +namespace arc { class particle_2d; } -namespace ARC { +namespace arc { // @todo - enum EVariationApplicationType : uint8_t { + enum variation_application_type : uint8_t { VariationPlus, VariationMinus, VariationHalfPlusHalfMinus, VariationPlusMinus }; - enum class EVariationApplicationTime : uint8_t { + enum class variation_application_time : uint8_t { OnEmit, - OnUpdate + on_update }; - class CParticle2D { + class particle_2d { public: - CParticle2D() : bIsActive(1u) {} - FVec3 Location = {0.f, 0.f, 0.f}; + particle_2d() : bIsActive(1u) {} + vec3 Location = {0.f, 0.f, 0.f}; float Rotation = 0.f; - FVec2 Scale = {1.f, 1.f}; - FColor4 Color = FColor4::White(); - TRef Texture = nullptr; - FVec3 Velocity = {0.f, 0.f, 0.f}; + vec2 Scale = {1.f, 1.f}; + color4 Color = color4::White(); + ref Texture = nullptr; + vec3 Velocity = {0.f, 0.f, 0.f}; float Life = 1.f; uint8_t bIsActive : 1; uint8_t bInitial : 1; }; - class CParticleSystem2D + class particle_system_2d { public: - CParticleSystem2D(uint32_t _PoolSize = 1000); - ~CParticleSystem2D(); + particle_system_2d(uint32_t pool_size = 1000); + ~particle_system_2d(); void Emit(); - void OnUpdate(float _DeltaTime); + void on_update(float delta_time); void OnRender(); - void AddParticleModifier(EVariationApplicationTime VAP, CParticleModifier2D* Variation) { mModifiers[VAP].push_back(Variation); }; + void AddParticleModifier(variation_application_time VAP, particle_modifier_2d* Variation) { modifiers_[VAP].push_back(Variation); }; - CParticle2D Defaults; + particle_2d Defaults; private: - std::unordered_map> mModifiers; - std::vector mParticlePool; - uint32_t mPoolIndex; + std::unordered_map> modifiers_; + std::vector particle_pool_; + uint32_t pool_index_; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/RenderCommand.cpp b/ARC-Engine/src/ARC/Renderer/RenderCommand.cpp index c8a8964989..e182e13df8 100644 --- a/ARC-Engine/src/ARC/Renderer/RenderCommand.cpp +++ b/ARC-Engine/src/ARC/Renderer/RenderCommand.cpp @@ -3,6 +3,6 @@ #include "Platform/OpenGl/OpenGLRendererAPI.h" -namespace ARC { - CRendererAPI* CRenderCommand::sRendererAPI = new COpenGLRendererAPI; +namespace arc { + renderer_api* render_command::sRendererAPI = new opengl_renderer_api; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/RenderCommand.h b/ARC-Engine/src/ARC/Renderer/RenderCommand.h index 728354b5b7..8dccffea3a 100644 --- a/ARC-Engine/src/ARC/Renderer/RenderCommand.h +++ b/ARC-Engine/src/ARC/Renderer/RenderCommand.h @@ -3,36 +3,36 @@ #include "RendererAPI.h" #include "ARC\Types\Pointer.h" -namespace ARC { - class CRenderCommand +namespace arc { + class render_command { public: - inline static void Init() { - sRendererAPI->Init(); + inline static void init() { + sRendererAPI->init(); }; - inline static void SetViewport(const TVec2 _BottemLeftCoord, const TVec2 _Dimentions) { - sRendererAPI->SetViewport(_BottemLeftCoord, _Dimentions); + inline static void set_viewport(const vec2 bottem_left_coord, const vec2 dimentions) { + sRendererAPI->set_viewport(bottem_left_coord, dimentions); } - inline static void SetClearColour(const FColor4 _Colour) { - sRendererAPI->SetClearColour(_Colour); + inline static void set_clear_colour(const color4 colour) { + sRendererAPI->set_clear_colour(colour); }; - inline static void Clear() { - sRendererAPI->Clear(); + inline static void clear() { + sRendererAPI->clear(); }; - // Draw All if _Count = 0 - inline static void DrawIndexed(const TRef& _VertexArray, uint32_t _Count = 0) { - sRendererAPI->DrawIndexed(_VertexArray, _Count); + // Draw All if count = 0 + inline static void draw_indexed(const ref& vertex_array, uint32_t count = 0) { + sRendererAPI->draw_indexed(vertex_array, count); } - inline static void DrawLine(const TRef& _VertexArray, uint32_t _Count = 0) { - sRendererAPI->DrawLine(_VertexArray, _Count); + inline static void draw_line(const ref& vertex_array, uint32_t count = 0) { + sRendererAPI->draw_line(vertex_array, count); } - inline static void SetLineThickness(float pThickness) { - sRendererAPI->SetLineThickness(pThickness); + inline static void set_line_thickness(float pThickness) { + sRendererAPI->set_line_thickness(pThickness); } private: - static CRendererAPI* sRendererAPI; + static renderer_api* sRendererAPI; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/Renderer.cpp b/ARC-Engine/src/ARC/Renderer/Renderer.cpp index b18182fbf9..39274eba8a 100644 --- a/ARC-Engine/src/ARC/Renderer/Renderer.cpp +++ b/ARC-Engine/src/ARC/Renderer/Renderer.cpp @@ -8,40 +8,40 @@ #include "ARC/Types/Vector.h" #include "Renderer2D.h" -namespace ARC { - CRenderer::SSceneData* CRenderer::mSceneData = new CRenderer::SSceneData; +namespace arc { + renderer::scene_data* renderer::scene_data_ = new renderer::scene_data; - void CRenderer::Init() + void renderer::init() { ARC_PROFILE_FUNCTION(); - CRenderCommand::Init(); - SRenderer2D::Init(); + render_command::init(); + renderer_2d::init(); } - void CRenderer::OnWindowResize(TVec2 _Dimentions) + void renderer::on_window_resize(vec2 dimentions) { - CRenderCommand::SetViewport(TVec2::ZeroVector(), _Dimentions); + render_command::set_viewport(vec2::ZeroVector(), dimentions); } - void CRenderer::BeginScene(COrthographicCamera& _Cam) + void renderer::begin_scene(orthographic_camera& cam) { // Submit View Projection Matrix - mSceneData->ViewProjectionMatrix = _Cam.GetViewProjectionMatrix(); + scene_data_->ViewProjectionMatrix = cam.get_view_projection_matrix(); } - void CRenderer::EndScene() + void renderer::end_scene() { } - void CRenderer::Submit(const TRef& _Shader, const TRef& _VertexArray, const FGLMMat4& _Transform) + void renderer::Submit(const ref& shader, const ref& vertex_array, const mat4& transform) { - _Shader->Bind(); - _Shader->Set("u_ViewProjection", mSceneData->ViewProjectionMatrix); - _Shader->Set("u_Transform", _Transform); - _VertexArray->Bind(); - CRenderCommand::DrawIndexed(_VertexArray); + shader->bind(); + shader->Set("u_ViewProjection", scene_data_->ViewProjectionMatrix); + shader->Set("u_Transform", transform); + vertex_array->bind(); + render_command::draw_indexed(vertex_array); } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/Renderer.h b/ARC-Engine/src/ARC/Renderer/Renderer.h index ee96b35a61..6868cb446e 100644 --- a/ARC-Engine/src/ARC/Renderer/Renderer.h +++ b/ARC-Engine/src/ARC/Renderer/Renderer.h @@ -4,30 +4,30 @@ #include "ARC\Wrappers\Glm.h" -namespace ARC { class CShader; } -namespace ARC { class CVertexArray; } -namespace ARC { class COrthographicCamera; } +namespace arc { class shader; } +namespace arc { class vertex_array; } +namespace arc { class orthographic_camera; } -namespace ARC { - class CRenderer { +namespace arc { + class renderer { public: - static void Init(); - static void OnWindowResize(TVec2 _Dimentions); - static void BeginScene(COrthographicCamera& _Cam); - static void EndScene(); + static void init(); + static void on_window_resize(vec2 dimentions); + static void begin_scene(orthographic_camera& cam); + static void end_scene(); - static FGLMMat4 GetViewProjectionMatrix() { return mSceneData->ViewProjectionMatrix; } + static mat4 get_view_projection_matrix() { return scene_data_->ViewProjectionMatrix; } - static void Submit(const TRef& _Shader, const TRef& _VertexArray, const FGLMMat4& _Transform = FGLMMat4(1.f)); + static void Submit(const ref& shader, const ref& vertex_array, const mat4& transform = mat4(1.f)); - inline static CRendererAPI::ERendererAPI GetCurrentAPI() { return CRendererAPI::GetAPI(); } + inline static renderer_api::renderer_api get_current_api() { return renderer_api::get_api(); } private: - struct SSceneData + struct scene_data { - FGLMMat4 ViewProjectionMatrix; + mat4 ViewProjectionMatrix; }; - static SSceneData* mSceneData; + static scene_data* scene_data_; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/Renderer2D.cpp b/ARC-Engine/src/ARC/Renderer/Renderer2D.cpp index d94a3dbc6d..af2d3e4182 100644 --- a/ARC-Engine/src/ARC/Renderer/Renderer2D.cpp +++ b/ARC-Engine/src/ARC/Renderer/Renderer2D.cpp @@ -18,118 +18,118 @@ #define GLM_ENABLE_EXPERIMENTAL #include #include "ARC/Scene/Entity.h" -namespace ARC { - struct SQuadVertex +namespace arc { + struct quad_vertex { - FGLMVec3 Position; - FGLMVec4 Color; - FGLMVec2 TexCoord; - FGLMVec2 TexScaling; + vec3 Position; + vec4 Color; + vec2 TexCoord; + vec2 TexScaling; int TexIndex; int EntityId; }; - struct SCircleVertex + struct circle_vertex { - FGLMVec3 WorldPosition; - FGLMVec3 LocalPosition; - FGLMVec4 Color; + vec3 WorldPosition; + vec3 LocalPosition; + vec4 Color; float Thickness; float Sharpness; int EntityId; }; - struct SLineVertex + struct line_vertex { - FGLMVec3 Position; - FGLMVec4 Color; + vec3 Position; + vec4 Color; int EntityId; }; struct SRenderer2DData { //@TODO : Load from ini file - static constexpr TUInt32 MaxQuads = 1000; - static constexpr TUInt32 MaxVertices = MaxQuads * 4; - static constexpr TUInt32 MaxIndices = MaxQuads * 6; - static constexpr TUInt32 MaxTextureSlots = 32; + static constexpr u32 MaxQuads = 1000; + static constexpr u32 MaxVertices = MaxQuads * 4; + static constexpr u32 MaxIndices = MaxQuads * 6; + static constexpr u32 MaxTextureSlots = 32; struct SQuadData { - TRef VertexArray; - TRef VertexBuffer; - TRef Shader; + ref VertexArray; + ref VertexBuffer; + ref Shader; - TUInt32 TranslucentIndexCount = 0; - SQuadVertex* TranslucentVertexBufferBase = nullptr; - SQuadVertex* TranslucentVertexBufferBasePtr = nullptr; + u32 TranslucentIndexCount = 0; + quad_vertex* TranslucentVertexBufferBase = nullptr; + quad_vertex* TranslucentVertexBufferBasePtr = nullptr; - TUInt32 OpaqueIndexCount = 0; - SQuadVertex* OpaqueVertexBufferBase = nullptr; - SQuadVertex* OpaqueVertexBufferBasePtr = nullptr; + u32 OpaqueIndexCount = 0; + quad_vertex* OpaqueVertexBufferBase = nullptr; + quad_vertex* OpaqueVertexBufferBasePtr = nullptr; - FGLMVec4 VertexPositions[4]; + vec4 VertexPositions[4]; } Quad; struct SCircleData { - TRef VertexArray; - TRef VertexBuffer; - TRef Shader; + ref VertexArray; + ref VertexBuffer; + ref Shader; - TUInt32 TranslucentIndexCount = 0; - SCircleVertex* TranslucentVertexBufferBase = nullptr; - SCircleVertex* TranslucentVertexBufferBasePtr = nullptr; + u32 TranslucentIndexCount = 0; + circle_vertex* TranslucentVertexBufferBase = nullptr; + circle_vertex* TranslucentVertexBufferBasePtr = nullptr; - FGLMVec4 VertexPositions[4]; + vec4 VertexPositions[4]; } Circle; struct SLineData { - TRef VertexArray; - TRef VertexBuffer; - TRef Shader; + ref VertexArray; + ref VertexBuffer; + ref Shader; float Thickness= 2; - TUInt32 IndexCount = 0; - SLineVertex* VertexBufferBase = nullptr; - SLineVertex* VertexBufferBasePtr = nullptr; + u32 IndexCount = 0; + line_vertex* VertexBufferBase = nullptr; + line_vertex* VertexBufferBasePtr = nullptr; } Line; - TRef WhiteTexture; - std::array, MaxTextureSlots> TextureSlots; - TUInt32 TextureSlotIndex = 1; + ref WhiteTexture; + std::array, MaxTextureSlots> TextureSlots; + u32 TextureSlotIndex = 1; - FGLMMat4 CameraTransform; + mat4 CameraTransform; - SRenderer2D::SStatistics Statistics; + renderer_2d::statistics Statistics; }; static SRenderer2DData sData; - void SRenderer2D::Init() + void renderer_2d::init() { ARC_PROFILE_FUNCTION(); - sData.WhiteTexture = CTexture2D::Create(TVec2(1, 1)); - TUInt32 whiteTextureData = 0xffffffff; - sData.WhiteTexture->SetData(&whiteTextureData, sizeof(TUInt32)); + sData.WhiteTexture = texture_2d::create(vec2(1, 1)); + u32 whiteTextureData = 0xffffffff; + sData.WhiteTexture->set_data(&whiteTextureData, sizeof(u32)); int32_t samplers[sData.MaxTextureSlots]; for (int32_t i = 0; i < sData.MaxTextureSlots; i++) samplers[i] = i; //--------------------------------+[Code for Quad]+--------------------------------// - sData.Quad.VertexArray = CVertexArray::Create(); - sData.Quad.VertexBuffer = CVertexBuffer::Create(sData.MaxVertices * sizeof(SQuadVertex)); - sData.Quad.VertexBuffer->SetLayout({ - { EShaderDataType::Float3, "a_Position" }, - { EShaderDataType::Float4, "a_Color" }, - { EShaderDataType::Float2, "a_TexCoord" }, - { EShaderDataType::Float2, "a_TexScaling" }, - { EShaderDataType::Int, "a_TexIndex" }, - { EShaderDataType::Int, "a_EntityId" } + sData.Quad.VertexArray = vertex_array::create(); + sData.Quad.VertexBuffer = vertex_buffer::create(sData.MaxVertices * sizeof(quad_vertex)); + sData.Quad.VertexBuffer->set_layout({ + { shader_data_type::Float3, "a_Position" }, + { shader_data_type::Float4, "a_Color" }, + { shader_data_type::Float2, "a_TexCoord" }, + { shader_data_type::Float2, "a_TexScaling" }, + { shader_data_type::Int, "a_TexIndex" }, + { shader_data_type::Int, "a_EntityId" } }); - sData.Quad.VertexArray->AddVertexBuffer(sData.Quad.VertexBuffer); - sData.Quad.OpaqueVertexBufferBase = new SQuadVertex[sData.MaxVertices]; - sData.Quad.TranslucentVertexBufferBase = new SQuadVertex[sData.MaxVertices]; + sData.Quad.VertexArray->add_vertex_buffer(sData.Quad.VertexBuffer); + sData.Quad.OpaqueVertexBufferBase = new quad_vertex[sData.MaxVertices]; + sData.Quad.TranslucentVertexBufferBase = new quad_vertex[sData.MaxVertices]; - auto* quad_indices = new TUInt32[sData.MaxIndices]; + auto* quad_indices = new u32[sData.MaxIndices]; - TUInt32 offset = 0; - for (TUInt32 i = 0; i < sData.MaxIndices; i += 6) + u32 offset = 0; + for (u32 i = 0; i < sData.MaxIndices; i += 6) { quad_indices[i+ 0] = offset + 0; quad_indices[i+ 1] = offset + 1; @@ -141,15 +141,15 @@ namespace ARC { offset += 4; } - TRef quad_ib = CIndexBuffer::Create(quad_indices, sData.MaxIndices); - sData.Quad.VertexArray->SetIndexBuffer(quad_ib); + ref quad_ib = index_buffer::create(quad_indices, sData.MaxIndices); + sData.Quad.VertexArray->set_index_buffer(quad_ib); // @TODO make thread safe delete[] quad_indices; - sData.Quad.Shader = CShader::Create("assets/shaders/R2D_Quad.glsl"); - sData.Quad.Shader->Bind(); - sData.Quad.Shader->SetArray("u_Textures", samplers, sData.MaxTextureSlots); + sData.Quad.Shader = shader::create("assets/shaders/R2D_Quad.glsl"); + sData.Quad.Shader->bind(); + sData.Quad.Shader->set_array("u_Textures", samplers, sData.MaxTextureSlots); sData.TextureSlots[0] = sData.WhiteTexture; sData.Quad.VertexPositions[0] = { -0.5f, -0.5f, 0.0f, 1.0f}; @@ -158,22 +158,22 @@ namespace ARC { sData.Quad.VertexPositions[3] = { -0.5f, 0.5f, 0.0f, 1.0f}; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-[Code for Quad]-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //-------------------------------+[Code for Circle]+-------------------------------// - sData.Circle.VertexArray = CVertexArray::Create(); - sData.Circle.VertexBuffer = CVertexBuffer::Create(sData.MaxVertices * sizeof(SCircleVertex)); - sData.Circle.VertexBuffer->SetLayout({ - { EShaderDataType::Float3, "a_WorldPosition" }, - { EShaderDataType::Float3, "a_LocalPosition" }, - { EShaderDataType::Float4, "a_Color" }, - { EShaderDataType::Float, "a_Thickness" }, - { EShaderDataType::Float, "a_Sharpness" }, - { EShaderDataType::Int, "a_EntityId" } + sData.Circle.VertexArray = vertex_array::create(); + sData.Circle.VertexBuffer = vertex_buffer::create(sData.MaxVertices * sizeof(circle_vertex)); + sData.Circle.VertexBuffer->set_layout({ + { shader_data_type::Float3, "a_WorldPosition" }, + { shader_data_type::Float3, "a_LocalPosition" }, + { shader_data_type::Float4, "a_Color" }, + { shader_data_type::Float, "a_Thickness" }, + { shader_data_type::Float, "a_Sharpness" }, + { shader_data_type::Int, "a_EntityId" } }); - sData.Circle.VertexArray->AddVertexBuffer(sData.Circle.VertexBuffer); - sData.Circle.TranslucentVertexBufferBase = new SCircleVertex[sData.MaxVertices]; - sData.Circle.VertexArray->SetIndexBuffer(quad_ib); // reuse quad one as same + sData.Circle.VertexArray->add_vertex_buffer(sData.Circle.VertexBuffer); + sData.Circle.TranslucentVertexBufferBase = new circle_vertex[sData.MaxVertices]; + sData.Circle.VertexArray->set_index_buffer(quad_ib); // reuse quad one as same - sData.Circle.Shader = CShader::Create("assets/shaders/R2D_Circle.glsl"); - sData.Circle.Shader->Bind(); + sData.Circle.Shader = shader::create("assets/shaders/R2D_Circle.glsl"); + sData.Circle.Shader->bind(); sData.Circle.VertexPositions[0] = { -0.5f, -0.5f, 0.0f, 1.0f }; sData.Circle.VertexPositions[1] = { 0.5f, -0.5f, 0.0f, 1.0f }; @@ -181,33 +181,33 @@ namespace ARC { sData.Circle.VertexPositions[3] = { -0.5f, 0.5f, 0.0f, 1.0f }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-[Code for Circle]-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //--------------------------------+[Code for Line]+--------------------------------// - sData.Line.VertexArray = CVertexArray::Create(); - sData.Line.VertexBuffer = CVertexBuffer::Create(sData.MaxVertices * sizeof(SLineVertex)); - sData.Line.VertexBuffer->SetLayout({ - { EShaderDataType::Float3, "a_Position" }, - { EShaderDataType::Float4, "a_Color" }, - { EShaderDataType::Int, "a_EntityId" } + sData.Line.VertexArray = vertex_array::create(); + sData.Line.VertexBuffer = vertex_buffer::create(sData.MaxVertices * sizeof(line_vertex)); + sData.Line.VertexBuffer->set_layout({ + { shader_data_type::Float3, "a_Position" }, + { shader_data_type::Float4, "a_Color" }, + { shader_data_type::Int, "a_EntityId" } }); - sData.Line.VertexArray->AddVertexBuffer(sData.Line.VertexBuffer); - sData.Line.VertexBufferBase = new SLineVertex[sData.MaxVertices]; + sData.Line.VertexArray->add_vertex_buffer(sData.Line.VertexBuffer); + sData.Line.VertexBufferBase = new line_vertex[sData.MaxVertices]; - sData.Line.Shader = CShader::Create("assets/shaders/R2D_Line.glsl"); - sData.Line.Shader->Bind(); + sData.Line.Shader = shader::create("assets/shaders/R2D_Line.glsl"); + sData.Line.Shader->bind(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-[Code for Line]-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// } - void SRenderer2D::Shutdown() + void renderer_2d::shutdown() { } - void SRenderer2D::BeginScene(const COrthographicCamera& pCamera) + void renderer_2d::begin_scene(const orthographic_camera& pCamera) { - FGLMMat4 Trans = pCamera.GetViewProjectionMatrix(); + mat4 Trans = pCamera.get_view_projection_matrix(); - sData.Quad.Shader->Bind(); - sData.Quad.Shader->Set("u_ViewProjection", pCamera.GetViewProjectionMatrix()); + sData.Quad.Shader->bind(); + sData.Quad.Shader->Set("u_ViewProjection", pCamera.get_view_projection_matrix()); sData.Quad.TranslucentIndexCount = 0; sData.Quad.TranslucentVertexBufferBasePtr = sData.Quad.TranslucentVertexBufferBase; @@ -215,8 +215,8 @@ namespace ARC { sData.Quad.OpaqueIndexCount = 0; sData.Quad.OpaqueVertexBufferBasePtr = sData.Quad.OpaqueVertexBufferBase; - sData.Circle.Shader->Bind(); - sData.Circle.Shader->Set("u_ViewProjection", Trans); + sData.Circle.Shader->bind(); + sData.Circle.Shader->Set("u_ViewProjection", Trans); sData.Circle.TranslucentIndexCount = 0; sData.Circle.TranslucentVertexBufferBasePtr = sData.Circle.TranslucentVertexBufferBase; @@ -225,12 +225,12 @@ namespace ARC { sData.CameraTransform = Trans; } - void SRenderer2D::BeginScene(const CEditorCamera& pCamera) + void renderer_2d::begin_scene(const editor_camera& pCamera) { - FGLMMat4 Trans = pCamera.GetViewProjectionMatrix(); + mat4 Trans = pCamera.get_view_projection_matrix(); - sData.Quad.Shader->Bind(); - sData.Quad.Shader->Set("u_ViewProjection", Trans); + sData.Quad.Shader->bind(); + sData.Quad.Shader->Set("u_ViewProjection", Trans); sData.Quad.TranslucentIndexCount = 0; sData.Quad.TranslucentVertexBufferBasePtr = sData.Quad.TranslucentVertexBufferBase; @@ -238,28 +238,28 @@ namespace ARC { sData.Quad.OpaqueIndexCount = 0; sData.Quad.OpaqueVertexBufferBasePtr = sData.Quad.OpaqueVertexBufferBase; - sData.Circle.Shader->Bind(); - sData.Circle.Shader->Set("u_ViewProjection", Trans); + sData.Circle.Shader->bind(); + sData.Circle.Shader->Set("u_ViewProjection", Trans); sData.Circle.TranslucentIndexCount = 0; sData.Circle.TranslucentVertexBufferBasePtr = sData.Circle.TranslucentVertexBufferBase; - sData.Line.Shader->Bind(); - sData.Line.Shader->Set("u_ViewProjection", Trans); + sData.Line.Shader->bind(); + sData.Line.Shader->Set("u_ViewProjection", Trans); sData.Line.IndexCount = 0; sData.Line.VertexBufferBasePtr = sData.Line.VertexBufferBase; sData.TextureSlotIndex = 1; - sData.CameraTransform = glm::translate(glm::mat4(1.0f), pCamera.GetPosition()) * glm::toMat4(pCamera.GetOrientation()); + sData.CameraTransform = glm::translate(glm::mat4(1.0f), pCamera.get_position()) * glm::toMat4(pCamera.get_orientation()); } - void SRenderer2D::BeginScene(const CCamera& pCamera, const FTransform2D& pTransform) + void renderer_2d::begin_scene(const camera& pCamera, const transform_2d& pTransform) { - FGLMMat4 Trans = pCamera.GetProjection() * glm::inverse(SHPR::Conv(pTransform)); + mat4 Trans = pCamera.get_projection() * glm::inverse(shpr::Conv(pTransform)); - sData.Quad.Shader->Bind(); - sData.Quad.Shader->Set("u_ViewProjection", Trans); + sData.Quad.Shader->bind(); + sData.Quad.Shader->Set("u_ViewProjection", Trans); sData.Quad.TranslucentIndexCount = 0; sData.Quad.TranslucentVertexBufferBasePtr = sData.Quad.TranslucentVertexBufferBase; @@ -267,145 +267,145 @@ namespace ARC { sData.Quad.OpaqueIndexCount = 0; sData.Quad.OpaqueVertexBufferBasePtr = sData.Quad.OpaqueVertexBufferBase; - sData.Circle.Shader->Bind(); - sData.Circle.Shader->Set("u_ViewProjection", Trans); + sData.Circle.Shader->bind(); + sData.Circle.Shader->Set("u_ViewProjection", Trans); sData.Circle.TranslucentIndexCount = 0; sData.Circle.TranslucentVertexBufferBasePtr = sData.Circle.TranslucentVertexBufferBase; - sData.Line.Shader->Bind(); - sData.Line.Shader->Set("u_ViewProjection", Trans); + sData.Line.Shader->bind(); + sData.Line.Shader->Set("u_ViewProjection", Trans); sData.Line.IndexCount = 0; sData.Line.VertexBufferBasePtr = sData.Line.VertexBufferBase; sData.TextureSlotIndex = 1; - sData.CameraTransform = SHPR::Conv(pTransform); + sData.CameraTransform = shpr::Conv(pTransform); } - constexpr void SRenderer2D::EndScene(TGeometery pG, TTransparencyType pT) + constexpr void renderer_2d::end_scene(geometry_type pG, transparency_type pT) { ARC_PROFILE_FUNCTION(); - if (pG & EGeometery::Quad) + if (pG & geometry_type::Quad) { - if (pT & ETransparencyType::Opaque) + if (pT & transparency_type::Opaque) { if (sData.Quad.OpaqueIndexCount) { - if (auto data_size = TUInt32((TUInt8*)sData.Quad.OpaqueVertexBufferBasePtr - (TUInt8*)sData.Quad.OpaqueVertexBufferBase)) { - sData.Quad.VertexBuffer->SetData(sData.Quad.OpaqueVertexBufferBase, data_size); - Flush(EGeometery::Quad, ETransparencyType::Opaque); + if (auto data_size = u32((u8*)sData.Quad.OpaqueVertexBufferBasePtr - (u8*)sData.Quad.OpaqueVertexBufferBase)) { + sData.Quad.VertexBuffer->set_data(sData.Quad.OpaqueVertexBufferBase, data_size); + flush(geometry_type::Quad, transparency_type::Opaque); } } } - if (pT & ETransparencyType::Translucent) + if (pT & transparency_type::Translucent) { if (sData.Quad.TranslucentIndexCount) { - if (auto data_size = TUInt32((TUInt8*)sData.Quad.TranslucentVertexBufferBasePtr - (TUInt8*)sData.Quad.TranslucentVertexBufferBase)) { - struct Block { SQuadVertex n_[4]; }; + if (auto data_size = u32((u8*)sData.Quad.TranslucentVertexBufferBasePtr - (u8*)sData.Quad.TranslucentVertexBufferBase)) { + struct Block { quad_vertex n_[4]; }; std::sort((Block*)sData.Quad.TranslucentVertexBufferBase, (Block*)sData.Quad.TranslucentVertexBufferBasePtr, [&](const Block& p1, const Block& p2) -> bool { - FGLMVec3 tmp = FGLMVec3(sData.CameraTransform[3]) - p1.n_[0].Position; - FGLMVec3 tmp2 = FGLMVec3(sData.CameraTransform[3]) - p2.n_[0].Position; + vec3 tmp = vec3(sData.CameraTransform[3]) - p1.n_[0].Position; + vec3 tmp2 = vec3(sData.CameraTransform[3]) - p2.n_[0].Position; return p1.n_[0].Position[2] < p2.n_[0].Position[2]; }); Block* _ = (Block*)sData.Quad.TranslucentVertexBufferBase; - sData.Quad.VertexBuffer->SetData(sData.Quad.TranslucentVertexBufferBase, data_size); - Flush(EGeometery::Quad, ETransparencyType::Translucent); + sData.Quad.VertexBuffer->set_data(sData.Quad.TranslucentVertexBufferBase, data_size); + flush(geometry_type::Quad, transparency_type::Translucent); } } } } - if (pG & EGeometery::Circle) + if (pG & geometry_type::Circle) { if (sData.Circle.TranslucentIndexCount) { - if (auto data_size = TUInt32((TUInt8*)sData.Circle.TranslucentVertexBufferBasePtr - (TUInt8*)sData.Circle.TranslucentVertexBufferBase)) + if (auto data_size = u32((u8*)sData.Circle.TranslucentVertexBufferBasePtr - (u8*)sData.Circle.TranslucentVertexBufferBase)) { - struct Block { SCircleVertex n_[4]; }; + struct Block { circle_vertex n_[4]; }; // @ BUG ZINDEXING NOT WORKING FOR QUAD VS CIRCLE if translucent std::sort((Block*)sData.Circle.TranslucentVertexBufferBase, (Block*)sData.Circle.TranslucentVertexBufferBasePtr, [&](const Block& p1, const Block& p2) -> bool { - FGLMVec3 tmp = FGLMVec3(sData.CameraTransform[3]) - p1.n_[0].WorldPosition; - FGLMVec3 tmp2 = FGLMVec3(sData.CameraTransform[3]) - p2.n_[0].WorldPosition; + vec3 tmp = vec3(sData.CameraTransform[3]) - p1.n_[0].WorldPosition; + vec3 tmp2 = vec3(sData.CameraTransform[3]) - p2.n_[0].WorldPosition; return p1.n_[0].WorldPosition[2] < p2.n_[0].WorldPosition[2]; }); Block* _ = (Block*)sData.Circle.TranslucentVertexBufferBase; - sData.Circle.VertexBuffer->SetData(sData.Circle.TranslucentVertexBufferBase, data_size); - Flush(EGeometery::Circle, ETransparencyType::Translucent); + sData.Circle.VertexBuffer->set_data(sData.Circle.TranslucentVertexBufferBase, data_size); + flush(geometry_type::Circle, transparency_type::Translucent); } } } - if (pG & EGeometery::Line) + if (pG & geometry_type::Line) { - if (auto data_size = TUInt32((TUInt8*)sData.Line.VertexBufferBasePtr - (TUInt8*)sData.Line.VertexBufferBase)) + if (auto data_size = u32((u8*)sData.Line.VertexBufferBasePtr - (u8*)sData.Line.VertexBufferBase)) { - sData.Line.VertexBuffer->SetData(sData.Line.VertexBufferBase, data_size); - Flush(EGeometery::Line, ETransparencyType::Translucent); + sData.Line.VertexBuffer->set_data(sData.Line.VertexBufferBase, data_size); + flush(geometry_type::Line, transparency_type::Translucent); } } } - constexpr void SRenderer2D::Flush(TGeometery pG, TTransparencyType pT) + constexpr void renderer_2d::flush(geometry_type pG, transparency_type pT) { - if (pG & EGeometery::Quad) + if (pG & geometry_type::Quad) { - for (TUInt32 i = 0; i < sData.TextureSlotIndex; i++) - sData.TextureSlots[i]->Bind(i); + for (u32 i = 0; i < sData.TextureSlotIndex; i++) + sData.TextureSlots[i]->bind(i); - if (pT & ETransparencyType::Opaque) + if (pT & transparency_type::Opaque) { if (sData.Quad.OpaqueIndexCount) { ++sData.Statistics.DrawCalls; - sData.Quad.Shader->Bind(); - CRenderCommand::DrawIndexed(sData.Quad.VertexArray, sData.Quad.OpaqueIndexCount); + sData.Quad.Shader->bind(); + render_command::draw_indexed(sData.Quad.VertexArray, sData.Quad.OpaqueIndexCount); } } - if (pT & ETransparencyType::Translucent) + if (pT & transparency_type::Translucent) { if (sData.Quad.TranslucentIndexCount) { ++sData.Statistics.DrawCalls; - sData.Quad.Shader->Bind(); - CRenderCommand::DrawIndexed(sData.Quad.VertexArray, sData.Quad.TranslucentIndexCount); + sData.Quad.Shader->bind(); + render_command::draw_indexed(sData.Quad.VertexArray, sData.Quad.TranslucentIndexCount); } } } - if (pG & EGeometery::Circle) + if (pG & geometry_type::Circle) { if (sData.Circle.TranslucentIndexCount) { ++sData.Statistics.DrawCalls; - sData.Circle.Shader->Bind(); - CRenderCommand::DrawIndexed(sData.Circle.VertexArray, sData.Circle.TranslucentIndexCount); + sData.Circle.Shader->bind(); + render_command::draw_indexed(sData.Circle.VertexArray, sData.Circle.TranslucentIndexCount); } } - if (pG & EGeometery::Line) + if (pG & geometry_type::Line) { if (sData.Line.IndexCount) { ++sData.Statistics.DrawCalls; - sData.Line.Shader->Bind(); - CRenderCommand::SetLineThickness(sData.Line.Thickness); - CRenderCommand::DrawLine(sData.Line.VertexArray, sData.Line.IndexCount); + sData.Line.Shader->bind(); + render_command::set_line_thickness(sData.Line.Thickness); + render_command::draw_line(sData.Line.VertexArray, sData.Line.IndexCount); } } } - void SRenderer2D::DrawQuad(const FVec3& pPosition, const float pRotation, const FVec2& pSize, const TTransparencyType pTransparencyLevel, const FColor4& pColor, const TRef& pTex, const FVec2& pTextureScaling, const int& pId) + void renderer_2d::draw_quad(const vec3& pPosition, const float pRotation, const vec2& pSize, const transparency_type pTransparencyLevel, const color4& pColor, const ref& pTex, const vec2& pTextureScaling, const int& pId) { ARC_PROFILE_FUNCTION(); if (sData.Quad.OpaqueIndexCount >= SRenderer2DData::MaxIndices) - FlushAndReset(EGeometery::Quad, ETransparencyType::Opaque); + flush_and_reset(geometry_type::Quad, transparency_type::Opaque); if (sData.Quad.TranslucentIndexCount >= SRenderer2DData::MaxIndices) - FlushAndReset(EGeometery::Quad, ETransparencyType::Translucent); + flush_and_reset(geometry_type::Quad, transparency_type::Translucent); - TUInt32 textureIndex = 0; + u32 textureIndex = 0; if (pTex != nullptr) { @@ -425,32 +425,32 @@ namespace ARC { } } - FGLMMat4 transform = - glm::translate(FGLMMat4(1.0f), FGLMVec3(pPosition.x, pPosition.y, pPosition.z)) * - glm::rotate(FGLMMat4(1.0f), pRotation, FGLMVec3(0, 0, 1)) * - glm::scale(FGLMMat4(1.0f), FGLMVec3(pSize.x, pSize.y, 1.0f)); + mat4 transform = + glm::translate(mat4(1.0f), vec3(pPosition.x, pPosition.y, pPosition.z)) * + glm::rotate(mat4(1.0f), pRotation, vec3(0, 0, 1)) * + glm::scale(mat4(1.0f), vec3(pSize.x, pSize.y, 1.0f)); - if (pTransparencyLevel & ETransparencyType::Opaque) { + if (pTransparencyLevel & transparency_type::Opaque) { for (size_t i = 0; i < 4; i++) { sData.Quad.OpaqueVertexBufferBasePtr->Position = transform * sData.Quad.VertexPositions[i]; - sData.Quad.OpaqueVertexBufferBasePtr->Color = FGLMVec4(pColor.r, pColor.g, pColor.b, pColor.a); - sData.Quad.OpaqueVertexBufferBasePtr->TexCoord = CTexture2D::TexCoords[i]; + sData.Quad.OpaqueVertexBufferBasePtr->Color = vec4(pColor.r, pColor.g, pColor.b, pColor.a); + sData.Quad.OpaqueVertexBufferBasePtr->TexCoord = texture_2d::TexCoords[i]; sData.Quad.OpaqueVertexBufferBasePtr->TexIndex = textureIndex; - sData.Quad.OpaqueVertexBufferBasePtr->TexScaling = FGLMVec2(pTextureScaling.x, pTextureScaling.y); + sData.Quad.OpaqueVertexBufferBasePtr->TexScaling = vec2(pTextureScaling.x, pTextureScaling.y); sData.Quad.OpaqueVertexBufferBasePtr->EntityId = pId; sData.Quad.OpaqueVertexBufferBasePtr++; } sData.Quad.OpaqueIndexCount += 6; } - else if (pTransparencyLevel & ETransparencyType::Translucent) { + else if (pTransparencyLevel & transparency_type::Translucent) { for (size_t i = 0; i < 4; i++) { sData.Quad.TranslucentVertexBufferBasePtr->Position = transform * sData.Quad.VertexPositions[i]; - sData.Quad.TranslucentVertexBufferBasePtr->Color = FGLMVec4(pColor.r, pColor.g, pColor.b, pColor.a); - sData.Quad.TranslucentVertexBufferBasePtr->TexCoord = CTexture2D::TexCoords[i]; + sData.Quad.TranslucentVertexBufferBasePtr->Color = vec4(pColor.r, pColor.g, pColor.b, pColor.a); + sData.Quad.TranslucentVertexBufferBasePtr->TexCoord = texture_2d::TexCoords[i]; sData.Quad.TranslucentVertexBufferBasePtr->TexIndex = textureIndex; - sData.Quad.TranslucentVertexBufferBasePtr->TexScaling = FGLMVec2(pTextureScaling.x, pTextureScaling.y); + sData.Quad.TranslucentVertexBufferBasePtr->TexScaling = vec2(pTextureScaling.x, pTextureScaling.y); sData.Quad.TranslucentVertexBufferBasePtr->EntityId = pId; sData.Quad.TranslucentVertexBufferBasePtr++; } @@ -459,20 +459,20 @@ namespace ARC { ++sData.Statistics.QuadCount; } - void SRenderer2D::DrawQuad(const FVec3& pPosition, const float pRotation, const FVec2& pSize, const TTransparencyType pTransparencyLevel, const FColor4& pColor, const TRef& pSubTex, const FVec2& pTextureScaling, const int& pId) + void renderer_2d::draw_quad(const vec3& pPosition, const float pRotation, const vec2& pSize, const transparency_type pTransparencyLevel, const color4& pColor, const ref& pSubTex, const vec2& pTextureScaling, const int& pId) { if (sData.Quad.OpaqueIndexCount >= SRenderer2DData::MaxIndices) - FlushAndReset(EGeometery::Quad, ETransparencyType::Opaque); + flush_and_reset(geometry_type::Quad, transparency_type::Opaque); if (sData.Quad.TranslucentIndexCount >= SRenderer2DData::MaxIndices) - FlushAndReset(EGeometery::Quad, ETransparencyType::Translucent); + flush_and_reset(geometry_type::Quad, transparency_type::Translucent); - TUInt32 textureIndex = 0; + u32 textureIndex = 0; if (pSubTex != nullptr) { for (size_t i = 1; i < sData.TextureSlotIndex; i++) { - if (*sData.TextureSlots[i].get() == *pSubTex->GetTexture().get()) + if (*sData.TextureSlots[i].get() == *pSubTex->get_texture().get()) { textureIndex = i; break; @@ -481,37 +481,37 @@ namespace ARC { if (!textureIndex) { textureIndex = sData.TextureSlotIndex; - sData.TextureSlots[sData.TextureSlotIndex] = pSubTex->GetTexture(); + sData.TextureSlots[sData.TextureSlotIndex] = pSubTex->get_texture(); sData.TextureSlotIndex++; } } - FGLMMat4 transform = - glm::translate(FGLMMat4(1.0f), FGLMVec3(pPosition.x, pPosition.y, pPosition.z)) * - glm::rotate(FGLMMat4(1.0f), pRotation, FGLMVec3(0, 0, 1)) * - glm::scale(FGLMMat4(1.0f), FGLMVec3(pSize.x, pSize.y, 1.0f)); + mat4 transform = + glm::translate(mat4(1.0f), vec3(pPosition.x, pPosition.y, pPosition.z)) * + glm::rotate(mat4(1.0f), pRotation, vec3(0, 0, 1)) * + glm::scale(mat4(1.0f), vec3(pSize.x, pSize.y, 1.0f)); - if (pTransparencyLevel & ETransparencyType::Opaque) { + if (pTransparencyLevel & transparency_type::Opaque) { for (size_t i = 0; i < 4; i++) { sData.Quad.OpaqueVertexBufferBasePtr->Position = transform * sData.Quad.VertexPositions[i]; - sData.Quad.OpaqueVertexBufferBasePtr->Color = FGLMVec4(pColor.r, pColor.g, pColor.b, pColor.a); - sData.Quad.OpaqueVertexBufferBasePtr->TexCoord = pSubTex->GetTexCoords()[i]; + sData.Quad.OpaqueVertexBufferBasePtr->Color = vec4(pColor.r, pColor.g, pColor.b, pColor.a); + sData.Quad.OpaqueVertexBufferBasePtr->TexCoord = pSubTex->get_tex_coords()[i]; sData.Quad.OpaqueVertexBufferBasePtr->TexIndex = textureIndex; - sData.Quad.OpaqueVertexBufferBasePtr->TexScaling = FGLMVec2(pTextureScaling.x, pTextureScaling.y); + sData.Quad.OpaqueVertexBufferBasePtr->TexScaling = vec2(pTextureScaling.x, pTextureScaling.y); sData.Quad.OpaqueVertexBufferBasePtr->EntityId = pId; sData.Quad.OpaqueVertexBufferBasePtr++; } sData.Quad.OpaqueIndexCount += 6; } - else if (pTransparencyLevel & ETransparencyType::Translucent) { + else if (pTransparencyLevel & transparency_type::Translucent) { for (size_t i = 0; i < 4; i++) { sData.Quad.TranslucentVertexBufferBasePtr->Position = transform * sData.Quad.VertexPositions[i]; - sData.Quad.TranslucentVertexBufferBasePtr->Color = FGLMVec4(pColor.r, pColor.g, pColor.b, pColor.a); - sData.Quad.TranslucentVertexBufferBasePtr->TexCoord = pSubTex->GetTexCoords()[i]; + sData.Quad.TranslucentVertexBufferBasePtr->Color = vec4(pColor.r, pColor.g, pColor.b, pColor.a); + sData.Quad.TranslucentVertexBufferBasePtr->TexCoord = pSubTex->get_tex_coords()[i]; sData.Quad.TranslucentVertexBufferBasePtr->TexIndex = textureIndex; - sData.Quad.TranslucentVertexBufferBasePtr->TexScaling = FGLMVec2(pTextureScaling.x, pTextureScaling.y); + sData.Quad.TranslucentVertexBufferBasePtr->TexScaling = vec2(pTextureScaling.x, pTextureScaling.y); sData.Quad.TranslucentVertexBufferBasePtr->EntityId = pId; sData.Quad.TranslucentVertexBufferBasePtr++; } @@ -522,32 +522,32 @@ namespace ARC { } - void SRenderer2D::DrawQuad(const CPrimitive2D& Quad, const int& pId) + void renderer_2d::draw_quad(const primitive_2d& Quad, const int& pId) { ARC_PROFILE_FUNCTION(); - DrawQuad(Quad.GetLocation(), Quad.GetRotation(), Quad.GetScale(), Quad.TransparencyLevel, Quad.Color, Quad.Texture ? Quad.Texture : sData.WhiteTexture, Quad.TextureScaling, pId); + draw_quad(Quad.get_location(), Quad.get_rotation(), Quad.get_scale(), Quad.TransparencyLevel, Quad.Color, Quad.Texture ? Quad.Texture : sData.WhiteTexture, Quad.TextureScaling, pId); } - void SRenderer2D::DrawCircle(const FVec3& pPosition, const float pRotation /*= 0.f*/, const FVec2& pSize /*= FVec2::OneVector()*/, const FColor4& pColor /*= FColor4::White()*/, const float pThickness /*= 1.f*/, const float pSharpness /*= 0.995f*/, const int& pId /*= -1*/) + void renderer_2d::draw_circle(const vec3& pPosition, const float pRotation /*= 0.f*/, const vec2& pSize /*= vec2::OneVector()*/, const color4& pColor /*= color4::White()*/, const float pThickness /*= 1.f*/, const float pSharpness /*= 0.995f*/, const int& pId /*= -1*/) { ARC_PROFILE_FUNCTION(); if (sData.Circle.TranslucentIndexCount >= SRenderer2DData::MaxIndices){} - FlushAndReset(EGeometery::Circle, ETransparencyType::Translucent); + flush_and_reset(geometry_type::Circle, transparency_type::Translucent); // multi batch z sorting bug - FGLMMat4 transform = - glm::translate(FGLMMat4(1.0f), FGLMVec3(pPosition.x, pPosition.y, pPosition.z)) * - glm::rotate(FGLMMat4(1.0f), pRotation, FGLMVec3(0, 0, 1)) * - glm::scale(FGLMMat4(1.0f), FGLMVec3(pSize.x, pSize.y, 1.0f)); + mat4 transform = + glm::translate(mat4(1.0f), vec3(pPosition.x, pPosition.y, pPosition.z)) * + glm::rotate(mat4(1.0f), pRotation, vec3(0, 0, 1)) * + glm::scale(mat4(1.0f), vec3(pSize.x, pSize.y, 1.0f)); for (size_t i = 0; i < 4; i++) { sData.Circle.TranslucentVertexBufferBasePtr->WorldPosition = transform * sData.Circle.VertexPositions[i]; sData.Circle.TranslucentVertexBufferBasePtr->LocalPosition = sData.Circle.VertexPositions[i] * 2.f; - sData.Circle.TranslucentVertexBufferBasePtr->Color = FGLMVec4(pColor.r, pColor.g, pColor.b, pColor.a); + sData.Circle.TranslucentVertexBufferBasePtr->Color = vec4(pColor.r, pColor.g, pColor.b, pColor.a); sData.Circle.TranslucentVertexBufferBasePtr->Thickness = pThickness; sData.Circle.TranslucentVertexBufferBasePtr->Sharpness = pSharpness; sData.Circle.TranslucentVertexBufferBasePtr->EntityId = pId; @@ -558,16 +558,16 @@ namespace ARC { ++sData.Statistics.QuadCount; } - void SRenderer2D::DrawLine(const FVec3& pPositionStart, const FVec3& pPositionEnd, const FColor4& pColor /*= FColor4::White()*/, const int& pId /*= -1*/) + void renderer_2d::draw_line(const vec3& pPositionStart, const vec3& pPositionEnd, const color4& pColor /*= color4::White()*/, const int& pId /*= -1*/) { - sData.Line.VertexBufferBasePtr->Position = FGLMVec3(pPositionStart.x, pPositionStart.y, pPositionStart.z); - sData.Line.VertexBufferBasePtr->Color = FGLMVec4(pColor.r, pColor.g, pColor.b, pColor.a); + sData.Line.VertexBufferBasePtr->Position = vec3(pPositionStart.x, pPositionStart.y, pPositionStart.z); + sData.Line.VertexBufferBasePtr->Color = vec4(pColor.r, pColor.g, pColor.b, pColor.a); sData.Line.VertexBufferBasePtr->EntityId = pId; sData.Line.VertexBufferBasePtr++; - sData.Line.VertexBufferBasePtr->Position = FGLMVec3(pPositionEnd.x, pPositionEnd.y, pPositionEnd.z); - sData.Line.VertexBufferBasePtr->Color = FGLMVec4(pColor.r, pColor.g, pColor.b, pColor.a); + sData.Line.VertexBufferBasePtr->Position = vec3(pPositionEnd.x, pPositionEnd.y, pPositionEnd.z); + sData.Line.VertexBufferBasePtr->Color = vec4(pColor.r, pColor.g, pColor.b, pColor.a); sData.Line.VertexBufferBasePtr->EntityId = pId; sData.Line.VertexBufferBasePtr++; @@ -575,69 +575,69 @@ namespace ARC { sData.Line.IndexCount+=2; } - void SRenderer2D::DrawRect(const FVec3& pPosition, const float pRotation, const FVec2& pSize, const FColor4& pColor, const int& pId /*= -1*/) + void renderer_2d::DrawRect(const vec3& pPosition, const float pRotation, const vec2& pSize, const color4& pColor, const int& pId /*= -1*/) { - FGLMMat4 transform = - glm::translate(FGLMMat4(1.0f), FGLMVec3(pPosition.x, pPosition.y, pPosition.z)) * - glm::rotate(FGLMMat4(1.0f), pRotation, FGLMVec3(0, 0, 1)) * - glm::scale(FGLMMat4(1.0f), FGLMVec3(pSize.x, pSize.y, 1.0f)); + mat4 transform = + glm::translate(mat4(1.0f), vec3(pPosition.x, pPosition.y, pPosition.z)) * + glm::rotate(mat4(1.0f), pRotation, vec3(0, 0, 1)) * + glm::scale(mat4(1.0f), vec3(pSize.x, pSize.y, 1.0f)); - FGLMVec3 verts[4]; + vec3 verts[4]; for (size_t i = 0; i < 4; i++) verts[i] = transform * sData.Quad.VertexPositions[i]; for (size_t i = 0; i < 4; i++) - DrawLine(reinterpret_cast(verts[i]), reinterpret_cast(verts[(i+1)%4]), pColor, pId); + draw_line(reinterpret_cast(verts[i]), reinterpret_cast(verts[(i+1)%4]), pColor, pId); } - SRenderer2D::SStatistics SRenderer2D::GetStats() + renderer_2d::statistics renderer_2d::get_stats() { return sData.Statistics; } - void SRenderer2D::ResetStats() + void renderer_2d::ResetStats() { - memset(&sData.Statistics, 0, sizeof(SStatistics)); + memset(&sData.Statistics, 0, sizeof(statistics)); } - constexpr void SRenderer2D::FlushAndReset(TGeometery pG, TTransparencyType pT) { + constexpr void renderer_2d::flush_and_reset(geometry_type pG, transparency_type pT) { - EndScene(pG, pT); + end_scene(pG, pT); - if (pG & EGeometery::Quad) + if (pG & geometry_type::Quad) { - if (pT & ETransparencyType::Translucent) + if (pT & transparency_type::Translucent) { sData.Quad.TranslucentIndexCount = 0; sData.Quad.TranslucentVertexBufferBasePtr = sData.Quad.TranslucentVertexBufferBase; } - if (pT & ETransparencyType::Opaque) { + if (pT & transparency_type::Opaque) { sData.Quad.OpaqueIndexCount = 0; sData.Quad.OpaqueVertexBufferBasePtr = sData.Quad.OpaqueVertexBufferBase; } } - if (pG & EGeometery::Circle) + if (pG & geometry_type::Circle) { - if (pT & ETransparencyType::Translucent) + if (pT & transparency_type::Translucent) { sData.Circle.TranslucentIndexCount = 0; sData.Circle.TranslucentVertexBufferBasePtr = sData.Circle.TranslucentVertexBufferBase; } } - if (pG & EGeometery::Line) + if (pG & geometry_type::Line) { sData.Line.IndexCount = 0; sData.Line.VertexBufferBasePtr = sData.Line.VertexBufferBase; } } - void SRenderer2D::SetLineThickness(float pThickness) + void renderer_2d::set_line_thickness(float pThickness) { sData.Line.Thickness = pThickness; } - float SRenderer2D::GetLineThickness() + float renderer_2d::get_line_thickness() { return sData.Line.Thickness; } diff --git a/ARC-Engine/src/ARC/Renderer/Renderer2D.h b/ARC-Engine/src/ARC/Renderer/Renderer2D.h index 3af920479d..2198b8ddf3 100644 --- a/ARC-Engine/src/ARC/Renderer/Renderer2D.h +++ b/ARC-Engine/src/ARC/Renderer/Renderer2D.h @@ -3,77 +3,77 @@ #include "ARC/Types/Transform2D.h" #include "../Scene/Entity.h" -namespace ARC { class CEditorCamera; } +namespace arc { class editor_camera; } -namespace ARC { class CEditorCamera; } +namespace arc { class editor_camera; } -namespace ARC { class CCamera; } +namespace arc { class camera; } -namespace ARC { class CSubTexture2D; } -namespace ARC { class CPrimitive2D; } +namespace arc { class sub_texture_2d; } +namespace arc { class primitive_2d; } -namespace ARC { class COrthographicCamera; } -namespace ARC { class CVertexArray; } -namespace ARC { class CTexture2D; } -namespace ARC { class CShader; } +namespace arc { class orthographic_camera; } +namespace arc { class vertex_array; } +namespace arc { class texture_2d; } +namespace arc { class shader; } -namespace ARC { +namespace arc { - namespace EGeometery { - enum EGeometery { Quad = 1, Circle= 2, Line=3}; + namespace geometry_type { + enum geometry_type { Quad = 1, Circle= 2, Line=3}; }; - using TGeometery = TUInt8; - class SRenderer2D + using geometry_type = u8; + class renderer_2d { public: - static void Init(); - static void Shutdown(); + static void init(); + static void shutdown(); - static void BeginScene(const COrthographicCamera& pCamera); - static void BeginScene(const CEditorCamera& pCamera); - static void BeginScene(const CCamera& pCamera, const FTransform2D& pTransform); + static void begin_scene(const orthographic_camera& pCamera); + static void begin_scene(const editor_camera& pCamera); + static void begin_scene(const camera& pCamera, const transform_2d& pTransform); - constexpr static void EndScene(TGeometery pG = EGeometery::Quad | EGeometery::Circle | EGeometery::Line, TTransparencyType pT = ETransparencyType::Opaque | ETransparencyType::Translucent | ETransparencyType::Transparent); - constexpr static void Flush(TGeometery pG = EGeometery::Quad | EGeometery::Circle | EGeometery::Line, TTransparencyType pT = ETransparencyType::Opaque | ETransparencyType::Translucent | ETransparencyType::Transparent); + constexpr static void end_scene(geometry_type pG = geometry_type::Quad | geometry_type::Circle | geometry_type::Line, transparency_type pT = transparency_type::Opaque | transparency_type::Translucent | transparency_type::Transparent); + constexpr static void flush(geometry_type pG = geometry_type::Quad | geometry_type::Circle | geometry_type::Line, transparency_type pT = transparency_type::Opaque | transparency_type::Translucent | transparency_type::Transparent); /* * @param pPosition: Center location of quad. * @param pRotation: Rotation of quad in radians. - * @param pSize: Size of quad. + * @param pSize: size of quad. * @param pColor: Color of quad. * @param pTexture: Texture of quad. * @param pTextureScaling: Scaling applied to the texture. */ - static void DrawQuad(const FVec3& pPosition, const float pRotation = 0.f, const FVec2& pSize = FVec2::OneVector(), const TTransparencyType pTransparencyLevel = ETransparencyType::Translucent, const FColor4& pColor = FColor4::White(), const TRef& pTex = nullptr, const FVec2& pTextureScaling = FVec2::OneVector(), const int& pId = -1); + static void draw_quad(const vec3& pPosition, const float pRotation = 0.f, const vec2& pSize = vec2::OneVector(), const transparency_type pTransparencyLevel = transparency_type::Translucent, const color4& pColor = color4::White(), const ref& pTex = nullptr, const vec2& pTextureScaling = vec2::OneVector(), const int& pId = -1); /* * @param pPosition: Center location of quad. * @param pRotation: Rotation of quad in radians. - * @param pSize: Size of quad. + * @param pSize: size of quad. * @param pColor: Color of quad. * @param pTexture: Texture of quad. * @param pTextureScaling: Scaling applied to the texture. */ - static void DrawQuad(const FVec3& pPosition, const float pRotation, const FVec2& pSize, const TTransparencyType pTransparencyLevel, const FColor4& pColor, const TRef& pTex, const FVec2& pTextureScaling, const int& pId = -1); - static void DrawQuad(const CPrimitive2D& Quad, const int& pId = -1); + static void draw_quad(const vec3& pPosition, const float pRotation, const vec2& pSize, const transparency_type pTransparencyLevel, const color4& pColor, const ref& pTex, const vec2& pTextureScaling, const int& pId = -1); + static void draw_quad(const primitive_2d& Quad, const int& pId = -1); - static void DrawCircle(const FVec3& pPosition, const float pRotation = 0.f, const FVec2& pSize = FVec2::OneVector(), const FColor4& pColor = FColor4::White(), const float pThickness = 1.f, const float pSharpness = 0.995f, const int& pId = -1); - static void DrawLine(const FVec3& pPositionStart, const FVec3& pPositionEnd, const FColor4& pColor = FColor4::White(), const int& pId = -1); - static void DrawRect(const FVec3& pPosition, const float pRotation, const FVec2& pSize, const FColor4& pColor, const int& pId = -1); + static void draw_circle(const vec3& pPosition, const float pRotation = 0.f, const vec2& pSize = vec2::OneVector(), const color4& pColor = color4::White(), const float pThickness = 1.f, const float pSharpness = 0.995f, const int& pId = -1); + static void draw_line(const vec3& pPositionStart, const vec3& pPositionEnd, const color4& pColor = color4::White(), const int& pId = -1); + static void DrawRect(const vec3& pPosition, const float pRotation, const vec2& pSize, const color4& pColor, const int& pId = -1); - static void SetLineThickness(float pThickness); - static float GetLineThickness(); + static void set_line_thickness(float pThickness); + static float get_line_thickness(); - struct SStatistics + struct statistics { - TUInt32 DrawCalls = 0; - TUInt32 QuadCount = 0; + u32 DrawCalls = 0; + u32 QuadCount = 0; - TUInt32 GetTotalVertexCount() const { return QuadCount * 4; } - TUInt32 GetTotalIndexCount() const{ return QuadCount * 6; } + u32 get_total_vertex_count() const { return QuadCount * 4; } + u32 get_total_index_count() const{ return QuadCount * 6; } }; - static SStatistics GetStats(); + static statistics get_stats(); static void ResetStats(); private: - constexpr static void FlushAndReset(TGeometery pG, TTransparencyType pT); + constexpr static void flush_and_reset(geometry_type pG, transparency_type pT); }; } diff --git a/ARC-Engine/src/ARC/Renderer/RendererAPI.h b/ARC-Engine/src/ARC/Renderer/RendererAPI.h index 9217ac7c4d..e8deb11583 100644 --- a/ARC-Engine/src/ARC/Renderer/RendererAPI.h +++ b/ARC-Engine/src/ARC/Renderer/RendererAPI.h @@ -4,30 +4,30 @@ #include "ARC\Types\Pointer.h" #include "ARC\Types\Color.h" -namespace ARC { class CVertexArray; } +namespace arc { class vertex_array; } -namespace ARC { - class CRendererAPI { +namespace arc { + class renderer_api { public: - enum class ERendererAPI + enum class renderer_api { None = 0, OpenGL = 1 }; public: - virtual ~CRendererAPI() = default; + virtual ~renderer_api() = default; - virtual void Init() = 0; - virtual void SetViewport(const TVec2 _BottemLeftCoord, const TVec2 _Dimentions) = 0; - virtual void SetClearColour(const FColor4 _Colour) = 0; - virtual void Clear() = 0; + virtual void init() = 0; + virtual void set_viewport(const vec2 bottem_left_coord, const vec2 dimentions) = 0; + virtual void set_clear_colour(const color4 colour) = 0; + virtual void clear() = 0; - virtual void DrawIndexed(const TRef& _VertexArray, uint32_t _Count) = 0; - virtual void DrawLine(const TRef& _VertexArray, uint32_t _Count) = 0; - virtual void SetLineThickness(float pThickness) = 0; + virtual void draw_indexed(const ref& vertex_array, uint32_t count) = 0; + virtual void draw_line(const ref& vertex_array, uint32_t count) = 0; + virtual void set_line_thickness(float pThickness) = 0; - inline static ERendererAPI GetAPI() { return s_API; }; + inline static renderer_api get_api() { return api; }; private: - inline static ERendererAPI s_API = ERendererAPI::OpenGL; + inline static renderer_api api = renderer_api::OpenGL; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/Shader.cpp b/ARC-Engine/src/ARC/Renderer/Shader.cpp index 7b073bb157..aec43647fb 100644 --- a/ARC-Engine/src/ARC/Renderer/Shader.cpp +++ b/ARC-Engine/src/ARC/Renderer/Shader.cpp @@ -7,145 +7,145 @@ #include "glm/gtx/compatibility.hpp" #include "glm/gtc/type_ptr.inl" -namespace ARC { - TRef CShader::Create(const TString& _Name, const TString& _VertexSrc, const TString& _FragmentSrc) +namespace arc { + ref shader::create(const string& name, const string& vertex_src, const string& fragment_src) { - switch (CRenderer::GetCurrentAPI()) + switch (renderer::get_current_api()) { - case CRendererAPI::ERendererAPI::None: - ARC_CORE_ASSERT(false, "Selected renderer API is not supported (ERendererAPI::None)"); + case renderer_api::renderer_api::None: + ARC_CORE_ASSERT(false, "Selected renderer API is not supported (renderer_api::None)"); return nullptr; - case CRendererAPI::ERendererAPI::OpenGL: - return CreateRef(_Name, _VertexSrc, _FragmentSrc); + case renderer_api::renderer_api::OpenGL: + return create_ref(name, vertex_src, fragment_src); } ARC_CORE_ASSERT(false, "Unknown renderer API"); return nullptr; } - TRef CShader::Create(const TString& _Path) + ref shader::create(const string& path) { - switch (CRenderer::GetCurrentAPI()) + switch (renderer::get_current_api()) { - case CRendererAPI::ERendererAPI::None: - ARC_CORE_ASSERT(false, "Selected renderer API is not supported (ERendererAPI::None)"); + case renderer_api::renderer_api::None: + ARC_CORE_ASSERT(false, "Selected renderer API is not supported (renderer_api::None)"); return nullptr; - case CRendererAPI::ERendererAPI::OpenGL: - return CreateRef(_Path); + case renderer_api::renderer_api::OpenGL: + return create_ref(path); } ARC_CORE_ASSERT(false, "Unknown renderer API"); return nullptr; } - void CShaderLibrary::Add(const TRef& _Shader) + void shader_library::Add(const ref& shader) { - auto& name = _Shader->GetName(); - Add(name, _Shader); + auto& name = shader->get_name(); + Add(name, shader); } - void CShaderLibrary::Add(const TString& _Name, const TRef& _Shader) + void shader_library::Add(const string& name, const ref& shader) { - ARC_CORE_ASSERT(!Exists(_Name), "Shader Already Exists"); - mShaders[_Name] = _Shader; + ARC_CORE_ASSERT(!Exists(name), "Shader Already Exists"); + shaders_[name] = shader; } - TRef CShaderLibrary::Load(const TString& _Path, const TString& _Name /*= ""*/) + ref shader_library::Load(const string& path, const string& name /*= ""*/) { ARC_PROFILE_FUNCTION(); - auto shader = CShader::Create(_Path); - if(_Name == "") Add(shader); - else Add(_Name, shader); + auto shader = shader::create(path); + if(name == "") Add(shader); + else Add(name, shader); return shader; } - TRef CShaderLibrary::GetShader(const TString& _Name) + ref shader_library::get_shader(const string& name) { - ARC_CORE_ASSERT(Exists(_Name), "Shader Not Found"); - return mShaders[_Name]; + ARC_CORE_ASSERT(Exists(name), "Shader Not Found"); + return shaders_[name]; } - bool CShaderLibrary::Exists(const TString& _Name) const + bool shader_library::Exists(const string& name) const { - return mShaders.find(_Name) != mShaders.end(); + return shaders_.find(name) != shaders_.end(); } template - void CShader::Set(const TString& _Name, const T& _Value) + void shader::Set(const string& name, const T& value) { ARC_CORE_WARN("Uploading {0} to Shader is currently not supported", typeid(T).name()); } template<> - void CShader::Set(const TString& _Name, const FVec4& _Value) + void shader::Set(const string& name, const vec4& value) { - SetFloat4(_Name, _Value.Data()); + set_float4(name, value.Data()); } template<> - void CShader::Set(const TString& _Name, const FVec3& _Value) + void shader::Set(const string& name, const vec3& value) { - SetFloat3(_Name, _Value.Data()); + set_float3(name, value.Data()); } template<> - void CShader::Set(const TString& _Name, const FVec2& _Value) + void shader::Set(const string& name, const vec2& value) { - SetFloat2(_Name, _Value.Data()); + set_float2(name, value.Data()); } template<> - void CShader::Set(const TString& _Name, const FColor4& _Value) + void shader::Set(const string& name, const color4& value) { - SetFloat4(_Name, _Value.Data()); + set_float4(name, value.Data()); } template<> - void CShader::Set(const TString& _Name, const glm::vec4& _Value) + void shader::Set(const string& name, const glm::vec4& value) { - SetFloat4(_Name, glm::value_ptr(_Value)); + set_float4(name, glm::value_ptr(value)); } template<> - void CShader::Set(const TString& _Name, const glm::mat4& _Value) + void shader::Set(const string& name, const glm::mat4& value) { - SetMat4(_Name, glm::value_ptr(_Value)); + set_mat4(name, glm::value_ptr(value)); } template<> - void CShader::Set(const TString& _Name, const glm::mat3& _Value) + void shader::Set(const string& name, const glm::mat3& value) { - SetMat3(_Name, glm::value_ptr(_Value)); + set_mat3(name, glm::value_ptr(value)); } template<> - void CShader::Set(const TString& _Name, const float& _Value) + void shader::Set(const string& name, const float& value) { - SetFloat(_Name, &_Value); + set_float(name, &value); } template<> - void CShader::Set(const TString& _Name, const glm::float2& _Value) + void shader::Set(const string& name, const glm::float2& value) { - SetFloat2(_Name, glm::value_ptr(_Value)); + set_float2(name, glm::value_ptr(value)); } template<> - void CShader::Set(const TString& _Name, const glm::float3& _Value) + void shader::Set(const string& name, const glm::float3& value) { - SetFloat3(_Name, glm::value_ptr(_Value)); + set_float3(name, glm::value_ptr(value)); } template<> - void CShader::Set(const TString& _Name, const int& _Value) + void shader::Set(const string& name, const int& value) { - SetInt(_Name, &_Value); + set_int(name, &value); } template - void CShader::SetArray(const TString& _Name, const T* _Value, uint32_t _Count) + void shader::set_array(const string& name, const T* value, uint32_t count) { ARC_CORE_WARN("Uploading {0} Array to Shader is currently not supported", typeid(T).name()); } template<> - void CShader::SetArray(const TString& _Name, const int* _Value, uint32_t _Count) + void shader::set_array(const string& name, const int* value, uint32_t count) { - SetIntArray(_Name, _Value, _Count); + set_int_array(name, value, count); } template<> - void CShader::SetArray(const TString& _Name, const float* _Value, uint32_t _Count) + void shader::set_array(const string& name, const float* value, uint32_t count) { - SetFloatArray( _Name, _Value, _Count); + set_float_array( name, value, count); } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/Shader.h b/ARC-Engine/src/ARC/Renderer/Shader.h index 55688159f1..962159f125 100644 --- a/ARC-Engine/src/ARC/Renderer/Shader.h +++ b/ARC-Engine/src/ARC/Renderer/Shader.h @@ -2,51 +2,51 @@ #include #include "ARC\Types\Pointer.h" -namespace ARC { - class CShader +namespace arc { + class shader { public: - virtual ~CShader() = default; + virtual ~shader() = default; - virtual void Bind() const = 0; + virtual void bind() const = 0; virtual void UnBind() const = 0; - virtual const TString& GetName() const = 0; + virtual const string& get_name() const = 0; - static TRef Create(const TString& _Name, const TString& _VertexSrc, const TString& _FragmentSrc); - static TRef Create(const TString& _Path); + static ref create(const string& name, const string& vertex_src, const string& fragment_src); + static ref create(const string& path); template - inline void Set(const TString& _Name, const T& _Value); + inline void Set(const string& name, const T& value); template - inline void SetArray(const TString& _Name, const T* _Value, uint32_t _Count); + inline void set_array(const string& name, const T* value, uint32_t count); protected: - virtual void SetInt(const TString& _Name, const int* _Value) = 0; - virtual void SetInt2(const TString& _Name, const int* _Value) = 0; - virtual void SetInt3(const TString& _Name, const int* _Value) = 0; - virtual void SetInt4(const TString& _Name, const int* _Value) = 0; - virtual void SetMat3(const TString& _Name, const float* _Value) = 0; - virtual void SetMat4(const TString& _Name, const float* _Value) = 0; - virtual void SetFloat(const TString& _Name, const float* _Value) = 0; - virtual void SetFloat2(const TString& _Name, const float* _Value) = 0; - virtual void SetFloat3(const TString& _Name, const float* _Value) = 0; - virtual void SetFloat4(const TString& _Name, const float* _Value) = 0; + virtual void set_int(const string& name, const int* value) = 0; + virtual void set_int2(const string& name, const int* value) = 0; + virtual void set_int3(const string& name, const int* value) = 0; + virtual void set_int4(const string& name, const int* value) = 0; + virtual void set_mat3(const string& name, const float* value) = 0; + virtual void set_mat4(const string& name, const float* value) = 0; + virtual void set_float(const string& name, const float* value) = 0; + virtual void set_float2(const string& name, const float* value) = 0; + virtual void set_float3(const string& name, const float* value) = 0; + virtual void set_float4(const string& name, const float* value) = 0; - virtual void SetIntArray(const TString& _Name, const int* _Values, uint32_t _Count) = 0; - virtual void SetFloatArray(const TString& _Name, const float* _Values, uint32_t _Count) = 0; + virtual void set_int_array(const string& name, const int* values, uint32_t count) = 0; + virtual void set_float_array(const string& name, const float* values, uint32_t count) = 0; }; - class CShaderLibrary + class shader_library { public: - void Add(const TRef& _Shader); - void Add(const TString& _Name, const TRef& _Shader); - TRef Load(const TString& _Path, const TString& _Name = ""); + void Add(const ref& shader); + void Add(const string& name, const ref& shader); + ref Load(const string& path, const string& name = ""); public: - TRef GetShader(const TString& _Name); - bool Exists(const TString& _Name) const; + ref get_shader(const string& name); + bool Exists(const string& name) const; private: - std::unordered_map> mShaders; + std::unordered_map> shaders_; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/SubTexture2D.cpp b/ARC-Engine/src/ARC/Renderer/SubTexture2D.cpp index c841cc8b40..eb272f2b02 100644 --- a/ARC-Engine/src/ARC/Renderer/SubTexture2D.cpp +++ b/ARC-Engine/src/ARC/Renderer/SubTexture2D.cpp @@ -2,23 +2,23 @@ #include "SubTexture2D.h" #include "ARC\Renderer\Texture.h" -namespace ARC { +namespace arc { - CSubTexture2D::CSubTexture2D(const TRef& _Texture, const FVec2& _Min, const FVec2& _Max) : - mTexture(_Texture) + sub_texture_2d::sub_texture_2d(const ref& texture, const vec2& min, const vec2& max) : + texture_(texture) { - mTexCoords[0] = { _Min.x, _Min.y }; - mTexCoords[1] = { _Max.x, _Min.y }; - mTexCoords[2] = { _Max.x, _Max.y }; - mTexCoords[3] = { _Min.x, _Max.y }; + tex_coords_[0] = { min.x, min.y }; + tex_coords_[1] = { max.x, min.y }; + tex_coords_[2] = { max.x, max.y }; + tex_coords_[3] = { min.x, max.y }; } - TRef CSubTexture2D::CreateFromCoords(const TRef& _Texture, const FVec2& _Coords, const FVec2& _CellSize, const FVec2& _SpriteSize) + ref sub_texture_2d::CreateFromCoords(const ref& texture, const vec2& coords, const vec2& cell_size, const vec2& sprite_size) { - return CreateRef( - _Texture, - FVec2(_Coords.x * _CellSize.x / _Texture->Dimensions.x, _Coords.y * _CellSize.y / _Texture->Dimensions.y), - FVec2((_Coords.x + _SpriteSize.x) * _CellSize.x / _Texture->Dimensions.x, (_Coords.y + _SpriteSize.y) * _CellSize.y / _Texture->Dimensions.y) + return create_ref( + texture, + vec2(coords.x * cell_size.x / texture->Dimensions.x, coords.y * cell_size.y / texture->Dimensions.y), + vec2((coords.x + sprite_size.x) * cell_size.x / texture->Dimensions.x, (coords.y + sprite_size.y) * cell_size.y / texture->Dimensions.y) ); } diff --git a/ARC-Engine/src/ARC/Renderer/SubTexture2D.h b/ARC-Engine/src/ARC/Renderer/SubTexture2D.h index e60ecfc0bc..d88786d59d 100644 --- a/ARC-Engine/src/ARC/Renderer/SubTexture2D.h +++ b/ARC-Engine/src/ARC/Renderer/SubTexture2D.h @@ -3,21 +3,21 @@ #include "ARC\Types\vector.h" #include "glm\ext\vector_float2.hpp" -namespace ARC { class CTexture2D; } +namespace arc { class texture_2d; } -namespace ARC { - class CSubTexture2D +namespace arc { + class sub_texture_2d { public: - CSubTexture2D(const TRef& _Texture, const FVec2& _Min, const FVec2& _Max); + sub_texture_2d(const ref& texture, const vec2& min, const vec2& max); - inline const TRef GetTexture() const { return mTexture; }; - inline const glm::vec2* GetTexCoords() const { return mTexCoords; }; + inline const ref get_texture() const { return texture_; }; + inline const glm::vec2* get_tex_coords() const { return tex_coords_; }; - static TRef CreateFromCoords(const TRef& _Texture, const FVec2& _Coords, const FVec2& _CellSize, const FVec2& _SpriteSize={1, 1}); + static ref CreateFromCoords(const ref& texture, const vec2& coords, const vec2& cell_size, const vec2& sprite_size={1, 1}); protected: private: - TRef mTexture; - glm::vec2 mTexCoords[4]; + ref texture_; + glm::vec2 tex_coords_[4]; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Renderer/Texture.cpp b/ARC-Engine/src/ARC/Renderer/Texture.cpp index 70826fa6a7..bd23d82f4d 100644 --- a/ARC-Engine/src/ARC/Renderer/Texture.cpp +++ b/ARC-Engine/src/ARC/Renderer/Texture.cpp @@ -4,32 +4,32 @@ #include "Platform\OpenGl\OpenGLTexture.h" #include "ARC\Core\Core.h" -namespace ARC { +namespace arc { - TRef CTexture2D::Create(const std::filesystem::path& pPath, bool pbManualClear) + ref texture_2d::create(const std::filesystem::path& pPath, bool pbManualClear) { - switch (CRenderer::GetCurrentAPI()) + switch (renderer::get_current_api()) { - case CRendererAPI::ERendererAPI::None: - ARC_CORE_ASSERT(false, "Selected renderer API is not supported (ERendererAPI::None)"); + case renderer_api::renderer_api::None: + ARC_CORE_ASSERT(false, "Selected renderer API is not supported (renderer_api::None)"); return nullptr; - case CRendererAPI::ERendererAPI::OpenGL: - return CreateRef(pPath, pbManualClear); + case renderer_api::renderer_api::OpenGL: + return create_ref(pPath, pbManualClear); } ARC_CORE_ASSERT(false, "Unknown renderer API"); return nullptr; } - TRef CTexture2D::Create(const TVec2 pDimentions) + ref texture_2d::create(const vec2 pDimentions) { - switch (CRenderer::GetCurrentAPI()) + switch (renderer::get_current_api()) { - case CRendererAPI::ERendererAPI::None: - ARC_CORE_ASSERT(false, "Selected renderer API is not supported (ERendererAPI::None)"); + case renderer_api::renderer_api::None: + ARC_CORE_ASSERT(false, "Selected renderer API is not supported (renderer_api::None)"); return nullptr; - case CRendererAPI::ERendererAPI::OpenGL: - return CreateRef(pDimentions); + case renderer_api::renderer_api::OpenGL: + return create_ref(pDimentions); } ARC_CORE_ASSERT(false, "Unknown renderer API"); diff --git a/ARC-Engine/src/ARC/Renderer/Texture.h b/ARC-Engine/src/ARC/Renderer/Texture.h index 19a73578bb..ce0d713775 100644 --- a/ARC-Engine/src/ARC/Renderer/Texture.h +++ b/ARC-Engine/src/ARC/Renderer/Texture.h @@ -3,34 +3,34 @@ #include "..\Types\vector.h" #include "glm\ext\vector_float2.hpp" -namespace ARC { - class CTexture +namespace arc { + class texture { public: - virtual ~CTexture() = default; + virtual ~texture() = default; virtual void ClearData() = 0; - virtual const std::filesystem::path& GetPath() const = 0; - virtual void SetData(void*, uint32_t _Size) = 0; - virtual void Bind(uint32_t _Slot = 0) const = 0; + virtual const std::filesystem::path& get_path() const = 0; + virtual void set_data(void*, uint32_t size) = 0; + virtual void bind(uint32_t slot = 0) const = 0; - virtual uint32_t GetRendererID() = 0; + virtual uint32_t get_renderer_id() = 0; - virtual bool operator==(const CTexture& _Tex) const = 0; + virtual bool operator==(const texture& tex) const = 0; }; - class CTexture2D : public CTexture + class texture_2d : public texture { public: - static TRef Create(const TVec2 _Dimentions); - static TRef Create(const std::filesystem::path& _Path, bool bManualClear = false); + static ref create(const vec2 dimentions); + static ref create(const std::filesystem::path& path, bool bManualClear = false); - virtual TVec4 GetPixelColor(TVec2 xy) = 0; + virtual vec4 get_pixel_color(vec2 xy) = 0; protected: - inline CTexture2D(TVec2 _Dimentions) : Dimensions(_Dimentions) {} + inline texture_2d(vec2 dimentions) : Dimensions(dimentions) {} public: - TVec2 Dimensions; + vec2 Dimensions; static constexpr glm::vec2 TexCoords[] = { {0.f, 0.f}, diff --git a/ARC-Engine/src/ARC/Renderer/VertexArray.cpp b/ARC-Engine/src/ARC/Renderer/VertexArray.cpp index d1ced626b5..55cac34a48 100644 --- a/ARC-Engine/src/ARC/Renderer/VertexArray.cpp +++ b/ARC-Engine/src/ARC/Renderer/VertexArray.cpp @@ -3,16 +3,16 @@ #include "..\..\Platform\OpenGl\OpenGLVertexArray.h" #include "Renderer.h" -namespace ARC { - TRef CVertexArray::Create() +namespace arc { + ref vertex_array::create() { - switch (CRenderer::GetCurrentAPI()) + switch (renderer::get_current_api()) { - case CRendererAPI::ERendererAPI::None: - ARC_CORE_ASSERT(false, "Selected renderer API is not supported (ERendererAPI::None)"); + case renderer_api::renderer_api::None: + ARC_CORE_ASSERT(false, "Selected renderer API is not supported (renderer_api::None)"); return nullptr; - case CRendererAPI::ERendererAPI::OpenGL: - return std::make_shared(); + case renderer_api::renderer_api::OpenGL: + return std::make_shared(); } ARC_CORE_ASSERT(false, "Unknown renderer API"); diff --git a/ARC-Engine/src/ARC/Renderer/VertexArray.h b/ARC-Engine/src/ARC/Renderer/VertexArray.h index 2c3d5857b3..bb841eb602 100644 --- a/ARC-Engine/src/ARC/Renderer/VertexArray.h +++ b/ARC-Engine/src/ARC/Renderer/VertexArray.h @@ -2,20 +2,20 @@ #include "ARC\Renderer\Buffer.h" #include -namespace ARC { - class CVertexArray +namespace arc { + class vertex_array { public: - virtual ~CVertexArray() = default; - static TRef Create(); + virtual ~vertex_array() = default; + static ref create(); - virtual void AddVertexBuffer(const TRef& _VertexBuffer) = 0; - virtual void SetIndexBuffer(const TRef& _IndexBuffer) = 0; + virtual void add_vertex_buffer(const ref& vertex_buffer) = 0; + virtual void set_index_buffer(const ref& index_buffer) = 0; - virtual const std::vector>& GetVertexBuffers() const = 0; - virtual const TRef& GetIndexBuffer() const = 0; + virtual const std::vector>& get_vertex_buffers() const = 0; + virtual const ref& get_index_buffer() const = 0; - virtual void Bind() const = 0; + virtual void bind() const = 0; virtual void UnBind() const = 0; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Scene/BasicComponents.cpp b/ARC-Engine/src/ARC/Scene/BasicComponents.cpp index 58661df11c..b07f11749c 100644 --- a/ARC-Engine/src/ARC/Scene/BasicComponents.cpp +++ b/ARC-Engine/src/ARC/Scene/BasicComponents.cpp @@ -8,43 +8,43 @@ #include "ARC/GUI/ImGuiHelper.h" #include "ARC/Core/PlatformUtils.h" -namespace ARC +namespace arc { - void CNativeScriptComponent::OnConstruct(CEntity& pOwningEntity) + void native_script_component::on_construct(entity& pOwningEntity) { OwningEntity = &pOwningEntity; } - void CTransform2DComponent::DrawPropertiesUI(CEntity& pEntity) + void transform_2d_component::draw_properties_ui(entity& pEntity) { - SGuiHelper::DrawGuiControl(Transform.Location, "Translation", 100.f, FVec3::ZeroVector()); - FVec1 _ = SMath::Degrees(Transform.Rotation); - SGuiHelper::DrawGuiControl(_, "Rotation", 100.f); - Transform.Rotation = SMath::Radians(_.x); - SGuiHelper::DrawGuiControl(Transform.Scale, "Scale", 100.f, FVec2::OneVector()); + gui_helper::draw_gui_control(Transform.Location, "Translation", 100.f, vec3::ZeroVector()); + vec1 _ = math::Degrees(Transform.Rotation); + gui_helper::draw_gui_control(_, "Rotation", 100.f); + Transform.Rotation = math::Radians(_.x); + gui_helper::draw_gui_control(Transform.Scale, "Scale", 100.f, vec2::OneVector()); } - void CTransform2DComponent::Serialize(YAML::Emitter& pOut) + void transform_2d_component::serialize(YAML::Emitter& pOut) { pOut << YAML::Key << "Location" << YAML::Value << Transform.Location << YAML::Key << "Rotation" << YAML::Value << Transform.Rotation << YAML::Key << "Scale" << YAML::Value << Transform.Scale; } - void CTransform2DComponent::Deserialize(YAML::Node& pData) + void transform_2d_component::deserialize(YAML::Node& pData) { - Transform.Location = pData["Location"].as(); + Transform.Location = pData["Location"].as(); Transform.Rotation = pData["Rotation"].as(); - Transform.Scale = pData["Scale"].as(); + Transform.Scale = pData["Scale"].as(); } - void CCameraComponent::DrawPropertiesUI(CEntity& pEntity) + void camera_component::draw_properties_ui(entity& pEntity) { bool bprimary = Primary; ImGui::Checkbox("PrimaryCamera", &bprimary); Primary = bprimary; static const char* projectionTypeStrings[] = { "Perspective", "Orthographic" }; - const char* currentProjectionTypeString = projectionTypeStrings[(int)Camera.GetProjectionType()]; + const char* currentProjectionTypeString = projectionTypeStrings[(int)Camera.get_projection_type()]; if (ImGui::BeginCombo("Projection", currentProjectionTypeString)) { @@ -54,79 +54,79 @@ namespace ARC if (ImGui::Selectable(projectionTypeStrings[i], isSelected)) { currentProjectionTypeString = projectionTypeStrings[i]; - Camera.SetProjectionType(CSceneCamera::EProjectionType(i)); + Camera.set_projection_type(scene_camera::projection_type(i)); } if (isSelected) - ImGui::SetItemDefaultFocus(); + ImGui::set_item_default_focus(); } ImGui::EndCombo(); } - if (Camera.GetProjectionType() == CSceneCamera::EProjectionType::Orthographic) + if (Camera.get_projection_type() == scene_camera::projection_type::Orthographic) { - float orthoSize = Camera.GetOrthographicSize(); - if (ImGui::DragFloat("Size", &orthoSize)) - Camera.SetOrthographicSize(orthoSize); + float orthoSize = Camera.get_orthographic_size(); + if (ImGui::DragFloat("size", &orthoSize)) + Camera.set_orthographic_size(orthoSize); - float orthoNearClip = Camera.GetOrthographicNearClip(); + float orthoNearClip = Camera.get_orthographic_near_clip(); if (ImGui::DragFloat("NearClip", &orthoNearClip)) - Camera.SetOrthographicNearClip(orthoNearClip); + Camera.set_orthographic_near_clip(orthoNearClip); - float orthoFarClip = Camera.GetOrthographicFarClip(); + float orthoFarClip = Camera.get_orthographic_far_clip(); if (ImGui::DragFloat("FarClip", &orthoFarClip)) - Camera.SetOrthographicFarClip(orthoFarClip); + Camera.set_orthographic_far_clip(orthoFarClip); } - if (Camera.GetProjectionType() == CSceneCamera::EProjectionType::Perspective) + if (Camera.get_projection_type() == scene_camera::projection_type::Perspective) { - float perspectiveFOV = SMath::Conv(Camera.GetPerspectiveFOV()); + float perspectiveFOV = math::Conv(Camera.get_perspective_fov()); if (ImGui::DragFloat("FOV", &perspectiveFOV)) - Camera.SetPerspectiveFOV(perspectiveFOV); + Camera.set_perspective_fov(perspectiveFOV); - float perspectiveNearClip = Camera.GetPerspectiveNearClip(); + float perspectiveNearClip = Camera.get_perspective_near_clip(); if (ImGui::DragFloat("NearClip", &perspectiveNearClip)) - Camera.SetPerspectiveNearClip(perspectiveNearClip); + Camera.set_perspective_near_clip(perspectiveNearClip); - float perspectiveFarClip = Camera.GetPerspectiveFarClip(); + float perspectiveFarClip = Camera.get_perspective_far_clip(); if (ImGui::DragFloat("FarClip", &perspectiveFarClip)) - Camera.SetPerspectiveFarClip(perspectiveFarClip); + Camera.set_perspective_far_clip(perspectiveFarClip); } } - void CCameraComponent::Serialize(YAML::Emitter& pOut) + void camera_component::serialize(YAML::Emitter& pOut) { pOut << YAML::Key << "Primary" << YAML::Value << bool(Primary) << YAML::Key << "FixedAspectRatio" << YAML::Value << bool(FixedAspectRatio) << - YAML::Key << "ProjectionType" << YAML::Value << (int)Camera.GetProjectionType() << + YAML::Key << "ProjectionType" << YAML::Value << (int)Camera.get_projection_type() << YAML::Key << "Perspective" << YAML::Value << YAML::BeginMap << - YAML::Key << "FOV" << YAML::Value << Camera.GetPerspectiveFOV() << - YAML::Key << "NearClip" << YAML::Value << Camera.GetPerspectiveNearClip() << - YAML::Key << "FarClip" << YAML::Value << Camera.GetPerspectiveFarClip() << + YAML::Key << "FOV" << YAML::Value << Camera.get_perspective_fov() << + YAML::Key << "NearClip" << YAML::Value << Camera.get_perspective_near_clip() << + YAML::Key << "FarClip" << YAML::Value << Camera.get_perspective_far_clip() << YAML::EndMap << YAML::Key << "Orthographic" << YAML::Value << YAML::BeginMap << - YAML::Key << "Size" << YAML::Value << Camera.GetOrthographicSize() << - YAML::Key << "NearClip" << YAML::Value << Camera.GetOrthographicNearClip() << - YAML::Key << "FarClip" << YAML::Value << Camera.GetOrthographicFarClip() << + YAML::Key << "size" << YAML::Value << Camera.get_orthographic_size() << + YAML::Key << "NearClip" << YAML::Value << Camera.get_orthographic_near_clip() << + YAML::Key << "FarClip" << YAML::Value << Camera.get_orthographic_far_clip() << YAML::EndMap; } - void CCameraComponent::Deserialize(YAML::Node& pData) + void camera_component::deserialize(YAML::Node& pData) { Primary = pData["Primary"].as(); FixedAspectRatio = pData["FixedAspectRatio"].as(); - Camera.SetProjectionType(CSceneCamera::EProjectionType(pData["ProjectionType"].as())); + Camera.set_projection_type(scene_camera::projection_type(pData["ProjectionType"].as())); - Camera.SetOrthographicSize(pData["Orthographic"]["Size"].as()); - Camera.SetOrthographicNearClip(pData["Orthographic"]["NearClip"].as()); - Camera.SetOrthographicFarClip(pData["Orthographic"]["FarClip"].as()); + Camera.set_orthographic_size(pData["Orthographic"]["size"].as()); + Camera.set_orthographic_near_clip(pData["Orthographic"]["NearClip"].as()); + Camera.set_orthographic_far_clip(pData["Orthographic"]["FarClip"].as()); - Camera.SetPerspectiveFOV(pData["Perspective"]["FOV"].as()); - Camera.SetPerspectiveNearClip(pData["Perspective"]["NearClip"].as()); - Camera.SetPerspectiveFarClip(pData["Perspective"]["FarClip"].as()); + Camera.set_perspective_fov(pData["Perspective"]["FOV"].as()); + Camera.set_perspective_near_clip(pData["Perspective"]["NearClip"].as()); + Camera.set_perspective_far_clip(pData["Perspective"]["FarClip"].as()); } - void CNameComponent::DrawPropertiesUI(CEntity& pEntity) + void name_component::draw_properties_ui(entity& pEntity) { char buffer[256]; memset(buffer, 0, sizeof(buffer)); @@ -135,29 +135,29 @@ namespace ARC Name = buffer; } - void CNameComponent::Serialize(YAML::Emitter& pOut) + void name_component::serialize(YAML::Emitter& pOut) { pOut << YAML::Key << "Name" << YAML::Value << Name; } - void CNameComponent::Deserialize(YAML::Node& pData) + void name_component::deserialize(YAML::Node& pData) { - Name = pData["Name"].as(); + Name = pData["Name"].as(); } - void CSpriteRendererComponent::DrawPropertiesUI(CEntity& pEntity) + void sprite_renderer_component::draw_properties_ui(entity& pEntity) { char buffer[256]; memset(buffer, 0, sizeof(buffer)); if (Texture) - strcpy_s(buffer, Texture->GetPath().string().c_str()); - SGuiHelper::DrawGuiControl(Color, "Color", 100.f, FColor4::Black()); + strcpy_s(buffer, Texture->get_path().string().c_str()); + gui_helper::draw_gui_control(Color, "Color", 100.f, color4::Black()); ImGui::InputText("TexturePath ", buffer, 256); - if (ImGui::IsItemDeactivatedAfterEdit() && - (!Texture || Texture->GetPath() != buffer)) + if (ImGui::is_item_deactivated_after_edit() && + (!Texture || Texture->get_path() != buffer)) { - Texture = CTexture2D::Create(std::filesystem::path(buffer)); + Texture = texture_2d::create(std::filesystem::path(buffer)); } if (ImGui::BeginDragDropTarget()) @@ -165,66 +165,66 @@ namespace ARC if (const auto* payload = ImGui::AcceptDragDropPayload("CONTENT_BROWSER_ITEM")) { const auto* path = (const wchar_t*)payload->Data; - Texture = CTexture2D::Create(std::filesystem::path("assets") / std::filesystem::path(path)); // todo replace assets path + Texture = texture_2d::create(std::filesystem::path("assets") / std::filesystem::path(path)); // todo replace assets path } ImGui::EndDragDropTarget(); } ImGui::SameLine(); if(ImGui::Button("...")) { - auto filepath = SFileDialogs::OpenFile("ARC-Engine Texture (*.png)\0*.png\0"); + auto filepath = file_dialogs::open_file("ARC-Engine Texture (*.png)\0*.png\0"); if (!filepath.empty()) { - Texture = CTexture2D::Create(filepath); + Texture = texture_2d::create(filepath); } } - SGuiHelper::DrawGuiControl(TextureScaling, "Scaling", 100.f, FVec2::OneVector()); + gui_helper::draw_gui_control(TextureScaling, "Scaling", 100.f, vec2::OneVector()); } - void CSpriteRendererComponent::Serialize(YAML::Emitter& pOut) + void sprite_renderer_component::serialize(YAML::Emitter& pOut) { pOut << YAML::Key << "Color" << YAML::Value << Color; if (Texture) pOut << - YAML::Key << "TexturePath" << YAML::Value << Texture->GetPath().string() << + YAML::Key << "TexturePath" << YAML::Value << Texture->get_path().string() << YAML::Key << "TextureScaling" << YAML::Value << TextureScaling; } - void CSpriteRendererComponent::Deserialize(YAML::Node& pData) + void sprite_renderer_component::deserialize(YAML::Node& pData) { - Color = pData["Color"].as(); + Color = pData["Color"].as(); if (pData["TexturePath"]) { - TString texturePath = pData["TexturePath"].as(); - Texture = CTexture2D::Create(texturePath); - TextureScaling = pData["TextureScaling"].as(); + string texturePath = pData["TexturePath"].as(); + Texture = texture_2d::create(texturePath); + TextureScaling = pData["TextureScaling"].as(); } } - void CBoxCollider2DComponent::DrawPropertiesUI(CEntity& pEntity) + void box_collider_2d_component::draw_properties_ui(entity& pEntity) { ImGui::DragFloat2("Offset", Offset.Data()); - ImGui::DragFloat2("Size", Size.Data()); + ImGui::DragFloat2("size", size.Data()); ImGui::DragFloat("Density", &Density); ImGui::DragFloat("Friction", &Friction); ImGui::DragFloat("Restitution", &Restitution); ImGui::DragFloat("RestitutionThreshhold", &RestitutionThreshhold); } - void CBoxCollider2DComponent::Serialize(YAML::Emitter& pOut) + void box_collider_2d_component::serialize(YAML::Emitter& pOut) { pOut << YAML::Key << "Offset" << YAML::Value << Offset - << YAML::Key << "Size" << YAML::Value << Size + << YAML::Key << "size" << YAML::Value << size << YAML::Key << "Density" << YAML::Value << Density << YAML::Key << "Friction" << YAML::Value << Friction << YAML::Key << "Restitution" << YAML::Value << Restitution << YAML::Key << "RestitutionThreshhold" << YAML::Value << RestitutionThreshhold; } - void CBoxCollider2DComponent::Deserialize(YAML::Node& pData) + void box_collider_2d_component::deserialize(YAML::Node& pData) { - Offset = pData["Offset"].as(); - Size = pData["Size"].as(); + Offset = pData["Offset"].as(); + size = pData["size"].as(); Density = pData["Density"].as(); Friction = pData["Friction"].as(); Restitution = pData["Restitution"].as(); @@ -232,7 +232,7 @@ namespace ARC } - void CCircleCollider2DComponent::DrawPropertiesUI(CEntity& pEntity) + void circle_collider_2d_component::draw_properties_ui(entity& pEntity) { ImGui::DragFloat2("Offset", Offset.Data()); ImGui::DragFloat("Radius", &Radius); @@ -242,7 +242,7 @@ namespace ARC ImGui::DragFloat("RestitutionThreshhold", &RestitutionThreshhold); } - void CCircleCollider2DComponent::Serialize(YAML::Emitter& pOut) + void circle_collider_2d_component::serialize(YAML::Emitter& pOut) { pOut << YAML::Key << "Offset" << YAML::Value << Offset @@ -253,9 +253,9 @@ namespace ARC << YAML::Key << "RestitutionThreshhold" << YAML::Value << RestitutionThreshhold; } - void CCircleCollider2DComponent::Deserialize(YAML::Node& pData) + void circle_collider_2d_component::deserialize(YAML::Node& pData) { - Offset = pData["Offset"].as(); + Offset = pData["Offset"].as(); Radius = pData["Radius"].as(); Density = pData["Density"].as(); Friction = pData["Friction"].as(); @@ -264,7 +264,7 @@ namespace ARC } - void CRigidBody2DComponent::DrawPropertiesUI(CEntity& pEntity) + void rigid_body_2d_component::draw_properties_ui(entity& pEntity) { static const char* bodyTypeStrings[] = { "Static", "Kinematic", "Dynamic" }; const char* currentBodyTypeString = bodyTypeStrings[(int)Type]; @@ -277,10 +277,10 @@ namespace ARC if (ImGui::Selectable(bodyTypeStrings[i], isSelected)) { currentBodyTypeString = bodyTypeStrings[i]; - Type = CRigidBody2DComponent::EBodyType(i); + Type = rigid_body_2d_component::body_type(i); } if (isSelected) - ImGui::SetItemDefaultFocus(); + ImGui::set_item_default_focus(); } ImGui::EndCombo(); @@ -289,26 +289,26 @@ namespace ARC ImGui::Checkbox("Fixed Rotation", &bFixedRotation); } - void CRigidBody2DComponent::Serialize(YAML::Emitter& pOut) + void rigid_body_2d_component::serialize(YAML::Emitter& pOut) { pOut << YAML::Key << "Type" << YAML::Value << (int)Type << YAML::Key << "bFixedRotation" << YAML::Value << bool(bFixedRotation); } - void CRigidBody2DComponent::Deserialize(YAML::Node& pData) + void rigid_body_2d_component::deserialize(YAML::Node& pData) { - Type = (EBodyType)pData["Type"].as(); + Type = (body_type)pData["Type"].as(); bFixedRotation = pData["bFixedRotation"].as(); } - void CCircleRendererComponent::DrawPropertiesUI(CEntity& pEntity) + void circle_renderer_component::draw_properties_ui(entity& pEntity) { - SGuiHelper::DrawGuiControl(Color, "Color", 100.f, FColor4::Black()); + gui_helper::draw_gui_control(Color, "Color", 100.f, color4::Black()); ImGui::DragFloat("Thickness", &Thickness, 0.025f, 0.0f, 1.0f); ImGui::DragFloat("Sharpness", &Sharpness, 0.0005f, 0.0f, 1.0f); } - void CCircleRendererComponent::Serialize(YAML::Emitter& pOut) + void circle_renderer_component::serialize(YAML::Emitter& pOut) { pOut << YAML::Key << "Color" << YAML::Value << Color << @@ -317,9 +317,9 @@ namespace ARC } - void CCircleRendererComponent::Deserialize(YAML::Node& pData) + void circle_renderer_component::deserialize(YAML::Node& pData) { - Color = pData["Color"].as(); + Color = pData["Color"].as(); Thickness = pData["Thickness"].as(); Sharpness = pData["Sharpness"].as(); } diff --git a/ARC-Engine/src/ARC/Scene/BasicComponents.h b/ARC-Engine/src/ARC/Scene/BasicComponents.h index e3580d0fdb..5097ec59c4 100644 --- a/ARC-Engine/src/ARC/Scene/BasicComponents.h +++ b/ARC-Engine/src/ARC/Scene/BasicComponents.h @@ -5,161 +5,161 @@ namespace YAML { class Node; } namespace YAML { class Emitter; } -namespace ARC { - struct CTransform2DComponent : public CComponentBase +namespace arc { + struct transform_2d_component : public component_base { - FTransform2D Transform; + transform_2d Transform; - CTransform2DComponent() = default; - CTransform2DComponent(const CTransform2DComponent&) = default; - CTransform2DComponent(const FTransform2D& pTransform) : Transform(pTransform) {}; + transform_2d_component() = default; + transform_2d_component(const transform_2d_component&) = default; + transform_2d_component(const transform_2d& pTransform) : Transform(pTransform) {}; - virtual void DrawPropertiesUI(CEntity& pEntity) override; - virtual void Serialize(YAML::Emitter& pOut) override; - virtual void Deserialize(YAML::Node& pData) override; - virtual TUInt32 GetFlags() override { return Flags; }; + virtual void draw_properties_ui(entity& pEntity) override; + virtual void serialize(YAML::Emitter& pOut) override; + virtual void deserialize(YAML::Node& pData) override; + virtual u32 get_flags() override { return Flags; }; - static inline TUInt32 Flags = ECF::DefaultComponentFlags | ECF::Serializable; + static inline u32 Flags = ecf::DefaultComponentFlags | ecf::Serializable; - operator FTransform2D& () { return Transform; } - operator const FTransform2D& () const { return Transform; } + operator transform_2d& () { return Transform; } + operator const transform_2d& () const { return Transform; } }; - struct CSpriteRendererComponent : public CComponentBase + struct sprite_renderer_component : public component_base { - FColor4 Color = FColor4::White(); - TRef Texture = nullptr; - FVec2 TextureScaling = FVec2::OneVector(); + color4 Color = color4::White(); + ref Texture = nullptr; + vec2 TextureScaling = vec2::OneVector(); - CSpriteRendererComponent() = default; - CSpriteRendererComponent(const CSpriteRendererComponent&) = default; - CSpriteRendererComponent(const FColor4& pColor, const TRef& pTex, const FVec2& pTexScaling) : Color(pColor), Texture(pTex), TextureScaling(pTexScaling) {}; + sprite_renderer_component() = default; + sprite_renderer_component(const sprite_renderer_component&) = default; + sprite_renderer_component(const color4& pColor, const ref& pTex, const vec2& pTexScaling) : Color(pColor), Texture(pTex), TextureScaling(pTexScaling) {}; - virtual void DrawPropertiesUI(CEntity& pEntity) override; - virtual void Serialize(YAML::Emitter& pOut) override; - virtual void Deserialize(YAML::Node& pData) override; - virtual TUInt32 GetFlags() override { return Flags; }; + virtual void draw_properties_ui(entity& pEntity) override; + virtual void serialize(YAML::Emitter& pOut) override; + virtual void deserialize(YAML::Node& pData) override; + virtual u32 get_flags() override { return Flags; }; - static inline TUInt32 Flags = ECF::DefaultComponentFlags | ECF::Serializable; + static inline u32 Flags = ecf::DefaultComponentFlags | ecf::Serializable; }; - struct CCircleRendererComponent : public CComponentBase + struct circle_renderer_component : public component_base { - FColor4 Color = FColor4::White(); + color4 Color = color4::White(); float Thickness = 1.0f; float Sharpness = 0.995f; - CCircleRendererComponent() = default; - CCircleRendererComponent(const CCircleRendererComponent&) = default; + circle_renderer_component() = default; + circle_renderer_component(const circle_renderer_component&) = default; - virtual void DrawPropertiesUI(CEntity& pEntity) override; - virtual void Serialize(YAML::Emitter& pOut) override; - virtual void Deserialize(YAML::Node& pData) override; - virtual TUInt32 GetFlags() override { return Flags; }; + virtual void draw_properties_ui(entity& pEntity) override; + virtual void serialize(YAML::Emitter& pOut) override; + virtual void deserialize(YAML::Node& pData) override; + virtual u32 get_flags() override { return Flags; }; - static inline TUInt32 Flags = ECF::DefaultComponentFlags | ECF::Serializable; + static inline u32 Flags = ecf::DefaultComponentFlags | ecf::Serializable; }; - struct CIDComponent : public CComponentBase + struct id_component : public component_base { - TUUID ID = SUUID::Generate(); + uuid ID = uuid::generate(); - CIDComponent() = default; - CIDComponent(const CIDComponent& p) = default; - CIDComponent(const TUUID& pID) : ID(pID) {}; + id_component() = default; + id_component(const id_component& p) = default; + id_component(const uuid& pID) : ID(pID) {}; - virtual TUInt32 GetFlags() override { return Flags; }; - static inline TUInt32 Flags = ECF::ComponentFlagsNone; // using custom serialisation ECF::Serializable; + virtual u32 get_flags() override { return Flags; }; + static inline u32 Flags = ecf::ComponentFlagsNone; // using custom serialisation ecf::Serializable; operator auto& () { return ID; } operator const auto& () const { return ID; } }; - struct CNameComponent : public CComponentBase + struct name_component : public component_base { - TString Name; + string Name; - CNameComponent() = default; - CNameComponent(const CNameComponent&) = default; - CNameComponent(const TString& pName) : Name(pName) {}; + name_component() = default; + name_component(const name_component&) = default; + name_component(const string& pName) : Name(pName) {}; - virtual void DrawPropertiesUI(CEntity& pEntity) override; - virtual void Serialize(YAML::Emitter& pOut) override; - virtual void Deserialize(YAML::Node& pData) override; - virtual TUInt32 GetFlags() override { return Flags; }; + virtual void draw_properties_ui(entity& pEntity) override; + virtual void serialize(YAML::Emitter& pOut) override; + virtual void deserialize(YAML::Node& pData) override; + virtual u32 get_flags() override { return Flags; }; - static inline TUInt32 Flags = ECF::ShowInPropertiesPanel | ECF::Serializable; + static inline u32 Flags = ecf::ShowInPropertiesPanel | ecf::Serializable; operator auto& () { return Name; } operator const auto& () const { return Name; } }; - struct CCameraComponent : public CComponentBase + struct camera_component : public component_base { - CSceneCamera Camera; - virtual ~CCameraComponent() = default; + scene_camera Camera; + virtual ~camera_component() = default; uint8_t Primary : 1; uint8_t FixedAspectRatio : 1; - CCameraComponent() = default; - CCameraComponent(const CCameraComponent&) = default; + camera_component() = default; + camera_component(const camera_component&) = default; - virtual void DrawPropertiesUI(CEntity& pEntity) override; - virtual void Serialize(YAML::Emitter& pOut) override; - virtual void Deserialize(YAML::Node& pData) override; - virtual TUInt32 GetFlags() override { return Flags; }; + virtual void draw_properties_ui(entity& pEntity) override; + virtual void serialize(YAML::Emitter& pOut) override; + virtual void deserialize(YAML::Node& pData) override; + virtual u32 get_flags() override { return Flags; }; - static inline TUInt32 Flags = ECF::DefaultComponentFlags | ECF::Serializable; + static inline u32 Flags = ecf::DefaultComponentFlags | ecf::Serializable; operator auto& () { return Camera; } operator const auto& () const { return Camera; } }; - struct CNativeScriptComponent : public CComponentBase + struct native_script_component : public component_base { - CEntity* OwningEntity = nullptr; - CEntityController* Controller = nullptr; + entity* OwningEntity = nullptr; + entity_controller* Controller = nullptr; - TDelegate InstantiateDelegate; - TDelegate DestroyInstancesDelegate; + delegate InstantiateDelegate; + delegate DestroyInstancesDelegate; - virtual void OnConstruct(CEntity& pOwningEntity) override; - virtual TUInt32 GetFlags() override { return Flags; }; + virtual void on_construct(entity& pOwningEntity) override; + virtual u32 get_flags() override { return Flags; }; - static inline TUInt32 Flags = ECF::ComponentFlagsNone; + static inline u32 Flags = ecf::ComponentFlagsNone; template void BindController() { - InstantiateDelegate.Bind([]() { return new T(); }); - DestroyInstancesDelegate.Bind([](CEntityController*& pInst) { delete pInst; pInst = nullptr; }); + InstantiateDelegate.bind([]() { return new T(); }); + DestroyInstancesDelegate.bind([](entity_controller*& pInst) { delete pInst; pInst = nullptr; }); } }; - struct CRigidBody2DComponent : public CComponentBase + struct rigid_body_2d_component : public component_base { - enum class EBodyType { Static = 0, Kinematic, Dynamic }; - EBodyType Type = EBodyType::Static; + enum class body_type { Static = 0, Kinematic, Dynamic }; + body_type Type = body_type::Static; bool bFixedRotation; void* RuntimeBody = nullptr; - CRigidBody2DComponent() = default; - CRigidBody2DComponent(const CRigidBody2DComponent&) = default; + rigid_body_2d_component() = default; + rigid_body_2d_component(const rigid_body_2d_component&) = default; - virtual void DrawPropertiesUI(CEntity& pEntity) override; - virtual void Serialize(YAML::Emitter& pOut) override; - virtual void Deserialize(YAML::Node& pData) override; - virtual TUInt32 GetFlags() override { return Flags; }; + virtual void draw_properties_ui(entity& pEntity) override; + virtual void serialize(YAML::Emitter& pOut) override; + virtual void deserialize(YAML::Node& pData) override; + virtual u32 get_flags() override { return Flags; }; - static inline TUInt32 Flags = ECF::DefaultComponentFlags | ECF::Serializable; + static inline u32 Flags = ecf::DefaultComponentFlags | ecf::Serializable; }; - struct CBoxCollider2DComponent : public CComponentBase + struct box_collider_2d_component : public component_base { - FVec2 Offset = FVec2::ZeroVector(); - FVec2 Size = FVec2::OneVector()*0.5f; + vec2 Offset = vec2::ZeroVector(); + vec2 size = vec2::OneVector()*0.5f; float Density=1.f; float Friction=0.5f; @@ -168,20 +168,20 @@ namespace ARC { void* RuntimeFixture = nullptr; - CBoxCollider2DComponent() = default; - CBoxCollider2DComponent(const CBoxCollider2DComponent&) = default; + box_collider_2d_component() = default; + box_collider_2d_component(const box_collider_2d_component&) = default; - virtual void DrawPropertiesUI(CEntity& pEntity) override; - virtual void Serialize(YAML::Emitter& pOut) override; - virtual void Deserialize(YAML::Node& pData) override; - virtual TUInt32 GetFlags() override { return Flags; }; + virtual void draw_properties_ui(entity& pEntity) override; + virtual void serialize(YAML::Emitter& pOut) override; + virtual void deserialize(YAML::Node& pData) override; + virtual u32 get_flags() override { return Flags; }; - static inline TUInt32 Flags = ECF::DefaultComponentFlags | ECF::Serializable; + static inline u32 Flags = ecf::DefaultComponentFlags | ecf::Serializable; }; - struct CCircleCollider2DComponent : public CComponentBase + struct circle_collider_2d_component : public component_base { - FVec2 Offset = FVec2::ZeroVector(); + vec2 Offset = vec2::ZeroVector(); float Radius = 0.5f; float Density = 1.f; @@ -191,14 +191,14 @@ namespace ARC { void* RuntimeFixture = nullptr; - CCircleCollider2DComponent() = default; - CCircleCollider2DComponent(const CCircleCollider2DComponent&) = default; + circle_collider_2d_component() = default; + circle_collider_2d_component(const circle_collider_2d_component&) = default; - virtual void DrawPropertiesUI(CEntity& pEntity) override; - virtual void Serialize(YAML::Emitter& pOut) override; - virtual void Deserialize(YAML::Node& pData) override; - virtual TUInt32 GetFlags() override { return Flags; }; + virtual void draw_properties_ui(entity& pEntity) override; + virtual void serialize(YAML::Emitter& pOut) override; + virtual void deserialize(YAML::Node& pData) override; + virtual u32 get_flags() override { return Flags; }; - static inline TUInt32 Flags = ECF::DefaultComponentFlags | ECF::Serializable; + static inline u32 Flags = ecf::DefaultComponentFlags | ecf::Serializable; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Scene/Component.h b/ARC-Engine/src/ARC/Scene/Component.h index ae5c6f083a..e79956fc59 100644 --- a/ARC-Engine/src/ARC/Scene/Component.h +++ b/ARC-Engine/src/ARC/Scene/Component.h @@ -12,11 +12,11 @@ namespace YAML { class Emitter; } namespace YAML { class Node; } -namespace ARC { - class CEntity; +namespace arc { + class entity; - namespace ECF { - enum EComponentFlags : uint32_t + namespace ecf { + enum component_flags : uint32_t { ComponentFlagsNone = 0, ShowInPropertiesPanel = 1 << 0, @@ -26,15 +26,15 @@ namespace ARC { }; } - struct CComponentBase + struct component_base { - virtual void OnConstruct(CEntity& pOwningEntity){}; - virtual void DrawPropertiesUI(CEntity& pEntity) {}; - virtual void Serialize(YAML::Emitter& pOut) {}; - virtual void Deserialize(YAML::Node& pData) {}; - virtual uint32_t GetFlags()=0; + virtual void on_construct(entity& pOwningEntity){}; + virtual void draw_properties_ui(entity& pEntity) {}; + virtual void serialize(YAML::Emitter& pOut) {}; + virtual void deserialize(YAML::Node& pData) {}; + virtual uint32_t get_flags()=0; - static inline uint32_t Flags = ECF::DefaultComponentFlags; + static inline uint32_t Flags = ecf::DefaultComponentFlags; static inline int32_t OnTopPriority = 0; // >1 top priority, <1 means bottom priority in scene heirachy panel @TODO implemeant }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Scene/Controller.cpp b/ARC-Engine/src/ARC/Scene/Controller.cpp index 47fc1930e3..b55d95971b 100644 --- a/ARC-Engine/src/ARC/Scene/Controller.cpp +++ b/ARC-Engine/src/ARC/Scene/Controller.cpp @@ -7,42 +7,42 @@ #include "Scene.h" #include "BasicComponents.h" -namespace ARC +namespace arc { - void CEntityController::Setup(CEntity* pEntity) + void entity_controller::set_up(entity* pEntity) { - mControlledEntity = pEntity; + controlled_entity_ = pEntity; } - CEntity* CEntityController::GetControlledEntity() { return mControlledEntity; } + entity* entity_controller::get_controlled_entity() { return controlled_entity_; } //----------------------------------------------------------------------------// - void CCameraController::OnCreate() + void camera_controller::on_create() { } - void CCameraController::OnDestroy() + void camera_controller::OnDestroy() { } - void CCameraController::OnUpdate(float pDeltaTime) + void camera_controller::on_update(float pDeltaTime) { return; - if (!GetControlledEntity()->IsValid()) return; + if (!get_controlled_entity()->is_valid()) return; - auto& trans = GetControlledEntity()->GetComponent().Transform; + auto& trans = get_controlled_entity()->get_component().Transform; float speed = 5.f; - if (SInput::IsKeyPressed(EKey::W)) + if (input::is_key_pressed(key::W)) trans.Location.y -= speed * pDeltaTime; - if (SInput::IsKeyPressed(EKey::A)) + if (input::is_key_pressed(key::A)) trans.Location.x += speed * pDeltaTime; - if (SInput::IsKeyPressed(EKey::S)) + if (input::is_key_pressed(key::S)) trans.Location.y += speed * pDeltaTime; - if (SInput::IsKeyPressed(EKey::D)) + if (input::is_key_pressed(key::D)) trans.Location.x -= speed * pDeltaTime; } diff --git a/ARC-Engine/src/ARC/Scene/Controller.h b/ARC-Engine/src/ARC/Scene/Controller.h index ecff947329..43501480e4 100644 --- a/ARC-Engine/src/ARC/Scene/Controller.h +++ b/ARC-Engine/src/ARC/Scene/Controller.h @@ -1,35 +1,35 @@ #pragma once -namespace ARC { class CEntity; } +namespace arc { class entity; } -namespace ARC +namespace arc { - class CEntityController + class entity_controller { public: - virtual ~CEntityController(){}; + virtual ~entity_controller(){}; - inline bool IsSetup() const { return mControlledEntity; } - CEntity* GetControlledEntity(); + inline bool is_setup() const { return controlled_entity_; } + entity* get_controlled_entity(); - virtual void Setup(CEntity* pEntity); + virtual void set_up(entity* pEntity); - virtual void OnCreate() {}; + virtual void on_create() {}; virtual void OnDestroy() {}; - virtual void OnUpdate(float pDeltaTime) {}; + virtual void on_update(float pDeltaTime) {}; private: - CEntity* mControlledEntity; - friend class CScene; + entity* controlled_entity_; + friend class scene; }; - class CCameraController : public CEntityController + class camera_controller : public entity_controller { public: - CCameraController() {}; + camera_controller() {}; - virtual void OnCreate() override; + virtual void on_create() override; virtual void OnDestroy() override; - virtual void OnUpdate(float pDeltaTime) override; + virtual void on_update(float pDeltaTime) override; private: }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Scene/EditorCamera.cpp b/ARC-Engine/src/ARC/Scene/EditorCamera.cpp index 4e2e10ba93..54338b0f99 100644 --- a/ARC-Engine/src/ARC/Scene/EditorCamera.cpp +++ b/ARC-Engine/src/ARC/Scene/EditorCamera.cpp @@ -10,134 +10,134 @@ #include #include "../Events/MouseEvent.h" -namespace ARC { +namespace arc { - CEditorCamera::CEditorCamera(float fov, float aspectRatio, float nearClip, float farClip) - : mFOV(fov), mAspectRatio(aspectRatio), mNearClip(nearClip), mFarClip(farClip), CCamera(glm::perspective(glm::radians(fov), aspectRatio, nearClip, farClip)) + editor_camera::editor_camera(float fov, float aspectRatio, float nearClip, float farClip) + : fov_(fov), aspect_ratio_(aspectRatio), near_clip_(nearClip), far_clip_(farClip), camera(glm::perspective(glm::radians(fov), aspectRatio, nearClip, farClip)) { UpdateView(); } - void CEditorCamera::UpdateProjection() + void editor_camera::UpdateProjection() { - mAspectRatio = mViewportWidth / mViewportHeight; - mProjection = glm::perspective(glm::radians(mFOV), mAspectRatio, mNearClip, mFarClip); + aspect_ratio_ = viewport_width_ / viewport_height_; + projection_ = glm::perspective(glm::radians(fov_), aspect_ratio_, near_clip_, far_clip_); } - void CEditorCamera::UpdateView() + void editor_camera::UpdateView() { - // mYaw = mPitch = 0.0f; // Lock the camera's rotation - mPosition = CalculatePosition(); + // yaw_ = pitch_ = 0.0f; // Lock the camera's rotation + position_ = CalculatePosition(); - glm::quat orientation = GetOrientation(); - mViewMatrix = glm::translate(glm::mat4(1.0f), mPosition) * glm::toMat4(orientation); - mViewMatrix = glm::inverse(mViewMatrix); + glm::quat orientation = get_orientation(); + view_matrix_ = glm::translate(glm::mat4(1.0f), position_) * glm::toMat4(orientation); + view_matrix_ = glm::inverse(view_matrix_); } - std::pair CEditorCamera::PanSpeed() const + std::pair editor_camera::PanSpeed() const { - float x = std::min(mViewportWidth / 1000.0f, 2.4f); // max = 2.4f + float x = std::min(viewport_width_ / 1000.0f, 2.4f); // max = 2.4f float xFactor = 0.0366f * (x * x) - 0.1778f * x + 0.3021f; - float y = std::min(mViewportHeight / 1000.0f, 2.4f); // max = 2.4f + float y = std::min(viewport_height_ / 1000.0f, 2.4f); // max = 2.4f float yFactor = 0.0366f * (y * y) - 0.1778f * y + 0.3021f; return { xFactor, yFactor }; } - float CEditorCamera::RotationSpeed() const + float editor_camera::RotationSpeed() const { return 0.8f; } - float CEditorCamera::ZoomSpeed() const + float editor_camera::ZoomSpeed() const { - float distance = mDistance * 0.2f; + float distance = distance_ * 0.2f; distance = std::max(distance, 0.0f); float speed = distance * distance; speed = std::min(speed, 100.0f); // max speed = 100 return speed; } - void CEditorCamera::OnUpdate(float ts) + void editor_camera::on_update(float ts) { - if (SInput::IsKeyPressed(EKey::LeftAlt)) + if (input::is_key_pressed(key::LeftAlt)) { - const FGLMVec2& mouse = (const FGLMVec2&)SInput::GetMouseXY(); - FGLMVec2 delta = (mouse - mInitialMousePosition) * 0.003f; - mInitialMousePosition = mouse; + const vec2& mouse = (const vec2&)input::get_mouse_xy(); + vec2 delta = (mouse - initial_mouse_position_) * 0.003f; + initial_mouse_position_ = mouse; - if (SInput::IsMouseButtonPressed(EMouse::ButtonMiddle)) + if (input::is_mouse_button_pressed(mouse::ButtonMiddle)) MousePan(delta); - else if (SInput::IsMouseButtonPressed(EMouse::ButtonLeft)) + else if (input::is_mouse_button_pressed(mouse::ButtonLeft)) MouseRotate(delta); - else if (SInput::IsMouseButtonPressed(EMouse::ButtonRight)) + else if (input::is_mouse_button_pressed(mouse::ButtonRight)) MouseZoom(delta.y); } UpdateView(); } - void CEditorCamera::OnEvent(CEvent& e) + void editor_camera::on_event(event& e) { - CEventDispatcher dispatcher(e); - dispatcher.Dispatch(BIND_FN(&CEditorCamera::OnMouseScroll)); + event_dispatcher dispatcher(e); + dispatcher.Dispatch(BIND_FN(&editor_camera::OnMouseScroll)); } - bool CEditorCamera::OnMouseScroll(CMouseScrolledEvent& e) + bool editor_camera::OnMouseScroll(mouse_scrolled_event& e) { - float delta = e.GetYOffset() * 0.1f; + float delta = e.get_y_offset() * 0.1f; MouseZoom(delta); UpdateView(); return false; } - void CEditorCamera::MousePan(const FGLMVec2& delta) + void editor_camera::MousePan(const vec2& delta) { auto [xSpeed, ySpeed] = PanSpeed(); - mFocalPoint += -GetRightDirection() * delta.x * xSpeed * mDistance; - mFocalPoint += GetUpDirection() * delta.y * ySpeed * mDistance; + focal_point_ += -get_right_direction() * delta.x * xSpeed * distance_; + focal_point_ += get_up_direction() * delta.y * ySpeed * distance_; } - void CEditorCamera::MouseRotate(const FGLMVec2& delta) + void editor_camera::MouseRotate(const vec2& delta) { - float yawSign = GetUpDirection().y < 0 ? -1.0f : 1.0f; - mYaw += yawSign * delta.x * RotationSpeed(); - mPitch += delta.y * RotationSpeed(); + float yawSign = get_up_direction().y < 0 ? -1.0f : 1.0f; + yaw_ += yawSign * delta.x * RotationSpeed(); + pitch_ += delta.y * RotationSpeed(); } - void CEditorCamera::MouseZoom(float delta) + void editor_camera::MouseZoom(float delta) { - mDistance -= delta * ZoomSpeed(); - if (mDistance < 1.0f) + distance_ -= delta * ZoomSpeed(); + if (distance_ < 1.0f) { - mFocalPoint += GetForwardDirection(); - mDistance = 1.0f; + focal_point_ += get_forward_direction(); + distance_ = 1.0f; } } - FGLMVec3 CEditorCamera::GetUpDirection() const + vec3 editor_camera::get_up_direction() const { - return glm::rotate(GetOrientation(), FGLMVec3(0.0f, 1.0f, 0.0f)); + return glm::rotate(get_orientation(), vec3(0.0f, 1.0f, 0.0f)); } - FGLMVec3 CEditorCamera::GetRightDirection() const + vec3 editor_camera::get_right_direction() const { - return glm::rotate(GetOrientation(), FGLMVec3(1.0f, 0.0f, 0.0f)); + return glm::rotate(get_orientation(), vec3(1.0f, 0.0f, 0.0f)); } - FGLMVec3 CEditorCamera::GetForwardDirection() const + vec3 editor_camera::get_forward_direction() const { - return glm::rotate(GetOrientation(), FGLMVec3(0.0f, 0.0f, -1.0f)); + return glm::rotate(get_orientation(), vec3(0.0f, 0.0f, -1.0f)); } - FGLMVec3 CEditorCamera::CalculatePosition() const + vec3 editor_camera::CalculatePosition() const { - return mFocalPoint - GetForwardDirection() * mDistance; + return focal_point_ - get_forward_direction() * distance_; } - glm::quat CEditorCamera::GetOrientation() const + glm::quat editor_camera::get_orientation() const { - return glm::quat(FGLMVec3(-mPitch, -mYaw, 0.0f)); + return glm::quat(vec3(-pitch_, -yaw_, 0.0f)); } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Scene/EditorCamera.h b/ARC-Engine/src/ARC/Scene/EditorCamera.h index 0558313d53..307e20e971 100644 --- a/ARC-Engine/src/ARC/Scene/EditorCamera.h +++ b/ARC-Engine/src/ARC/Scene/EditorCamera.h @@ -2,64 +2,64 @@ #include "ARC\Renderer\Camera.h" #include "ARC\Wrappers\Glm.h" -namespace ARC { class CEvent; } -namespace ARC { class CMouseScrolledEvent; } +namespace arc { class event; } +namespace arc { class mouse_scrolled_event; } -namespace ARC { +namespace arc { - class CEditorCamera : public CCamera + class editor_camera : public camera { public: - CEditorCamera() = default; - CEditorCamera(float fov, float aspectRatio, float nearClip, float farClip); + editor_camera() = default; + editor_camera(float fov, float aspectRatio, float nearClip, float farClip); - void OnUpdate(float ts); - void OnEvent(CEvent& e); + void on_update(float ts); + void on_event(event& e); - inline float GetDistance() const { return mDistance; } - inline void SetDistance(float distance) { mDistance = distance; } + inline float get_distance() const { return distance_; } + inline void set_distance(float distance) { distance_ = distance; } - inline void SetViewportSize(float width, float height) { mViewportWidth = width; mViewportHeight = height; UpdateProjection(); } + inline void set_viewport_size(float width, float height) { viewport_width_ = width; viewport_height_ = height; UpdateProjection(); } - const FGLMMat4& GetViewMatrix() const { return mViewMatrix; } - FGLMMat4 GetViewProjectionMatrix() const { return mProjection * mViewMatrix; } + const mat4& get_view_matrix() const { return view_matrix_; } + mat4 get_view_projection_matrix() const { return projection_ * view_matrix_; } - FGLMVec3 GetUpDirection() const; - FGLMVec3 GetRightDirection() const; - FGLMVec3 GetForwardDirection() const; - const FGLMVec3& GetPosition() const { return mPosition; } - glm::quat GetOrientation() const; + vec3 get_up_direction() const; + vec3 get_right_direction() const; + vec3 get_forward_direction() const; + const vec3& get_position() const { return position_; } + glm::quat get_orientation() const; - float GetPitch() const { return mPitch; } - float GetYaw() const { return mYaw; } + float get_pitch() const { return pitch_; } + float get_yaw() const { return yaw_; } private: void UpdateProjection(); void UpdateView(); - bool OnMouseScroll(CMouseScrolledEvent& e); + bool OnMouseScroll(mouse_scrolled_event& e); - void MousePan(const FGLMVec2& delta); - void MouseRotate(const FGLMVec2& delta); + void MousePan(const vec2& delta); + void MouseRotate(const vec2& delta); void MouseZoom(float delta); - FGLMVec3 CalculatePosition() const; + vec3 CalculatePosition() const; std::pair PanSpeed() const; float RotationSpeed() const; float ZoomSpeed() const; private: - float mFOV = 45.0f, mAspectRatio = 1.778f, mNearClip = 0.1f, mFarClip = 1000.0f; + float fov_ = 45.0f, aspect_ratio_ = 1.778f, near_clip_ = 0.1f, far_clip_ = 1000.0f; - FGLMMat4 mViewMatrix; - FGLMVec3 mPosition = { 0.0f, 0.0f, 0.0f }; - FGLMVec3 mFocalPoint = { 0.0f, 0.0f, 0.0f }; + mat4 view_matrix_; + vec3 position_ = { 0.0f, 0.0f, 0.0f }; + vec3 focal_point_ = { 0.0f, 0.0f, 0.0f }; - FGLMVec2 mInitialMousePosition = { 0.0f, 0.0f }; + vec2 initial_mouse_position_ = { 0.0f, 0.0f }; - float mDistance = 10.0f; - float mPitch = 0.0f, mYaw = 0.0f; + float distance_ = 10.0f; + float pitch_ = 0.0f, yaw_ = 0.0f; - float mViewportWidth = 1280, mViewportHeight = 720; + float viewport_width_ = 1280, viewport_height_ = 720; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Scene/Entity.h b/ARC-Engine/src/ARC/Scene/Entity.h index 7f9bdc2ad1..10735dd719 100644 --- a/ARC-Engine/src/ARC/Scene/Entity.h +++ b/ARC-Engine/src/ARC/Scene/Entity.h @@ -5,83 +5,83 @@ #include "Scene.h" #include "ARC/Core/UUID.h" -namespace ARC { class CScene; } -namespace ARC { class CEntity; } +namespace arc { class scene; } +namespace arc { class entity; } -namespace ARC { - using TEntityID = entt::entity; +namespace arc { + using entity_id = entt::entity; - class CEntity + class entity { public: - CEntity() =default; - CEntity(TEntityID pHandle, CScene* pScene) : mEntity(pHandle), mScene(pScene) {}; - CEntity(const CEntity&) = default; + entity() =default; + entity(entity_id pHandle, scene* pScene) : entity_(pHandle), scene_(pScene) {}; + entity(const entity&) = default; - TEntityID GetID() const { return mEntity; } - const TString& GetName() { return GetComponent().Name; } - TUUID GetUUID() { return GetComponent().ID; } + entity_id get_id() const { return entity_; } + const string& get_name() { return get_component().Name; } + uuid get_uuid() { return get_component().ID; } - bool IsValid() const + bool is_valid() const { - return mEntity != entt::null && mScene != nullptr; + return entity_ != entt::null && scene_ != nullptr; } template - void RemoveComponent() { - ARC_CORE_ASSERT(mScene && HasComponent()) - mScene->GetManager().remove(mEntity); + void remove_component() { + ARC_CORE_ASSERT(scene_ && has_component()) + scene_->get_manager().remove(entity_); } template - [[nodiscard]] inline bool HasComponent() const { - ARC_CORE_ASSERT(mScene); - return mScene && mScene->GetManager().all_of(mEntity); + [[nodiscard]] inline bool has_component() const { + ARC_CORE_ASSERT(scene_); + return scene_ && scene_->get_manager().all_of(entity_); } template - [[nodiscard]] inline T& GetComponent() { - ARC_CORE_ASSERT(mScene && HasComponent()); - auto& rval = mScene->GetManager().get(mEntity); + [[nodiscard]] inline T& get_component() { + ARC_CORE_ASSERT(scene_ && has_component()); + auto& rval = scene_->get_manager().get(entity_); return rval; } template - [[nodiscard]] inline T& GetComponent() const { - ARC_CORE_ASSERT(mScene && HasComponent()); - auto& rval = mScene->GetManager().get(mEntity); + [[nodiscard]] inline T& get_component() const { + ARC_CORE_ASSERT(scene_ && has_component()); + auto& rval = scene_->get_manager().get(entity_); return rval; } template - inline T& AddComponent(Ts&&... pArgs) { - ARC_CORE_ASSERT(mScene) - auto& comp = mScene->GetManager().emplace(mEntity, std::forward(pArgs)...); - comp.OnConstruct(*this); + inline T& add_component(Ts&&... pArgs) { + ARC_CORE_ASSERT(scene_) + auto& comp = scene_->get_manager().emplace(entity_, std::forward(pArgs)...); + comp.on_construct(*this); return comp; } void Kill() { - mScene->GetManager().destroy(mEntity); - OnKill(); + scene_->get_manager().destroy(entity_); + on_kill(); } - CEntity Duplicate() + entity Duplicate() { - return mScene->DuplicateEntity(*this); + return scene_->duplicate_entity(*this); } - operator bool() const { return mEntity != entt::null && mScene->GetManager().valid(mEntity); } - bool operator == (const CEntity _) const { return mEntity == _.mEntity && mScene == _.mScene; } - bool operator != (const CEntity _) const { return !(*this == _); } + operator bool() const { return entity_ != entt::null && scene_->get_manager().valid(entity_); } + bool operator == (const entity _) const { return entity_ == _.entity_ && scene_ == _.scene_; } + bool operator != (const entity _) const { return !(*this == _); } protected: - virtual void OnKill() + virtual void on_kill() { - mEntity = entt::null; - mScene = nullptr; + entity_ = entt::null; + scene_ = nullptr; } private: - TEntityID mEntity = entt::null; - CScene* mScene = nullptr; + entity_id entity_ = entt::null; + scene* scene_ = nullptr; - friend class CScene; + friend class scene; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Scene/PhysicsHandler.cpp b/ARC-Engine/src/ARC/Scene/PhysicsHandler.cpp index 0e316a174c..144a347b9d 100644 --- a/ARC-Engine/src/ARC/Scene/PhysicsHandler.cpp +++ b/ARC-Engine/src/ARC/Scene/PhysicsHandler.cpp @@ -1,63 +1,63 @@ #include "arc_pch.h" #include "PhysicsHandler.h" -namespace ARC { - void SPhysyicsHandler::ProjectVertices(std::vector& pA, FVec3 pAxis, OUT float& pMin, OUT float& pMax) { +namespace arc { + void physyics_handler::ProjectVertices(std::vector& pA, vec3 pAxis, OUT float& pMin, OUT float& pMax) { pMin = std::numeric_limits::max(); pMax = -std::numeric_limits::max(); for (auto _ : pA) { - auto proj = SMath::Dot(_, pAxis); + auto proj = math::Dot(_, pAxis); - pMin = SMath::Min(pMin, proj); - pMax = SMath::Max(pMax, proj); + pMin = math::Min(pMin, proj); + pMax = math::Max(pMax, proj); } }; - void SPhysyicsHandler::ProjectSphere(FVec3 pLoc, float pRadius, FVec3 pAxis, OUT float& pMin, OUT float& pMax) + void physyics_handler::ProjectSphere(vec3 pLoc, float pRadius, vec3 pAxis, OUT float& pMin, OUT float& pMax) { auto p1 = pLoc + pAxis.Normalize()*pRadius; auto p2 = pLoc - pAxis.Normalize()*pRadius; - auto d1 = SMath::Dot(p1, pAxis); - auto d2 = SMath::Dot(p2, pAxis); + auto d1 = math::Dot(p1, pAxis); + auto d2 = math::Dot(p2, pAxis); - pMin = SMath::Min(d1, d2); - pMax = SMath::Max(d1, d2); + pMin = math::Min(d1, d2); + pMax = math::Max(d1, d2); } - bool SPhysyicsHandler::IsCollidingSphere(FVec3 pLoc1, FVec3 pLoc2, float pRadiusSum, OUT FVec3& pNormal, OUT float& pDepth) + bool physyics_handler::is_colliding_sphere(vec3 pLoc1, vec3 pLoc2, float pRadiusSum, OUT vec3& pNormal, OUT float& pDepth) { - float dist = SMath::DistSqr(pLoc1, pLoc2); + float dist = math::DistSqr(pLoc1, pLoc2); - if (dist > SMath::Sqr(pRadiusSum)) return false; + if (dist > math::Sqr(pRadiusSum)) return false; - dist = SMath::Sqrt(dist); + dist = math::Sqrt(dist); pDepth = pRadiusSum-dist; pNormal = (pLoc2 - pLoc1) / dist; return true; } - bool SPhysyicsHandler::IsCollidingSphere(FVec3 pLoc1, FVec3 pLoc2, float pRadiusSum) + bool physyics_handler::is_colliding_sphere(vec3 pLoc1, vec3 pLoc2, float pRadiusSum) { - return SMath::DistSqr(pLoc1, pLoc2) <= SMath::Sqr(pRadiusSum); + return math::DistSqr(pLoc1, pLoc2) <= math::Sqr(pRadiusSum); } - bool SPhysyicsHandler::IsCollidingPolygon2D(std::vector& pA, std::vector& pB, OUT FVec3& pNormal, OUT float& pDepth) + bool physyics_handler::is_colliding_polygon2_d(std::vector& pA, std::vector& pB, OUT vec3& pNormal, OUT float& pDepth) { - pNormal = FVec3::ZeroVector(); + pNormal = vec3::ZeroVector(); pDepth = std::numeric_limits::max(); - auto fn = [&](std::vector& p1) -> bool { + auto fn = [&](std::vector& p1) -> bool { for (size_t i = 0; i < p1.size(); i++) { - FVec3 vi = p1[i]; - FVec3 vi2 = p1[(i + 1) % p1.size()]; + vec3 vi = p1[i]; + vec3 vi2 = p1[(i + 1) % p1.size()]; - FVec3 edge = vi2 - vi; - FVec3 axis = FVec3(-edge.y, edge.x, 0); + vec3 edge = vi2 - vi; + vec3 axis = vec3(-edge.y, edge.x, 0); float min, max, min2, max2; ProjectVertices(pA, axis, min, max); @@ -66,7 +66,7 @@ namespace ARC { if (min >= max2 || min2 >= max) return false; - float axisDepth = SMath::Min(max2 - min, max - min2); + float axisDepth = math::Min(max2 - min, max - min2); if (axisDepth < pDepth) { pDepth = axisDepth; @@ -82,7 +82,7 @@ namespace ARC { pDepth /= pNormal.Length(); pNormal = pNormal.Normalize(); - if (SMath::Dot( SMath::Mean(pB) - SMath::Mean(pA), pNormal ) < 0.f ) + if (math::Dot( math::Mean(pB) - math::Mean(pA), pNormal ) < 0.f ) { pNormal=pNormal*-1.f; } @@ -90,13 +90,13 @@ namespace ARC { return true; } - bool SPhysyicsHandler::IsCollidingPolygon2DVsSphere(std::vector& pA, FVec3 pSphereLoc, float pRadius, OUT FVec3& pNormal, OUT float& pDepth) + bool physyics_handler::is_colliding_polygon2_d_vs_sphere(std::vector& pA, vec3 pSphereLoc, float pRadius, OUT vec3& pNormal, OUT float& pDepth) { - pNormal = FVec3::ZeroVector(); + pNormal = vec3::ZeroVector(); pDepth = std::numeric_limits::max(); - auto fn = [&](FVec3 edge) -> bool { - FVec3 axis = FVec3(-edge.y, edge.x, 0); + auto fn = [&](vec3 edge) -> bool { + vec3 axis = vec3(-edge.y, edge.x, 0); float min, max, min2, max2; ProjectVertices(pA, axis, min, max); @@ -105,7 +105,7 @@ namespace ARC { if (min >= max2 || min2 >= max) return false; - float axisDepth = SMath::Min(max2 - min, max - min2); + float axisDepth = math::Min(max2 - min, max - min2); if (axisDepth < pDepth) { pDepth = axisDepth; @@ -124,7 +124,7 @@ namespace ARC { float MinDistSqr = std::numeric_limits::max(); for (int i = 0; i < pA.size(); i++) { - auto distSqr = SMath::DistSqr(pA[i], pSphereLoc); + auto distSqr = math::DistSqr(pA[i], pSphereLoc); if (MinDistSqr > distSqr) { ClossestPointIndex = i; @@ -137,7 +137,7 @@ namespace ARC { pDepth /= pNormal.Length(); pNormal = pNormal.Normalize(); - if (SMath::Dot(pSphereLoc - SMath::Mean(pA), pNormal) < 0.f) + if (math::Dot(pSphereLoc - math::Mean(pA), pNormal) < 0.f) { pNormal = pNormal * -1.f; } @@ -145,41 +145,41 @@ namespace ARC { return true; } - void SPhysyicsHandler::ClearOverlap(FVec3& pLHS, FVec3& pRHS, FVec3 pNormal, float pDepth) + void physyics_handler::ClearOverlap(vec3& pLHS, vec3& pRHS, vec3 pNormal, float pDepth) { pLHS -= pNormal * pDepth / 2.f; pRHS += pNormal * pDepth / 2.f; } - void SPhysyicsHandler::HandleLinearCollisionResponse(FVec3& pVelocity1, FVec3& pVelocity2, float pMass1, float pMass2, FVec3 pNormal, float pRestitution /*= 1.f*/) + void physyics_handler::HandleLinearCollisionResponse(vec3& pVelocity1, vec3& pVelocity2, float pMass1, float pMass2, vec3 pNormal, float pRestitution /*= 1.f*/) { - float j = -(1.f + pRestitution) * SMath::Dot((pVelocity2 - pVelocity1), pNormal) / (1 / pMass1 + 1 / pMass2); + float j = -(1.f + pRestitution) * math::Dot((pVelocity2 - pVelocity1), pNormal) / (1 / pMass1 + 1 / pMass2); pVelocity1 -= pNormal * j / pMass1; pVelocity2 += pNormal * j / pMass2; } - void SPhysyicsHandler::HandleAngularCollisionResponse(FVec3& pAngularVelocity1, FVec3& pAngularVelocity2, float pMass1, float pMass2, FVec3 pNormal, float pRestitution /*= 1.f*/) + void physyics_handler::HandleAngularCollisionResponse(vec3& pAngularVelocity1, vec3& pAngularVelocity2, float pMass1, float pMass2, vec3 pNormal, float pRestitution /*= 1.f*/) { } - void SPhysyicsHandler::UpdateFrameLinearVelocity(FTransform2D& pTrans, const FVec3& pVelocity, float pDeltaTime) + void physyics_handler::UpdateFrameLinearVelocity(transform_2d& pTrans, const vec3& pVelocity, float pDeltaTime) { pTrans.Location += pVelocity * pDeltaTime; } - void SPhysyicsHandler::UpdateFrameAngularVelocity(FTransform2D& pTrans, const FVec3& pAngularVelocity, float pDeltaTime) + void physyics_handler::UpdateFrameAngularVelocity(transform_2d& pTrans, const vec3& pAngularVelocity, float pDeltaTime) { pTrans.Rotation += pAngularVelocity.x * pDeltaTime; } - void SPhysyicsHandler::UpdateFrameAcceleration(FVec3& pVelocity, const FVec3& pAcceleration, float pDeltaTime) + void physyics_handler::UpdateFrameAcceleration(vec3& pVelocity, const vec3& pAcceleration, float pDeltaTime) { pVelocity += pAcceleration * pDeltaTime; } - void SPhysyicsHandler::UpdateFrameAngularAcceleration(FVec3& pAngularVelocity, const FVec3& pAngularAcceleration, float pDeltaTime) + void physyics_handler::UpdateFrameAngularAcceleration(vec3& pAngularVelocity, const vec3& pAngularAcceleration, float pDeltaTime) { pAngularVelocity += pAngularAcceleration * pDeltaTime; } diff --git a/ARC-Engine/src/ARC/Scene/PhysicsHandler.h b/ARC-Engine/src/ARC/Scene/PhysicsHandler.h index 4a40c2560e..6a807e8925 100644 --- a/ARC-Engine/src/ARC/Scene/PhysicsHandler.h +++ b/ARC-Engine/src/ARC/Scene/PhysicsHandler.h @@ -1,26 +1,26 @@ #pragma once -namespace ARC { - class SPhysyicsHandler +namespace arc { + class physyics_handler { public: - static void ProjectVertices(std::vector& pA, FVec3 pAxis, OUT float& pMin, OUT float& pMax); - static void ProjectSphere(FVec3 pLoc, float pRadius, FVec3 pAxis, OUT float& pMin, OUT float& pMax); + static void ProjectVertices(std::vector& pA, vec3 pAxis, OUT float& pMin, OUT float& pMax); + static void ProjectSphere(vec3 pLoc, float pRadius, vec3 pAxis, OUT float& pMin, OUT float& pMax); - static bool IsCollidingSphere(FVec3 pLoc1, FVec3 pLoc2, float pRadiusSum, OUT FVec3& pNormal, OUT float& pDepth); - static bool IsCollidingSphere(FVec3 pLoc1, FVec3 pLoc2, float pRadiusSum); - static bool IsCollidingPolygon2D(std::vector& pA, std::vector& pB, OUT FVec3& pNormal, OUT float& pDepth); //@TODO using 3d cause im lazy - static bool IsCollidingPolygon2DVsSphere(std::vector& pA, FVec3 pSphereLoc, float pRadius, OUT FVec3& pNormal, OUT float& pDepth); //@TODO using 3d cause im lazy - //static bool IsCollidingPolygon2D(std::vector& pA, std::vector& pB); + static bool is_colliding_sphere(vec3 pLoc1, vec3 pLoc2, float pRadiusSum, OUT vec3& pNormal, OUT float& pDepth); + static bool is_colliding_sphere(vec3 pLoc1, vec3 pLoc2, float pRadiusSum); + static bool is_colliding_polygon2_d(std::vector& pA, std::vector& pB, OUT vec3& pNormal, OUT float& pDepth); //@TODO using 3d cause im lazy + static bool is_colliding_polygon2_d_vs_sphere(std::vector& pA, vec3 pSphereLoc, float pRadius, OUT vec3& pNormal, OUT float& pDepth); //@TODO using 3d cause im lazy + //static bool IsCollidingPolygon2D(std::vector& pA, std::vector& pB); - static void ClearOverlap(FVec3& pLHS, FVec3& pRHS, FVec3 pNormal, float pDepth); + static void ClearOverlap(vec3& pLHS, vec3& pRHS, vec3 pNormal, float pDepth); - static void HandleLinearCollisionResponse(FVec3& pVelocity1, FVec3& pVelocity2, float pMass1, float pMass2, FVec3 pNormal, float pRestitution = 1.f); - static void HandleAngularCollisionResponse(FVec3& pAngularVelocity1, FVec3& pAngularVelocity2, float pMass1, float pMass2, FVec3 pNormal, float pRestitution = 1.f); + static void HandleLinearCollisionResponse(vec3& pVelocity1, vec3& pVelocity2, float pMass1, float pMass2, vec3 pNormal, float pRestitution = 1.f); + static void HandleAngularCollisionResponse(vec3& pAngularVelocity1, vec3& pAngularVelocity2, float pMass1, float pMass2, vec3 pNormal, float pRestitution = 1.f); - static void UpdateFrameLinearVelocity(FTransform2D& pTrans, const FVec3& pVelocity, float pDeltaTime); - static void UpdateFrameAngularVelocity(FTransform2D& pTrans, const FVec3& pAngularVelocity, float pDeltaTime); - static void UpdateFrameAcceleration(FVec3& pVelocity, const FVec3& pAcceleration, float pDeltaTime); - static void UpdateFrameAngularAcceleration(FVec3& pAngularVelocity, const FVec3& pAngularAcceleration, float pDeltaTime); + static void UpdateFrameLinearVelocity(transform_2d& pTrans, const vec3& pVelocity, float pDeltaTime); + static void UpdateFrameAngularVelocity(transform_2d& pTrans, const vec3& pAngularVelocity, float pDeltaTime); + static void UpdateFrameAcceleration(vec3& pVelocity, const vec3& pAcceleration, float pDeltaTime); + static void UpdateFrameAngularAcceleration(vec3& pAngularVelocity, const vec3& pAngularAcceleration, float pDeltaTime); }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Scene/Scene.cpp b/ARC-Engine/src/ARC/Scene/Scene.cpp index 8dcdfae4cc..abda1e3247 100644 --- a/ARC-Engine/src/ARC/Scene/Scene.cpp +++ b/ARC-Engine/src/ARC/Scene/Scene.cpp @@ -13,82 +13,82 @@ #include "box2d/b2_polygon_shape.h" #include "box2d/b2_circle_shape.h" -namespace ARC { - CScene::CScene() +namespace arc { + scene::scene() { - SSceneRegistry::SetupComponent(); - SSceneRegistry::SetupComponent(); - SSceneRegistry::SetupComponent(); - SSceneRegistry::SetupComponent(); - SSceneRegistry::SetupComponent(); - SSceneRegistry::SetupComponent(); - SSceneRegistry::SetupComponent(); - SSceneRegistry::SetupComponent(); - SSceneRegistry::SetupComponent(); - SSceneRegistry::SetupComponent(); + scene_registry::setup_component(); + scene_registry::setup_component(); + scene_registry::setup_component(); + scene_registry::setup_component(); + scene_registry::setup_component(); + scene_registry::setup_component(); + scene_registry::setup_component(); + scene_registry::setup_component(); + scene_registry::setup_component(); + scene_registry::setup_component(); } - CScene::~CScene() + scene::~scene() { - if (mPhysicsWorld) EndPhysics(); // just in case + if (physics_world_) end_physics(); // just in case } - TRef CScene::Copy(const TRef p) + ref scene::copy(const ref p) { - TRef cpy = CreateRef(); - cpy->mViewportSize = p->mViewportSize; + ref cpy = create_ref(); + cpy->viewport_size_ = p->viewport_size_; - p->mManager.view().each([=](auto iID, auto iUUID){ - cpy->DuplicateEntity(CEntity(iID, p.get())); + p->manager_.view().each([=](auto iID, auto iUUID){ + cpy->duplicate_entity(entity(iID, p.get())); }); return cpy; } - CEntity CScene::CreateEntity(const TString& pName, const TUUID pUUID) + entity scene::create_entity(const string& pName, const uuid pUUID) { - CEntity entity(mManager.create(), this); + entity entity(manager_.create(), this); - entity.AddComponent(pUUID); - entity.AddComponent(pName); + entity.add_component(pUUID); + entity.add_component(pName); return entity; } - void CScene::RemoveEntity(CEntity Entity) + void scene::remove_entity(entity Entity) { - mManager.destroy(Entity.GetID()); - Entity.OnKill(); + manager_.destroy(Entity.get_id()); + Entity.on_kill(); } - void CScene::OnUpdateEditor(float DeltaTime, CEditorCamera& pCamera) + void scene::on_update_editor(float DeltaTime, editor_camera& pCamera) { - SRenderer2D::BeginScene(pCamera); + renderer_2d::begin_scene(pCamera); RenderScene(); - SRenderer2D::EndScene(); + renderer_2d::end_scene(); } - void CScene::OnUpdateRuntime(float pDeltaTime) + void scene::on_update_runtime(float pDeltaTime) { - mManager.view().each([pDeltaTime](auto entity, auto& nativeScriptcomp) + manager_.view().each([pDeltaTime](auto entity, auto& nativeScriptcomp) { if (!nativeScriptcomp.Controller) { nativeScriptcomp.Controller = nativeScriptcomp.InstantiateDelegate(); - nativeScriptcomp.Controller->Setup(nativeScriptcomp.OwningEntity); - nativeScriptcomp.Controller->OnCreate(); + nativeScriptcomp.Controller->set_up(nativeScriptcomp.OwningEntity); + nativeScriptcomp.Controller->on_create(); } - nativeScriptcomp.Controller->OnUpdate(pDeltaTime); + nativeScriptcomp.Controller->on_update(pDeltaTime); }); - UpdatePhysics(pDeltaTime); + update_physics(pDeltaTime); - if (auto primaryCameraEntity = GetPrimaryCameraEntity()) + if (auto primaryCameraEntity = get_primary_camera_entity()) { - SRenderer2D::BeginScene(primaryCameraEntity.GetComponent().Camera, primaryCameraEntity.GetComponent().Transform); + renderer_2d::begin_scene(primaryCameraEntity.get_component().Camera, primaryCameraEntity.get_component().Transform); RenderScene(); - SRenderer2D::EndScene(); + renderer_2d::end_scene(); } //std::for_each(std::execution::par_unseq, view.begin(), view.end(), [&view](auto entity) { @@ -96,44 +96,44 @@ namespace ARC { // }); } - void CScene::OnUpdateSimulation(float pDeltaTime, CEditorCamera& pCamera) + void scene::on_update_simulation(float pDeltaTime, editor_camera& pCamera) { - SRenderer2D::BeginScene(pCamera); + renderer_2d::begin_scene(pCamera); RenderScene(); - UpdatePhysics(pDeltaTime); - SRenderer2D::EndScene(); + update_physics(pDeltaTime); + renderer_2d::end_scene(); } - void CScene::OnViewportResize(TVec2 pNewSize) + void scene::on_viewport_resize(vec2 pNewSize) { - mViewportSize = pNewSize; + viewport_size_ = pNewSize; - mManager.view().each([=](auto entity, auto& cameraComp) + manager_.view().each([=](auto entity, auto& cameraComp) { //if (cameraComp.bFixedAspectRatio) return @todo - cameraComp.Camera.SetViewportSize(pNewSize); + cameraComp.Camera.set_viewport_size(pNewSize); }); } - void CScene::BeginPhysics(){ - OnViewportResize(mViewportSize); - mPhysicsWorld = new b2World({ 0.0f, -9.8f }); - mManager.view().each([&](auto e, auto& transformComponent, auto& rigidBody2dComponent) { - CEntity entity = { e, this }; + void scene::begin_physics(){ + on_viewport_resize(viewport_size_); + physics_world_ = new b2World({ 0.0f, -9.8f }); + manager_.view().each([&](auto e, auto& transformComponent, auto& rigidBody2dComponent) { + entity entity = { e, this }; b2BodyDef bodyDef; bodyDef.type = (b2BodyType)rigidBody2dComponent.Type; bodyDef.position.Set(transformComponent.Transform.Location.x, transformComponent.Transform.Location.y); bodyDef.angle = transformComponent.Transform.Rotation; bodyDef.fixedRotation = rigidBody2dComponent.bFixedRotation; - auto* body = mPhysicsWorld->CreateBody(&bodyDef); + auto* body = physics_world_->CreateBody(&bodyDef); rigidBody2dComponent.RuntimeBody = body; - if (entity.HasComponent()) + if (entity.has_component()) { - auto& colliderComponent = entity.GetComponent(); + auto& colliderComponent = entity.get_component(); b2PolygonShape boxShape; - boxShape.SetAsBox( - transformComponent.Transform.Scale.x * colliderComponent.Size.x, - transformComponent.Transform.Scale.y * colliderComponent.Size.y + boxShape.set_as_box( + transformComponent.Transform.Scale.x * colliderComponent.size.x, + transformComponent.Transform.Scale.y * colliderComponent.size.y ); b2FixtureDef fixureDef; @@ -145,9 +145,9 @@ namespace ARC { colliderComponent.RuntimeFixture = body->CreateFixture(&fixureDef); } - if (entity.HasComponent()) + if (entity.has_component()) { - auto& colliderComponent = entity.GetComponent(); + auto& colliderComponent = entity.get_component(); b2CircleShape circleShape; circleShape.m_p.Set(colliderComponent.Offset.x, colliderComponent.Offset.y); circleShape.m_radius = colliderComponent.Radius * transformComponent.Transform.Scale.x; @@ -164,27 +164,27 @@ namespace ARC { }); } - void CScene::EndPhysics() + void scene::end_physics() { - delete mPhysicsWorld; - mPhysicsWorld = nullptr; + delete physics_world_; + physics_world_ = nullptr; } - void CScene::RenderScene() + void scene::RenderScene() { - mManager.group(entt::get).each([](auto entity, auto& transformComp, auto& spriteRendererComp) + manager_.group(entt::get).each([](auto entity, auto& transformComp, auto& spriteRendererComp) { - static CPrimitive2D Quad; + static primitive_2d Quad; Quad.Color = spriteRendererComp.Color; Quad.Texture = spriteRendererComp.Texture; Quad.TextureScaling = spriteRendererComp.TextureScaling; Quad.Transform = transformComp; - Quad.TransparencyLevel = (Quad.Texture || !SMath::IsEqual(Quad.Color.a, 1.f, 0.01f)) ? ETransparencyType::Translucent : ETransparencyType::Opaque; - SRenderer2D::DrawQuad(Quad, int(entity)); + Quad.TransparencyLevel = (Quad.Texture || !math::is_equal(Quad.Color.a, 1.f, 0.01f)) ? transparency_type::Translucent : transparency_type::Opaque; + renderer_2d::draw_quad(Quad, int(entity)); }); - mManager.view().each([](auto entity, auto& transformComp, auto& circleRendererComp) + manager_.view().each([](auto entity, auto& transformComp, auto& circleRendererComp) { - SRenderer2D::DrawCircle( + renderer_2d::draw_circle( transformComp.Transform.Location, transformComp.Transform.Rotation, transformComp.Transform.Scale, @@ -195,15 +195,15 @@ namespace ARC { }); } - void CScene::UpdatePhysics(float pDeltaTime) + void scene::update_physics(float pDeltaTime) { - mPhysicsWorld->Step(pDeltaTime, 6, 2); /// expose to editor - mManager.view().each([&](auto e, auto& transformComponent, auto& rb2dComponent) { - CEntity entity = {e, this}; + physics_world_->Step(pDeltaTime, 6, 2); /// expose to editor + manager_.view().each([&](auto e, auto& transformComponent, auto& rb2dComponent) { + entity entity = {e, this}; b2Body* body = (b2Body*)rb2dComponent.RuntimeBody; - transformComponent.Transform.Location.x = body->GetPosition().x; - transformComponent.Transform.Location.y = body->GetPosition().y; - transformComponent.Transform.Rotation = body->GetAngle(); + transformComponent.Transform.Location.x = body->get_position().x; + transformComponent.Transform.Location.y = body->get_position().y; + transformComponent.Transform.Rotation = body->get_angle(); }); } @@ -213,22 +213,22 @@ namespace ARC { * Play=2, * Simulate=3 */ - void CScene::OnSetSceneState(TUInt8 pCurrentSceneState, TUInt8 pNewSceneState) + void scene::on_set_scene_state(u8 pCurrentSceneState, u8 pNewSceneState) { switch (pCurrentSceneState) { case 0: break; case 1: - //End Edit + //end Edit break; case 2: - //End Play - EndPhysics(); + //end Play + end_physics(); break; case 3: - //End Simulate - EndPhysics(); + //end Simulate + end_physics(); default: ARC_CORE_ASSERT("Invalid (Current) Scene State"); } @@ -241,12 +241,12 @@ namespace ARC { break; case 2: //Start Play - BeginPhysics(); + begin_physics(); break; case 3: //Start Simulate - BeginPhysics(); + begin_physics(); break; default: @@ -254,20 +254,20 @@ namespace ARC { } } - void CScene::SerializeEntity(YAML::Emitter& pOut, CEntity pEntity) + void scene::serialize_entity(YAML::Emitter& pOut, entity pEntity) { pOut << YAML::BeginMap; - pOut << YAML::Key << "Entity" << YAML::Value << pEntity.GetComponent().ID; // @TODO + pOut << YAML::Key << "Entity" << YAML::Value << pEntity.get_component().ID; // @TODO pOut << YAML::Key << "Components" << YAML::Value << YAML::BeginSeq; - for (auto& compMeta : SSceneRegistry::GetMetaComponents()) - if (auto* compPtr = compMeta.second.GetComponent(pEntity)) - if (compPtr->GetFlags() & ECF::EComponentFlags::Serializable) + for (auto& compMeta : scene_registry::get_meta_components()) + if (auto* compPtr = compMeta.second.get_component(pEntity)) + if (compPtr->get_flags() & ecf::component_flags::Serializable) { pOut << YAML::BeginMap; - pOut << YAML::Key << "Name" << YAML::Value << compMeta.second.GetName(); + pOut << YAML::Key << "Name" << YAML::Value << compMeta.second.get_name(); pOut << YAML::Key << "Data" << YAML::Value << YAML::BeginMap; - compPtr->Serialize(pOut); + compPtr->serialize(pOut); pOut << YAML::EndMap; pOut << YAML::EndMap; } @@ -276,19 +276,19 @@ namespace ARC { pOut << YAML::EndMap; } - void CScene::SerializeToText(const std::filesystem::path& pFilepath) + void scene::serialize_to_text(const std::filesystem::path& pFilepath) { YAML::Emitter out; out << YAML::BeginMap; out << YAML::Key << "Scene" << YAML::Value << "Untitled"; out << YAML::Key << "Entities" << YAML::Value << YAML::BeginSeq; - mManager.each([&](const TEntityID pEID) + manager_.each([&](const entity_id pEID) { - CEntity entity = { pEID, this }; + entity entity = { pEID, this }; if (!entity) return; - CScene::SerializeEntity(out, entity); + scene::serialize_entity(out, entity); }); out << YAML::EndSeq; @@ -298,49 +298,49 @@ namespace ARC { fout << out.c_str(); } - void CScene::SerializeToBinary(const std::filesystem::path& pFilepath) + void scene::serialize_to_binary(const std::filesystem::path& pFilepath) { } - bool CScene::DeserializeFromText(const std::filesystem::path& pFilepath) + bool scene::deserialize_from_text(const std::filesystem::path& pFilepath) { YAML::Node data = YAML::LoadFile(pFilepath.string()); if (!data["Scene"]) return false; - TString SceneName = data["Scene"].as(); + string SceneName = data["Scene"].as(); auto entities = data["Entities"]; for (auto entity : entities) { - CEntity deserializedEntity = CreateEntity("Entity", entity["Entity"].as()); + entity deserializedEntity = create_entity("Entity", entity["Entity"].as()); for (auto compData : entity["Components"]) { auto Node = compData["Data"]; - if (compData["Name"].as() == SComponentTraits::GetName()) { - deserializedEntity.GetComponent().Deserialize(Node); + if (compData["Name"].as() == component_traits::get_name()) { + deserializedEntity.get_component().deserialize(Node); continue; } - auto compName = compData["Name"].as(); + auto compName = compData["Name"].as(); - SSceneRegistry::GetMetaComponents()[SSceneRegistry::GetRegisteredComponentNameIDMap()[compData["Name"].as()]].AddComponent(deserializedEntity)->Deserialize(Node); + scene_registry::get_meta_components()[scene_registry::get_registered_component_name_id_map()[compData["Name"].as()]].add_component(deserializedEntity)->deserialize(Node); } } return true; } - bool CScene::DeserializeFromBinary(const std::filesystem::path& pFilepath) + bool scene::deserialize_from_binary(const std::filesystem::path& pFilepath) { return false; } - CEntity CScene::GetPrimaryCameraEntity() + entity scene::get_primary_camera_entity() { - CEntity rval; - mManager.view().each([&](auto entity, auto& transformComp, auto& cameraComp) + entity rval; + manager_.view().each([&](auto entity, auto& transformComp, auto& cameraComp) { if (cameraComp.Primary) { @@ -351,12 +351,12 @@ namespace ARC { return rval; } - CEntity CScene::DuplicateEntity(CEntity pSrcEntity) + entity scene::duplicate_entity(entity pSrcEntity) { - auto dstEntity = CreateEntity(pSrcEntity.GetName(), pSrcEntity.GetUUID()); - for (auto i : SSceneRegistry::GetMetaComponents()) { - if (i.first == SComponentTraits::GetID() || i.first == SComponentTraits::GetID()) continue; - i.second.CopyComponent(dstEntity, pSrcEntity); + auto dstEntity = create_entity(pSrcEntity.get_name(), pSrcEntity.get_uuid()); + for (auto i : scene_registry::get_meta_components()) { + if (i.first == component_traits::get_id() || i.first == component_traits::get_id()) continue; + i.second.copy_component(dstEntity, pSrcEntity); } return dstEntity; } diff --git a/ARC-Engine/src/ARC/Scene/Scene.h b/ARC-Engine/src/ARC/Scene/Scene.h index dfd1762002..05d2fc3863 100644 --- a/ARC-Engine/src/ARC/Scene/Scene.h +++ b/ARC-Engine/src/ARC/Scene/Scene.h @@ -7,68 +7,68 @@ class b2World; -namespace ARC { +namespace arc { - using SManager = entt::registry; + using manager = entt::registry; - class CEditorCamera; - class CEntity; + class editor_camera; + class entity; - class CScene + class scene { public: - CScene(); - ~CScene(); + scene(); + ~scene(); - static TRef Copy(const TRef p); + static ref copy(const ref p); - CEntity CreateEntity(const TString& pName = "Entity", const TUUID pUUID = SUUID::Generate()); - void RemoveEntity(CEntity Entity); + entity create_entity(const string& pName = "Entity", const uuid pUUID = uuid::generate()); + void remove_entity(entity Entity); - inline size_t GetEntityCount() const { return mManager.alive(); } + inline size_t get_entity_count() const { return manager_.alive(); } - inline SManager& GetManager() { return mManager; } - inline const SManager& GetManager() const { return mManager; } + inline manager& get_manager() { return manager_; } + inline const manager& get_manager() const { return manager_; } - void OnUpdateEditor(float DeltaTime, CEditorCamera& pCamera); - void OnUpdateRuntime(float DeltaTime); - void OnUpdateSimulation(float pDeltaTime, CEditorCamera& pCamera); + void on_update_editor(float DeltaTime, editor_camera& pCamera); + void on_update_runtime(float DeltaTime); + void on_update_simulation(float pDeltaTime, editor_camera& pCamera); - void OnViewportResize(TVec2 pNewSize); - void OnSetSceneState(TUInt8 pCurrentSceneState, TUInt8 pNewSceneState); // Raw ESceneState + void on_viewport_resize(vec2 pNewSize); + void on_set_scene_state(u8 pCurrentSceneState, u8 pNewSceneState); // Raw scene_state - void SerializeToText(const std::filesystem::path& pFilepath); - void SerializeToBinary(const std::filesystem::path& pFilepath); - bool DeserializeFromText(const std::filesystem::path& pFilepath); - bool DeserializeFromBinary(const std::filesystem::path& pFilepath); + void serialize_to_text(const std::filesystem::path& pFilepath); + void serialize_to_binary(const std::filesystem::path& pFilepath); + bool deserialize_from_text(const std::filesystem::path& pFilepath); + bool deserialize_from_binary(const std::filesystem::path& pFilepath); template - decltype(auto) FilterByComponents() { return mManager.view(); } + decltype(auto) FilterByComponents() { return manager_.view(); } - inline decltype(auto) GetViewportSize() { return mViewportSize; } + inline decltype(auto) get_viewport_size() { return viewport_size_; } - CEntity GetPrimaryCameraEntity(); - CEntity DuplicateEntity(CEntity pSrcEntity); + entity get_primary_camera_entity(); + entity duplicate_entity(entity pSrcEntity); private: - void BeginPhysics(); - void EndPhysics(); + void begin_physics(); + void end_physics(); void RenderScene(); - void UpdatePhysics(float pDeltaTime); + void update_physics(float pDeltaTime); - void SerializeEntity(YAML::Emitter& pOut, CEntity pEntity); - void DeserializeEntity(YAML::Emitter& pOut, CEntity pEntity); + void serialize_entity(YAML::Emitter& pOut, entity pEntity); + void DeserializeEntity(YAML::Emitter& pOut, entity pEntity); public: private: - TVec2 mViewportSize; + vec2 viewport_size_; - SManager mManager; - b2World* mPhysicsWorld = nullptr; + manager manager_; + b2World* physics_world_ = nullptr; - TDelegate mTreeNodeBeginFunc; - TDelegate mTreeNodeEndFunc; + delegate tree_node_begin_func_; + delegate tree_node_end_func_; - friend class CSceneHierarchyPanel; + friend class scene_hierarchy_panel; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Scene/SceneCamera.cpp b/ARC-Engine/src/ARC/Scene/SceneCamera.cpp index d31b3ccc08..d4c0b39752 100644 --- a/ARC-Engine/src/ARC/Scene/SceneCamera.cpp +++ b/ARC-Engine/src/ARC/Scene/SceneCamera.cpp @@ -2,53 +2,53 @@ #include "SceneCamera.h" #include "glm\ext\matrix_clip_space.inl" -namespace ARC { +namespace arc { - CSceneCamera::CSceneCamera() + scene_camera::scene_camera() { RecalculateProjection(); } - void CSceneCamera::SetOrthographic(float pSize, float pNearClip, float pFarClip) + void scene_camera::set_orthographic(float pSize, float pNearClip, float pFarClip) { - mCurrentProjectionType = EProjectionType::Orthographic; - mOrthographicSize = pSize; - mOrthographicNear = pNearClip; - mOrthographicFar = pFarClip; + current_projection_type_ = projection_type::Orthographic; + orthographic_size_ = pSize; + orthographic_near_ = pNearClip; + orthographic_far_ = pFarClip; RecalculateProjection(); } - void CSceneCamera::SetPerspective(float pFOV, float pNearClip, float pFarClip) + void scene_camera::set_perspective(float pFOV, float pNearClip, float pFarClip) { - mCurrentProjectionType = EProjectionType::Perspective; - mPerspectiveFOV = pFOV; - mPerspectiveNear = pNearClip; - mPerspectiveFar = pFarClip; + current_projection_type_ = projection_type::Perspective; + perspective_fov_ = pFOV; + perspective_near_ = pNearClip; + perspective_far_ = pFarClip; RecalculateProjection(); } - void CSceneCamera::SetViewportSize(TVec2 pSize) + void scene_camera::set_viewport_size(vec2 pSize) { - mAspectRatio = (float)pSize.x / (float)pSize.y; + aspect_ratio_ = (float)pSize.x / (float)pSize.y; RecalculateProjection(); } - void CSceneCamera::RecalculateProjection() + void scene_camera::RecalculateProjection() { - switch (mCurrentProjectionType) + switch (current_projection_type_) { - case EProjectionType::Orthographic: + case projection_type::Orthographic: { - float orthoLeft = -mOrthographicSize * mAspectRatio * 0.5f; - float orthoRight = mOrthographicSize * mAspectRatio * 0.5f; - float orthoBottom = -mOrthographicSize * 0.5f; - float orthoTop = mOrthographicSize * 0.5f; - mProjection = glm::ortho(orthoLeft, orthoRight, orthoBottom, orthoTop, mOrthographicNear, mOrthographicFar); + float orthoLeft = -orthographic_size_ * aspect_ratio_ * 0.5f; + float orthoRight = orthographic_size_ * aspect_ratio_ * 0.5f; + float orthoBottom = -orthographic_size_ * 0.5f; + float orthoTop = orthographic_size_ * 0.5f; + projection_ = glm::ortho(orthoLeft, orthoRight, orthoBottom, orthoTop, orthographic_near_, orthographic_far_); break; } - case EProjectionType::Perspective: + case projection_type::Perspective: { - mProjection = glm::perspective(mPerspectiveFOV, mAspectRatio, mPerspectiveNear, mPerspectiveFar); + projection_ = glm::perspective(perspective_fov_, aspect_ratio_, perspective_near_, perspective_far_); break; } default: diff --git a/ARC-Engine/src/ARC/Scene/SceneCamera.h b/ARC-Engine/src/ARC/Scene/SceneCamera.h index b7005a29c5..1ec216d1f1 100644 --- a/ARC-Engine/src/ARC/Scene/SceneCamera.h +++ b/ARC-Engine/src/ARC/Scene/SceneCamera.h @@ -1,53 +1,53 @@ #pragma once #include "ARC\Renderer\Camera.h" -namespace ARC +namespace arc { - struct CSceneCamera : public CCamera + struct scene_camera : public camera { public: - enum class EProjectionType { Perspective, Orthographic }; + enum class projection_type { Perspective, Orthographic }; - CSceneCamera(); - virtual ~CSceneCamera() = default; + scene_camera(); + virtual ~scene_camera() = default; - EProjectionType GetProjectionType() const { return mCurrentProjectionType; } - void SetViewportSize(TVec2 p_NewSize); + projection_type get_projection_type() const { return current_projection_type_; } + void set_viewport_size(vec2 new_size); - void SetOrthographic(float pSize, float pNearClip, float pFarClip); - void SetPerspective(float pFOV, float pNearClip, float pFarClip); + void set_orthographic(float pSize, float pNearClip, float pFarClip); + void set_perspective(float pFOV, float pNearClip, float pFarClip); - float GetOrthographicSize() const { return mOrthographicSize; } - float GetOrthographicNearClip() const { return mOrthographicNear; } - float GetOrthographicFarClip() const { return mOrthographicFar; } + float get_orthographic_size() const { return orthographic_size_; } + float get_orthographic_near_clip() const { return orthographic_near_; } + float get_orthographic_far_clip() const { return orthographic_far_; } - float GetPerspectiveFOV() const { return mPerspectiveFOV; } - float GetPerspectiveNearClip() const { return mPerspectiveNear; } - float GetPerspectiveFarClip() const { return mPerspectiveFar; } + float get_perspective_fov() const { return perspective_fov_; } + float get_perspective_near_clip() const { return perspective_near_; } + float get_perspective_far_clip() const { return perspective_far_; } - void SetProjectionType(EProjectionType pProjectionType) { mCurrentProjectionType = pProjectionType; RecalculateProjection(); } + void set_projection_type(projection_type pProjectionType) { current_projection_type_ = pProjectionType; RecalculateProjection(); } - void SetOrthographicSize(float _) { mOrthographicSize = _; RecalculateProjection(); } - void SetOrthographicNearClip(float _) { mOrthographicNear = _; RecalculateProjection(); } - void SetOrthographicFarClip(float _) { mOrthographicFar = _; RecalculateProjection(); } + void set_orthographic_size(float _) { orthographic_size_ = _; RecalculateProjection(); } + void set_orthographic_near_clip(float _) { orthographic_near_ = _; RecalculateProjection(); } + void set_orthographic_far_clip(float _) { orthographic_far_ = _; RecalculateProjection(); } - void SetPerspectiveFOV(float _) { mPerspectiveFOV = _; RecalculateProjection(); } - void SetPerspectiveNearClip(float _) { mPerspectiveNear = _; RecalculateProjection(); } - void SetPerspectiveFarClip(float _) { mPerspectiveFar = _; RecalculateProjection(); } + void set_perspective_fov(float _) { perspective_fov_ = _; RecalculateProjection(); } + void set_perspective_near_clip(float _) { perspective_near_ = _; RecalculateProjection(); } + void set_perspective_far_clip(float _) { perspective_far_ = _; RecalculateProjection(); } private: void RecalculateProjection(); private: - EProjectionType mCurrentProjectionType = EProjectionType::Orthographic; + projection_type current_projection_type_ = projection_type::Orthographic; - float mOrthographicSize = 16.0f; - float mOrthographicNear = -1.0f; - float mOrthographicFar = 1.0f; + float orthographic_size_ = 16.0f; + float orthographic_near_ = -1.0f; + float orthographic_far_ = 1.0f; - float mPerspectiveFOV = SMath::Conv(45.f); - float mPerspectiveNear = 0.01f; - float mPerspectiveFar = 1.f; + float perspective_fov_ = math::Conv(45.f); + float perspective_near_ = 0.01f; + float perspective_far_ = 1.f; - float mAspectRatio = 0.f; + float aspect_ratio_ = 0.f; }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Scene/SceneRegistry.h b/ARC-Engine/src/ARC/Scene/SceneRegistry.h index 7e806e5a9a..eb68bbafdf 100644 --- a/ARC-Engine/src/ARC/Scene/SceneRegistry.h +++ b/ARC-Engine/src/ARC/Scene/SceneRegistry.h @@ -3,33 +3,33 @@ #include "ARC/Scene/Scene.h" #include "ARC/Scene/Entity.h" -namespace ARC { +namespace arc { - struct SComponentTraits + struct component_traits { template static constexpr inline - bool IsComponent() { return std::is_base_of_v; } + bool is_component() { return std::is_base_of_v; } template static constexpr inline - decltype(auto) GetName() + decltype(auto) get_name() { - static_assert(IsComponent()); - return SHPR::GetClassName(); + static_assert(is_component()); + return shpr::get_class_name(); } template static inline - auto& GetFlags() + auto& get_flags() { - static_assert(IsComponent()); + static_assert(is_component()); return T::Flags; } template static constexpr const inline - auto GetID() noexcept { + auto get_id() noexcept { static const auto value = ItrlCounter(); return value; } @@ -37,78 +37,78 @@ namespace ARC { private: static inline auto ItrlCounter() noexcept { - static TUInt32 value = 0; + static u32 value = 0; return value++; } }; - struct SSceneRegistry + struct scene_registry { - struct SMetaComponent { - TDelegate RemoveComponent; - TDelegate GetComponent; - TDelegate AddComponent; - TDelegate CopyComponent; - TDelegate GetFlags; - TDelegate GetName; + struct meta_component { + delegate remove_component; + delegate get_component; + delegate add_component; + delegate copy_component; + delegate get_flags; + delegate get_name; }; template - static void SetupComponent() + static void setup_component() { static bool bRet = false; if(bRet) return; bRet = true; - const TString& compName = SComponentTraits::GetName(); - const auto compID = SComponentTraits::GetID(); - mRegisteredComponentNames.push_back(compName); - mRegisteredComponentNameIDMap[compName] = compID; + const string& compName = component_traits::get_name(); + const auto compID = component_traits::get_id(); + registered_component_names_.push_back(compName); + registered_component_name_id_map_[compName] = compID; - auto& mc = mMetaComponents.emplace(compID, SMetaComponent()).first->second; - mc.GetComponent = [](CEntity pEntity) -> CComponentBase* { - static_assert(SComponentTraits::IsComponent()); - if (pEntity && pEntity.HasComponent()) - return &pEntity.GetComponent(); + auto& mc = meta_components_.emplace(compID, meta_component()).first->second; + mc.get_component = [](entity pEntity) -> component_base* { + static_assert(component_traits::is_component()); + if (pEntity && pEntity.has_component()) + return &pEntity.get_component(); return nullptr; }; - mc.AddComponent = [](CEntity pEntity) -> CComponentBase* { - static_assert(SComponentTraits::IsComponent()); - if (pEntity && !pEntity.HasComponent()) - return &pEntity.AddComponent(); + mc.add_component = [](entity pEntity) -> component_base* { + static_assert(component_traits::is_component()); + if (pEntity && !pEntity.has_component()) + return &pEntity.add_component(); return nullptr; }; - mc.RemoveComponent = [](CEntity pEntity) { - static_assert(SComponentTraits::IsComponent()); - if (pEntity && pEntity.HasComponent()) - pEntity.RemoveComponent(); + mc.remove_component = [](entity pEntity) { + static_assert(component_traits::is_component()); + if (pEntity && pEntity.has_component()) + pEntity.remove_component(); }; - mc.CopyComponent = [](CEntity pDstEntity, const CEntity pSrcEntity) -> CComponentBase* { - static_assert(SComponentTraits::IsComponent()); - if (pDstEntity && pSrcEntity && pSrcEntity.HasComponent()) - return &pDstEntity.AddComponent(pSrcEntity.GetComponent()); + mc.copy_component = [](entity pDstEntity, const entity pSrcEntity) -> component_base* { + static_assert(component_traits::is_component()); + if (pDstEntity && pSrcEntity && pSrcEntity.has_component()) + return &pDstEntity.add_component(pSrcEntity.get_component()); return nullptr; }; - mc.GetFlags = []() -> TUInt32& { - static_assert(SComponentTraits::IsComponent()); - return SComponentTraits::GetFlags(); + mc.get_flags = []() -> u32& { + static_assert(component_traits::is_component()); + return component_traits::get_flags(); }; - mc.GetName = []() { - static_assert(SComponentTraits::IsComponent()); - return SComponentTraits::GetName(); + mc.get_name = []() { + static_assert(component_traits::is_component()); + return component_traits::get_name(); }; }; - static auto& GetRegisteredComponentsNames() { return mRegisteredComponentNames; } - static auto& GetRegisteredComponentNameIDMap() { return mRegisteredComponentNameIDMap; } - static auto& GetMetaComponents() { return mMetaComponents; } + static auto& get_registered_components_names() { return registered_component_names_; } + static auto& get_registered_component_name_id_map() { return registered_component_name_id_map_; } + static auto& get_meta_components() { return meta_components_; } private: // @Editor functionality @ TODO wrap around macro - static inline std::vector mRegisteredComponentNames; - static inline std::unordered_map mRegisteredComponentNameIDMap; - static inline std::unordered_map mMetaComponents; + static inline std::vector registered_component_names_; + static inline std::unordered_map registered_component_name_id_map_; + static inline std::unordered_map meta_components_; }; diff --git a/ARC-Engine/src/ARC/Types/Array.h b/ARC-Engine/src/ARC/Types/Array.h index 41335f0a60..cf391722fd 100644 --- a/ARC-Engine/src/ARC/Types/Array.h +++ b/ARC-Engine/src/ARC/Types/Array.h @@ -1,26 +1,26 @@ #pragma once #include "TybeBase.h" -namespace ARC +namespace arc { namespace Base { - struct FArray_Base : public TTypeBase{}; + struct array_base : public type_base{}; } template - struct TArray : public FArray_Base + struct array : public array_base { /*--------------FUNCS--------------*/ public: - TArray(size_t p_cap = 5u) : mCap(p_cap); - ~TArray(); - TArray(const TArray& p_obj) + array(size_t p_cap = 5u) : cap_(p_cap); + ~array(); + array(const array& p_obj) T& operator[](const size_t p_index) - void Init(const T& p_from); - void Init(const size_t& p_from); + void init(const T& p_from); + void init(const size_t& p_from); void Expand(); void Push(); @@ -28,8 +28,8 @@ namespace ARC void Pop(const size_t& p_index); void Remove(); - virtual __forceinline const size_t& GetSize() const override { - return mLen; + virtual __forceinline const size_t& get_size() const override { + return len_; } protected: private: @@ -39,9 +39,9 @@ namespace ARC public: protected: private: - size_t mLen; - size_t mCap; - T** mArr; + size_t len_; + size_t cap_; + T** arr_; /*---------------------------------*/ }; }; \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Types/Color.h b/ARC-Engine/src/ARC/Types/Color.h index bdc792b99c..9fb128c5db 100644 --- a/ARC-Engine/src/ARC/Types/Color.h +++ b/ARC-Engine/src/ARC/Types/Color.h @@ -2,34 +2,34 @@ #include "Vector.h" -namespace ARC { +namespace arc { - namespace ETransparencyType { - enum ETransparencyType { + namespace transparency_type { + enum transparency_type { Opaque=1, Translucent=2, Transparent=3 }; } - using TTransparencyType = TUInt8; - class FColor4 : public FVec4 + using transparency_type = u8; + class color4 : public vec4 { public: - FColor4() : FVec4(FVec4::ZeroVector()) {} - FColor4(const FVec4& _) : FVec4(_) {}; - FColor4(float _r, float _g, float _b, float _a) : FVec4(_r, _g, _b, _a) {}; + color4() : vec4(vec4::ZeroVector()) {} + color4(const vec4& _) : vec4(_) {}; + color4(float _r, float _g, float _b, float _a) : vec4(_r, _g, _b, _a) {}; [[nodiscard]] static - const FColor4& White() { static FColor4 rval = FColor4(1.f); return rval; } + const color4& White() { static color4 rval = color4(1.f); return rval; } [[nodiscard]] static - const FColor4& Red() { static FColor4 rval = FColor4(1.f, 0.f, 0.f, 1.f); return rval; } + const color4& Red() { static color4 rval = color4(1.f, 0.f, 0.f, 1.f); return rval; } [[nodiscard]] static - const FColor4& Green() { static FColor4 rval = FColor4(0.f, 1.f, 0.f, 1.f); return rval; } + const color4& Green() { static color4 rval = color4(0.f, 1.f, 0.f, 1.f); return rval; } [[nodiscard]] static - const FColor4& Blue() { static FColor4 rval = FColor4(0.f, 0.f, 1.f, 1.f); return rval; } + const color4& Blue() { static color4 rval = color4(0.f, 0.f, 1.f, 1.f); return rval; } [[nodiscard]] static - const FColor4& Yellow() { static FColor4 rval = FColor4(1.f, 1.f, 0.f, 1.f); return rval; } + const color4& Yellow() { static color4 rval = color4(1.f, 1.f, 0.f, 1.f); return rval; } [[nodiscard]] static - const FColor4& Black() { static FColor4 rval = FColor4(0.f, 0.f, 0.f, 1.f); return rval; } + const color4& Black() { static color4 rval = color4(0.f, 0.f, 0.f, 1.f); return rval; } }; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Types/Delegate.h b/ARC-Engine/src/ARC/Types/Delegate.h index a7606b23d5..3514f75191 100644 --- a/ARC-Engine/src/ARC/Types/Delegate.h +++ b/ARC-Engine/src/ARC/Types/Delegate.h @@ -3,16 +3,16 @@ #include #include -namespace ARC { +namespace arc { template - class TDelegateBase; + class delegate_base; template - class TDelegate; + class delegate; template - class TMulticastDelegate; + class multicast_delegate; template - class TDelegateBase { + class delegate_base { protected: using stub_type = RET(*)(void* this_ptr, PARAMS...); @@ -36,61 +36,61 @@ namespace ARC { }; template - class TDelegate final : private TDelegateBase { + class delegate final : private delegate_base { public: - TDelegate() = default; + delegate() = default; operator bool() const { return invocation.Stub == nullptr; } bool operator ==(void* ptr) const { - return (ptr == nullptr) && this->IsNull(); + return (ptr == nullptr) && this->is_null(); } //operator == bool operator !=(void* ptr) const { - return (ptr != nullptr) || (!this->IsNull()); + return (ptr != nullptr) || (!this->is_null()); } //operator != - TDelegate(const TDelegate& another) { another.invocation.Clone(invocation); } + delegate(const delegate& another) { another.invocation.Clone(invocation); } template - TDelegate(const LAMBDA& lambda) { - Bind((void*)(&lambda), LambdaStub); - } //TDelegate + delegate(const LAMBDA& lambda) { + bind((void*)(&lambda), LambdaStub); + } //delegate - TDelegate& operator =(const TDelegate& another) { + delegate& operator =(const delegate& another) { another.invocation.Clone(invocation); return *this; } //operator = template // template instantiation is not needed, will be deduced (inferred): - TDelegate& operator =(const LAMBDA& instance) { - Bind((void*)(&instance), LambdaStub); + delegate& operator =(const LAMBDA& instance) { + bind((void*)(&instance), LambdaStub); return *this; } //operator = - bool operator == (const TDelegate& another) const { return invocation == another.invocation; } - bool operator != (const TDelegate& another) const { return invocation != another.invocation; } + bool operator == (const delegate& another) const { return invocation == another.invocation; } + bool operator != (const delegate& another) const { return invocation != another.invocation; } - bool operator ==(const TMulticastDelegate& another) const { return another == (*this); } - bool operator !=(const TMulticastDelegate& another) const { return another != (*this); } + bool operator ==(const multicast_delegate& another) const { return another == (*this); } + bool operator !=(const multicast_delegate& another) const { return another != (*this); } template - static TDelegate Create(T* instance) { - return TDelegate(instance, MethodStub); + static delegate create(T* instance) { + return delegate(instance, MethodStub); } template - static TDelegate Create(T const* instance) { - return TDelegate(const_cast(instance), ConstMethodStub); + static delegate create(T const* instance) { + return delegate(const_cast(instance), ConstMethodStub); } template - static TDelegate Create() { - return TDelegate(nullptr, FunctionStub); + static delegate create() { + return delegate(nullptr, FunctionStub); } template - static TDelegate Create(const LAMBDA& instance) { - return TDelegate((void*)(&instance), LambdaStub); + static delegate create(const LAMBDA& instance) { + return delegate((void*)(&instance), LambdaStub); } RET operator()(PARAMS... arg) const { @@ -99,12 +99,12 @@ namespace ARC { private: - TDelegate(void* anObject, typename TDelegateBase::stub_type aStub) { + delegate(void* anObject, typename delegate_base::stub_type aStub) { invocation.Object = anObject; invocation.Stub = aStub; } - void Bind(void* anObject, typename TDelegateBase::stub_type aStub) { + void bind(void* anObject, typename delegate_base::stub_type aStub) { this->invocation.Object = anObject; this->invocation.Stub = aStub; } @@ -132,19 +132,19 @@ namespace ARC { return (p->operator())(arg...); } - friend class TMulticastDelegate; - typename TDelegateBase::InvocationElement invocation; + friend class multicast_delegate; + typename delegate_base::InvocationElement invocation; }; template - class TMulticastDelegate final : private TDelegateBase { + class multicast_delegate final : private delegate_base { public: - TMulticastDelegate() = default; - ~TMulticastDelegate() { + multicast_delegate() = default; + ~multicast_delegate() { for (auto& element : invocationList) delete element; invocationList.clear(); - } //~TMulticastDelegate + } //~multicast_delegate operator bool() const { return invocationList.size() < 1; } bool operator ==(void* ptr) const { @@ -156,40 +156,40 @@ namespace ARC { size_t size() const { return invocationList.size(); } - TMulticastDelegate& operator =(const TMulticastDelegate&) = delete; - TMulticastDelegate(const TMulticastDelegate&) = delete; + multicast_delegate& operator =(const multicast_delegate&) = delete; + multicast_delegate(const multicast_delegate&) = delete; - bool operator ==(const TMulticastDelegate& another) const { + bool operator ==(const multicast_delegate& another) const { if (invocationList.size() != another.invocationList.size()) return false; auto anotherIt = another.invocationList.begin(); for (auto it = invocationList.begin(); it != invocationList.end(); ++it) if (**it != **anotherIt) return false; return true; } //== - bool operator !=(const TMulticastDelegate& another) const { return !(*this == another); } + bool operator !=(const multicast_delegate& another) const { return !(*this == another); } - bool operator ==(const TDelegate& another) const { + bool operator ==(const delegate& another) const { if (*this && another) return true; if (another || (size() != 1)) return false; return (another.invocation == **invocationList.begin()); } //== - bool operator !=(const TDelegate& another) const { return !(*this == another); } + bool operator !=(const delegate& another) const { return !(*this == another); } - TMulticastDelegate& operator +=(const TMulticastDelegate& another) { + multicast_delegate& operator +=(const multicast_delegate& another) { for (auto& item : another.invocationList) // clone, not copy; flattens hierarchy: - this->invocationList.push_back(new typename TDelegateBase::InvocationElement(item->Object, item->Stub)); + this->invocationList.push_back(new typename delegate_base::InvocationElement(item->Object, item->Stub)); return *this; } //operator += template // template instantiation is not neededm, will be deduced/inferred: - TMulticastDelegate& operator +=(const LAMBDA& lambda) { - TDelegate d = TDelegate::template create(lambda); + multicast_delegate& operator +=(const LAMBDA& lambda) { + delegate d = delegate::template create(lambda); return *this += d; } //operator += - TMulticastDelegate& operator +=(const TDelegate& another) { + multicast_delegate& operator +=(const delegate& another) { if (another) return *this; - this->invocationList.push_back(new typename TDelegateBase::InvocationElement(another.invocation.Object, another.invocation.Stub)); + this->invocationList.push_back(new typename delegate_base::InvocationElement(another.invocation.Object, another.invocation.Stub)); return *this; } //operator += @@ -210,7 +210,7 @@ namespace ARC { } //loop } //operator() - void operator()(PARAMS... arg, TDelegate handler) const { + void operator()(PARAMS... arg, delegate handler) const { operator() < decltype(handler) > (arg..., handler); } //operator() void operator()(PARAMS... arg, std::function handler) const { @@ -219,7 +219,7 @@ namespace ARC { private: - std::list::InvocationElement*> invocationList; + std::list::InvocationElement*> invocationList; - }; //class TMulticastDelegate + }; //class multicast_delegate } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Types/Pointer.h b/ARC-Engine/src/ARC/Types/Pointer.h index 6785d20ec1..7d2d6af680 100644 --- a/ARC-Engine/src/ARC/Types/Pointer.h +++ b/ARC-Engine/src/ARC/Types/Pointer.h @@ -1,19 +1,19 @@ #pragma once #include -namespace ARC { +namespace arc { template - using TRef = std::shared_ptr; + using ref = std::shared_ptr; template using TScope = std::unique_ptr; template - inline constexpr TRef CreateRef(TArgs&& ... _Args) { - return std::make_shared(std::forward(_Args)...); + inline constexpr ref create_ref(TArgs&& ... args) { + return std::make_shared(std::forward(args)...); } template - inline constexpr TScope CreateScope(TArgs&& ... _Args) { - return std::make_unique(std::forward(_Args)...); + inline constexpr TScope create_scope(TArgs&& ... args) { + return std::make_unique(std::forward(args)...); } } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Types/Transform2D.h b/ARC-Engine/src/ARC/Types/Transform2D.h index cfad0b4ce8..19024194fe 100644 --- a/ARC-Engine/src/ARC/Types/Transform2D.h +++ b/ARC-Engine/src/ARC/Types/Transform2D.h @@ -1,22 +1,22 @@ #pragma once #include "Vector.h" -namespace ARC { +namespace arc { template - class TTransform2D : public TTypeBase + class transform_2d : public type_base { ARC_TYPE(); public: - TTransform2D() : Location(TVec3::ZeroVector()), Rotation(0), Scale(TVec2::OneVector()) {} - TTransform2D(TVec3 _L, T _R, TVec2 _S) : Location(_L), Rotation(_R), Scale(_S) {} + transform_2d() : Location(vec3::ZeroVector()), Rotation(0), Scale(vec2::OneVector()) {} + transform_2d(vec3 l, T r, vec2 s) : Location(l), Rotation(r), Scale(s) {} - TVec3 Location; + vec3 Location; T Rotation; - TVec2 Scale; + vec2 Scale; - static const TTransform2D& DefaultTransform() { static TTransform2D s; return s; }; + static const transform_2d& default_transform() { static transform_2d s; return s; }; }; - using FTransform2D = TTransform2D; + using transform_2d = transform_2d; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Types/Transform3D.h b/ARC-Engine/src/ARC/Types/Transform3D.h index fb6ed80d80..20aa774d76 100644 --- a/ARC-Engine/src/ARC/Types/Transform3D.h +++ b/ARC-Engine/src/ARC/Types/Transform3D.h @@ -2,20 +2,20 @@ #include "Vector.h" #include "Transform2D.h" -namespace ARC { +namespace arc { template - class TTransform3D : public TTypeBase + class transform_3d : public type_base { ARC_TYPE(); public: - TTransform3D() : Location(TVec3::ZeroVector()), Rotation(TVec3::ZeroVector()), Scale(TVec3::OneVector()) {} - TTransform3D(const TVec3& _L, const TVec3& _R, const TVec3& _S) : Location(_L), Rotation(_R), Scale(_S) {} + transform_3d() : Location(vec3::ZeroVector()), Rotation(vec3::ZeroVector()), Scale(vec3::OneVector()) {} + transform_3d(const vec3& l, const vec3& r, const vec3& s) : Location(l), Rotation(r), Scale(s) {} - TVec3 Location; - TVec3 Rotation; - TVec3 Scale; + vec3 Location; + vec3 Rotation; + vec3 Scale; }; - using FTransform3D = TTransform3D; + using transform_3d = transform_3d; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Types/TybeBase.h b/ARC-Engine/src/ARC/Types/TybeBase.h index 6078580510..7098468c3b 100644 --- a/ARC-Engine/src/ARC/Types/TybeBase.h +++ b/ARC-Engine/src/ARC/Types/TybeBase.h @@ -4,25 +4,25 @@ #define ARC_TYPE() // public: template __T__ To() const { return HPR::template Conv<__T__>(*this); } private: -namespace ARC +namespace arc { - struct ARC_API TTypeBase + struct ARC_API type_base { protected: - TTypeBase() {}; + type_base() {}; }; - using TString = std::string; - using TName = const char*; // very temp + using string = std::string; + using name = const char*; // very temp - using TUInt = unsigned int; - using TUChar = unsigned char; - using TULong = unsigned long; + using uint = unsigned int; + using uchar = unsigned char; + using ulong = unsigned long; - using TUInt8 = uint8_t; - using TUInt16 = uint16_t; - using TUInt32 = uint32_t; - using TUInt64 = uint64_t; + using u8 = uint8_t; + using u16 = uint16_t; + using u32 = uint32_t; + using u64 = uint64_t; - using TFloat = float; + using float32 = float; } \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Types/Vector.h b/ARC-Engine/src/ARC/Types/Vector.h index a2244c394f..7fcf0d3fae 100644 --- a/ARC-Engine/src/ARC/Types/Vector.h +++ b/ARC-Engine/src/ARC/Types/Vector.h @@ -6,18 +6,18 @@ #include "ARC/Helpers/Math.h" #include "spdlog/spdlog.h" -namespace ARC +namespace arc { #define VM_FUNC [[nodiscard]] inline constexpr namespace Base { template - struct ARC_API TVec_Base : public TTypeBase { + struct ARC_API TVec_Base : public type_base { protected: TVec_Base() = default; public: - using Super = TTypeBase; + using Super = type_base; using value_type = T; using size_type = size_t; using type = TVec_Base; @@ -34,8 +34,8 @@ namespace ARC const value_type* begin() const { return (value_type*)this; } const value_type* end() const { return begin() + N; } - TString ToString() { - TString x = fmt::format("{}", *begin()) ; + string to_string() { + string x = fmt::format("{}", *begin()) ; for (size_t i = 1; i < N; i++) { x = fmt::format("{}, {}", x, (*this)[i]); @@ -45,23 +45,23 @@ namespace ARC }; } template - class ARC_API TVec : public Base::TVec_Base + class ARC_API vec : public Base::TVec_Base { public: using value_type = T; using Super = typename Base::TVec_Base; - using type = TVec; + using type = vec; using type_float = typename std::common_type::type; using size_type = size_t; - TVec() : mData() {}; - TVec(const value_type* _) : mData(_) {}; - TVec(const value_type& _) { for (auto& iv : *this) iv=_; }; + vec() : data_() {}; + vec(const value_type* _) : data_(_) {}; + vec(const value_type& _) { for (auto& iv : *this) iv=_; }; - TVec(value_type pData[N]) : mData(pData) {} + vec(value_type pData[N]) : data_(pData) {} - value_type& operator[](size_type _) { return mData[_]; }; - const value_type& operator[](size_type _) const { return mData[_]; }; + value_type& operator[](size_type _) { return data_[_]; }; + const value_type& operator[](size_type _) const { return data_[_]; }; constexpr bool operator==(const type& _) { @@ -113,35 +113,35 @@ namespace ARC constexpr type operator*(const value_type& _) const { return *this*type(_); } constexpr type operator/(const value_type& _) const { return *this/type(_); } - inline value_type* Data() { return mData; } - inline const value_type* Data() const { return mData; } + inline value_type* Data() { return data_; } + inline const value_type* Data() const { return data_; } private: - value_type mData[N]; + value_type data_[N]; }; template - class ARC_API TVec<1, T> : public Base::TVec_Base + class ARC_API vec<1, T> : public Base::TVec_Base { public: using Super = Base::TVec_Base; using value_type = T; - using type = TVec<1, value_type>; + using type = vec<1, value_type>; using type_float = typename std::common_type::type; using size_type = size_t; union { value_type x, r; }; - TVec() {} - TVec(const value_type& _x) : x(_x){} + vec() {} + vec(const value_type& _x) : x(_x){} - void DrawGuiControl(const char* ID, float pColumnWidth); + void draw_gui_control(const char* ID, float pColumnWidth); - VM_FUNC type_float Dist(const type& _) const { return SMath::Abs(_-*this); } + VM_FUNC type_float Dist(const type& _) const { return math::Abs(_-*this); } VM_FUNC type_float Length() const { return *this; } VM_FUNC type Normalize() const { return this / Length(); } - VM_FUNC bool AlmostEqual(const type& _, float _Tollerance) const { return SMath::IsEqual(this, _, _Tollerance); } + VM_FUNC bool AlmostEqual(const type& _, float tollerance) const { return math::is_equal(this, _, tollerance); } [[nodiscard]] static const type& ZeroVector() { static type rval = type(0); return rval; } @@ -150,7 +150,7 @@ namespace ARC }; template - class ARC_API TVec<2, T> : public Base::TVec_Base + class ARC_API vec<2, T> : public Base::TVec_Base { ARC_TYPE(); @@ -159,16 +159,16 @@ namespace ARC using Super = Base::TVec_Base; using value_type = T; - using type = TVec<2, value_type>; + using type = vec<2, value_type>; using type_float = typename std::common_type::type; using size_type = size_t; union { value_type x, r; }; union { value_type y, g; }; - TVec() {} - TVec(const value_type& _x, const value_type& _y) : x(_x), y(_y) {} - TVec(const value_type& _) : x(_), y(_) {} + vec() {} + vec(const value_type& _x, const value_type& _y) : x(_x), y(_y) {} + vec(const value_type& _) : x(_), y(_) {} constexpr bool operator==(const type& _) const { return x == _.x && y == _.y; } constexpr bool operator!=(const type& _) const { return !(*this == _); } @@ -191,21 +191,21 @@ namespace ARC constexpr void operator/=(const value_type _) { x /= _; y /= _; } constexpr void operator*=(const value_type _) { x *= _; y *= _; } - void DrawGuiControl(const char* pID, float pColumnWidth, type pDefaults); + void draw_gui_control(const char* pID, float pColumnWidth, type pDefaults); - VM_FUNC value_type MinComponent() const { return SMath::Min(x, y); } - VM_FUNC value_type MaxComponent() const { return SMath::Max(x, y); } + VM_FUNC value_type MinComponent() const { return math::Min(x, y); } + VM_FUNC value_type MaxComponent() const { return math::Max(x, y); } - VM_FUNC bool IsWithinBounds(const type& pMin, const type& pMax) + VM_FUNC bool is_within_bounds(const type& pMin, const type& pMax) { - return SMath::IsInRange(x, pMin.x, pMax.x) && SMath::IsInRange(y, pMin.y, pMax.y); + return math::is_in_range(x, pMin.x, pMax.x) && math::is_in_range(y, pMin.y, pMax.y); } - VM_FUNC type_float Dist(const type& _) const { return SMath::Dist(*this, _); } - VM_FUNC type_float DistSqr(const type& _) const { return SMath::DistSqr(*this, _); } + VM_FUNC type_float Dist(const type& _) const { return math::Dist(*this, _); } + VM_FUNC type_float DistSqr(const type& _) const { return math::DistSqr(*this, _); } VM_FUNC type_float Length() const { return Dist(ZeroVector()); } VM_FUNC type Normalize() const { return this / Length(); } - VM_FUNC bool AlmostEqual(const type& _, float _Tollerance) const { return SMath::IsEqual(*this, _, _Tollerance); } + VM_FUNC bool AlmostEqual(const type& _, float tollerance) const { return math::is_equal(*this, _, tollerance); } [[nodiscard]] static const type& ZeroVector() { static type rval = type(0); return rval; } [[nodiscard]] static @@ -214,13 +214,13 @@ namespace ARC }; template - class ARC_API TVec<3, T> : public Base::TVec_Base + class ARC_API vec<3, T> : public Base::TVec_Base { public: using Super = Base::TVec_Base; using value_type = T; - using type = TVec<3, T>; + using type = vec<3, T>; using type_float = typename std::common_type::type; using size_type = size_t; @@ -228,9 +228,9 @@ namespace ARC union { value_type y, g; }; union { value_type z, b; }; - TVec() {} - TVec(const value_type& _x, const value_type& _y, const value_type& _z) : x(_x), y(_y), z(_z) {} - TVec(const value_type _) : x(_), y(_), z(_) {} + vec() {} + vec(const value_type& _x, const value_type& _y, const value_type& _z) : x(_x), y(_y), z(_z) {} + vec(const value_type _) : x(_), y(_), z(_) {} constexpr bool operator==(const type& _) const { return x == _.x && y == _.y && z == _.z; } constexpr bool operator!=(const type& _) const { return !(*this == _); } @@ -256,13 +256,13 @@ namespace ARC inline value_type* Data() { return &x; } inline const value_type* Data() const { return &x; } - void DrawGuiControl(const char* pID, float pColumnWidth, type pDefaults); + void draw_gui_control(const char* pID, float pColumnWidth, type pDefaults); - VM_FUNC value_type MinComponent() const { return SMath::Min(x, y, z); } - VM_FUNC value_type MaxComponent() const { return SMath::Max(x, y, z); } + VM_FUNC value_type MinComponent() const { return math::Min(x, y, z); } + VM_FUNC value_type MaxComponent() const { return math::Max(x, y, z); } - VM_FUNC type_float Dist(const type& _) const { return SMath::Dist(*this, _); } - VM_FUNC type_float DistSqr(const type& _) const { return SMath::DistSqr(*this, _); } + VM_FUNC type_float Dist(const type& _) const { return math::Dist(*this, _); } + VM_FUNC type_float DistSqr(const type& _) const { return math::DistSqr(*this, _); } VM_FUNC type_float Length() const { return Dist(ZeroVector()); } VM_FUNC type Cross(const type& _1, const type& _2) { @@ -272,7 +272,7 @@ namespace ARC } VM_FUNC type Normalize() const { return *this / Length(); } - VM_FUNC bool AlmostEqual(const type& _, float _Tollerance) const { return SMath::IsEqual(*this, _, _Tollerance); } + VM_FUNC bool AlmostEqual(const type& _, float tollerance) const { return math::is_equal(*this, _, tollerance); } VM_FUNC type Mask(type _) { return *this * _; } [[nodiscard]] static @@ -283,13 +283,13 @@ namespace ARC }; template - class ARC_API TVec<4, T> : public Base::TVec_Base + class ARC_API vec<4, T> : public Base::TVec_Base { public: using Super = Base::TVec_Base; using value_type = T; - using type = TVec<4, T>; + using type = vec<4, T>; using type_float = typename std::common_type::type; using size_type = size_t; @@ -298,9 +298,9 @@ namespace ARC union { value_type z, b; }; union { value_type w, a; }; - TVec() {} - TVec(const value_type& _x, const value_type& _y, const value_type& _z, const value_type& _w) : x(_x), y(_y), z(_z), w(_w) {} - TVec(const value_type _) : x(_), y(_), z(_), w(_) {} + vec() {} + vec(const value_type& _x, const value_type& _y, const value_type& _z, const value_type& _w) : x(_x), y(_y), z(_z), w(_w) {} + vec(const value_type _) : x(_), y(_), z(_), w(_) {} constexpr bool operator==(const type& _) const { return x == _.x && y == _.y && z == _.z, w == _.w; } constexpr bool operator!=(const type& _) const { return !(*this == _); } @@ -324,16 +324,16 @@ namespace ARC inline value_type* Data() { return &x; } inline const value_type* Data() const { return &x; } - void DrawGuiControl(const char* pID, float pColumnWidth, type pDefaults); + void draw_gui_control(const char* pID, float pColumnWidth, type pDefaults); - VM_FUNC value_type MinComponent() { return SMath::Min(x, y, z, w); } - VM_FUNC value_type MaxComponent() { return SMath::Max(x, y, z, w); } + VM_FUNC value_type MinComponent() { return math::Min(x, y, z, w); } + VM_FUNC value_type MaxComponent() { return math::Max(x, y, z, w); } - VM_FUNC type_float Dist(const type& _) const { return SMath::Dist(*this, _); } - VM_FUNC type_float DistSqr(const type& _) const { return SMath::DistSqr(*this, _); } + VM_FUNC type_float Dist(const type& _) const { return math::Dist(*this, _); } + VM_FUNC type_float DistSqr(const type& _) const { return math::DistSqr(*this, _); } VM_FUNC type_float Length() const { return Dist(ZeroVector()); } VM_FUNC type Normalize() const { return this / Length(); } - VM_FUNC bool AlmostEqual(const type& _, float _Tollerance) const { return SMath::IsEqual(*this, _, _Tollerance); } + VM_FUNC bool AlmostEqual(const type& _, float tollerance) const { return math::is_equal(*this, _, tollerance); } [[nodiscard]] static const type& ZeroVector() { static type rval = type(0); return rval; } @@ -344,23 +344,23 @@ namespace ARC #undef VM_FUNC - template using TVec1 = TVec<1, T>; - template using TVec2 = TVec<2, T>; - template using TVec3 = TVec<3, T>; - template using TVec4 = TVec<4, T>; - - using FVec1 = TVec1; - using FVec2 = TVec2; - using FVec3 = TVec3; - using FVec4 = TVec4; - - using IVec1 = TVec1; - using IVec2 = TVec2; - using IVec3 = TVec3; - using IVec4 = TVec4; - - using UIVec1 = TVec1; - using UIVec2 = TVec2; - using UIVec3 = TVec3; - using UIVec4 = TVec4; + template using vec1 = vec<1, T>; + template using vec2 = vec<2, T>; + template using vec3 = vec<3, T>; + template using vec4 = vec<4, T>; + + using vec1 = vec1; + using vec2 = vec2; + using vec3 = vec3; + using vec4 = vec4; + + using ivec1 = vec1; + using ivec2 = vec2; + using ivec3 = vec3; + using ivec4 = vec4; + + using uvec1 = vec1; + using uvec2 = vec2; + using uvec3 = vec3; + using uvec4 = vec4; }; \ No newline at end of file diff --git a/ARC-Engine/src/ARC/Wrappers/Glm.cpp b/ARC-Engine/src/ARC/Wrappers/Glm.cpp index dad941d883..8de2d0c989 100644 --- a/ARC-Engine/src/ARC/Wrappers/Glm.cpp +++ b/ARC-Engine/src/ARC/Wrappers/Glm.cpp @@ -4,22 +4,22 @@ #define GLM_ENABLE_EXPERIMENTAL #include -namespace ARC { - FGLMMat4 SConvert::Conv(const FTransform2D& pRhs) +namespace arc { + mat4 convert::Conv(const transform_2d& pRhs) { - return glm::translate(FGLMMat4(1.0f), FGLMVec3(pRhs.Location.x, pRhs.Location.y, pRhs.Location.z)) * - glm::rotate(FGLMMat4(1.0f), pRhs.Rotation, FGLMVec3(0, 0, 1)) * - glm::scale(FGLMMat4(1.0f), FGLMVec3(pRhs.Scale.x, pRhs.Scale.y, 1.0f)); + return glm::translate(mat4(1.0f), vec3(pRhs.Location.x, pRhs.Location.y, pRhs.Location.z)) * + glm::rotate(mat4(1.0f), pRhs.Rotation, vec3(0, 0, 1)) * + glm::scale(mat4(1.0f), vec3(pRhs.Scale.x, pRhs.Scale.y, 1.0f)); } - bool SConvert::CanConv(const FGLMMat4& pRhs) + bool convert::CanConv(const mat4& pRhs) { using namespace glm; using T = float; return !epsilonEqual(pRhs[3][3], static_cast(0), epsilon()); } - FTransform3D SConvert::Conv(const FGLMMat4& pRhs) + transform_3d convert::Conv(const mat4& pRhs) { // From glm::decompose in matrix_decompose.inl @@ -27,7 +27,7 @@ namespace ARC { using T = float; mat4 localMatrix(pRhs); - FTransform3D rval; + transform_3d rval; // Normalize the matrix. ARC_CORE_ASSERT(!epsilonEqual(localMatrix[3][3], static_cast(0), epsilon())) @@ -38,14 +38,14 @@ namespace ARC { epsilonNotEqual(localMatrix[1][3], static_cast(0), epsilon()) || epsilonNotEqual(localMatrix[2][3], static_cast(0), epsilon())) { - // Clear the perspective partition + // clear the perspective partition localMatrix[0][3] = localMatrix[1][3] = localMatrix[2][3] = static_cast(0); localMatrix[3][3] = static_cast(1); } // Next take care of translation (easy). - rval.Location = FVec3(localMatrix[3].x, localMatrix[3].y, localMatrix[3].z); - localMatrix[3] = FGLMVec4(0, 0, 0, localMatrix[3].w); + rval.Location = vec3(localMatrix[3].x, localMatrix[3].y, localMatrix[3].z); + localMatrix[3] = vec4(0, 0, 0, localMatrix[3].w); vec3 Row[3]; @@ -89,7 +89,7 @@ namespace ARC { return rval; } - FTransform2D SConvert::Conv(const FGLMMat4& pRhs) + transform_2d convert::Conv(const mat4& pRhs) { // From glm::decompose in matrix_decompose.inl @@ -97,7 +97,7 @@ namespace ARC { using T = float; mat4 localMatrix(pRhs); - FTransform2D rval; + transform_2d rval; // Normalize the matrix. ARC_CORE_ASSERT(!epsilonEqual(localMatrix[3][3], static_cast(0), epsilon())) @@ -108,14 +108,14 @@ namespace ARC { epsilonNotEqual(localMatrix[1][3], static_cast(0), epsilon()) || epsilonNotEqual(localMatrix[2][3], static_cast(0), epsilon())) { - // Clear the perspective partition + // clear the perspective partition localMatrix[0][3] = localMatrix[1][3] = localMatrix[2][3] = static_cast(0); localMatrix[3][3] = static_cast(1); } // Next take care of translation (easy). - rval.Location = FVec3(localMatrix[3].x, localMatrix[3].y, localMatrix[3].z); - localMatrix[3] = FGLMVec4(0, 0, 0, localMatrix[3].w); + rval.Location = vec3(localMatrix[3].x, localMatrix[3].y, localMatrix[3].z); + localMatrix[3] = vec4(0, 0, 0, localMatrix[3].w); vec3 Row[3]; diff --git a/ARC-Engine/src/ARC/Wrappers/Glm.h b/ARC-Engine/src/ARC/Wrappers/Glm.h index 04ff4fda88..b42eebeeed 100644 --- a/ARC-Engine/src/ARC/Wrappers/Glm.h +++ b/ARC-Engine/src/ARC/Wrappers/Glm.h @@ -5,30 +5,30 @@ #include "ARC/Types/Transform2D.h" #include "ARC/Types/Transform3D.h" -namespace ARC +namespace arc { - using FGLMMat4 = glm::mat4; - using FGLMMat3 = glm::mat3; - using FGLMMat2 = glm::mat2; + using mat4 = glm::mat4; + using mat3 = glm::mat3; + using mat2 = glm::mat2; - using FGLMVec4 = glm::vec4; - using FGLMVec3 = glm::vec3; - using FGLMVec2 = glm::vec2; + using vec4 = glm::vec4; + using vec3 = glm::vec3; + using vec2 = glm::vec2; template <> - struct SConvert + struct convert { - static FGLMMat4 Conv(const FTransform2D& p); + static mat4 Conv(const transform_2d& p); }; template <> - struct SConvert + struct convert { - static bool CanConv(const FGLMMat4& p); - static FTransform3D Conv(const FGLMMat4& p); + static bool CanConv(const mat4& p); + static transform_3d Conv(const mat4& p); }; template <> - struct SConvert + struct convert { - static FTransform2D Conv(const FGLMMat4& p); + static transform_2d Conv(const mat4& p); }; } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLBuffer.cpp b/ARC-Engine/src/Platform/OpenGl/OpenGLBuffer.cpp index 21cb39e96e..ec84c1978c 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLBuffer.cpp +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLBuffer.cpp @@ -2,70 +2,70 @@ #include "OpenGLBuffer.h" #include "glad\glad.h" -namespace ARC { - //---------------------------[CVertexBuffer]----------------------------// +namespace arc { + //---------------------------[vertex_buffer]----------------------------// - COpenGLVertexBuffer::COpenGLVertexBuffer(uint32_t _Size) + opengl_vertex_buffer::opengl_vertex_buffer(uint32_t size) { - glCreateBuffers(1, &mRenderer_id); - Bind(); - glBufferData(GL_ARRAY_BUFFER, _Size, nullptr, GL_DYNAMIC_DRAW); + glCreateBuffers(1, &renderer_id_); + bind(); + glBufferData(GL_ARRAY_BUFFER, size, nullptr, GL_DYNAMIC_DRAW); } - COpenGLVertexBuffer::COpenGLVertexBuffer(float* _Vertices, uint32_t _Size) + opengl_vertex_buffer::opengl_vertex_buffer(float* vertices, uint32_t size) { - glCreateBuffers(1, &mRenderer_id); - Bind(); - glBufferData(GL_ARRAY_BUFFER, _Size, _Vertices, GL_STATIC_DRAW); + glCreateBuffers(1, &renderer_id_); + bind(); + glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW); } - COpenGLVertexBuffer::~COpenGLVertexBuffer() + opengl_vertex_buffer::~opengl_vertex_buffer() { - glDeleteBuffers(1, &mRenderer_id); + glDeleteBuffers(1, &renderer_id_); } - void COpenGLVertexBuffer::Bind() const + void opengl_vertex_buffer::bind() const { - glBindBuffer(GL_ARRAY_BUFFER, mRenderer_id); + glBindBuffer(GL_ARRAY_BUFFER, renderer_id_); } - void COpenGLVertexBuffer::UnBind() const + void opengl_vertex_buffer::UnBind() const { glBindBuffer(GL_ARRAY_BUFFER, 0); } - void COpenGLVertexBuffer::SetData(const void* _Data, uint32_t _Size) + void opengl_vertex_buffer::set_data(const void* data, uint32_t size) { - Bind(); - glBufferSubData(GL_ARRAY_BUFFER, 0, _Size, _Data); + bind(); + glBufferSubData(GL_ARRAY_BUFFER, 0, size, data); } - //---------------------------[CIndexBuffer]----------------------------// + //---------------------------[index_buffer]----------------------------// - COpenGLIndexBuffer::COpenGLIndexBuffer(uint32_t* _Indiices, uint32_t _Count) - : mCount(_Count) + opengl_index_buffer::opengl_index_buffer(uint32_t* indiices, uint32_t count) + : count_(count) { - glCreateBuffers(1, &mRenderer_id); - Bind(); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, _Count*sizeof(uint32_t), _Indiices, GL_STATIC_DRAW); + glCreateBuffers(1, &renderer_id_); + bind(); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, count*sizeof(uint32_t), indiices, GL_STATIC_DRAW); } - COpenGLIndexBuffer::~COpenGLIndexBuffer() + opengl_index_buffer::~opengl_index_buffer() { - glDeleteBuffers(1, &mRenderer_id); + glDeleteBuffers(1, &renderer_id_); } - void COpenGLIndexBuffer::Bind() const + void opengl_index_buffer::bind() const { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mRenderer_id); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, renderer_id_); } - void COpenGLIndexBuffer::UnBind() const + void opengl_index_buffer::UnBind() const { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } - uint32_t COpenGLIndexBuffer::GetCount() const + uint32_t opengl_index_buffer::get_count() const { - return mCount; + return count_; } } diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLBuffer.h b/ARC-Engine/src/Platform/OpenGl/OpenGLBuffer.h index dd9bdda95a..7176a04f55 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLBuffer.h +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLBuffer.h @@ -1,40 +1,40 @@ #pragma once #include "ARC\Renderer\Buffer.h" -namespace ARC { - class COpenGLVertexBuffer : public CVertexBuffer +namespace arc { + class opengl_vertex_buffer : public vertex_buffer { public: - COpenGLVertexBuffer(float* pVertices, TUInt32 pSize); - COpenGLVertexBuffer(TUInt32 pSize); - virtual ~COpenGLVertexBuffer(); + opengl_vertex_buffer(float* pVertices, u32 pSize); + opengl_vertex_buffer(u32 pSize); + virtual ~opengl_vertex_buffer(); - virtual void Bind() const override; + virtual void bind() const override; virtual void UnBind() const override; - virtual void SetLayout(const CBufferLayout& pLayout) override { mLayout = pLayout; } - virtual const CBufferLayout& GetLayout() const override { return mLayout; } + virtual void set_layout(const buffer_layout& pLayout) override { layout_ = pLayout; } + virtual const buffer_layout& get_layout() const override { return layout_; } - virtual void SetData(const void* pData, TUInt32 pSize) override; + virtual void set_data(const void* pData, u32 pSize) override; private: - TUInt32 mRenderer_id; - CBufferLayout mLayout; + u32 renderer_id_; + buffer_layout layout_; }; - class COpenGLIndexBuffer : public CIndexBuffer + class opengl_index_buffer : public index_buffer { public: - COpenGLIndexBuffer(TUInt32* pIndiices, TUInt32 pCount); - virtual ~COpenGLIndexBuffer(); + opengl_index_buffer(u32* pIndiices, u32 pCount); + virtual ~opengl_index_buffer(); - virtual void Bind() const override; + virtual void bind() const override; virtual void UnBind() const override; - virtual TUInt32 GetCount() const override; + virtual u32 get_count() const override; private: - TUInt32 mRenderer_id; - TUInt32 mCount; + u32 renderer_id_; + u32 count_; }; } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLContext.cpp b/ARC-Engine/src/Platform/OpenGl/OpenGLContext.cpp index 133fe459cf..568c0d1c4d 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLContext.cpp +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLContext.cpp @@ -3,16 +3,16 @@ #include "GLFW\glfw3.h" #include "glad\glad.h" -namespace ARC { +namespace arc { - COpenGLContext::COpenGLContext(GLFWwindow* _WindowHandle) : mWindowHandle(_WindowHandle) + opengl_context::opengl_context(GLFWwindow* window_handle) : window_handle_(window_handle) { - ARC_CORE_ASSERT(mWindowHandle, "Window handle is null") + ARC_CORE_ASSERT(window_handle_, "Window handle is null") } - void COpenGLContext::Init() + void opengl_context::init() { ARC_PROFILE_FUNCTION(); - glfwMakeContextCurrent(mWindowHandle); + glfwMakeContextCurrent(window_handle_); int status = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); ARC_CORE_ASSERT(status, "Failed to load GLAD!") @@ -30,8 +30,8 @@ namespace ARC { ARC_CORE_ASSERT(versionMajor > 4 || (versionMajor == 4 && versionMinor >= 5), "ARC requires at least OpenGL version 4.5!"); } - void COpenGLContext::SwapBuffers() + void opengl_context::swap_buffers() { - glfwSwapBuffers(mWindowHandle); + glfwSwapBuffers(window_handle_); } } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLContext.h b/ARC-Engine/src/Platform/OpenGl/OpenGLContext.h index 389b5c5ed3..fe29814c1b 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLContext.h +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLContext.h @@ -3,15 +3,15 @@ struct GLFWwindow; -namespace ARC { - class COpenGLContext : public CGraphicsContext +namespace arc { + class opengl_context : public graphics_context { public: - COpenGLContext(GLFWwindow* _WindowHandle); - virtual void Init() override; - virtual void SwapBuffers() override; + opengl_context(GLFWwindow* window_handle); + virtual void init() override; + virtual void swap_buffers() override; private: - GLFWwindow* mWindowHandle; + GLFWwindow* window_handle_; }; } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLFrameBuffer.cpp b/ARC-Engine/src/Platform/OpenGl/OpenGLFrameBuffer.cpp index 4fd07657fb..4c165c30ab 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLFrameBuffer.cpp +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLFrameBuffer.cpp @@ -2,8 +2,8 @@ #include "OpenGLFrameBuffer.h" #include "glad\glad.h" -namespace ARC { - static constexpr TUInt32 MaxFrameBufferSize = 10000; +namespace arc { + static constexpr u32 MaxFrameBufferSize = 10000; static void CreateTextures(bool pbMultisampled, uint32_t* pOutID, uint32_t pCount) { @@ -106,120 +106,120 @@ namespace ARC { ); } - static GLenum ARCFBTextureFormatToGL(EFrameBufferTextureFormat pFormat) + static GLenum ARCFBTextureFormatToGL(frame_buffer_texture_format pFormat) { switch (pFormat) { - case EFrameBufferTextureFormat::RGBA8: return GL_RGBA8; - case EFrameBufferTextureFormat::RED_INTEGER: return GL_RED_INTEGER; + case frame_buffer_texture_format::RGBA8: return GL_RGBA8; + case frame_buffer_texture_format::RED_INTEGER: return GL_RED_INTEGER; } ARC_CORE_ASSERT(false); return 0; } - static GLenum GLDataType(EFrameBufferTextureFormat pFormat) + static GLenum GLDataType(frame_buffer_texture_format pFormat) { switch (pFormat) { - case EFrameBufferTextureFormat::RGBA8: return GL_UNSIGNED_BYTE; - case EFrameBufferTextureFormat::RED_INTEGER: return GL_RED_INTEGER; + case frame_buffer_texture_format::RGBA8: return GL_UNSIGNED_BYTE; + case frame_buffer_texture_format::RED_INTEGER: return GL_RED_INTEGER; } ARC_CORE_ASSERT(false); return 0; } - COpenGLFrameBuffer::COpenGLFrameBuffer(const SFrameBufferSpecification& pSpecs) : - mSpecification(pSpecs) + opengl_framebuffer::opengl_framebuffer(const frame_buffer_specification& pSpecs) : + specification_(pSpecs) { - for (EFrameBufferTextureFormat ispec : mSpecification.Attachments) + for (frame_buffer_texture_format ispec : specification_.Attachments) { - if (ispec != EFrameBufferTextureFormat::DEPTH24STENCIL8) - mColorAttachmentSpecifications.emplace_back(ispec); + if (ispec != frame_buffer_texture_format::DEPTH24STENCIL8) + color_attachment_specifications_.emplace_back(ispec); else - mDepthAttachmentSpecification = ispec; + depth_attachment_specification_ = ispec; } Invalidate(); } - COpenGLFrameBuffer::~COpenGLFrameBuffer() + opengl_framebuffer::~opengl_framebuffer() { - glDeleteFramebuffers(1, &mRendererID); - glDeleteTextures(mColorAttachmentSpecifications.size(), mColorAttachments.data()); - glDeleteTextures(1, &mDepthAttachment); + glDeleteFramebuffers(1, &renderer_id_); + glDeleteTextures(color_attachment_specifications_.size(), color_attachments_.data()); + glDeleteTextures(1, &depth_attachment_); } - void COpenGLFrameBuffer::Invalidate() + void opengl_framebuffer::Invalidate() { - if (mRendererID) + if (renderer_id_) { - glDeleteFramebuffers(1, &mRendererID); - glDeleteTextures(mColorAttachmentSpecifications.size(), mColorAttachments.data()); - glDeleteTextures(1, &mDepthAttachment); + glDeleteFramebuffers(1, &renderer_id_); + glDeleteTextures(color_attachment_specifications_.size(), color_attachments_.data()); + glDeleteTextures(1, &depth_attachment_); - mColorAttachments.clear(); - mDepthAttachment=0; + color_attachments_.clear(); + depth_attachment_=0; } - glCreateFramebuffers(1, &mRendererID); - glBindFramebuffer(GL_FRAMEBUFFER, mRendererID); + glCreateFramebuffers(1, &renderer_id_); + glBindFramebuffer(GL_FRAMEBUFFER, renderer_id_); - bool bmultisample = mSpecification.Samples>1; + bool bmultisample = specification_.Samples>1; - if (mColorAttachmentSpecifications.size()) + if (color_attachment_specifications_.size()) { - mColorAttachments.resize(mColorAttachmentSpecifications.size()); - CreateTextures(bmultisample, mColorAttachments.data(), (TUInt32)mColorAttachments.size()); + color_attachments_.resize(color_attachment_specifications_.size()); + CreateTextures(bmultisample, color_attachments_.data(), (u32)color_attachments_.size()); - for (int i=0; i < mColorAttachments.size(); i++) { - BindTexture(bmultisample, mColorAttachments[i]); + for (int i=0; i < color_attachments_.size(); i++) { + BindTexture(bmultisample, color_attachments_[i]); - switch (mColorAttachmentSpecifications[i]) { - case EFrameBufferTextureFormat::RGBA8: + switch (color_attachment_specifications_[i]) { + case frame_buffer_texture_format::RGBA8: AttachColorTexture( - mColorAttachments[i], - mSpecification.Samples, + color_attachments_[i], + specification_.Samples, GL_RGBA8, GL_RGBA, - mSpecification.Width, - mSpecification.Height, + specification_.Width, + specification_.Height, i ); break; - case EFrameBufferTextureFormat::RED_INTEGER: + case frame_buffer_texture_format::RED_INTEGER: AttachColorTexture( - mColorAttachments[i], - mSpecification.Samples, + color_attachments_[i], + specification_.Samples, GL_R32I, GL_RED_INTEGER, - mSpecification.Width, - mSpecification.Height, + specification_.Width, + specification_.Height, i ); break; } } } - if (mDepthAttachmentSpecification != EFrameBufferTextureFormat::None) + if (depth_attachment_specification_ != frame_buffer_texture_format::None) { - CreateTextures(bmultisample, &mDepthAttachment, 1); - BindTexture(bmultisample, mDepthAttachment); + CreateTextures(bmultisample, &depth_attachment_, 1); + BindTexture(bmultisample, depth_attachment_); - if (mDepthAttachmentSpecification == EFrameBufferTextureFormat::DEPTH24STENCIL8) + if (depth_attachment_specification_ == frame_buffer_texture_format::DEPTH24STENCIL8) AttachDepthTexture( - mDepthAttachment, - mSpecification.Samples, + depth_attachment_, + specification_.Samples, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL_ATTACHMENT, - mSpecification.Width, - mSpecification.Height + specification_.Width, + specification_.Height ); } - if (mColorAttachments.size()>1) + if (color_attachments_.size()>1) { - ARC_CORE_ASSERT(mColorAttachments.size()<=4, "Currently only 4 ColorAttachments Supported"); + ARC_CORE_ASSERT(color_attachments_.size()<=4, "Currently only 4 ColorAttachments Supported"); GLenum buffers[4] = { GL_COLOR_ATTACHMENT0, @@ -228,9 +228,9 @@ namespace ARC { GL_COLOR_ATTACHMENT3, }; - glDrawBuffers(mColorAttachments.size(), buffers); + glDrawBuffers(color_attachments_.size(), buffers); } - else if (mColorAttachments.empty()) + else if (color_attachments_.empty()) glDrawBuffer(GL_NONE); ARC_CORE_ASSERT(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Framebuffer is incomplete!"); @@ -238,30 +238,30 @@ namespace ARC { glBindFramebuffer(GL_FRAMEBUFFER, 0); } - void COpenGLFrameBuffer::Bind() + void opengl_framebuffer::bind() { - glBindFramebuffer(GL_FRAMEBUFFER, mRendererID); - glViewport(0,0,mSpecification.Width, mSpecification.Height); + glBindFramebuffer(GL_FRAMEBUFFER, renderer_id_); + glViewport(0,0,specification_.Width, specification_.Height); } - void COpenGLFrameBuffer::UnBind() + void opengl_framebuffer::UnBind() { glBindFramebuffer(GL_FRAMEBUFFER, 0); } - void COpenGLFrameBuffer::Resize(const TVec2& p) + void opengl_framebuffer::resize(const vec2& p) { - if (mSpecification.Width==0.f || mSpecification.Height==0.f || mSpecification.Height > MaxFrameBufferSize || mSpecification.Width > MaxFrameBufferSize) + if (specification_.Width==0.f || specification_.Height==0.f || specification_.Height > MaxFrameBufferSize || specification_.Width > MaxFrameBufferSize) return; - mSpecification.Width = p.x; - mSpecification.Height = p.y; + specification_.Width = p.x; + specification_.Height = p.y; Invalidate(); } - int COpenGLFrameBuffer::ReadPixel(TUInt32 pAttachmentIndex, int pX, int pY) + int opengl_framebuffer::read_pixel(u32 pAttachmentIndex, int pX, int pY) { - ARC_CORE_ASSERT(pAttachmentIndex& p) override; + virtual void resize(const vec2& p) override; - virtual int ReadPixel(TUInt32 pAttachmentIndex, int pX, int pY) override; + virtual int read_pixel(u32 pAttachmentIndex, int pX, int pY) override; - virtual void ClearColorAttachment(TUInt32 pAttachmentIndex, const int pValue) override; - virtual void ClearColorAttachment(TUInt32 pAttachmentIndex, const float pValue) override; + virtual void ClearColorAttachment(u32 pAttachmentIndex, const int pValue) override; + virtual void ClearColorAttachment(u32 pAttachmentIndex, const float pValue) override; private: - TUInt32 mRendererID=0; - SFrameBufferSpecification mSpecification; + u32 renderer_id_=0; + frame_buffer_specification specification_; - std::vector mColorAttachmentSpecifications; - EFrameBufferTextureFormat mDepthAttachmentSpecification= EFrameBufferTextureFormat::None; + std::vector color_attachment_specifications_; + frame_buffer_texture_format depth_attachment_specification_= frame_buffer_texture_format::None; - std::vector mColorAttachments; - TUInt32 mDepthAttachment=0; + std::vector color_attachments_; + u32 depth_attachment_=0; }; } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLRendererAPI.cpp b/ARC-Engine/src/Platform/OpenGl/OpenGLRendererAPI.cpp index 38ce697248..3e3481510e 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLRendererAPI.cpp +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLRendererAPI.cpp @@ -3,9 +3,9 @@ #include #include "ARC/Renderer/VertexArray.h" -namespace ARC { +namespace arc { - void COpenGLRendererAPI::Init() + void opengl_renderer_api::init() { ARC_PROFILE_FUNCTION(); glEnable(GL_BLEND); @@ -14,37 +14,37 @@ namespace ARC { glEnable(GL_DEPTH_TEST); } - void COpenGLRendererAPI::SetViewport(const TVec2 _BottemLeftCoord, const TVec2 _Dimentions) + void opengl_renderer_api::set_viewport(const vec2 bottem_left_coord, const vec2 dimentions) { - glViewport(_BottemLeftCoord.x, _BottemLeftCoord.y, _Dimentions.x, _Dimentions.y); + glViewport(bottem_left_coord.x, bottem_left_coord.y, dimentions.x, dimentions.y); } - void COpenGLRendererAPI::SetClearColour(const FColor4 _Colour) + void opengl_renderer_api::set_clear_colour(const color4 colour) { - glClearColor(_Colour.r, _Colour.g, _Colour.b, _Colour.a); + glClearColor(colour.r, colour.g, colour.b, colour.a); } - void COpenGLRendererAPI::Clear() + void opengl_renderer_api::clear() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } - void COpenGLRendererAPI::DrawIndexed(const TRef& _VertexArray, TUInt32 _Count) + void opengl_renderer_api::draw_indexed(const ref& vertex_array, u32 count) { ARC_PROFILE_FUNCTION(); - _VertexArray->Bind(); - TUInt32 count = _Count ? _Count : _VertexArray->GetIndexBuffer()->GetCount(); + vertex_array->bind(); + u32 count = count ? count : vertex_array->get_index_buffer()->get_count(); glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, nullptr); } - void COpenGLRendererAPI::DrawLine(const TRef& _VertexArray, TUInt32 _Count) + void opengl_renderer_api::draw_line(const ref& vertex_array, u32 count) { ARC_PROFILE_FUNCTION(); - _VertexArray->Bind(); - glDrawArrays(GL_LINES, 0, _Count); + vertex_array->bind(); + glDrawArrays(GL_LINES, 0, count); } - void COpenGLRendererAPI::SetLineThickness(float pThickness) + void opengl_renderer_api::set_line_thickness(float pThickness) { glLineWidth(pThickness); } diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLRendererAPI.h b/ARC-Engine/src/Platform/OpenGl/OpenGLRendererAPI.h index 654c0b3d1f..d12532ccc3 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLRendererAPI.h +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLRendererAPI.h @@ -1,16 +1,16 @@ #pragma once #include "ARC\Renderer\RendererAPI.h" -namespace ARC { - class COpenGLRendererAPI : public CRendererAPI +namespace arc { + class opengl_renderer_api : public renderer_api { public: - virtual void Init() override; - virtual void SetViewport(const TVec2 _BottemLeftCoord, const TVec2 _Dimentions) override; - virtual void SetClearColour(const FColor4 _Colour) override; - virtual void Clear() override; - virtual void DrawIndexed(const TRef& _VertexArray, uint32_t _Count) override; - virtual void DrawLine(const TRef& _VertexArray, uint32_t _Count) override; - virtual void SetLineThickness(float pThickness) override; + virtual void init() override; + virtual void set_viewport(const vec2 bottem_left_coord, const vec2 dimentions) override; + virtual void set_clear_colour(const color4 colour) override; + virtual void clear() override; + virtual void draw_indexed(const ref& vertex_array, uint32_t count) override; + virtual void draw_line(const ref& vertex_array, uint32_t count) override; + virtual void set_line_thickness(float pThickness) override; }; } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLShader.cpp b/ARC-Engine/src/Platform/OpenGl/OpenGLShader.cpp index 4cde59cc24..c3f5df8682 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLShader.cpp +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLShader.cpp @@ -6,56 +6,56 @@ #include "ARC\Helpers\Helpers.h" #include "ARC/Types/Color.h" -namespace ARC { - TString COpenGLShader::s_Seperator = "#type"; +namespace arc { + string opengl_shader::seperator = "#type"; - COpenGLShader::COpenGLShader(const TString& _Name, const TString& _VertexSrc, const TString& _FragmentSrc) : - mName(_Name) + opengl_shader::opengl_shader(const string& name, const string& vertex_src, const string& fragment_src) : + name_(name) { - std::unordered_map sources; - sources[GL_VERTEX_SHADER] = _VertexSrc; - sources[GL_FRAGMENT_SHADER] = _FragmentSrc; + std::unordered_map sources; + sources[GL_VERTEX_SHADER] = vertex_src; + sources[GL_FRAGMENT_SHADER] = fragment_src; Compile(sources); } - COpenGLShader::COpenGLShader(const TString& _Path) + opengl_shader::opengl_shader(const string& path) { - TString source = SHPR::ReadFile(_Path); + string source = shpr::ReadFile(path); auto shaderSources = PreProcess(source); Compile(shaderSources); - mName = SHPR::ExtractFileNameFromPath(_Path); + name_ = shpr::ExtractFileNameFromPath(path); } - COpenGLShader::~COpenGLShader() + opengl_shader::~opengl_shader() { - glDeleteProgram(mRendererID); + glDeleteProgram(renderer_id_); } - void COpenGLShader::Bind() const + void opengl_shader::bind() const { - glUseProgram(mRendererID); + glUseProgram(renderer_id_); } - void COpenGLShader::UnBind() const + void opengl_shader::UnBind() const { glUseProgram(0); } - unsigned int COpenGLShader::ShaderTypeFromString(TString& _Type) + unsigned int opengl_shader::ShaderTypeFromString(string& type) { - if (_Type == "vertex") + if (type == "vertex") return GL_VERTEX_SHADER; - if (_Type == "fragment" || _Type == "pixel") + if (type == "fragment" || type == "pixel") return GL_FRAGMENT_SHADER; ARC_CORE_ASSERT(0, "Invalid shader type specifier"); return 0; } - TString COpenGLShader::StringFromShaderType(unsigned int _Type) + string opengl_shader::StringFromShaderType(unsigned int type) { - switch (_Type) + switch (type) { case GL_VERTEX_SHADER: return "vertex"; @@ -67,45 +67,45 @@ namespace ARC { } } - std::unordered_map COpenGLShader::PreProcess(const TString& _Source) + std::unordered_map opengl_shader::PreProcess(const string& source) { ARC_PROFILE_FUNCTION(); - std::unordered_map shaderSources; - size_t pos = _Source.find(s_Seperator.c_str(), 0); + std::unordered_map shaderSources; + size_t pos = source.find(seperator.c_str(), 0); - while (pos != TString::npos) + while (pos != string::npos) { - size_t eol = _Source.find_first_of("\r\n", pos); // Finds first newline position - ARC_CORE_ASSERT(eol != TString::npos, "Syntax Error"); - size_t begin = pos + s_Seperator.length() + 1; // Find first s_Seperator - TString type = _Source.substr(begin, eol - begin); + size_t eol = source.find_first_of("\r\n", pos); // Finds first newline position + ARC_CORE_ASSERT(eol != string::npos, "Syntax Error"); + size_t begin = pos + seperator.length() + 1; // Find first seperator + string type = source.substr(begin, eol - begin); - size_t nextLinePos = _Source.find_first_not_of("\r\n", eol); - ARC_CORE_ASSERT(nextLinePos != TString::npos, "Syntax error"); - pos = _Source.find(s_Seperator, nextLinePos); - shaderSources[ShaderTypeFromString(type)] = _Source.substr(nextLinePos, pos - (nextLinePos == TString::npos ? _Source.length() - 1 : nextLinePos)); + size_t nextLinePos = source.find_first_not_of("\r\n", eol); + ARC_CORE_ASSERT(nextLinePos != string::npos, "Syntax error"); + pos = source.find(seperator, nextLinePos); + shaderSources[ShaderTypeFromString(type)] = source.substr(nextLinePos, pos - (nextLinePos == string::npos ? source.length() - 1 : nextLinePos)); } return shaderSources; } - void COpenGLShader::Compile(const std::unordered_map& _ShaderSources) + void opengl_shader::Compile(const std::unordered_map& shader_sources) { ARC_PROFILE_FUNCTION(); // Get a program object. GLuint program = glCreateProgram(); - ARC_CORE_ASSERT(_ShaderSources.size() <= 2, "Only 2 shaders are supported currently"); + ARC_CORE_ASSERT(shader_sources.size() <= 2, "Only 2 shaders are supported currently"); std::array shaderHandles; size_t shaderHandleIndex = 0; - for(auto&&[key, value]: _ShaderSources) + for(auto&&[key, value]: shader_sources) { - // Create an empty shader handle + // create an empty shader handle GLuint shader = glCreateShader(key); // Send the shader source code to GL - // Note that TString's .CStr is NULL character terminated. + // Note that string's .CStr is NULL character terminated. const GLchar* source = value.c_str(); glShaderSource(shader, 1, &source, 0); @@ -167,7 +167,7 @@ namespace ARC { return; } - mRendererID = program; + renderer_id_ = program; // Always detach shaders after a successful link. for (auto& shaderHandle : shaderHandles) @@ -177,74 +177,74 @@ namespace ARC { } } - void COpenGLShader::SetMat4(const TString& _Name, const float* _Value) + void opengl_shader::set_mat4(const string& name, const float* value) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniformMatrix4fv(location, 1, GL_FALSE, _Value); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniformMatrix4fv(location, 1, GL_FALSE, value); } - void COpenGLShader::SetMat3(const TString& _Name, const float* _Value) + void opengl_shader::set_mat3(const string& name, const float* value) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniformMatrix3fv(location, 1, GL_FALSE, _Value); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniformMatrix3fv(location, 1, GL_FALSE, value); } - void COpenGLShader::SetInt(const TString& _Name, const int* _Value) + void opengl_shader::set_int(const string& name, const int* value) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniform1iv(location, 1, _Value); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniform1iv(location, 1, value); } - void COpenGLShader::SetInt2(const TString& _Name, const int* _Value) + void opengl_shader::set_int2(const string& name, const int* value) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniform2iv(location, 1, _Value); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniform2iv(location, 1, value); } - void COpenGLShader::SetInt3(const TString& _Name, const int* _Value) + void opengl_shader::set_int3(const string& name, const int* value) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniform3iv(location, 1, _Value); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniform3iv(location, 1, value); } - void COpenGLShader::SetInt4(const TString& _Name, const int* _Value) + void opengl_shader::set_int4(const string& name, const int* value) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniform4iv(location, 1, _Value); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniform4iv(location, 1, value); } - void COpenGLShader::SetFloat(const TString& _Name, const float* _Value) + void opengl_shader::set_float(const string& name, const float* value) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniform1fv(location, 1, _Value); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniform1fv(location, 1, value); } - void COpenGLShader::SetFloat2(const TString& _Name, const float* _Value) + void opengl_shader::set_float2(const string& name, const float* value) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniform2fv(location, 1, _Value); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniform2fv(location, 1, value); } - void COpenGLShader::SetFloat3(const TString& _Name, const float* _Value) + void opengl_shader::set_float3(const string& name, const float* value) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniform3fv(location, 1, _Value); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniform3fv(location, 1, value); } - void COpenGLShader::SetFloat4(const TString& _Name, const float* _Value) + void opengl_shader::set_float4(const string& name, const float* value) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniform4fv(location, 1, _Value); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniform4fv(location, 1, value); } - void COpenGLShader::SetIntArray(const TString& _Name, const int* _Values, uint32_t _Count) + void opengl_shader::set_int_array(const string& name, const int* values, uint32_t count) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniform1iv(location, _Count, _Values); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniform1iv(location, count, values); } - void COpenGLShader::SetFloatArray(const TString& _Name, const float* _Values, uint32_t _Count) + void opengl_shader::set_float_array(const string& name, const float* values, uint32_t count) { - GLint location = glGetUniformLocation(mRendererID, _Name.c_str()); - glUniform1fv(location, _Count, _Values); + GLint location = glGetUniformLocation(renderer_id_, name.c_str()); + glUniform1fv(location, count, values); } } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLShader.h b/ARC-Engine/src/Platform/OpenGl/OpenGLShader.h index 535623690e..1db1576903 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLShader.h +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLShader.h @@ -4,45 +4,45 @@ #include #include "glm/glm.hpp" -namespace ARC { - class COpenGLShader : - public CShader +namespace arc { + class opengl_shader : + public shader { public: - COpenGLShader(const TString& _Name, const TString& _VertexSrc, const TString& _FragmentSrc); - COpenGLShader(const TString& _Path); + opengl_shader(const string& name, const string& vertex_src, const string& fragment_src); + opengl_shader(const string& path); - virtual ~COpenGLShader(); + virtual ~opengl_shader(); - virtual void Bind() const override; + virtual void bind() const override; virtual void UnBind() const override; - virtual inline const TString& GetName() const override { return mName; }; + virtual inline const string& get_name() const override { return name_; }; private: - static unsigned int ShaderTypeFromString(TString& _Type); - static TString StringFromShaderType(unsigned int _Type); + static unsigned int ShaderTypeFromString(string& type); + static string StringFromShaderType(unsigned int type); - std::unordered_map PreProcess(const TString& _Source); - void Compile(const std::unordered_map& _ShaderSources); + std::unordered_map PreProcess(const string& source); + void Compile(const std::unordered_map& shader_sources); private: - static TString s_Seperator; - TString mName; - uint32_t mRendererID; + static string seperator; + string name_; + uint32_t renderer_id_; protected: - virtual void SetInt(const TString& _Name, const int* _Value) override; - virtual void SetInt2(const TString& _Name, const int* _Value) override; - virtual void SetInt3(const TString& _Name, const int* _Value) override; - virtual void SetInt4(const TString& _Name, const int* _Value) override; - virtual void SetMat4(const TString& _Name, const float* _Value) override; - virtual void SetMat3(const TString& _Name, const float* _Value) override; - virtual void SetFloat(const TString& _Name, const float* _Value) override; - virtual void SetFloat2(const TString& _Name, const float* _Value) override; - virtual void SetFloat3(const TString& _Name, const float* _Value) override; - virtual void SetFloat4(const TString& _Name, const float* _Value) override; - - virtual void SetIntArray(const TString& _Name, const int* _Values, uint32_t _Count) override; - virtual void SetFloatArray(const TString& _Name, const float* _Values, uint32_t _Count) override; + virtual void set_int(const string& name, const int* value) override; + virtual void set_int2(const string& name, const int* value) override; + virtual void set_int3(const string& name, const int* value) override; + virtual void set_int4(const string& name, const int* value) override; + virtual void set_mat4(const string& name, const float* value) override; + virtual void set_mat3(const string& name, const float* value) override; + virtual void set_float(const string& name, const float* value) override; + virtual void set_float2(const string& name, const float* value) override; + virtual void set_float3(const string& name, const float* value) override; + virtual void set_float4(const string& name, const float* value) override; + + virtual void set_int_array(const string& name, const int* values, uint32_t count) override; + virtual void set_float_array(const string& name, const float* values, uint32_t count) override; }; } diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLTexture.cpp b/ARC-Engine/src/Platform/OpenGl/OpenGLTexture.cpp index de5a642913..1fce44fda1 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLTexture.cpp +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLTexture.cpp @@ -4,10 +4,10 @@ #include "ARC\Core\Core.h" #include "glad\glad.h" -namespace ARC { - COpenGLTexture2D::COpenGLTexture2D(const std::filesystem::path& _Path, bool bManualClear) : - CTexture2D(Load(_Path)), - mPath(_Path) +namespace arc { + opengl_texture_2d::opengl_texture_2d(const std::filesystem::path& path, bool bManualClear) : + texture_2d(Load(path)), + path_(path) { if (!bManualClear) { @@ -15,40 +15,40 @@ namespace ARC { } } - COpenGLTexture2D::COpenGLTexture2D(const TVec2& _Dimentions) : - CTexture2D(Load(_Dimentions)) + opengl_texture_2d::opengl_texture_2d(const vec2& dimentions) : + texture_2d(Load(dimentions)) { } - COpenGLTexture2D::~COpenGLTexture2D() + opengl_texture_2d::~opengl_texture_2d() { - glDeleteTextures(1, &mRendererID); + glDeleteTextures(1, &renderer_id_); } - void COpenGLTexture2D::SetData(void* _Data, uint32_t _Size) + void opengl_texture_2d::set_data(void* data, uint32_t size) { - ARC_CORE_ASSERT(_Size == Dimensions.x * Dimensions.y * mBytesPerPixel, "Data must be entire texture"); - glTextureSubImage2D(mRendererID, 0, 0, 0, Dimensions.x, Dimensions.y, mDataFormat, GL_UNSIGNED_BYTE, _Data); + ARC_CORE_ASSERT(size == Dimensions.x * Dimensions.y * bytes_per_pixel_, "Data must be entire texture"); + glTextureSubImage2D(renderer_id_, 0, 0, 0, Dimensions.x, Dimensions.y, data_format_, GL_UNSIGNED_BYTE, data); } - void COpenGLTexture2D::Bind(uint32_t _Slot /*= 0*/) const + void opengl_texture_2d::bind(uint32_t slot /*= 0*/) const { - glBindTextureUnit(_Slot, mRendererID); + glBindTextureUnit(slot, renderer_id_); } - void COpenGLTexture2D::ClearData() + void opengl_texture_2d::ClearData() { - if (mData) + if (data_) { - stbi_image_free(mData); + stbi_image_free(data_); } } - TVec4 COpenGLTexture2D::GetPixelColor(TVec2 xy) + vec4 opengl_texture_2d::get_pixel_color(vec2 xy) { - TVec4 rval; - const stbi_uc* p = mData + (4 * (xy.y * Dimensions.x + xy.x)); + vec4 rval; + const stbi_uc* p = data_ + (4 * (xy.y * Dimensions.x + xy.x)); rval.r = p[0]; rval.g = p[1]; rval.b = p[2]; @@ -56,68 +56,68 @@ namespace ARC { return rval; } - TVec2 COpenGLTexture2D::Load(const std::filesystem::path& _Path) + vec2 opengl_texture_2d::Load(const std::filesystem::path& path) { ARC_PROFILE_FUNCTION(); int channels, width, height; stbi_set_flip_vertically_on_load(1); - mData = stbi_load(_Path.string().c_str(), &width, &height, &channels, 0); - ARC_CORE_ASSERT(mData, "Error loading texture from file"); + data_ = stbi_load(path.string().c_str(), &width, &height, &channels, 0); + ARC_CORE_ASSERT(data_, "Error loading texture from file"); - mInternalFormat = 0; - mDataFormat = 0; - mBytesPerPixel = channels; + internal_format_ = 0; + data_format_ = 0; + bytes_per_pixel_ = channels; switch (channels) { case 4: - mInternalFormat = GL_RGBA8; - mDataFormat = GL_RGBA; + internal_format_ = GL_RGBA8; + data_format_ = GL_RGBA; break; case 3: - mInternalFormat = GL_RGB8; - mDataFormat = GL_RGB; + internal_format_ = GL_RGB8; + data_format_ = GL_RGB; break; case 2: - mInternalFormat = GL_RG8; - mDataFormat = GL_RG; + internal_format_ = GL_RG8; + data_format_ = GL_RG; break; case 1: - mInternalFormat = GL_R; - mDataFormat = GL_R; + internal_format_ = GL_R; + data_format_ = GL_R; break; default: - ARC_CORE_ASSERT(mData, "Texture format is not supported"); + ARC_CORE_ASSERT(data_, "Texture format is not supported"); break; } - glCreateTextures(GL_TEXTURE_2D, 1, &mRendererID); - glTextureStorage2D(mRendererID, 1, mInternalFormat, width, height); + glCreateTextures(GL_TEXTURE_2D, 1, &renderer_id_); + glTextureStorage2D(renderer_id_, 1, internal_format_, width, height); - glTextureParameteri(mRendererID, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTextureParameteri(mRendererID, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTextureParameteri(mRendererID, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTextureParameteri(mRendererID, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTextureParameteri(renderer_id_, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTextureParameteri(renderer_id_, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTextureParameteri(renderer_id_, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTextureParameteri(renderer_id_, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTextureSubImage2D(mRendererID, 0, 0, 0, width, height, mDataFormat, GL_UNSIGNED_BYTE, mData); - return TVec2(width, height); + glTextureSubImage2D(renderer_id_, 0, 0, 0, width, height, data_format_, GL_UNSIGNED_BYTE, data_); + return vec2(width, height); } - TVec2 COpenGLTexture2D::Load(const TVec2& _Dimentions) + vec2 opengl_texture_2d::Load(const vec2& dimentions) { ARC_PROFILE_FUNCTION(); - mInternalFormat = GL_RGBA8; - mDataFormat = GL_RGBA; - mBytesPerPixel = 4; + internal_format_ = GL_RGBA8; + data_format_ = GL_RGBA; + bytes_per_pixel_ = 4; - glCreateTextures(GL_TEXTURE_2D, 1, &mRendererID); - glTextureStorage2D(mRendererID, 1, mInternalFormat, _Dimentions.x, _Dimentions.y); + glCreateTextures(GL_TEXTURE_2D, 1, &renderer_id_); + glTextureStorage2D(renderer_id_, 1, internal_format_, dimentions.x, dimentions.y); - glTextureParameteri(mRendererID, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTextureParameteri(mRendererID, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTextureParameteri(mRendererID, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTextureParameteri(mRendererID, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTextureParameteri(renderer_id_, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTextureParameteri(renderer_id_, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTextureParameteri(renderer_id_, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTextureParameteri(renderer_id_, GL_TEXTURE_WRAP_T, GL_REPEAT); - return _Dimentions; + return dimentions; } } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLTexture.h b/ARC-Engine/src/Platform/OpenGl/OpenGLTexture.h index 3ba4d6ac50..ae902e2111 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLTexture.h +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLTexture.h @@ -2,40 +2,40 @@ #include "ARC\Renderer\Texture.h" #include -namespace ARC { - class COpenGLTexture2D : - public CTexture2D +namespace arc { + class opengl_texture_2d : + public texture_2d { public: - COpenGLTexture2D(const TVec2& _Dimentions); - COpenGLTexture2D(const std::filesystem::path & _Path, bool bManualClear = false); - virtual ~COpenGLTexture2D() override; + opengl_texture_2d(const vec2& dimentions); + opengl_texture_2d(const std::filesystem::path & path, bool bManualClear = false); + virtual ~opengl_texture_2d() override; - virtual void SetData(void* _Data, uint32_t _Size) override; + virtual void set_data(void* data, uint32_t size) override; - virtual void Bind(uint32_t _Slot = 0) const override; + virtual void bind(uint32_t slot = 0) const override; virtual void ClearData() override; - virtual const std::filesystem::path& GetPath() const override { return mPath; }; + virtual const std::filesystem::path& get_path() const override { return path_; }; - virtual TVec4 GetPixelColor(TVec2 xy) override; + virtual vec4 get_pixel_color(vec2 xy) override; - virtual bool operator==(const CTexture& _Tex) const override { - return mRendererID == ((COpenGLTexture2D&)_Tex).mRendererID; + virtual bool operator==(const texture& tex) const override { + return renderer_id_ == ((opengl_texture_2d&)tex).renderer_id_; }; - uint32_t GetRendererID() override { return mRendererID; }; + uint32_t get_renderer_id() override { return renderer_id_; }; private: - TVec2 Load(const TVec2& _Dimentions); - TVec2 Load(const std::filesystem::path& _Path); + vec2 Load(const vec2& dimentions); + vec2 Load(const std::filesystem::path& path); private: - uint32_t mBytesPerPixel; + uint32_t bytes_per_pixel_; - unsigned int mInternalFormat; //GLenum - unsigned int mDataFormat; //GLenum - unsigned char* mData; - std::filesystem::path mPath; - uint32_t mRendererID; + unsigned int internal_format_; //GLenum + unsigned int data_format_; //GLenum + unsigned char* data_; + std::filesystem::path path_; + uint32_t renderer_id_; }; } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLVertexArray.cpp b/ARC-Engine/src/Platform/OpenGl/OpenGLVertexArray.cpp index d3edc2f2b6..2d1278ef9b 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLVertexArray.cpp +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLVertexArray.cpp @@ -3,22 +3,22 @@ #include "glad\glad.h" #include "ARC\Renderer\Buffer.h" -namespace ARC { +namespace arc { struct SOpenGLShaderHelper { - static GLenum ShaderTypeToOpenGlBaseType(EShaderDataType _Type) { - switch (_Type) + static GLenum ShaderTypeToOpenGlBaseType(shader_data_type type) { + switch (type) { - case EShaderDataType::Float: return GL_FLOAT; - case EShaderDataType::Float2: return GL_FLOAT; - case EShaderDataType::Float3: return GL_FLOAT; - case EShaderDataType::Float4: return GL_FLOAT; - case EShaderDataType::Mat3: return GL_FLOAT; - case EShaderDataType::Mat4: return GL_FLOAT; - case EShaderDataType::Int: return GL_INT; - case EShaderDataType::Int2: return GL_INT; - case EShaderDataType::Int3: return GL_INT; - case EShaderDataType::Int4: return GL_INT; - case EShaderDataType::Bool: return GL_BOOL; + case shader_data_type::Float: return GL_FLOAT; + case shader_data_type::Float2: return GL_FLOAT; + case shader_data_type::Float3: return GL_FLOAT; + case shader_data_type::Float4: return GL_FLOAT; + case shader_data_type::Mat3: return GL_FLOAT; + case shader_data_type::Mat4: return GL_FLOAT; + case shader_data_type::Int: return GL_INT; + case shader_data_type::Int2: return GL_INT; + case shader_data_type::Int3: return GL_INT; + case shader_data_type::Int4: return GL_INT; + case shader_data_type::Bool: return GL_BOOL; } ARC_CORE_ASSERT(false, "UnknownShaderDataType"); @@ -26,63 +26,63 @@ namespace ARC { }; }; - COpenGLVertexArray::COpenGLVertexArray() + opengl_vertex_array::opengl_vertex_array() { - glCreateVertexArrays(1, &mRendererId); + glCreateVertexArrays(1, &renderer_id_); } - COpenGLVertexArray::~COpenGLVertexArray() + opengl_vertex_array::~opengl_vertex_array() { - glDeleteVertexArrays(1, &mRendererId); + glDeleteVertexArrays(1, &renderer_id_); } - void COpenGLVertexArray::AddVertexBuffer(const TRef& _VertexBuffer) + void opengl_vertex_array::add_vertex_buffer(const ref& vertex_buffer) { - Bind(); - _VertexBuffer->Bind(); + bind(); + vertex_buffer->bind(); - ARC_CORE_ASSERT(_VertexBuffer->GetLayout().GetElements().size(), "Vertex Buffer has no layout!"); + ARC_CORE_ASSERT(vertex_buffer->get_layout().get_elements().size(), "Vertex Buffer has no layout!"); uint32_t index = 0; - const auto& layout = _VertexBuffer->GetLayout(); + const auto& layout = vertex_buffer->get_layout(); for (const auto& ielement : layout) { switch (ielement.Type) { - case EShaderDataType::Float: - case EShaderDataType::Float2: - case EShaderDataType::Float3: - case EShaderDataType::Float4: + case shader_data_type::Float: + case shader_data_type::Float2: + case shader_data_type::Float3: + case shader_data_type::Float4: { glEnableVertexAttribArray(index); glVertexAttribPointer(index, - SShaderHelper::GetComponentCount(ielement.Type), + shader_helper::get_component_count(ielement.Type), SOpenGLShaderHelper::ShaderTypeToOpenGlBaseType(ielement.Type), ielement.bNormalized ? GL_TRUE : GL_FALSE, - layout.GetStride(), - (const void*)(const TUInt64)ielement.Offset); + layout.get_stride(), + (const void*)(const u64)ielement.Offset); index++; break; } - case EShaderDataType::Int: - case EShaderDataType::Int2: - case EShaderDataType::Int3: - case EShaderDataType::Int4: - case EShaderDataType::Bool: + case shader_data_type::Int: + case shader_data_type::Int2: + case shader_data_type::Int3: + case shader_data_type::Int4: + case shader_data_type::Bool: { glEnableVertexAttribArray(index); glVertexAttribIPointer(index, - SShaderHelper::GetComponentCount(ielement.Type), + shader_helper::get_component_count(ielement.Type), SOpenGLShaderHelper::ShaderTypeToOpenGlBaseType(ielement.Type), - layout.GetStride(), - (const void*)(const TUInt64)ielement.Offset); + layout.get_stride(), + (const void*)(const u64)ielement.Offset); index++; break; } - case EShaderDataType::Mat3: - case EShaderDataType::Mat4: + case shader_data_type::Mat3: + case shader_data_type::Mat4: { - uint8_t count = SShaderHelper::GetComponentCount(ielement.Type); + uint8_t count = shader_helper::get_component_count(ielement.Type); for (uint8_t i = 0; i < count; i++) { glEnableVertexAttribArray(index); @@ -90,7 +90,7 @@ namespace ARC { count, SOpenGLShaderHelper::ShaderTypeToOpenGlBaseType(ielement.Type), ielement.bNormalized ? GL_TRUE : GL_FALSE, - layout.GetStride(), + layout.get_stride(), (const void*)(ielement.Offset + sizeof(float) * count * i)); glVertexAttribDivisor(index, 1); index++; @@ -98,36 +98,36 @@ namespace ARC { break; } default: - ARC_CORE_ASSERT(false, "Unknown EShaderDataType!"); + ARC_CORE_ASSERT(false, "Unknown shader_data_type!"); } } - mVertexBuffers.push_back(_VertexBuffer); + vertex_buffers_.push_back(vertex_buffer); } - void COpenGLVertexArray::SetIndexBuffer(const TRef& _IndexBuffer) + void opengl_vertex_array::set_index_buffer(const ref& index_buffer) { - Bind(); - _IndexBuffer->Bind(); + bind(); + index_buffer->bind(); - mIndexBuffer = _IndexBuffer; + index_buffer_ = index_buffer; } - const std::vector>& COpenGLVertexArray::GetVertexBuffers() const + const std::vector>& opengl_vertex_array::get_vertex_buffers() const { - return mVertexBuffers; + return vertex_buffers_; } - const TRef& COpenGLVertexArray::GetIndexBuffer() const + const ref& opengl_vertex_array::get_index_buffer() const { - return mIndexBuffer; + return index_buffer_; } - void COpenGLVertexArray::Bind() const + void opengl_vertex_array::bind() const { - glBindVertexArray(mRendererId); + glBindVertexArray(renderer_id_); } - void COpenGLVertexArray::UnBind() const + void opengl_vertex_array::UnBind() const { glBindVertexArray(0); } diff --git a/ARC-Engine/src/Platform/OpenGl/OpenGLVertexArray.h b/ARC-Engine/src/Platform/OpenGl/OpenGLVertexArray.h index fc895b3d6b..5060537fe4 100644 --- a/ARC-Engine/src/Platform/OpenGl/OpenGLVertexArray.h +++ b/ARC-Engine/src/Platform/OpenGl/OpenGLVertexArray.h @@ -1,29 +1,29 @@ #pragma once #include "..\..\ARC\Renderer\VertexArray.h" -namespace ARC { -class COpenGLVertexArray : public CVertexArray +namespace arc { +class opengl_vertex_array : public vertex_array { public: - COpenGLVertexArray(); - virtual ~COpenGLVertexArray(); + opengl_vertex_array(); + virtual ~opengl_vertex_array(); /* * @note Do not add vertex buffer before assigning a layout */ - virtual void AddVertexBuffer(const TRef& _VertexBuffer) override; - virtual void SetIndexBuffer(const TRef& _IndexBuffer) override; + virtual void add_vertex_buffer(const ref& vertex_buffer) override; + virtual void set_index_buffer(const ref& index_buffer) override; - virtual const std::vector>& GetVertexBuffers() const override; - virtual const TRef& GetIndexBuffer() const override; + virtual const std::vector>& get_vertex_buffers() const override; + virtual const ref& get_index_buffer() const override; - virtual void Bind() const override; + virtual void bind() const override; virtual void UnBind() const override; private: - uint32_t mRendererId; - std::vector> mVertexBuffers; - TRef mIndexBuffer; + uint32_t renderer_id_; + std::vector> vertex_buffers_; + ref index_buffer_; }; } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/Windows/WindowsInput.cpp b/ARC-Engine/src/Platform/Windows/WindowsInput.cpp index 514d41d8a3..d9d67206d0 100644 --- a/ARC-Engine/src/Platform/Windows/WindowsInput.cpp +++ b/ARC-Engine/src/Platform/Windows/WindowsInput.cpp @@ -4,31 +4,31 @@ #include "GLFW/glfw3.h" #include "ARC/Core/Window.h" -namespace ARC { - bool SInput::IsKeyPressed(int _keycode) +namespace arc { + bool input::is_key_pressed(int _keycode) { - auto state = GetKey(_keycode); + auto state = get_key(_keycode); return state == GLFW_PRESS || state == GLFW_REPEAT; } - bool SInput::IsMouseButtonPressed(int _button) + bool input::is_mouse_button_pressed(int _button) { - auto window = static_cast(CApplication::Get().GetWindow().GetNativeWindow()); + auto window = static_cast(application::Get().get_window().get_native_window()); auto state = glfwGetMouseButton(window, _button); return state == GLFW_PRESS; } - FVec2 SInput::GetMouseXY() + vec2 input::get_mouse_xy() { - auto window = static_cast(CApplication::Get().GetWindow().GetNativeWindow()); - TVec2 mousexy; + auto window = static_cast(application::Get().get_window().get_native_window()); + vec2 mousexy; glfwGetCursorPos(window, &mousexy.x, &mousexy.y); - return FVec2((float)mousexy.x, (float)mousexy.y); + return vec2((float)mousexy.x, (float)mousexy.y); } - int SInput::GetKey(int _keycode) + int input::get_key(int _keycode) { - auto window = static_cast(CApplication::Get().GetWindow().GetNativeWindow()); + auto window = static_cast(application::Get().get_window().get_native_window()); return glfwGetKey(window, _keycode); } } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/Windows/WindowsPlatformUtils.cpp b/ARC-Engine/src/Platform/Windows/WindowsPlatformUtils.cpp index 68879ae3a9..e5c64703ca 100644 --- a/ARC-Engine/src/Platform/Windows/WindowsPlatformUtils.cpp +++ b/ARC-Engine/src/Platform/Windows/WindowsPlatformUtils.cpp @@ -8,47 +8,47 @@ #include #include "ARC/Core/Window.h" -namespace ARC +namespace arc { - std::filesystem::path SFileDialogs::OpenFile(const char* _Filter) + std::filesystem::path file_dialogs::open_file(const char* filter) { OPENFILENAMEA ofn; CHAR szFile[260] = { 0 }; CHAR currentDir[256] = { 0 }; ZeroMemory(&ofn, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = glfwGetWin32Window((GLFWwindow*)CApplication::Get().GetWindow().GetNativeWindow()); + ofn.hwndOwner = glfwGetWin32Window((GLFWwindow*)application::Get().get_window().get_native_window()); ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); - if (GetCurrentDirectoryA(256, currentDir)) + if (get_current_directory_a(256, currentDir)) ofn.lpstrInitialDir = currentDir; - ofn.lpstrFilter = _Filter; + ofn.lpstrFilter = filter; ofn.nFilterIndex = 1; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR; - if (GetOpenFileNameA(&ofn) == TRUE) + if (get_open_file_name_a(&ofn) == TRUE) return ofn.lpstrFile; return std::filesystem::path(); } - std::filesystem::path SFileDialogs::SaveFile(const char* _Filter) + std::filesystem::path file_dialogs::save_file(const char* filter) { OPENFILENAMEA ofn; CHAR szFile[260] = { 0 }; CHAR currentDir[256] = { 0 }; ZeroMemory(&ofn, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = glfwGetWin32Window((GLFWwindow*)CApplication::Get().GetWindow().GetNativeWindow()); + ofn.hwndOwner = glfwGetWin32Window((GLFWwindow*)application::Get().get_window().get_native_window()); ofn.lpstrFile = szFile; ofn.nMaxFile = sizeof(szFile); - if (GetCurrentDirectoryA(256, currentDir)) + if (get_current_directory_a(256, currentDir)) ofn.lpstrInitialDir = currentDir; - ofn.lpstrFilter = _Filter; + ofn.lpstrFilter = filter; ofn.nFilterIndex = 1; - ofn.lpstrDefExt = std::strchr(_Filter, '\0') + 1; + ofn.lpstrDefExt = std::strchr(filter, '\0') + 1; ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR; - if (GetSaveFileNameA(&ofn) == TRUE) + if (get_save_file_name_a(&ofn) == TRUE) return ofn.lpstrFile; return std::string(); diff --git a/ARC-Engine/src/Platform/Windows/WindowsWindow.cpp b/ARC-Engine/src/Platform/Windows/WindowsWindow.cpp index ba521e4610..eaff39fe5c 100644 --- a/ARC-Engine/src/Platform/Windows/WindowsWindow.cpp +++ b/ARC-Engine/src/Platform/Windows/WindowsWindow.cpp @@ -12,51 +12,51 @@ #include "Platform\OpenGl\OpenGLContext.h" #include "ARC/Core/Macros.h" -namespace ARC{ +namespace arc{ static bool s_bGLFWInitialized = false; static void GLFWErrorCallback(int _error, const char* _description) { ARC_CORE_ERROR("GLFW Error ({0}): {1}", _error, _description); }; - CWindowsWindow::CWindowsWindow(const SWindowProps& _props) + windows_window::windows_window(const window_props& _props) { ARC_PROFILE_FUNCTION(); - Init(_props); + init(_props); } - CWindowsWindow::~CWindowsWindow() + windows_window::~windows_window() { - Shutdown(); + shutdown(); } - void CWindowsWindow::OnUpdate() + void windows_window::on_update() { glfwPollEvents(); - mContext->SwapBuffers(); + context_->swap_buffers(); } - void CWindowsWindow::SetVSync(bool _bEnabled) + void windows_window::set_vsync(bool _bEnabled) { glfwSwapInterval(_bEnabled); - mData.bVSync = _bEnabled; + data_.bVSync = _bEnabled; } - void* CWindowsWindow::GetNativeWindow() const + void* windows_window::get_native_window() const { - return mWindow; + return window_; } - CWindow* CWindow::Create(const SWindowProps& _props /*= WindowProps()*/) + window* window::create(const window_props& _props /*= WindowProps()*/) { - return new CWindowsWindow(_props); + return new windows_window(_props); } - void CWindowsWindow::Init(const SWindowProps& _props) + void windows_window::init(const window_props& _props) { ARC_PROFILE_FUNCTION(); - mData.Title = _props.Title; - mData.Width = _props.Width; - mData.Height = _props.Height; + data_.Title = _props.Title; + data_.Width = _props.Width; + data_.Height = _props.Height; ARC_CORE_INFO("Creating window {0} ({1}, {2})", _props.Title, _props.Width, _props.Height); @@ -67,83 +67,83 @@ namespace ARC{ s_bGLFWInitialized = success; } - mWindow = glfwCreateWindow((int)_props.Width, (int)_props.Height, _props.Title.c_str(), nullptr, nullptr); + window_ = glfwCreateWindow((int)_props.Width, (int)_props.Height, _props.Title.c_str(), nullptr, nullptr); - mContext = new COpenGLContext(mWindow); - mContext->Init(); + context_ = new opengl_context(window_); + context_->init(); - glfwSetWindowUserPointer(mWindow, &mData); - SetVSync(true); + glfwSetWindowUserPointer(window_, &data_); + set_vsync(true); - glfwSetWindowSizeCallback(mWindow, [](GLFWwindow* _window, int _width, int _height){ - SWindowData& Data = *(SWindowData*)glfwGetWindowUserPointer(_window); + glfwSetWindowSizeCallback(window_, [](GLFWwindow* _window, int _width, int _height){ + window_data& Data = *(window_data*)glfwGetWindowUserPointer(_window); Data.Width = _width; Data.Height = _height; - CWindowResizeEvent event(_width, _height); + window_resize_event event(_width, _height); Data.EventCallback(event); }); - glfwSetWindowCloseCallback(mWindow, [](GLFWwindow* _window){ - SWindowData& Data = *(SWindowData*)glfwGetWindowUserPointer(_window); - CWindowCloseEvent event; + glfwSetWindowCloseCallback(window_, [](GLFWwindow* _window){ + window_data& Data = *(window_data*)glfwGetWindowUserPointer(_window); + window_close_event event; Data.EventCallback(event); }); - glfwSetKeyCallback(mWindow, [](GLFWwindow* _window, int _key, int _scancode, int _action, int _mods){ - SWindowData& Data = *(SWindowData*)glfwGetWindowUserPointer(_window); + glfwSetKeyCallback(window_, [](GLFWwindow* _window, int _key, int _scancode, int _action, int _mods){ + window_data& Data = *(window_data*)glfwGetWindowUserPointer(_window); switch (_action) { case GLFW_PRESS: { - CKeyPressedEvent event(_key, 0); + key_pressed_event event(_key, 0); Data.EventCallback(event); break; } case GLFW_RELEASE: { - CKeyReleasedEvent event(_key); + key_released_event event(_key); Data.EventCallback(event); break; } case GLFW_REPEAT: { - CKeyReleasedEvent event(_key); + key_released_event event(_key); Data.EventCallback(event); break; } } }); - glfwSetCharCallback(mWindow, [](GLFWwindow* _window, TUInt _keycode) { - SWindowData& Data = *(SWindowData*)glfwGetWindowUserPointer(_window); - CKeyTypedEvent _event(_keycode); + glfwSetCharCallback(window_, [](GLFWwindow* _window, uint _keycode) { + window_data& Data = *(window_data*)glfwGetWindowUserPointer(_window); + key_typed_event _event(_keycode); Data.EventCallback(_event); }); - glfwSetMouseButtonCallback(mWindow, [](GLFWwindow* _window, int _button, int _action, int _mods) { - SWindowData& Data = *(SWindowData*)glfwGetWindowUserPointer(_window); + glfwSetMouseButtonCallback(window_, [](GLFWwindow* _window, int _button, int _action, int _mods) { + window_data& Data = *(window_data*)glfwGetWindowUserPointer(_window); switch (_action) { case GLFW_PRESS: { - CMouseButtonPressedEvent event(_button); + mouse_button_pressed_event event(_button); Data.EventCallback(event); break; } case GLFW_RELEASE: { - CMouseButtonReleasedEvent event(_button); + mouse_button_released_event event(_button); Data.EventCallback(event); break; } } }); - glfwSetScrollCallback(mWindow, [](GLFWwindow* _window, double _xoffset, double _yoffset) { - SWindowData& Data = *(SWindowData*)glfwGetWindowUserPointer(_window); - CMouseScrolledEvent event((float)_xoffset, (float)_yoffset); + glfwSetScrollCallback(window_, [](GLFWwindow* _window, double _xoffset, double _yoffset) { + window_data& Data = *(window_data*)glfwGetWindowUserPointer(_window); + mouse_scrolled_event event((float)_xoffset, (float)_yoffset); Data.EventCallback(event); }); - glfwSetCursorPosCallback(mWindow, [](GLFWwindow* _window, double _xpos, double _ypos) { - SWindowData& Data = *(SWindowData*)glfwGetWindowUserPointer(_window); - CMouseMovedEvent _event((float)_xpos, (float)_ypos); + glfwSetCursorPosCallback(window_, [](GLFWwindow* _window, double _xpos, double _ypos) { + window_data& Data = *(window_data*)glfwGetWindowUserPointer(_window); + mouse_moved_event _event((float)_xpos, (float)_ypos); Data.EventCallback(_event); }); } - void CWindowsWindow::Shutdown() + void windows_window::shutdown() { - glfwDestroyWindow(mWindow); + glfwDestroyWindow(window_); } } \ No newline at end of file diff --git a/ARC-Engine/src/Platform/Windows/WindowsWindow.h b/ARC-Engine/src/Platform/Windows/WindowsWindow.h index 57711534a1..edf9194225 100644 --- a/ARC-Engine/src/Platform/Windows/WindowsWindow.h +++ b/ARC-Engine/src/Platform/Windows/WindowsWindow.h @@ -5,51 +5,51 @@ #include "GLFW/glfw3.h" #pragma warning(pop) -namespace ARC { class CGraphicsContext; } +namespace arc { class graphics_context; } -namespace ARC{ - class CWindowsWindow : public CWindow +namespace arc{ + class windows_window : public window { /*--------------FUNCS--------------*/ public: - CWindowsWindow(const SWindowProps& _props); - virtual ~CWindowsWindow(); + windows_window(const window_props& _props); + virtual ~windows_window(); - void OnUpdate() override; + void on_update() override; - inline unsigned int GetWidth() const override { return mData.Width; } - inline unsigned int GetHeight() const override { return mData.Height; } - inline void SetWidth(unsigned int _) override {mData.Width = _; }; - inline void SetHeight(unsigned int _) override { mData.Height = _; }; + inline unsigned int get_width() const override { return data_.Width; } + inline unsigned int get_height() const override { return data_.Height; } + inline void set_width(unsigned int _) override {data_.Width = _; }; + inline void set_height(unsigned int _) override { data_.Height = _; }; - inline void SetEventCallback(const EventCallbackFn& _callback) override { mData.EventCallback = _callback; } + inline void set_event_callback(const event_callback_fn& _callback) override { data_.EventCallback = _callback; } - virtual void SetVSync(bool _bEnabled) override; - virtual bool IsVSync() const override {return mData.bVSync;} + virtual void set_vsync(bool _bEnabled) override; + virtual bool is_vsync() const override {return data_.bVSync;} - virtual void* GetNativeWindow() const override; + virtual void* get_native_window() const override; protected: private: - virtual void Init(const SWindowProps& _props); - virtual void Shutdown(); + virtual void init(const window_props& _props); + virtual void shutdown(); /*---------------------------------*/ /*---------------VARS--------------*/ public: protected: private: - GLFWwindow* mWindow; - CGraphicsContext* mContext; - struct SWindowData + GLFWwindow* window_; + graphics_context* context_; + struct window_data { std::string Title; unsigned int Width, Height; unsigned int bVSync : 1; - EventCallbackFn EventCallback; + event_callback_fn EventCallback; }; - SWindowData mData; + window_data data_; /*---------------------------------*/ }; diff --git a/Sandbox/src/ECSExample.cpp b/Sandbox/src/ECSExample.cpp index 8048cf533d..dadee443b9 100644 --- a/Sandbox/src/ECSExample.cpp +++ b/Sandbox/src/ECSExample.cpp @@ -6,25 +6,25 @@ // #include "ARC/Input/Input.h" // #include "ARC/Input/KeyCodes.h" // -// namespace ARC { +// namespace arc { // // using namespace ECS; // -// EntityIndex_t CECSExample::mkPlayer() +// EntityIndex_t ecs_example::mkPlayer() // { // auto e(mgr.CreateIndex()); // mgr.AddTag(e); // -// auto& pos(mgr.AddComponent(e).value); -// auto& vel(mgr.AddComponent(e).value); -// auto& hitbox(mgr.AddComponent(e).Primitive); -// auto& shape(mgr.AddComponent(e).Primitive); -// auto& cooldown(mgr.AddComponent(e)); +// auto& pos(mgr.add_component(e).value); +// auto& vel(mgr.add_component(e).value); +// auto& hitbox(mgr.add_component(e).Primitive); +// auto& shape(mgr.add_component(e).Primitive); +// auto& cooldown(mgr.add_component(e)); // // pos = { 0.32f / 2.f, 0.17f }; // vel = { 0.f, 0.f }; // shape.Color = CColor::Green; -// FVec2 size{ 0.4f, 0.4f }; +// vec2 size{ 0.4f, 0.4f }; // shape.Transform.Scale = size; // hitbox.Transform.Scale = size; // cooldown.value = cooldown.maxValue = 1.6f; @@ -32,22 +32,22 @@ // return e; // } // -// EntityIndex_t CECSExample::mkBoss() +// EntityIndex_t ecs_example::mkBoss() // { // auto e(mgr.CreateIndex()); // mgr.AddTag(e); // -// auto& pos(mgr.AddComponent(e).value); -// auto& vel(mgr.AddComponent(e).value); -// auto& hitbox(mgr.AddComponent(e).Primitive); -// auto& shape(mgr.AddComponent(e).Primitive); -// auto& health(mgr.AddComponent(e).value); -// auto& cooldown(mgr.AddComponent(e)); +// auto& pos(mgr.add_component(e).value); +// auto& vel(mgr.add_component(e).value); +// auto& hitbox(mgr.add_component(e).Primitive); +// auto& shape(mgr.add_component(e).Primitive); +// auto& health(mgr.add_component(e).value); +// auto& cooldown(mgr.add_component(e)); // // pos = { 0.32f / 2.f, 0.040f }; // vel = { 0.f, 0.f }; // shape.Color = CColor::Red; -// FVec2 size{ 0.6f, 0.6f }; +// vec2 size{ 0.6f, 0.6f }; // shape.Transform.Scale = size; // hitbox.Transform.Scale = size; // health = 10.f; @@ -56,19 +56,19 @@ // return e; // } // -// EntityIndex_t CECSExample::mkBullet(const FVec2& mPos) +// EntityIndex_t ecs_example::mkBullet(const vec2& pos_) // { // auto e(mgr.CreateIndex()); // mgr.AddTag(e); // -// auto& pos(mgr.AddComponent(e).value); -// auto& vel(mgr.AddComponent(e).value); -// auto& acc(mgr.AddComponent(e).value); -// auto& hitbox(mgr.AddComponent(e).Primitive); -// auto& shape(mgr.AddComponent(e).Primitive); -// auto& life(mgr.AddComponent(e).value); +// auto& pos(mgr.add_component(e).value); +// auto& vel(mgr.add_component(e).value); +// auto& acc(mgr.add_component(e).value); +// auto& hitbox(mgr.add_component(e).Primitive); +// auto& shape(mgr.add_component(e).Primitive); +// auto& life(mgr.add_component(e).value); // -// pos = mPos; +// pos = pos_; // vel = { 0.f, -0.6f }; // acc = { HPR::Random::Float(-0.01f, 0.01f), HPR::Random::Float(-0.01f, 0.02f) }; // shape.Color = CColor::Red; @@ -79,19 +79,19 @@ // return e; // } // -// EntityIndex_t CECSExample::mkPlayerBullet(const FVec2& mPos) +// EntityIndex_t ecs_example::mkPlayerBullet(const vec2& pos_) // { // auto e(mgr.CreateIndex()); // mgr.AddTag(e); // -// auto& pos(mgr.AddComponent(e).value); -// auto& vel(mgr.AddComponent(e).value); -// auto& acc(mgr.AddComponent(e).value); -// auto& hitbox(mgr.AddComponent(e).Primitive); -// auto& shape(mgr.AddComponent(e).Primitive); -// auto& life(mgr.AddComponent(e).value); +// auto& pos(mgr.add_component(e).value); +// auto& vel(mgr.add_component(e).value); +// auto& acc(mgr.add_component(e).value); +// auto& hitbox(mgr.add_component(e).Primitive); +// auto& shape(mgr.add_component(e).Primitive); +// auto& life(mgr.add_component(e).value); // -// pos = mPos; +// pos = pos_; // vel = { 0.f, 0.6f }; // acc = { 0.f, 0.f }; // shape.Color = CColor(0, 1, 1, 1); @@ -102,102 +102,102 @@ // return e; // } // -// auto IsCollision(const CPosition& mP0, const CHitbox& mC0, -// const CPosition& mP1, const CHitbox& mC1) +// auto IsCollision(const CPosition& p0_, const CHitbox& c0_, +// const CPosition& p1_, const CHitbox& c1_) // { -// auto dist(FVec2::Dist(mP0.value, mP1.value)); -// return dist <= (mC0.Primitive.GetScale().x + mC1.Primitive.GetScale().x)/2; // @temp +// auto dist(vec2::Dist(p0_.value, p1_.value)); +// return dist <= (c0_.Primitive.GetScale().x + c1_.Primitive.GetScale().x)/2; // @temp // } // // template -// void CooldownAction(float _DeltaTime, CCooldown& mCD, TFunction&& mFunction) +// void CooldownAction(float delta_time, CCooldown& cd_, TFunction&& function_) // { -// mCD.value -= _DeltaTime; -// if (mCD.value > 0.f) return; +// cd_.value -= delta_time; +// if (cd_.value > 0.f) return; // -// beforeRefresh.emplace_back(mFunction); -// mCD.value = mCD.maxValue; +// beforeRefresh.emplace_back(function_); +// cd_.value = cd_.maxValue; // } // -// void CECSExample::updatePlayerInput( -// float mFT, CPosition& pPos, CVelocity& pVel, CCooldown& pCD) +// void ecs_example::updatePlayerInput( +// float ft_, CPosition& pPos, CVelocity& pVel, CCooldown& pCD) // { // constexpr float speed{ 2.f }; -// FVec2 xyInput = {0.f, 0.f}; +// vec2 xyInput = {0.f, 0.f}; // bool shoot; // -// using ARCK = ARC::CInput; +// using ARCK = arc::CInput; // // // Get horizontal movement. -// if (ARCK::IsKeyPressed(ARC_KEY_LEFT)) +// if (ARCK::is_key_pressed(ARC_KEY_LEFT)) // xyInput.x = -1; -// else if (ARCK::IsKeyPressed(ARC_KEY_RIGHT)) +// else if (ARCK::is_key_pressed(ARC_KEY_RIGHT)) // xyInput.x = 1; // // // Get vertical movement. -// if (ARCK::IsKeyPressed(ARC_KEY_UP)) +// if (ARCK::is_key_pressed(ARC_KEY_UP)) // xyInput.y = 1; -// else if (ARCK::IsKeyPressed(ARC_KEY_DOWN)) +// else if (ARCK::is_key_pressed(ARC_KEY_DOWN)) // xyInput.y = -1; // // // Get shooting state. -// shoot = ARCK::IsKeyPressed(ARC_KEY_Z); +// shoot = ARCK::is_key_pressed(ARC_KEY_Z); // -// // Calculate velocity vector. +// // calculate velocity vector. // auto radians = Math::Atan2(xyInput.y, xyInput.x); // -// auto dir = FVec2(Math::Cos(radians), Math::Sin(radians)); +// auto dir = vec2(Math::Cos(radians), Math::Sin(radians)); // pVel.value = dir * speed * xyInput.Length(); // // // Enqueue shooting action. -// CooldownAction(mFT, pCD, [this, shoot, pPos] +// CooldownAction(ft_, pCD, [this, shoot, pPos] // { // if (!shoot) return; // mkPlayerBullet(pPos.value); // }); // } // -// CECSExample::CECSExample() : -// CLayer("ECSExample"), +// ecs_example::ecs_example() : +// layer("ECSExample"), // m_CameraController(1280.f / 780.f, true) // { -// ARC_CORE_INFO("CECSExample: {}", __COUNTER__); +// ARC_CORE_INFO("ecs_example: {}", __COUNTER__); // } // -// void CECSExample::OnAttach() +// void ecs_example::on_attach() // { // mkBoss(); // mkPlayer(); // m_CameraController.SetZoomLevel(1.f); // } // -// void CECSExample::OnDetach() +// void ecs_example::on_detach() // { // // } // -// void CECSExample::OnUpdate(float _DeltaTime) +// void ecs_example::on_update(float delta_time) // { // { // ARC_PROFILE_SCOPE("Stuff"); -// m_CameraController.OnUpdate(_DeltaTime); +// m_CameraController.on_update(delta_time); // -// CRenderCommand::SetClearColour({ .1f, .1f, .1f, 1.f }); -// CRenderCommand::Clear(); +// render_command::SetClearColour({ .1f, .1f, .1f, 1.f }); +// render_command::clear(); // } // -// ARC::CRenderer2D::ResetStats(); +// arc::CRenderer2D::ResetStats(); // // mgr.UpdateMatchingEntities( -// [_DeltaTime](auto cEnt, auto& cPosition, auto& cVelocity) +// [delta_time](auto cEnt, auto& cPosition, auto& cVelocity) // { -// cPosition.value += cVelocity.value * _DeltaTime; +// cPosition.value += cVelocity.value * delta_time; // }); // // mgr.UpdateMatchingEntities( -// [_DeltaTime](auto, auto& cVelocity, auto& cAcceleration) +// [delta_time](auto, auto& cVelocity, auto& cAcceleration) // { -// cVelocity.value += cAcceleration.value * _DeltaTime; +// cVelocity.value += cAcceleration.value * delta_time; // }); // // mgr.UpdateMatchingEntities( @@ -213,9 +213,9 @@ // s.Transform.Location = cPosition.value; // }); // -// mgr.UpdateMatchingEntities([this, _DeltaTime](auto e, auto& cLife) +// mgr.UpdateMatchingEntities([this, delta_time](auto e, auto& cLife) // { -// cLife.value -= _DeltaTime; +// cLife.value -= delta_time; // // if (cLife.value <= 0) // { @@ -223,22 +223,22 @@ // } // }); // -// mgr.UpdateMatchingEntities([this, _DeltaTime]( +// mgr.UpdateMatchingEntities([this, delta_time]( // auto pI, auto& pPos, auto& pVel, auto&, auto& pHitbox, auto& pCD) // { -// updatePlayerInput(_DeltaTime, pPos, pVel, pCD); +// updatePlayerInput(delta_time, pPos, pVel, pCD); // // // Player/Boss logic. // // If there is a player and a boss, the boss will move // // towards the player and try to shoot. -// mgr.UpdateMatchingEntities([this, _DeltaTime, &pPos](auto, +// mgr.UpdateMatchingEntities([this, delta_time, &pPos](auto, // auto& bssPos, auto& bssVel, auto&, auto&, auto&, auto& bssCD) // { // constexpr auto speed(0.7f); // auto left(pPos.value.x < bssPos.value.x); // bssVel.value.x = left ? -speed : speed; // -// CooldownAction(_DeltaTime, bssCD, [this, bssPos] +// CooldownAction(delta_time, bssCD, [this, bssPos] // { // mkBullet(bssPos.value); // }); @@ -288,39 +288,39 @@ // // mgr.Refresh(); // -// CRenderer2D::BeginScene(m_CameraController.GetCamera()); +// CRenderer2D::begin_scene(m_CameraController.GetCamera()); // // mgr.UpdateMatchingEntities([](auto, auto&, auto& cRender) // { -// CRenderer2D::DrawQuad(cRender.Primitive); +// CRenderer2D::draw_quad(cRender.Primitive); // }); // mgr.UpdateMatchingEntities([](auto, auto&, auto& cRender) // { -// CRenderer2D::DrawQuad(cRender.Primitive); +// CRenderer2D::draw_quad(cRender.Primitive); // }); // -// CRenderer2D::EndScene(); +// CRenderer2D::end_scene(); // } // -// void CECSExample::OnGuiRender() +// void ecs_example::on_gui_render() // { -// ImGui::Begin("ECSExample"); -// ImGui::Text("Entities: %i", mgr.GetEntityCount()); +// ImGui::begin("ECSExample"); +// ImGui::Text("Entities: %i", mgr.get_entity_count()); // mgr.UpdateMatchingEntities([](auto, // auto&, auto&, auto&, auto&, auto& Health, auto&) // { // ImGui::Text("-Boss:\n--Health: %f", Health.value); // }); -// ImGui::End(); +// ImGui::end(); // } // -// void CECSExample::OnEvent(ARC::CEvent& _Event) +// void ecs_example::on_event(arc::event& event) // { // ARC_PROFILE_FUNCTION(); -// m_CameraController.OnEvent(_Event); +// m_CameraController.on_event(event); // } // -// void CECSExample::Render(ECS::EntityIndex_t _, CPosition& _0, CRender& _1) +// void ecs_example::Render(ECS::EntityIndex_t _, CPosition& _0, CRender& _1) // { // // } diff --git a/Sandbox/src/ECSExample.h b/Sandbox/src/ECSExample.h index 4f4bc3a6f0..7c1bd2e457 100644 --- a/Sandbox/src/ECSExample.h +++ b/Sandbox/src/ECSExample.h @@ -4,13 +4,13 @@ // #include // #include "ARC/Objects/Trial.h" // -// namespace ARC { class CShader; } +// namespace arc { class shader; } // -// namespace ARC { class CVertexArray; } +// namespace arc { class vertex_array; } // -// namespace ARC { class CEvent; } +// namespace arc { class event; } // -// namespace ARC { +// namespace arc { // using MyComponents = ECS::IMPL::ITRL_ComponentList::Next()-1>::type; // //using MyComponents = ECS::ComponentList; // using MyTags = ECS::TagList; @@ -33,34 +33,34 @@ // using MySettings = ECS::SSettings; // using MyManager = ECS::CManager; // -// class CECSExample : -// public CLayer +// class ecs_example : +// public layer // { // public: -// CECSExample(); -// virtual ~CECSExample() = default; +// ecs_example(); +// virtual ~ecs_example() = default; // // public: -// virtual void OnAttach() override; -// virtual void OnDetach() override; -// virtual void OnUpdate(float _DeltaTime) override; -// virtual void OnGuiRender() override; -// virtual void OnEvent(CEvent& _) override; +// virtual void on_attach() override; +// virtual void on_detach() override; +// virtual void on_update(float delta_time) override; +// virtual void on_gui_render() override; +// virtual void on_event(event& _) override; // // void Render(ECS::EntityIndex_t _, CPosition& _0, CRender& _1); // -// void updatePlayerInput(float mFT, CPosition& pPos, CVelocity& pVel, CCooldown& pCD); +// void updatePlayerInput(float ft_, CPosition& pPos, CVelocity& pVel, CCooldown& pCD); // // ECS::EntityIndex_t mkPlayer(); // ECS::EntityIndex_t mkBoss(); -// ECS::EntityIndex_t mkBullet(const FVec2& mPos); -// ECS::EntityIndex_t mkPlayerBullet(const FVec2& mPos); +// ECS::EntityIndex_t mkBullet(const vec2& pos_); +// ECS::EntityIndex_t mkPlayerBullet(const vec2& pos_); // -// TRef m_Shader; -// TRef m_VertexArray; +// ref m_Shader; +// ref m_VertexArray; // // private: -// COrthographicCameraController m_CameraController; +// orthographic_camera_controller m_CameraController; // MyManager mgr; // }; // diff --git a/Sandbox/src/Sandbox2D.cpp b/Sandbox/src/Sandbox2D.cpp index 68efc345a9..48429b89d0 100644 --- a/Sandbox/src/Sandbox2D.cpp +++ b/Sandbox/src/Sandbox2D.cpp @@ -19,10 +19,10 @@ #include "ARC/Types/Vector.h" #include "ARC/Types/Delegate.h" -namespace ARC { static bool bStressTest = false; } -static const uint32_t s_MapWidth = 24; -static uint32_t s_MapHeight = 12; -static const char* s_MapTiles = +namespace arc { static bool bStressTest = false; } +static const uint32_t map_width = 24; +static uint32_t map_height = 12; +static const char* map_tiles = "WWWWWWWWWWWWWWWWWWWWWWWW" "WWWWDDDDDDDDWWWWWWWWWWWW" "WWWDDDDDDDDDDDDDDDWWWWWW" @@ -36,138 +36,138 @@ static const char* s_MapTiles = "WWWWWWWWDDDDDDDWWWWWWWWW" "WWWWWWWWWWWWWWWWWWWWWWWW"; -CSandbox2D::CSandbox2D() : - CLayer("Sandbox2D"), +sandbox_2d::sandbox_2d() : + layer("Sandbox2D"), m_CameraController(1280.f / 780.f, true) { - ParticleSystem = ARC::CreateRef(); + ParticleSystem = arc::create_ref(); ParticleSystem->Defaults.bIsActive=false; ParticleSystem->Defaults.Scale = {0.4f, 0.4f}; - ParticleSystem->Defaults.Color = ARC::CColor::Red; + ParticleSystem->Defaults.Color = arc::CColor::Red; ParticleSystem->Defaults.Velocity = {0.f, 3.f}; ParticleSystem->Defaults.Life = 1.1f; - ParticleSystem->AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Life, 0.3f)); - //ParticleSystem->AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Color, ARC::CColor(0.1f, 0.1f, 0.1f, 0.f))); - ParticleSystem->AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Location, ARC::FVec2(0.5f, 0.5f))); - ParticleSystem->AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Scale, ARC::FVec2(0.2f, 0.2f))); - ParticleSystem->AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Velocity, ARC::FVec2(0.6f, 1.0f))); - ParticleSystem->AddParticleModifier(ARC::EVariationApplicationTime::OnUpdate, new ARC::CParticleLifetimeModifier2D(&ARC::CParticle2D::Color, ARC::CColor(1.f,1.f,0.f,1.f))); - ParticleSystem->AddParticleModifier(ARC::EVariationApplicationTime::OnUpdate, new ARC::CParticleLifetimeModifier2D, ARC::FVec2>(&ARC::CParticle2D::Scale, ARC::FVec2::ZeroVector)); + ParticleSystem->AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Life, 0.3f)); + //ParticleSystem->AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Color, arc::CColor(0.1f, 0.1f, 0.1f, 0.f))); + ParticleSystem->AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Location, arc::vec2(0.5f, 0.5f))); + ParticleSystem->AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Scale, arc::vec2(0.2f, 0.2f))); + ParticleSystem->AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Velocity, arc::vec2(0.6f, 1.0f))); + ParticleSystem->AddParticleModifier(arc::variation_application_time::on_update, new arc::particle_lifetime_modifier_2d(&arc::particle_2d::Color, arc::CColor(1.f,1.f,0.f,1.f))); + ParticleSystem->AddParticleModifier(arc::variation_application_time::on_update, new arc::particle_lifetime_modifier_2d, arc::vec2>(&arc::particle_2d::Scale, arc::vec2::ZeroVector)); - Smoke = ARC::CreateRef(); + Smoke = arc::create_ref(); Smoke->Defaults.bIsActive=false; Smoke->Defaults.Scale = {0.4f, 0.4f}; Smoke->Defaults.Color = {0.2f, 0.2f, 0.2f, 1.f}; Smoke->Defaults.Velocity = {0.f, 3.f}; Smoke->Defaults.Life = 1.1f; - Smoke->AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Life, 0.3f)); - Smoke->AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Color, ARC::CColor(0.1f, 0.1f, 0.1f, 0.f))); - Smoke->AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Location, ARC::FVec2(1.f, 1.f))); - Smoke->AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Scale, ARC::FVec2(0.2f, 0.2f))); - Smoke->AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Velocity, ARC::FVec2(0.6f, 1.0f))); - Smoke->AddParticleModifier(ARC::EVariationApplicationTime::OnUpdate, new ARC::CParticleLifetimeModifier2D, ARC::FVec2>(&ARC::CParticle2D::Scale, ARC::FVec2::ZeroVector)); + Smoke->AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Life, 0.3f)); + Smoke->AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Color, arc::CColor(0.1f, 0.1f, 0.1f, 0.f))); + Smoke->AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Location, arc::vec2(1.f, 1.f))); + Smoke->AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Scale, arc::vec2(0.2f, 0.2f))); + Smoke->AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Velocity, arc::vec2(0.6f, 1.0f))); + Smoke->AddParticleModifier(arc::variation_application_time::on_update, new arc::particle_lifetime_modifier_2d, arc::vec2>(&arc::particle_2d::Scale, arc::vec2::ZeroVector)); } -void CSandbox2D::OnAttach() +void sandbox_2d::on_attach() { - ARC::CIniFile inif; - ARC::TMulticastDelegate x; - x.Bind<&CSandbox2D::___Print___>(this); - x.Bind<&CSandbox2D::___Print___>(this); - x.Bind<&CSandbox2D::___Print___>(this); - x.Bind<&CSandbox2D::___Print___>(this); - x.Bind([](const char* v) -> void { ARC_TRACE(v); }); + arc::CIniFile inif; + arc::multicast_delegate x; + x.bind<&sandbox_2d::___Print___>(this); + x.bind<&sandbox_2d::___Print___>(this); + x.bind<&sandbox_2d::___Print___>(this); + x.bind<&sandbox_2d::___Print___>(this); + x.bind([](const char* v) -> void { ARC_TRACE(v); }); x("Hello"); - ARC::TDelegate y; - y.Bind<&CSandbox2D::___Print___>(this); - y.Bind<&CSandbox2D::___Print___>(this); - y.Bind<&CSandbox2D::___Print___>(this); - y.Bind<&CSandbox2D::___Print___>(this); + arc::delegate y; + y.bind<&sandbox_2d::___Print___>(this); + y.bind<&sandbox_2d::___Print___>(this); + y.bind<&sandbox_2d::___Print___>(this); + y.bind<&sandbox_2d::___Print___>(this); y("Hi"); - ARC::FVec3 abxd; - ARC_TRACE("{}", abxd.ToString()); + arc::vec3 abxd; + ARC_TRACE("{}", abxd.to_string()); - //ARC::Experimental::EntityManager em(10); + //arc::Experimental::EntityManager em(10); //for (size_t i = 0; i < 100; i++) //{ - // em.CreateEntity(); + // em.create_entity(); //} - m_CheckerboardTexture = ARC::CTexture2D::Create("assets/textures/Checkerboard.png"); - m_Spritesheet = ARC::CTexture2D::Create("assets/textures/RPGpack_sheet_2X.png"); + m_CheckerboardTexture = arc::texture_2d::create("assets/textures/Checkerboard.png"); + m_Spritesheet = arc::texture_2d::create("assets/textures/RPGpack_sheet_2X.png"); - s_MapHeight = strlen(s_MapTiles) / s_MapWidth; + map_height = strlen(map_tiles) / map_width; - m_Tree = ARC::CSubTexture2D::CreateFromCoords(m_Spritesheet, {2.f, 1.f}, {128.f, 128.f}, {1, 2}); - s_textureMap['W'] = ARC::CSubTexture2D::CreateFromCoords(m_Spritesheet, { 11.f, 11.f }, { 128.f, 128.f }); - s_textureMap['D'] = ARC::CSubTexture2D::CreateFromCoords(m_Spritesheet, { 6.f, 11.f }, { 128.f, 128.f }); + m_Tree = arc::sub_texture_2d::CreateFromCoords(m_Spritesheet, {2.f, 1.f}, {128.f, 128.f}, {1, 2}); + s_textureMap['W'] = arc::sub_texture_2d::CreateFromCoords(m_Spritesheet, { 11.f, 11.f }, { 128.f, 128.f }); + s_textureMap['D'] = arc::sub_texture_2d::CreateFromCoords(m_Spritesheet, { 6.f, 11.f }, { 128.f, 128.f }); ParticleSystem->Defaults.Texture = m_CheckerboardTexture; - m_CameraController.SetZoomLevel(1.f); + m_CameraController.set_zoom_level(1.f); - ARC::SFrameBufferSpecifications frame_buffer_specs; + arc::SFrameBufferSpecifications frame_buffer_specs; frame_buffer_specs.Width = 1280; frame_buffer_specs.Height = 720; } -void CSandbox2D::OnDetach() +void sandbox_2d::on_detach() { - ARC::CInstrumentor::Get().EndSession(); + arc::instrumentor::Get().end_session(); } -void CSandbox2D::OnUpdate(float _DeltaTime) +void sandbox_2d::on_update(float delta_time) { ARC_PROFILE_FUNCTION(); { ARC_PROFILE_SCOPE("Stuff"); - m_CameraController.OnUpdate(_DeltaTime); + m_CameraController.on_update(delta_time); - ARC::CRenderCommand::SetClearColour({ .1f, .1f, .1f, 1.f }); - ARC::CRenderCommand::Clear(); + arc::render_command::set_clear_colour({ .1f, .1f, .1f, 1.f }); + arc::render_command::clear(); } - ARC::CRenderer2D::ResetStats(); + arc::CRenderer2D::ResetStats(); { ARC_PROFILE_SCOPE("Stuff2"); - ARC::CRenderer2D::BeginScene(m_CameraController.GetCamera()); + arc::CRenderer2D::begin_scene(m_CameraController.get_camera()); ParticleSystem->Emit(); - ParticleSystem->OnUpdate(_DeltaTime); + ParticleSystem->on_update(delta_time); ParticleSystem->OnRender(); Smoke->Emit(); - Smoke->OnUpdate(_DeltaTime); + Smoke->on_update(delta_time); Smoke->OnRender(); - for (size_t x = 0; x < s_MapWidth; x++) + for (size_t x = 0; x < map_width; x++) { - for (size_t y = 0; y < s_MapHeight; y++) + for (size_t y = 0; y < map_height; y++) { - char tt = s_MapTiles[x+y*s_MapWidth]; - ARC::TRef tex; + char tt = map_tiles[x+y*map_width]; + arc::ref tex; if (s_textureMap.find(tt) != s_textureMap.end()) tex = s_textureMap[tt]; else continue; - ARC::CRenderer2D::DrawQuad({ (float)x-s_MapWidth/2, (float)s_MapHeight- y-s_MapHeight/2 }, 0.f, ARC::FVec2(1.f, 1.f), .5f, ARC::CColor::White, tex, {1.f, 1.f}); + arc::CRenderer2D::draw_quad({ (float)x-map_width/2, (float)map_height- y-map_height/2 }, 0.f, arc::vec2(1.f, 1.f), .5f, arc::CColor::White, tex, {1.f, 1.f}); } } - ARC::CRenderer2D::DrawQuad({ 0.0f, 2.f }, 0, ARC::FVec2(1.f, 2.f), 0.6f, ARC::CColor::White, m_Tree, {1.f, 1.f}); + arc::CRenderer2D::draw_quad({ 0.0f, 2.f }, 0, arc::vec2(1.f, 2.f), 0.6f, arc::CColor::White, m_Tree, {1.f, 1.f}); - if (ARC::bStressTest) + if (arc::bStressTest) { - ARC::CPrimitive2D Quad; - Quad.Color = ARC::FColor::Red; + arc::primitive_2d Quad; + Quad.Color = arc::FColor::Red; - ARC::CRenderer2D::DrawQuad({ 0.0f, 0.0f }, 0, { 50.0f, 50.f }, 0.f, ARC::CColor::White, m_CheckerboardTexture); + arc::CRenderer2D::draw_quad({ 0.0f, 0.0f }, 0, { 50.0f, 50.f }, 0.f, arc::CColor::White, m_CheckerboardTexture); for (float x = -10.f; x <= 10; x += 0.5) { for (float y = -10; y <= 10; y += 0.5) @@ -175,152 +175,152 @@ void CSandbox2D::OnUpdate(float _DeltaTime) Quad.Transform.Location = { x, y }; Quad.Transform.Scale = { 0.45f, 0.45f }; Quad.Transform.ZOrder = 0.1f; - Quad.Color = ARC::FColor((x + 5) / 10, 0.4f, (y + 5) / 10, 0.69f); - ARC::CRenderer2D::DrawQuad(Quad); + Quad.Color = arc::FColor((x + 5) / 10, 0.4f, (y + 5) / 10, 0.69f); + arc::CRenderer2D::draw_quad(Quad); } } - prev += 10.f * _DeltaTime; + prev += 10.f * delta_time; - ARC::CPrimitive2D Quad2; + arc::primitive_2d Quad2; Quad2.Transform.Location = { 0.f, 0.f }; Quad2.Transform.Rotation = glm::radians(prev); Quad2.Transform.Scale = { 10.f, 10.f }; Quad2.Transform.ZOrder = 0.2f; - Quad2.Color = ARC::FColor::Red; + Quad2.Color = arc::FColor::Red; - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(prev + 30); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(prev + 60); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(prev + 90); Quad2.Transform.Scale = { 9.f, 9.f }; Quad2.Transform.ZOrder += 0.001f; - Quad2.Color = ARC::CColor::Yellow; + Quad2.Color = arc::CColor::Yellow; Quad2.Transform.Rotation = glm::radians(-prev - 30); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(-prev - 60); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(-prev - 90); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Scale = { 8.f, 8.f }; Quad2.Transform.ZOrder += 0.001f; - Quad2.Color = ARC::CColor::Black; + Quad2.Color = arc::CColor::Black; Quad2.Transform.Rotation = glm::radians(prev + 30); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(prev + 60); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(prev + 90); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Scale = { 7.f, 7.f }; Quad2.Transform.ZOrder += 0.001f; - Quad2.Color = ARC::CColor::Yellow; + Quad2.Color = arc::CColor::Yellow; Quad2.Transform.Rotation = glm::radians(-prev - 30); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(-prev - 60); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(-prev - 90); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Scale = { 6.f, 6.f }; Quad2.Transform.ZOrder += 0.001f; - Quad2.Color = ARC::CColor::Black; + Quad2.Color = arc::CColor::Black; Quad2.Transform.Rotation = glm::radians(prev + 30); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(prev + 60); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(prev + 90); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Scale = { 5.f, 5.f }; Quad2.Transform.ZOrder += 0.001f; - Quad2.Color = ARC::CColor::Yellow; + Quad2.Color = arc::CColor::Yellow; Quad2.Transform.Rotation = glm::radians(-prev - 30); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(-prev - 60); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(-prev - 90); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Scale = { 4.f, 4.f }; Quad2.Transform.ZOrder += 0.001f; - Quad2.Color = ARC::CColor::Black; + Quad2.Color = arc::CColor::Black; Quad2.Transform.Rotation = glm::radians(prev + 30); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(prev + 60); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(prev + 90); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Scale = { 3.f, 3.f }; Quad2.Transform.ZOrder += 0.001f; - Quad2.Color = ARC::CColor::Yellow; + Quad2.Color = arc::CColor::Yellow; Quad2.Transform.Rotation = glm::radians(-prev - 30); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(-prev - 60); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(-prev - 90); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Scale = { 2.f, 2.f }; Quad2.Transform.ZOrder += 0.001f; - Quad2.Color = ARC::CColor::Black; + Quad2.Color = arc::CColor::Black; Quad2.Transform.Rotation = glm::radians(prev + 30); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(prev + 60); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(prev + 90); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Scale = { 1.f, 1.f }; Quad2.Transform.ZOrder += 0.001f; - Quad2.Color = ARC::FColor::Red; + Quad2.Color = arc::FColor::Red; Quad2.Transform.Rotation = glm::radians(-prev - 30); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(-prev - 60); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); Quad2.Transform.Rotation = glm::radians(-prev - 90); - ARC::CRenderer2D::DrawQuad(Quad2); + arc::CRenderer2D::draw_quad(Quad2); - ARC::CRenderer2D::DrawQuad(ARC::FVec2::ZeroVector, 0.f, { 50.0f, 50.f }, 0.f, ARC::CColor::White, m_CheckerboardTexture); + arc::CRenderer2D::draw_quad(arc::vec2::ZeroVector, 0.f, { 50.0f, 50.f }, 0.f, arc::CColor::White, m_CheckerboardTexture); } - ARC::CRenderer2D::EndScene(); - m_CameraController.GetCamera().RecalculateViewProjectionMatrix(); + arc::CRenderer2D::end_scene(); + m_CameraController.get_camera().RecalculateViewProjectionMatrix(); } } -void CSandbox2D::OnEvent(ARC::CEvent& _Event) +void sandbox_2d::on_event(arc::event& event) { ARC_PROFILE_FUNCTION(); - m_CameraController.OnEvent(_Event); + m_CameraController.on_event(event); } -void CSandbox2D::OnGuiRender() +void sandbox_2d::on_gui_render() { ARC_PROFILE_FUNCTION(); - auto stats = ARC::CRenderer2D::GetStats(); - ImGui::Begin("Renderer2D"); - ImGui::Image((void*)m_CheckerboardTexture->GetRendererID(), ImVec2(100.f, 100.f)); + auto stats = arc::CRenderer2D::get_stats(); + ImGui::begin("Renderer2D"); + ImGui::Image((void*)m_CheckerboardTexture->get_renderer_id(), ImVec2(100.f, 100.f)); ImGui::Text("DrawCalls: %d", stats.DrawCalls); ImGui::Text("QuadCount: %d", stats.QuadCount); - ImGui::Text("Vertices: %d", stats.GetTotalVertexCount()); - ImGui::Text("Indices: %d", stats.GetTotalIndexCount()); - ImGui::End(); - ImGui::Begin((ARC::bStressTest ? "StressTest" : "Sandbox")); + ImGui::Text("Vertices: %d", stats.get_total_vertex_count()); + ImGui::Text("Indices: %d", stats.get_total_index_count()); + ImGui::end(); + ImGui::begin((arc::bStressTest ? "StressTest" : "Sandbox")); if (ImGui::TreeNode("Particles")) { ImGui::DragFloat3("Particle Loc", ParticleSystem->Defaults.Location.Data()); @@ -331,11 +331,11 @@ void CSandbox2D::OnGuiRender() ImGui::ColorEdit4("SQ_Colour", SQ_Colour.Data()); ImGui::TreePop(); } - if (ImGui::Button(ARC::bStressTest ? "Go to Sandbox?" : "Go to StressTest?")) { ARC::bStressTest = !ARC::bStressTest; } - ImGui::End(); + if (ImGui::Button(arc::bStressTest ? "Go to Sandbox?" : "Go to StressTest?")) { arc::bStressTest = !arc::bStressTest; } + ImGui::end(); } -void CSandbox2D::___Print___(const char* _) +void sandbox_2d::___Print___(const char* _) { ARC_WARN(_); } diff --git a/Sandbox/src/Sandbox2D.h b/Sandbox/src/Sandbox2D.h index 88593ed69c..0ca3f862bd 100644 --- a/Sandbox/src/Sandbox2D.h +++ b/Sandbox/src/Sandbox2D.h @@ -5,46 +5,46 @@ #include "ARC/Renderer/ParticleSystem2D.h" #include "ARC/Objects/Primitive2D.h" -namespace ARC { class CFrameBuffer; } +namespace arc { class framebuffer; } -namespace ARC { class CSubTexture2D; } +namespace arc { class sub_texture_2d; } -namespace ARC { class CTexture2D; } +namespace arc { class texture_2d; } -namespace ARC { class CVertexArray; } +namespace arc { class vertex_array; } -namespace ARC { class CShader; } +namespace arc { class shader; } -namespace ARC { class CEvent; } +namespace arc { class event; } -class CSandbox2D : public ARC::CLayer +class sandbox_2d : public arc::layer { public: - CSandbox2D(); - virtual ~CSandbox2D() = default; + sandbox_2d(); + virtual ~sandbox_2d() = default; - virtual void OnAttach(); - virtual void OnDetach(); + virtual void on_attach(); + virtual void on_detach(); - virtual void OnUpdate(float _DeltaTime) override; - virtual void OnEvent(ARC::CEvent& _Event) override; - virtual void OnGuiRender() override; + virtual void on_update(float delta_time) override; + virtual void on_event(arc::event& event) override; + virtual void on_gui_render() override; virtual void ___Print___(const char* _); float prev = 0.f; protected: - ARC::TRef m_Shader; - ARC::TRef m_VertexArray; - ARC::TRef m_CheckerboardTexture; - ARC::TRef m_Spritesheet; - ARC::TRef m_Tree; - ARC::TRef ParticleSystem; - ARC::TRef Smoke; + arc::ref m_Shader; + arc::ref m_VertexArray; + arc::ref m_CheckerboardTexture; + arc::ref m_Spritesheet; + arc::ref m_Tree; + arc::ref ParticleSystem; + arc::ref Smoke; - ARC::CColor SQ_Colour = ARC::CColor::Blue; + arc::CColor SQ_Colour = arc::CColor::Blue; private: - ARC::COrthographicCameraController m_CameraController; - std::unordered_map> s_textureMap; + arc::orthographic_camera_controller m_CameraController; + std::unordered_map> s_textureMap; }; \ No newline at end of file diff --git a/Sandbox/src/SandboxApp.cpp b/Sandbox/src/SandboxApp.cpp index 227389ff49..daf7c5c621 100644 --- a/Sandbox/src/SandboxApp.cpp +++ b/Sandbox/src/SandboxApp.cpp @@ -28,14 +28,14 @@ #include "Sandbox2D.h" #endif -ARC::Core::CApplication* ARC::Core::CreateApplication() +arc::Core::application* arc::Core::create_application() { - return new CSandbox; + return new sandbox; } //-------------------[Layer]----------------------// -CExampleLayer::CExampleLayer() : - ARC::CLayer("Example"), +example_layer::example_layer() : + arc::layer("Example"), m_CameraController(1280.f / 780.f, true) { //-------------------------------+[Code for triangle]+-------------------------------// @@ -46,30 +46,30 @@ CExampleLayer::CExampleLayer() : 0.0f, 0.5f, 0.0f, 0.8f, 0.8f, 0.2f, 1.0f }; - ARC::TRef triangle_vertex_buffer; - triangle_vertex_buffer = ARC::CVertexBuffer::Create(triangle_verts, sizeof(triangle_verts)); - ARC::CBufferLayout triangle_layout = { - { ARC::EShaderDataType::Float3, "a_Position" }, - { ARC::EShaderDataType::Float4, "a_Colour" } + arc::ref triangle_vertex_buffer; + triangle_vertex_buffer = arc::vertex_buffer::create(triangle_verts, sizeof(triangle_verts)); + arc::buffer_layout triangle_layout = { + { arc::shader_data_type::Float3, "a_Position" }, + { arc::shader_data_type::Float4, "a_Colour" } }; - triangle_vertex_buffer->SetLayout(triangle_layout); + triangle_vertex_buffer->set_layout(triangle_layout); - m_TriangleVertexArray = ARC::CVertexArray::Create(); - m_TriangleVertexArray->AddVertexBuffer(triangle_vertex_buffer); + m_TriangleVertexArray = arc::vertex_array::create(); + m_TriangleVertexArray->add_vertex_buffer(triangle_vertex_buffer); unsigned int triangle_indices[] = { 0,1,2 }; - ARC::TRef triangle_index_buffer; - triangle_index_buffer = ARC::CIndexBuffer::Create(triangle_indices, sizeof(triangle_indices) / sizeof(uint32_t)); - m_TriangleVertexArray->SetIndexBuffer(triangle_index_buffer); + arc::ref triangle_index_buffer; + triangle_index_buffer = arc::index_buffer::create(triangle_indices, sizeof(triangle_indices) / sizeof(uint32_t)); + m_TriangleVertexArray->set_index_buffer(triangle_index_buffer); - //m_TriangleShader = ARC::CShader::Create(); + //m_TriangleShader = arc::shader::create(); } //-------------------------------~[Code for triangle]~-------------------------------// //--------------------------------+[Code for square]+--------------------------------// - m_SquareVertexArray = ARC::CVertexArray::Create(); + m_SquareVertexArray = arc::vertex_array::create(); float square_verts[5 * 4] = { -0.5f, -0.5f, 0.0f, 0.0f, 0.0f, @@ -78,22 +78,22 @@ CExampleLayer::CExampleLayer() : -0.5f, 0.5f, 0.0f, 0.0f, 1.0f }; - ARC::TRef square_vertex_buffer; - square_vertex_buffer = ARC::CVertexBuffer::Create(square_verts, sizeof(square_verts)); + arc::ref square_vertex_buffer; + square_vertex_buffer = arc::vertex_buffer::create(square_verts, sizeof(square_verts)); - ARC::CBufferLayout square_layout = { - { ARC::EShaderDataType::Float3, "a_Position" }, - { ARC::EShaderDataType::Float2, "a_TexCoord" } + arc::buffer_layout square_layout = { + { arc::shader_data_type::Float3, "a_Position" }, + { arc::shader_data_type::Float2, "a_TexCoord" } }; - square_vertex_buffer->SetLayout(square_layout); + square_vertex_buffer->set_layout(square_layout); - m_SquareVertexArray->AddVertexBuffer(square_vertex_buffer); + m_SquareVertexArray->add_vertex_buffer(square_vertex_buffer); unsigned int square_indices[] = { 0, 1, 2, 2, 3, 0 }; - ARC::TRef square_index_buffer; - square_index_buffer = ARC::CIndexBuffer::Create(square_indices, sizeof(square_indices) / sizeof(uint32_t)); - m_SquareVertexArray->SetIndexBuffer(square_index_buffer); + arc::ref square_index_buffer; + square_index_buffer = arc::index_buffer::create(square_indices, sizeof(square_indices) / sizeof(uint32_t)); + m_SquareVertexArray->set_index_buffer(square_index_buffer); //--------------------------------~[Code for square]~--------------------------------// //---------------------------+[Code for FlatColor Shader]+---------------------------// const std::string flat_color_vertex_source = R"( @@ -126,32 +126,32 @@ CExampleLayer::CExampleLayer() : o_Color = u_Color; } )"; - m_FlatColorShader = ARC::CShader::Create("FlatColorShader", flat_color_vertex_source, flat_color_fragment_source); + m_FlatColorShader = arc::shader::create("FlatColorShader", flat_color_vertex_source, flat_color_fragment_source); //---------------------------~[Code for FlatColor Shader]~---------------------------// //----------------------------+[Code for Texture Shader]+----------------------------// auto textureShader = m_ShaderLibrary.Load("assets/shaders/Texture.glsl"); //----------------------------~[Code for Texture Shader]~----------------------------// - m_Texture = ARC::CTexture2D::Create("assets/textures/Checkerboard.png"); - m_TestTexture = ARC::CTexture2D::Create("assets/textures/ChernoLogo.png"); + m_Texture = arc::texture_2d::create("assets/textures/Checkerboard.png"); + m_TestTexture = arc::texture_2d::create("assets/textures/ChernoLogo.png"); - textureShader->Bind(); + textureShader->bind(); textureShader->Set("u_Texture", 0); } -void CExampleLayer::OnUpdate(float _DeltaTime) +void example_layer::on_update(float delta_time) { - m_CameraController.OnUpdate(_DeltaTime); + m_CameraController.on_update(delta_time); - ARC::CRenderCommand::SetClearColour({ .1f, .1f, .1f, 1.f }); - ARC::CRenderCommand::Clear(); + arc::render_command::set_clear_colour({ .1f, .1f, .1f, 1.f }); + arc::render_command::clear(); - ARC::CRenderer::BeginScene(m_CameraController.GetCamera()); + arc::renderer::begin_scene(m_CameraController.get_camera()); //SQ_Data.Scale = {0.1f, 0.1f, 0.1f}; - m_FlatColorShader->Bind(); - m_FlatColorShader->Set("u_Color", SQ_Colour); + m_FlatColorShader->bind(); + m_FlatColorShader->Set("u_Color", SQ_Colour); //for (size_t x = 0; x < 20; x++) // for (size_t y = 0; y < 20; y++) @@ -159,34 +159,34 @@ void CExampleLayer::OnUpdate(float _DeltaTime) // glm::vec3 pos = { x * 0.11f, y * 0.11f, 0.f }; // pos += SQ_Data.Position; // glm::mat4 transform = glm::scale(glm::translate(glm::mat4(1.0f), pos), SQ_Data.Scale); - // ARC::CRenderer::Submit(m_FlatColorShader, m_SquareVertexArray, transform); + // arc::renderer::Submit(m_FlatColorShader, m_SquareVertexArray, transform); // } - m_Texture->Bind(); - ARC::CRenderer::Submit(m_ShaderLibrary.GetShader("Texture"), m_SquareVertexArray, glm::scale(glm::mat4(1.0f), glm::vec3(1.5f))); + m_Texture->bind(); + arc::renderer::Submit(m_ShaderLibrary.get_shader("Texture"), m_SquareVertexArray, glm::scale(glm::mat4(1.0f), glm::vec3(1.5f))); - m_TestTexture->Bind(); - ARC::CRenderer::Submit(m_ShaderLibrary.GetShader("Texture"), m_SquareVertexArray, glm::scale(glm::mat4(1.0f), glm::vec3(1.5f))); + m_TestTexture->bind(); + arc::renderer::Submit(m_ShaderLibrary.get_shader("Texture"), m_SquareVertexArray, glm::scale(glm::mat4(1.0f), glm::vec3(1.5f))); - //ARC::CRenderer::Submit(m_TriangleShader, m_TriangleVertexArray); - ARC::CRenderer::EndScene(); + //arc::renderer::Submit(m_TriangleShader, m_TriangleVertexArray); + arc::renderer::end_scene(); - GetCam().RecalculateViewProjectionMatrix(); + get_cam().RecalculateViewProjectionMatrix(); } -void CExampleLayer::OnEvent(ARC::CEvent& _Event) +void example_layer::on_event(arc::event& event) { - m_CameraController.OnEvent(_Event); + m_CameraController.on_event(event); } -bool CExampleLayer::OnKeyPressedEvent(ARC::CKeyPressedEvent& _Event) +bool example_layer::OnKeyPressedEvent(arc::key_pressed_event& event) { return false; } -void CExampleLayer::OnGuiRender() +void example_layer::on_gui_render() { - ImGui::Begin("Sandbox"); + ImGui::begin("Sandbox"); if (ImGui::TreeNode("Camera")) { // ImGui::DragFloat3("CamLocation", &GetCam().Position[0]); @@ -200,17 +200,17 @@ void CExampleLayer::OnGuiRender() ImGui::ColorEdit4("SQ_Colour", SQ_Colour.Data()); ImGui::TreePop(); } - ImGui::End(); + ImGui::end(); } //-------------------[Layer]----------------------// -CSandbox::CSandbox() +sandbox::sandbox() { #ifdef SpaceWar - PushLayer(new CSpaceWar()); + push_layer(new space_war()); #elif defined Ecs - PushLayer(new ARC::CECSExample()); + push_layer(new arc::ecs_example()); #else - PushLayer(new CSandbox2D()); + push_layer(new sandbox_2d()); #endif } diff --git a/Sandbox/src/SandboxApp.h b/Sandbox/src/SandboxApp.h index 12b1f648a9..289610c63d 100644 --- a/Sandbox/src/SandboxApp.h +++ b/Sandbox/src/SandboxApp.h @@ -6,53 +6,53 @@ #include "ARC/Objects/Primitive2D.h" #include "ARC/Renderer/Color.h" -namespace ARC { class CTexture2D; } -namespace ARC { class CKeyPressedEvent; } -namespace ARC { class CEvent; } -namespace ARC { class CVertexArray; } -namespace ARC { class CIndexBuffer; } -namespace ARC { class CVertexBuffer; } -namespace ARC { class CShader; } +namespace arc { class texture_2d; } +namespace arc { class key_pressed_event; } +namespace arc { class event; } +namespace arc { class vertex_array; } +namespace arc { class index_buffer; } +namespace arc { class vertex_buffer; } +namespace arc { class shader; } -class CExampleLayer : public ARC::CLayer +class example_layer : public arc::layer { public: - CExampleLayer(); - virtual void OnUpdate(float _DeltaTime) override; - virtual void OnEvent(ARC::CEvent& _event) override; + example_layer(); + virtual void on_update(float delta_time) override; + virtual void on_event(arc::event& _event) override; - bool OnKeyPressedEvent(ARC::CKeyPressedEvent& _Event); + bool OnKeyPressedEvent(arc::key_pressed_event& event); - virtual void OnGuiRender() override; + virtual void on_gui_render() override; - inline ARC::COrthographicCameraBase& GetCam() { return m_CameraController.GetCamera(); } + inline arc::COrthographicCameraBase& get_cam() { return m_CameraController.get_camera(); } public: float SQ_MoveSpeed = 3.f; float SQ_RotSpeed = 180.f; - ARC::CColor SQ_Colour = ARC::CColor::Red; + arc::CColor SQ_Colour = arc::CColor::Red; private: - ARC::CShaderLibrary m_ShaderLibrary; + arc::shader_library m_ShaderLibrary; - ARC::TRef m_TriangleShader; - ARC::TRef m_TriangleVertexArray; + arc::ref m_TriangleShader; + arc::ref m_TriangleVertexArray; - ARC::TRef m_FlatColorShader; - ARC::TRef m_SquareVertexArray; - ARC::TRef m_Texture; - ARC::TRef m_TestTexture; + arc::ref m_FlatColorShader; + arc::ref m_SquareVertexArray; + arc::ref m_Texture; + arc::ref m_TestTexture; - ARC::COrthographicCameraController m_CameraController; + arc::orthographic_camera_controller m_CameraController; }; -class CSandbox : public ARC::Core::CApplication +class sandbox : public arc::Core::application { public: - CSandbox(); - ~CSandbox() {}; + sandbox(); + ~sandbox() {}; - inline virtual std::string GetAppName() override { return "Sandbox"; }; + inline virtual std::string get_app_name() override { return "Sandbox"; }; }; diff --git a/Sandbox/src/SpaceWar/Player.cpp b/Sandbox/src/SpaceWar/Player.cpp index b608068671..6515b2771b 100644 --- a/Sandbox/src/SpaceWar/Player.cpp +++ b/Sandbox/src/SpaceWar/Player.cpp @@ -25,44 +25,44 @@ #include "ARC/Renderer/ParticleSystem2D.h" #include "ARC/Renderer/ParticleModifier2D.h" -namespace ARC { - CPlayer::CPlayer() : +namespace arc { + player::player() : Speed(1) { ParticleSystem.Defaults.bIsActive = false; ParticleSystem.Defaults.Scale = { 0.05f, 0.05f}; - ParticleSystem.Defaults.Color = ARC::CColor::Red; + ParticleSystem.Defaults.Color = arc::CColor::Red; ParticleSystem.Defaults.Velocity = { 0.f, 2.f }; ParticleSystem.Defaults.Life = 0.5f; ParticleSystem.Defaults.ZOrder = 0.1f; - ParticleSystem.AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Life, 0.05f)); - //ParticleSystem->AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Color, ARC::CColor(0.1f, 0.1f, 0.1f, 0.f))); - //ParticleSystem.AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Location, ARC::FVec2(0.05, 0.05))); - ParticleSystem.AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Scale, ARC::FVec2(0.02f, 0.02f))); - //ParticleSystem.AddParticleModifier(ARC::EVariationApplicationTime::OnEmit, new ARC::CParticleVariationModifier2D(&ARC::CParticle2D::Velocity, ARC::FVec2(0.6f, 1.0f))); - ParticleSystem.AddParticleModifier(ARC::EVariationApplicationTime::OnUpdate, new ARC::CParticleLifetimeModifier2D(&ARC::CParticle2D::Color, ARC::CColor(1.f, 1.f, 0.f, 1.f))); - ParticleSystem.AddParticleModifier(ARC::EVariationApplicationTime::OnUpdate, new ARC::CParticleLifetimeModifier2D, ARC::FVec2>(&ARC::CParticle2D::Scale, ARC::FVec2::ZeroVector)); + ParticleSystem.AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Life, 0.05f)); + //ParticleSystem->AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Color, arc::CColor(0.1f, 0.1f, 0.1f, 0.f))); + //ParticleSystem.AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Location, arc::vec2(0.05, 0.05))); + ParticleSystem.AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Scale, arc::vec2(0.02f, 0.02f))); + //ParticleSystem.AddParticleModifier(arc::variation_application_time::OnEmit, new arc::particle_variation_modifier_2d(&arc::particle_2d::Velocity, arc::vec2(0.6f, 1.0f))); + ParticleSystem.AddParticleModifier(arc::variation_application_time::on_update, new arc::particle_lifetime_modifier_2d(&arc::particle_2d::Color, arc::CColor(1.f, 1.f, 0.f, 1.f))); + ParticleSystem.AddParticleModifier(arc::variation_application_time::on_update, new arc::particle_lifetime_modifier_2d, arc::vec2>(&arc::particle_2d::Scale, arc::vec2::ZeroVector)); } - void CPlayer::Load() + void player::Load() { - PlayerSprite.Texture = CTexture2D::Create("assets/textures/arcShip.png", true); + PlayerSprite.Texture = texture_2d::create("assets/textures/arcShip.png", true); PlayerSprite.Transform.Location = { 0.1f, 0.1f}; PlayerSprite.Transform.Scale = {0.1f, 0.1f}; PlayerSprite.Transform.ZOrder = 0.2f; - auto TL = HPR::QUAD::GetCorner(PlayerSprite.GetTransform()); - MinDist = FVec2::Dist(TL, PlayerSprite.GetLocation()); + auto TL = HPR::QUAD::get_corner(PlayerSprite.get_transform()); + MinDist = vec2::Dist(TL, PlayerSprite.get_location()); for (uint8_t x = 0; x < 32; x++) { for (uint8_t y = 0; y < 32; y++) { - if (PlayerSprite.Texture->GetPixelColor({ x, y }).a != 0) + if (PlayerSprite.Texture->get_pixel_color({ x, y }).a != 0) { - CollisionData.push_back( std::make_shared>( x, y )); + CollisionData.push_back( std::make_shared>( x, y )); } } } @@ -70,61 +70,61 @@ namespace ARC { PlayerSprite.Texture->ClearData(); } - void CPlayer::Reset() + void player::Reset() { PlayerSprite.Transform.Location = { 0.f, 0.f }; PlayerSprite.Transform.Scale = { 0.1f, 0.1f }; PlayerSprite.Transform.ZOrder = 0.2f; - Velocity = FVec2::ZeroVector; + Velocity = vec2::ZeroVector; } - void CPlayer::OnUpdate(float _DeltaTime) + void player::on_update(float delta_time) { - if (auto* SWL = (CSpaceWar*)OwningLayer) + if (auto* SWL = (space_war*)OwningLayer) { - if (SWL && SWL->GameState == EGameState::Play) + if (SWL && SWL->GameState == game_state::Play) { float lerpalpha = 0; - Velocity.x *= 0.97f*_DeltaTime*60.f; - Velocity.y *= 0.97f*_DeltaTime*60.f; + Velocity.x *= 0.97f*delta_time*60.f; + Velocity.y *= 0.97f*delta_time*60.f; - if (CInput::IsKeyPressed(ARC_KEY_A) || CInput::IsKeyPressed(ARC_KEY_W) || CInput::IsKeyPressed(ARC_KEY_S) || CInput::IsKeyPressed(ARC_KEY_D) || CInput::IsKeyPressed(ARC_KEY_RIGHT) || CInput::IsKeyPressed(ARC_KEY_LEFT) || CInput::IsKeyPressed(ARC_KEY_UP) || CInput::IsKeyPressed(ARC_KEY_DOWN)) { - lerpalpha += _DeltaTime; - if (CInput::IsKeyPressed(ARC_KEY_A) || CInput::IsKeyPressed(ARC_KEY_LEFT)) { - if (CInput::IsKeyPressed(ARC_KEY_D) || CInput::IsKeyPressed(ARC_KEY_RIGHT)) Velocity.x = 0; + if (CInput::is_key_pressed(ARC_KEY_A) || CInput::is_key_pressed(ARC_KEY_W) || CInput::is_key_pressed(ARC_KEY_S) || CInput::is_key_pressed(ARC_KEY_D) || CInput::is_key_pressed(ARC_KEY_RIGHT) || CInput::is_key_pressed(ARC_KEY_LEFT) || CInput::is_key_pressed(ARC_KEY_UP) || CInput::is_key_pressed(ARC_KEY_DOWN)) { + lerpalpha += delta_time; + if (CInput::is_key_pressed(ARC_KEY_A) || CInput::is_key_pressed(ARC_KEY_LEFT)) { + if (CInput::is_key_pressed(ARC_KEY_D) || CInput::is_key_pressed(ARC_KEY_RIGHT)) Velocity.x = 0; else Velocity.x = -1; } - else if (CInput::IsKeyPressed(ARC_KEY_D) || CInput::IsKeyPressed(ARC_KEY_RIGHT)) Velocity.x = 1; - if (CInput::IsKeyPressed(ARC_KEY_W) || CInput::IsKeyPressed(ARC_KEY_UP)) { - if (CInput::IsKeyPressed(ARC_KEY_S) || CInput::IsKeyPressed(ARC_KEY_DOWN)) Velocity.y = 0; + else if (CInput::is_key_pressed(ARC_KEY_D) || CInput::is_key_pressed(ARC_KEY_RIGHT)) Velocity.x = 1; + if (CInput::is_key_pressed(ARC_KEY_W) || CInput::is_key_pressed(ARC_KEY_UP)) { + if (CInput::is_key_pressed(ARC_KEY_S) || CInput::is_key_pressed(ARC_KEY_DOWN)) Velocity.y = 0; else Velocity.y = 1; } - else if (CInput::IsKeyPressed(ARC_KEY_S) || CInput::IsKeyPressed(ARC_KEY_DOWN)) Velocity.y = -1; + else if (CInput::is_key_pressed(ARC_KEY_S) || CInput::is_key_pressed(ARC_KEY_DOWN)) Velocity.y = -1; - FVec2 emissionPoint = { 0.0f, -0.05f }; - float s = std::sin(PlayerSprite.GetRotation()); - float c = std::cos(PlayerSprite.GetRotation()); + vec2 emissionPoint = { 0.0f, -0.05f }; + float s = std::sin(PlayerSprite.get_rotation()); + float c = std::cos(PlayerSprite.get_rotation()); - FVec2 rotated = FVec2(-emissionPoint.y*s, emissionPoint.y * c); - ParticleSystem.Defaults.Location = PlayerSprite.GetLocation(); + vec2 rotated = vec2(-emissionPoint.y*s, emissionPoint.y * c); + ParticleSystem.Defaults.Location = PlayerSprite.get_location(); ParticleSystem.Defaults.Velocity = Math::InterpF(ParticleSystem.Defaults.Velocity, (Velocity + rotated)* -1, lerpalpha); ParticleSystem.Emit(); } else { - lerpalpha-=_DeltaTime; + lerpalpha-=delta_time; lerpalpha = std::clamp(lerpalpha, 0.f, 1.f); } - PlayerSprite.Transform.Location.x += Velocity.x * Speed * _DeltaTime; - PlayerSprite.Transform.Location.y += Velocity.y * Speed * _DeltaTime; + PlayerSprite.Transform.Location.x += Velocity.x * Speed * delta_time; + PlayerSprite.Transform.Location.y += Velocity.y * Speed * delta_time; PlayerSprite.Transform.Location.x = std::clamp(PlayerSprite.Transform.Location.x, -1.6f, 1.6f); PlayerSprite.Transform.Location.y = std::clamp(PlayerSprite.Transform.Location.y, -0.94f, 0.94f); - ParticleSystem.OnUpdate(_DeltaTime); + ParticleSystem.on_update(delta_time); } - const FVec2 mouse_location = CInput::GetMouseXY(); - auto window_height = CApplication::Get().GetWindow().GetHeight(); - auto window_width = CApplication::Get().GetWindow().GetWidth(); + const vec2 mouse_location = CInput::get_mouse_xy(); + auto window_height = application::Get().get_window().get_height(); + auto window_width = application::Get().get_window().get_width(); const float y = -((mouse_location.y / window_height)*2-1); const float x = 1.6666f *((mouse_location.x / window_width)*2-1); @@ -137,8 +137,8 @@ namespace ARC { } } - void CPlayer::OnEvent(CEvent& _Event) + void player::on_event(event& event) { - CEventDispatcher dispatcher(_Event); + event_dispatcher dispatcher(event); } } diff --git a/Sandbox/src/SpaceWar/Player.h b/Sandbox/src/SpaceWar/Player.h index 68aa384479..3effeee418 100644 --- a/Sandbox/src/SpaceWar/Player.h +++ b/Sandbox/src/SpaceWar/Player.h @@ -5,33 +5,33 @@ #include #include "ARC/Renderer/ParticleSystem2D.h" -namespace ARC { class CLayer; } +namespace arc { class layer; } -namespace ARC { class CKeyReleasedEvent; } +namespace arc { class key_released_event; } -namespace ARC { class CKeyPressedEvent; } +namespace arc { class key_pressed_event; } -namespace ARC { class CEvent; } -namespace ARC { class CMouseMovedEvent; } +namespace arc { class event; } +namespace arc { class mouse_moved_event; } -namespace ARC { - class CPlayer +namespace arc { + class player { public: - CPlayer(); + player(); void Load(); void Reset(); - void OnUpdate(float _DeltaTime); - void OnEvent(ARC::CEvent& _Event); - CPrimitive2D PlayerSprite; - CParticleSystem2D ParticleSystem; + void on_update(float delta_time); + void on_event(arc::event& event); + primitive_2d PlayerSprite; + particle_system_2d ParticleSystem; uint8_t bIsAlive : 1; float Speed; // Minimum distance from object for collision to activate float MinDist; - FVec2 Velocity; - CLayer* OwningLayer; - std::vector>> CollisionData; + vec2 Velocity; + layer* OwningLayer; + std::vector>> CollisionData; protected: private: }; diff --git a/Sandbox/src/SpaceWar/Rock.cpp b/Sandbox/src/SpaceWar/Rock.cpp index 1bc1c2e65c..a2e51c6e4a 100644 --- a/Sandbox/src/SpaceWar/Rock.cpp +++ b/Sandbox/src/SpaceWar/Rock.cpp @@ -4,16 +4,16 @@ #include "ARC/Renderer/Renderer2D.h" #include "ARC/Helpers/Helpers.h" -namespace ARC { - std::array< std::vector>>, CRock::s_NumberOfRockSprites> CRock::SpriteCollisionData; +namespace arc { + std::array< std::vector>>, rock::number_of_rock_sprites> rock::SpriteCollisionData; - void CRock::Load(FVec2 _Velocity, FVec2 _Position) + void rock::Load(vec2 velocity, vec2 position) { - TString path = "assets/textures/Rock"; - SpriteIndex = (int)(HPR::Random::Float() * s_NumberOfRockSprites); + string path = "assets/textures/Rock"; + SpriteIndex = (int)(HPR::Random::Float() * number_of_rock_sprites); path.Append(std::to_string(SpriteIndex+1)); - path.Append(TString(".png")); - Sprite.Texture = CTexture2D::Create(path, true); + path.Append(string(".png")); + Sprite.Texture = texture_2d::create(path, true); if (SpriteCollisionData[SpriteIndex].empty()) { @@ -21,39 +21,39 @@ namespace ARC { { for (uint8_t y = 0; y < 32; y++) { - if (Sprite.Texture->GetPixelColor({x, y}).a != 0 ) + if (Sprite.Texture->get_pixel_color({x, y}).a != 0 ) { - SpriteCollisionData[SpriteIndex].push_back(std::make_shared>(x, y)); + SpriteCollisionData[SpriteIndex].push_back(std::make_shared>(x, y)); } } } } Sprite.Texture->ClearData(); - Sprite.Transform.Location = _Position; + Sprite.Transform.Location = position; Sprite.Transform.Rotation = HPR::Random::Float(0, 360); - ARC_CORE_TRACE("{0}", Sprite.GetRotation()); + ARC_CORE_TRACE("{0}", Sprite.get_rotation()); Sprite.Transform.Scale = { HPR::Random::Float(0.3f, 0.7f), HPR::Random::Float(0.3f, 0.7f) }; - Velocity = _Velocity; + Velocity = velocity; - auto TL = HPR::QUAD::GetCorner(Sprite.GetTransform()); - MinDist = FVec2::Dist(TL, Sprite.GetLocation()); + auto TL = HPR::QUAD::get_corner(Sprite.get_transform()); + MinDist = vec2::Dist(TL, Sprite.get_location()); } - void CRock::OnUpdate(float _DeltaTime) + void rock::on_update(float delta_time) { - Sprite.Transform.Location += Velocity * _DeltaTime; - Sprite.Transform.Rotation += RotationVelocity * _DeltaTime; + Sprite.Transform.Location += Velocity * delta_time; + Sprite.Transform.Rotation += RotationVelocity * delta_time; - if (Sprite.GetLocation().x >2 || Sprite.GetLocation().y > 1.5 || Sprite.GetLocation().x < -2 || Sprite.GetLocation().y < -1.5) { - CalculateRandomPosition(); - CalculateRandomVelocity(); + if (Sprite.get_location().x >2 || Sprite.get_location().y > 1.5 || Sprite.get_location().x < -2 || Sprite.get_location().y < -1.5) { + calculate_random_position(); + calculate_random_velocity(); } } - void CRock::CalculateRandomVelocity() + void rock::calculate_random_velocity() { if (int(HPR::Random::Float() * 2)) { Velocity.x = HPR::Random::Float(0.2f, 1.f); @@ -69,7 +69,7 @@ namespace ARC { RotationVelocity = HPR::Random::Float(0.f, 3.f); } - void CRock::CalculateRandomPosition() + void rock::calculate_random_position() { if (int(HPR::Random::Float()*2)) { Sprite.Transform.Location.x = HPR::Random::Float(-1.8f, 1.8f); diff --git a/Sandbox/src/SpaceWar/Rock.h b/Sandbox/src/SpaceWar/Rock.h index b602e91bd4..005e268489 100644 --- a/Sandbox/src/SpaceWar/Rock.h +++ b/Sandbox/src/SpaceWar/Rock.h @@ -4,24 +4,24 @@ #include #include #include -namespace ARC { - class CRock +namespace arc { + class rock { public: - void Load(FVec2 _Velocity, FVec2 _Position); - void OnUpdate(float _DeltaTime); + void Load(vec2 velocity, vec2 position); + void on_update(float delta_time); - void CalculateRandomVelocity(); - void CalculateRandomPosition(); + void calculate_random_velocity(); + void calculate_random_position(); - CPrimitive2D Sprite; - FVec2 Velocity; + primitive_2d Sprite; + vec2 Velocity; int SpriteIndex = 0; float MinDist = 0; float RotationVelocity = 0; private: - static constexpr size_t s_NumberOfRockSprites = 5; + static constexpr size_t number_of_rock_sprites = 5; public: - static std::array>>, s_NumberOfRockSprites> SpriteCollisionData; + static std::array>>, number_of_rock_sprites> SpriteCollisionData; }; } \ No newline at end of file diff --git a/Sandbox/src/SpaceWar/SpaceWar.cpp b/Sandbox/src/SpaceWar/SpaceWar.cpp index 055d1bc392..741d2a7e80 100644 --- a/Sandbox/src/SpaceWar/SpaceWar.cpp +++ b/Sandbox/src/SpaceWar/SpaceWar.cpp @@ -26,69 +26,69 @@ static float i = 0.5; -CSpaceWar::CSpaceWar() : - CLayer("SpaceWar"), +space_war::space_war() : + layer("SpaceWar"), m_CameraController(1280.f / 780.f, true) { } -void CSpaceWar::OnAttach() +void space_war::on_attach() { - ARC::HPR::Random::Init(); - GameState = EGameState::MainMenu; - m_Player = ARC::CreateRef(); + arc::HPR::Random::init(); + GameState = game_state::MainMenu; + m_Player = arc::create_ref(); m_Player->Load(); m_Player->OwningLayer = this; - ImGuiIO io = ImGui::GetIO(); + ImGuiIO io = ImGui::get_io(); m_Font = io.Fonts->AddFontFromFileTTF("assets/fonts/Inconsolata-Medium.ttf", 120.0f); } -void CSpaceWar::OnDetach() +void space_war::on_detach() { - ARC::CInstrumentor::Get().EndSession(); + arc::instrumentor::Get().end_session(); } -bool CSpaceWar::DetectCollision() +bool space_war::detect_collision() { ARC_PROFILE_FUNCTION(); - ARC::FVec2 TLPP = ARC::HPR::QUAD::GetCorner(m_Player->PlayerSprite.GetTransform()); - ARC::FVec2 TRPP = ARC::HPR::QUAD::GetCorner(m_Player->PlayerSprite.GetTransform()); - ARC::FVec2 BLPP = ARC::HPR::QUAD::GetCorner(m_Player->PlayerSprite.GetTransform()); - ARC::FVec2 BRPP = ARC::HPR::QUAD::GetCorner(m_Player->PlayerSprite.GetTransform()); + arc::vec2 TLPP = arc::HPR::QUAD::get_corner(m_Player->PlayerSprite.get_transform()); + arc::vec2 TRPP = arc::HPR::QUAD::get_corner(m_Player->PlayerSprite.get_transform()); + arc::vec2 BLPP = arc::HPR::QUAD::get_corner(m_Player->PlayerSprite.get_transform()); + arc::vec2 BRPP = arc::HPR::QUAD::get_corner(m_Player->PlayerSprite.get_transform()); - std::vector> cachedLocs; + std::vector> cachedLocs; cachedLocs.reserve(m_Player->CollisionData.size()); for (auto& PlayerCC : m_Player->CollisionData) { - ARC::FVec2 PCCTop = ARC::Math::InterpF(TLPP, TRPP, float(PlayerCC->x) / 32); - ARC::FVec2 PCCBottom = ARC::Math::InterpF(BLPP, BRPP, float(PlayerCC->x) / 32); - cachedLocs.push_back(std::make_shared( - ARC::Math::InterpF(PCCBottom, PCCTop, float(PlayerCC->y) / 32) + arc::vec2 PCCTop = arc::Math::InterpF(TLPP, TRPP, float(PlayerCC->x) / 32); + arc::vec2 PCCBottom = arc::Math::InterpF(BLPP, BRPP, float(PlayerCC->x) / 32); + cachedLocs.push_back(std::make_shared( + arc::Math::InterpF(PCCBottom, PCCTop, float(PlayerCC->y) / 32) )); } for (auto& rock : m_Rocks) { - auto dist1 = ARC::FVec2::Dist(rock->Sprite.GetLocation(), m_Player->PlayerSprite.GetLocation()); - auto dist2 = ARC::Math::Max(rock->MinDist, m_Player->MinDist); + auto dist1 = arc::vec2::Dist(rock->Sprite.get_location(), m_Player->PlayerSprite.get_location()); + auto dist2 = arc::Math::Max(rock->MinDist, m_Player->MinDist); if (dist1 < dist2) { - ARC::FVec2 TLRP = ARC::HPR::QUAD::GetCorner(rock->Sprite.GetTransform()); - ARC::FVec2 TRRP = ARC::HPR::QUAD::GetCorner(rock->Sprite.GetTransform()); - ARC::FVec2 BLRP = ARC::HPR::QUAD::GetCorner(rock->Sprite.GetTransform()); - ARC::FVec2 BRRP = ARC::HPR::QUAD::GetCorner(rock->Sprite.GetTransform()); + arc::vec2 TLRP = arc::HPR::QUAD::get_corner(rock->Sprite.get_transform()); + arc::vec2 TRRP = arc::HPR::QUAD::get_corner(rock->Sprite.get_transform()); + arc::vec2 BLRP = arc::HPR::QUAD::get_corner(rock->Sprite.get_transform()); + arc::vec2 BRRP = arc::HPR::QUAD::get_corner(rock->Sprite.get_transform()); - for (auto& RockCC : ARC::CRock::SpriteCollisionData[rock->SpriteIndex]) + for (auto& RockCC : arc::rock::SpriteCollisionData[rock->SpriteIndex]) { - ARC::FVec2 RCCTop = ARC::Math::InterpF(TLRP, TRRP, float(RockCC->x) / 32); - ARC::FVec2 RCCBottom = ARC::Math::InterpF(BLRP, BRRP, float(RockCC->x) / 32); + arc::vec2 RCCTop = arc::Math::InterpF(TLRP, TRRP, float(RockCC->x) / 32); + arc::vec2 RCCBottom = arc::Math::InterpF(BLRP, BRRP, float(RockCC->x) / 32); - ARC::FVec2 RCCN = ARC::Math::InterpF(RCCBottom, RCCTop, float(RockCC->y) / 32); + arc::vec2 RCCN = arc::Math::InterpF(RCCBottom, RCCTop, float(RockCC->y) / 32); for (auto& PlayerCC : cachedLocs) { - if (ARC::FVec2::AlmostEqual(*PlayerCC, RCCN, 0.01f)) + if (arc::vec2::AlmostEqual(*PlayerCC, RCCN, 0.01f)) { return true; } @@ -99,134 +99,134 @@ bool CSpaceWar::DetectCollision() return false; } -void CSpaceWar::OnUpdate(float _DeltaTime) +void space_war::on_update(float delta_time) { ARC_PROFILE_FUNCTION(); static float TimePassed = 0; static float PrevSpawnTime = 0; - TimePassed += _DeltaTime; + TimePassed += delta_time; if ((int)(TimePassed*10) % 10>8) m_Blink = !m_Blink; - m_CameraController.OnUpdate(_DeltaTime); + m_CameraController.on_update(delta_time); - ARC::CRenderCommand::SetClearColour({ .1f, .1f, .1f, 1.f }); - ARC::CRenderCommand::Clear(); + arc::render_command::set_clear_colour({ .1f, .1f, .1f, 1.f }); + arc::render_command::clear(); - ARC::CRenderer2D::BeginScene(m_CameraController.GetCamera()); - ARC::CRenderer2D::DrawQuad({0.f, 0.f}, 0.f, {10.f, 10.f}, 0.f, ARC::CColor(0.8f, 0.7f, 0.3f, 1.f)); + arc::CRenderer2D::begin_scene(m_CameraController.get_camera()); + arc::CRenderer2D::draw_quad({0.f, 0.f}, 0.f, {10.f, 10.f}, 0.f, arc::CColor(0.8f, 0.7f, 0.3f, 1.f)); - if (GameState == EGameState::Play) + if (GameState == game_state::Play) { if (TimePassed - PrevSpawnTime > 3) { if (!m_Rocks.empty() && m_Rocks.size() % 3 == 0) { - m_Rocks.push_back(ARC::CreateRef()); + m_Rocks.push_back(arc::create_ref()); i += 0.0001f; m_Rocks.back()->Sprite.Transform.ZOrder = i; - m_Rocks.back()->CalculateRandomPosition(); + m_Rocks.back()->calculate_random_position(); m_Rocks.back()->Load({ 0,0 }, { 0,0 }); - m_Rocks.back()->CalculateRandomPosition(); - m_Rocks.back()->Velocity = (m_Player->PlayerSprite.GetLocation() / m_Player->PlayerSprite.GetLocation().Length())*-1.f; + m_Rocks.back()->calculate_random_position(); + m_Rocks.back()->Velocity = (m_Player->PlayerSprite.get_location() / m_Player->PlayerSprite.get_location().Length())*-1.f; } else { - m_Rocks.push_back(ARC::CreateRef()); + m_Rocks.push_back(arc::create_ref()); i += 0.01f; m_Rocks.back()->Sprite.Transform.ZOrder = i; m_Rocks.back()->Load({ 0,0 }, { 0,0 }); - m_Rocks.back()->CalculateRandomPosition(); - m_Rocks.back()->CalculateRandomVelocity(); + m_Rocks.back()->calculate_random_position(); + m_Rocks.back()->calculate_random_velocity(); } PrevSpawnTime = TimePassed; } - if (DetectCollision()) + if (detect_collision()) { - GameState = EGameState::GameOver; + GameState = game_state::GameOver; m_Blink=true; } - m_Player->OnUpdate(_DeltaTime); + m_Player->on_update(delta_time); for (auto& rock : m_Rocks) { - rock->OnUpdate(_DeltaTime); + rock->on_update(delta_time); } } - ARC::CRenderer2D::DrawQuad(m_Player->PlayerSprite); + arc::CRenderer2D::draw_quad(m_Player->PlayerSprite); m_Player->ParticleSystem.OnRender(); for (auto& rock : m_Rocks) { - ARC::CRenderer2D::DrawQuad(rock->Sprite); + arc::CRenderer2D::draw_quad(rock->Sprite); } - ARC::CRenderer2D::EndScene(); + arc::CRenderer2D::end_scene(); } -void CSpaceWar::OnEvent(ARC::CEvent& _Event) +void space_war::on_event(arc::event& event) { ARC_PROFILE_FUNCTION(); - m_Player->OnEvent(_Event); - m_CameraController.OnEvent(_Event); + m_Player->on_event(event); + m_CameraController.on_event(event); - ARC::CEventDispatcher dispatcher(_Event); - dispatcher.Dispatch(BIND_FN(&CSpaceWar::OnMouseButtonPressed)); + arc::event_dispatcher dispatcher(event); + dispatcher.Dispatch(BIND_FN(&space_war::on_mouse_button_pressed)); } -bool CSpaceWar::OnMouseButtonPressed(ARC::CMouseButtonPressedEvent& _e) +bool space_war::on_mouse_button_pressed(arc::mouse_button_pressed_event& _e) { - if (GameState == EGameState::GameOver) - ResetLevel(); + if (GameState == game_state::GameOver) + reset_level(); - GameState = EGameState::Play; + GameState = game_state::Play; return false; } -void CSpaceWar::OnGuiRender() +void space_war::on_gui_render() { ARC_PROFILE_FUNCTION(); switch (GameState) { - case EGameState::Play: + case game_state::Play: { uint32_t playerScore = (uint32_t)m_Rocks.size(); std::string scoreStr = std::string("Score: ") + std::to_string(playerScore); - ImGui::GetForegroundDrawList()->AddText(m_Font, 48.0f, ImGui::GetWindowPos(), 0xffffffff, scoreStr.c_str()); + ImGui::get_foreground_draw_list()->AddText(m_Font, 48.0f, ImGui::get_window_pos(), 0xffffffff, scoreStr.c_str()); break; } - case EGameState::MainMenu: + case game_state::MainMenu: { - auto pos = ImGui::GetWindowPos(); - auto width = ARC::CApplication::Get().GetWindow().GetWidth(); - auto height = ARC::CApplication::Get().GetWindow().GetHeight(); + auto pos = ImGui::get_window_pos(); + auto width = arc::application::Get().get_window().get_width(); + auto height = arc::application::Get().get_window().get_height(); pos.x += width * 0.5f - 460.0f; pos.y += 50.0f; if (m_Blink) - ImGui::GetForegroundDrawList()->AddText(m_Font, 120.0f, pos, 0xffffffff, "Click to Play!"); + ImGui::get_foreground_draw_list()->AddText(m_Font, 120.0f, pos, 0xffffffff, "Click to Play!"); break; } - case EGameState::GameOver: + case game_state::GameOver: { - auto pos = ImGui::GetWindowPos(); - auto width = ARC::CApplication::Get().GetWindow().GetWidth(); - auto height = ARC::CApplication::Get().GetWindow().GetHeight(); + auto pos = ImGui::get_window_pos(); + auto width = arc::application::Get().get_window().get_width(); + auto height = arc::application::Get().get_window().get_height(); pos.x += width * 0.5f - 460.0f; pos.y += 50.0f; if (m_Blink) - ImGui::GetForegroundDrawList()->AddText(m_Font, 120.0f, pos, 0xffffffff, "Click to Play!"); + ImGui::get_foreground_draw_list()->AddText(m_Font, 120.0f, pos, 0xffffffff, "Click to Play!"); pos.x += 305.0f; pos.y += 150.0f; uint32_t playerScore = (uint32_t)m_Rocks.size(); std::string scoreStr = std::string("Score: ") + std::to_string(playerScore); - ImGui::GetForegroundDrawList()->AddText(m_Font, 48.0f, pos, 0xffffffff, scoreStr.c_str()); + ImGui::get_foreground_draw_list()->AddText(m_Font, 48.0f, pos, 0xffffffff, scoreStr.c_str()); break; } } } -void CSpaceWar::ResetLevel() +void space_war::reset_level() { - GameState = EGameState::Play; + GameState = game_state::Play; i=0.5; m_Player->Reset(); m_Rocks.clear(); diff --git a/Sandbox/src/SpaceWar/SpaceWar.h b/Sandbox/src/SpaceWar/SpaceWar.h index 4edc903617..672c8b34c8 100644 --- a/Sandbox/src/SpaceWar/SpaceWar.h +++ b/Sandbox/src/SpaceWar/SpaceWar.h @@ -7,50 +7,50 @@ #include #include "imgui/imgui.h" -namespace ARC { class CMouseButtonPressedEvent; } -namespace ARC { class CVertexArray; } -namespace ARC { class CTexture2D; } -namespace ARC { class CPlayer; } -namespace ARC { class CShader; } -namespace ARC { class CEvent; } -namespace ARC { class CRock; } - -enum class EGameState { +namespace arc { class mouse_button_pressed_event; } +namespace arc { class vertex_array; } +namespace arc { class texture_2d; } +namespace arc { class player; } +namespace arc { class shader; } +namespace arc { class event; } +namespace arc { class rock; } + +enum class game_state { Play = 0, MainMenu = 1, GameOver = 2 }; -class CSpaceWar : public ARC::CLayer +class space_war : public arc::layer { public: - CSpaceWar(); - virtual ~CSpaceWar() = default; + space_war(); + virtual ~space_war() = default; - virtual void OnAttach(); - virtual void OnDetach(); + virtual void on_attach(); + virtual void on_detach(); - virtual void OnUpdate(float _DeltaTime) override; - virtual void OnEvent(ARC::CEvent& _Event) override; - virtual void OnGuiRender() override; + virtual void on_update(float delta_time) override; + virtual void on_event(arc::event& event) override; + virtual void on_gui_render() override; - void ResetLevel(); - bool DetectCollision(); + void reset_level(); + bool detect_collision(); - bool OnMouseButtonPressed(ARC::CMouseButtonPressedEvent& _e); + bool on_mouse_button_pressed(arc::mouse_button_pressed_event& _e); float prev = 0.f; - EGameState GameState; + game_state GameState; protected: - ARC::TRef m_Shader; - ARC::TRef m_VertexArray; - ARC::TRef m_Player; - //CParticleSystem2D m_ParticleSystem; - std::vector> m_Rocks; + arc::ref m_Shader; + arc::ref m_VertexArray; + arc::ref m_Player; + //particle_system_2d m_ParticleSystem; + std::vector> m_Rocks; bool m_Blink = true; ImFont* m_Font; private: - ARC::COrthographicCameraController m_CameraController; + arc::orthographic_camera_controller m_CameraController; }; \ No newline at end of file