diff --git a/.gitmodules b/.gitmodules index ca63bf8..f4c6a38 100644 --- a/.gitmodules +++ b/.gitmodules @@ -23,3 +23,6 @@ [submodule "Hazel/vendor/SPIRV-Cross"] path = Hazel/vendor/SPIRV-Cross url = https://github.com/KhronosGroup/SPIRV-Cross.git +[submodule "Hazel/vendor/box2d"] + path = Hazel/vendor/box2d + url = https://github.com/erincatto/box2d.git diff --git a/Hazel/CMakeLists.txt b/Hazel/CMakeLists.txt index b8ecaa9..243dfac 100644 --- a/Hazel/CMakeLists.txt +++ b/Hazel/CMakeLists.txt @@ -8,6 +8,7 @@ add_subdirectory(vendor/glm) add_subdirectory(vendor/yaml-cpp) add_subdirectory(vendor/shaderc) add_subdirectory(vendor/SPIRV-Cross) +add_subdirectory(vendor/box2d) file(GLOB_RECURSE SOURCES "src/**.cpp") @@ -64,6 +65,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC shaderc spirv-cross-cpp spirv-cross-core + box2d ) # target_compile_definitions(${PROJECT_NAME} PRIVATE HZ_BUILD_DLL IMGUI_API=__declspec\(dllexport\) STB_IMAGE_IMPLEMENTATION)# 编译DLL时定义 target_compile_definitions(${PROJECT_NAME} PRIVATE STB_IMAGE_IMPLEMENTATION) diff --git a/Hazel/src/Hazel/Scene/Components.h b/Hazel/src/Hazel/Scene/Components.h index fc347b1..108ecda 100644 --- a/Hazel/src/Hazel/Scene/Components.h +++ b/Hazel/src/Hazel/Scene/Components.h @@ -18,6 +18,7 @@ namespace Hazel { + struct TransformComponent { glm::vec3 Translation{0.0f}; @@ -91,6 +92,41 @@ namespace Hazel DestroyScript = [](NativeScriptComponent* nsc) { delete nsc->Instance; nsc->Instance = nullptr; }; } }; + + // Physics + + struct RigidBody2DComponent + { + enum class BodyType { Static = 0, Dynamic, Kinematic }; + + BodyType Type = BodyType::Static; + bool FixedRotation = false; + + // Storage for runtime + b2BodyId RuntimeBody; + + RigidBody2DComponent() = default; + RigidBody2DComponent(const RigidBody2DComponent&) = default; + }; + + struct BoxCollider2DComponent + { + glm::vec2 Offset = {0.0f, 0.0f}; + glm::vec2 Size = {0.5f, 0.5f}; + + // TODO(Yan): move into material texture in the future + float Density = 1.0f; // 密度 + float Friction = 0.5f; // 摩擦力 + float Restitution = 0.0f; // 弹力 + float RestitutionThreshold = 0.5f; // 弹力阈值 + + // Storage for runtime + void *RuntimeBody = nullptr; + + BoxCollider2DComponent() = default; + BoxCollider2DComponent(const BoxCollider2DComponent&) = default; + }; + } diff --git a/Hazel/src/Hazel/Scene/Scene.cpp b/Hazel/src/Hazel/Scene/Scene.cpp index 7387093..d74346e 100644 --- a/Hazel/src/Hazel/Scene/Scene.cpp +++ b/Hazel/src/Hazel/Scene/Scene.cpp @@ -9,9 +9,26 @@ #include "Components.h" #include "Entity.h" +#include "../../../vendor/box2d/src/physics_world.h" +#include "box2d/box2d.h" +#include "box2d/id.h" + namespace Hazel { + static b2BodyType RigidBodyTypeToBox2DBodyType(RigidBody2DComponent::BodyType type) + { + switch (type) + { + case RigidBody2DComponent::BodyType::Static: return b2_staticBody; + case RigidBody2DComponent::BodyType::Dynamic: return b2_dynamicBody; + case RigidBody2DComponent::BodyType::Kinematic: return b2_kinematicBody; + } + + HZ_CORE_ERROR("Unknown body type"); + return b2_staticBody; + } + Scene::Scene() { } @@ -34,6 +51,57 @@ namespace Hazel m_Registry.destroy(entity); } + + + void Scene::OnRuntimeStart() + { + b2WorldDef worldDef = b2DefaultWorldDef(); + worldDef.gravity = b2Vec2(0.0f, -9.81f); + m_PhysicsWorld = b2CreateWorld( &worldDef ); + + auto view = m_Registry.view(); + for (auto e : view) + { + Entity entity = {e, this}; + auto &transform = entity.GetComponent(); + auto &rb2D = entity.GetComponent(); + + b2BodyDef bodyDef = b2DefaultBodyDef(); + bodyDef.type = RigidBodyTypeToBox2DBodyType(rb2D.Type); + bodyDef.position = {transform.Translation.x, transform.Translation.y}; + float angle = transform.Rotation.z; + bodyDef.rotation = b2Rot{cos(angle), sin(angle)}; + + // bodyDef.fixedRotation = true; + + b2BodyId body = b2CreateBody(m_PhysicsWorld, &bodyDef); + + rb2D.RuntimeBody = body; + if (entity.HasComponent()) + { + auto& bc2d = entity.GetComponent(); + + float hx = bc2d.Size.x * transform.Scale.x; + float hy = bc2d.Size.y * transform.Scale.y; + b2Polygon boxShape = b2MakeBox(hx, hy); + b2ShapeDef shapedef = b2DefaultShapeDef(); + + shapedef.density = bc2d.Density; + shapedef.material.friction = bc2d.Friction; + shapedef.material.restitution = bc2d.Restitution; + + b2CreatePolygonShape(body, &shapedef,&boxShape); + } + + } + } + + void Scene::OnRuntimeStop() + { + + b2DestroyWorld( m_PhysicsWorld ); + } + void Scene::OnUpdateRuntime(TimeStep& ts) { @@ -54,6 +122,30 @@ namespace Hazel }); } + // Physics + { + const int32_t velocityIteration = 6; + const int32_t positionIteration = 2; + + b2World_Step(m_PhysicsWorld, ts, 4); + + auto view = m_Registry.view(); + for (auto e : view) + { + Entity entity = {e, this}; + auto& transform = entity.GetComponent(); + auto& rb2D = entity.GetComponent(); + + b2BodyId &body = rb2D.RuntimeBody; + + const auto& position = b2Body_GetPosition(body); + transform.Translation.x = position.x; + transform.Translation.y = position.y; + const float angle = b2Rot_GetAngle(b2Body_GetRotation(body)); + transform.Rotation.z = angle; + } + } + // Renderer 2D Camera* mainCamera = nullptr; glm::mat4 cameraTranform; @@ -82,7 +174,7 @@ namespace Hazel { auto [transform, sprite] = group.get(entity); - Renderer2D::DrawQuad(transform.GetTransform(), sprite.Color); + Renderer2D::DrawSprite(transform.GetTransform(), sprite, (int)entity); } Renderer2D::EndScene(); @@ -169,10 +261,22 @@ namespace Hazel { } + template<> + void Scene::OnComponentAdded(Entity entity, RigidBody2DComponent& component) + { + } + + template<> + void Scene::OnComponentAdded(Entity entity, BoxCollider2DComponent& component) + { + } + template HAZEL_API void Scene::OnComponentAdded(Entity, TransformComponent&); template HAZEL_API void Scene::OnComponentAdded(Entity, CameraComponent&); template HAZEL_API void Scene::OnComponentAdded(Entity, TagComponent&); template HAZEL_API void Scene::OnComponentAdded(Entity, SpriteRendererComponent&); template HAZEL_API void Scene::OnComponentAdded(Entity, NativeScriptComponent&); + template HAZEL_API void Scene::OnComponentAdded(Entity, RigidBody2DComponent&); + template HAZEL_API void Scene::OnComponentAdded(Entity, BoxCollider2DComponent&); } diff --git a/Hazel/src/Hazel/Scene/Scene.h b/Hazel/src/Hazel/Scene/Scene.h index dd194dc..356eed0 100644 --- a/Hazel/src/Hazel/Scene/Scene.h +++ b/Hazel/src/Hazel/Scene/Scene.h @@ -6,6 +6,7 @@ #define SCENE_H +#include #include #include @@ -13,7 +14,6 @@ #include "Hazel/Core/Core.h" - namespace Hazel { class Entity; @@ -27,10 +27,11 @@ namespace Hazel void DestoryEntity(Entity entity); + void OnRuntimeStart(); + void OnRuntimeStop(); + void OnUpdateRuntime(TimeStep& ts); - void OnUpdateEditor(TimeStep& ts, const EditorCamera& camera); - void OnViewportResize(uint32_t width, uint32_t height); Entity GetPrimaryCameraEntity(); @@ -43,6 +44,8 @@ namespace Hazel entt::registry m_Registry; uint32_t m_ViewportWidth = 0, m_ViewportHeight = 0; + b2WorldId m_PhysicsWorld; + friend class Entity; friend class SceneSerializer; friend class SceneHierachyPanel; diff --git a/Hazel/src/Hazel/Scene/SceneSerializer.cpp b/Hazel/src/Hazel/Scene/SceneSerializer.cpp index 8bf6d5d..52654d9 100644 --- a/Hazel/src/Hazel/Scene/SceneSerializer.cpp +++ b/Hazel/src/Hazel/Scene/SceneSerializer.cpp @@ -12,6 +12,28 @@ namespace YAML { + template<> + struct convert + { + static Node encode(const glm::vec2& out) + { + Node node; + node.push_back(out.x); + node.push_back(out.y); + node.SetStyle(EmitterStyle::Flow); + return node; + } + + static bool decode(const Node& node, glm::vec2& out) + { + if (node.size() != 2 && !node.IsSequence()) + return false; + out.x = node[0].as(); + out.y = node[1].as(); + return true; + } + }; + template<> struct convert { @@ -62,6 +84,34 @@ namespace YAML } }; + static std::string RigidBody2DTypeToString(Hazel::RigidBody2DComponent::BodyType type) + { + switch (type) + { + case Hazel::RigidBody2DComponent::BodyType::Static: return "Static"; + case Hazel::RigidBody2DComponent::BodyType::Dynamic: return "Dynamic"; + case Hazel::RigidBody2DComponent::BodyType::Kinematic: return "Kinematic"; + } + HZ_CORE_ERROR("Unknown body type!"); + return {}; + } + + static Hazel::RigidBody2DComponent::BodyType RigidBody2DStringToType(const std::string& type) + { + if (type == "Static") return Hazel::RigidBody2DComponent::BodyType::Static; + if (type == "Dynamic") return Hazel::RigidBody2DComponent::BodyType::Dynamic; + if (type == "Kinematic") return Hazel::RigidBody2DComponent::BodyType::Kinematic; + HZ_CORE_ERROR("Unknown body type!"); + return Hazel::RigidBody2DComponent::BodyType::Static; + } + + Emitter& operator<<(Emitter& out, const glm::vec2& value) + { + out << Flow; + out << BeginSeq << value.x << value.y << EndSeq; + return out; + } + Emitter& operator<<(Emitter& out, const glm::vec3& value) { out << Flow; @@ -154,6 +204,33 @@ namespace Hazel out << YAML::EndMap; // SpriteRendererComponent } + if (entity.HasComponent()) + { + out << YAML::Key << "RigidBody2DComponent"; + + out << YAML::BeginMap; // RigidBody2DComponent + auto& rb2dComponent = entity.GetComponent(); + out << YAML::Key << "BodyType" << YAML::Value << YAML::RigidBody2DTypeToString(rb2dComponent.Type); + out << YAML::Key << "FixedRotation" << YAML::Value << rb2dComponent.FixedRotation; + out << YAML::EndMap; // RigidBody2DComponent + } + + if (entity.HasComponent()) + { + out << YAML::Key << "BoxCollider2DComponent"; + + out << YAML::BeginMap; // BoxCollider2DComponent + auto& bc2dComponent = entity.GetComponent(); + out << YAML::Key << "Offset" << YAML::Value << bc2dComponent.Offset; + out << YAML::Key << "Size" << YAML::Value << bc2dComponent.Size; + out << YAML::Key << "Density" << YAML::Value << bc2dComponent.Density; + out << YAML::Key << "Friction" << YAML::Value << bc2dComponent.Friction; + out << YAML::Key << "Restitution" << YAML::Value << bc2dComponent.Restitution; + out << YAML::Key << "Restitution" << YAML::Value << bc2dComponent.Restitution; + out << YAML::Key << "RestitutionThreshold" << YAML::Value << bc2dComponent.RestitutionThreshold; + out << YAML::EndMap; // BoxCollider2DComponent + } + out << YAML::EndMap; // entity } @@ -250,6 +327,26 @@ namespace Hazel sprite.Color = spriteRendererComponent["Color"].as(); } + auto rigidBody2DComponent = entity["RigidBody2DComponent"]; + if (rigidBody2DComponent) + { + auto& rb2d = deserializedEntity.AddComponent(); + rb2d.Type = YAML::RigidBody2DStringToType(rigidBody2DComponent["BodyType"].as()); + rb2d.FixedRotation = rigidBody2DComponent["FixedRotation"].as(); + } + + auto boxCollider2DComponent = entity["BoxCollider2DComponent"]; + if (boxCollider2DComponent) + { + auto& bc2d = deserializedEntity.AddComponent(); + bc2d.Offset = boxCollider2DComponent["Offset"].as(); + bc2d.Size = boxCollider2DComponent["Size"].as(); + bc2d.Density = boxCollider2DComponent["Density"].as(); + bc2d.Friction = boxCollider2DComponent["Friction"].as(); + bc2d.Restitution = boxCollider2DComponent["Restitution"].as(); + bc2d.RestitutionThreshold = boxCollider2DComponent["RestitutionThreshold"].as(); + } + } } diff --git a/Hazel/vendor/box2d b/Hazel/vendor/box2d new file mode 160000 index 0000000..fcc60b7 --- /dev/null +++ b/Hazel/vendor/box2d @@ -0,0 +1 @@ +Subproject commit fcc60b76e1c45353e6e44f3a5f3d80301378a0aa diff --git a/Sandbox/src/Editor/EditorLayer.cpp b/Sandbox/src/Editor/EditorLayer.cpp index 4336783..2c58411 100644 --- a/Sandbox/src/Editor/EditorLayer.cpp +++ b/Sandbox/src/Editor/EditorLayer.cpp @@ -38,6 +38,9 @@ namespace Hazel m_LogoTexture = Texture2D::Create("assets/textures/iceLogo.png"); m_CheckerBoardTexture = Texture2D::Create("assets/textures/Checkerboard.png"); + m_PlayIcon = Texture2D::Create("Resources/Icons/PlayButton.png"); + m_StopIcon = Texture2D::Create("Resources/Icons/PauseButton.png"); + m_ActiveScene = CreateRef(); m_EditorCamera = EditorCamera(45.0f, 1.667f, 0.1f, 1000.0f); @@ -66,11 +69,6 @@ namespace Hazel } // update camera - if (m_ViewportFocused) - { - m_CameraController.OnUpdate(ts); - m_EditorCamera.OnUpdate(ts); - } // update Renderer m_FrameBuffer->Bind(); @@ -79,10 +77,21 @@ namespace Hazel m_FrameBuffer->ClearAttachment(1, -1); - // Renderer2D::BeginScene(m_CameraController.GetCamera()); + switch (m_SceneState) + { + case SceneState::Play: + m_ActiveScene->OnUpdateRuntime(ts); + break; + case SceneState::Edit: + if (m_ViewportFocused) + m_CameraController.OnUpdate(ts); - // update Scene - m_ActiveScene->OnUpdateEditor(ts, m_EditorCamera); + m_EditorCamera.OnUpdate(ts); + m_ActiveScene->OnUpdateEditor(ts, m_EditorCamera); + break; + } + + // Renderer2D::BeginScene(m_CameraController.GetCamera()); auto [mx, my] = ImGui::GetMousePos(); mx -= m_ViewPortBounds[0].x; @@ -275,17 +284,27 @@ namespace Hazel ImGuizmo::SetRect(windowPos.x, windowPos.y, windowWidth, windowHeight); - // auto cameraEntity = m_ActiveScene->GetPrimaryCameraEntity(); if (m_GizmoType != -1) { - // const auto& camera = cameraEntity.GetComponent().Camera; + + glm::mat4 cameraProjection; + glm::mat4 cameraView; + + if (m_SceneState == SceneState::Play) + { + auto cameraEntity = m_ActiveScene->GetPrimaryCameraEntity(); + const auto& camera = cameraEntity.GetComponent().Camera; + + cameraProjection = camera.GetProjection(); + cameraView = glm::inverse(cameraEntity.GetComponent().GetTransform()); + }else if (m_SceneState == SceneState::Edit) + { + cameraProjection = m_EditorCamera.GetProjection(); + cameraView = m_EditorCamera.GetViewMatrix(); + } + auto& tc = selectedEntity.GetComponent(); - - // const glm::mat4& cameraProjection = camera.GetProjection(); - // glm::mat4 cameraView = glm::inverse(cameraEntity.GetComponent().GetTransform()); - glm::mat4 cameraProjection = m_EditorCamera.GetProjection(); - glm::mat4 cameraView = m_EditorCamera.GetViewMatrix(); glm::mat4 transform = tc.GetTransform(); bool snap = SDL_GetModState() & SDL_KMOD_CTRL; float snapValue = 0.5f; @@ -298,7 +317,7 @@ namespace Hazel float snapValues[3] = {snapValue, snapValue, snapValue}; if (ImGuizmo::Manipulate(glm::value_ptr(cameraView), glm::value_ptr(cameraProjection), - ImGuizmo::OPERATION(m_GizmoType), ImGuizmo::LOCAL, + static_cast(m_GizmoType), ImGuizmo::WORLD, glm::value_ptr(transform), nullptr, snap ? snapValues : nullptr) && !Input::IsKeyPressed(SDL_SCANCODE_LALT)) { if (ImGuizmo::IsUsing()) @@ -321,6 +340,9 @@ namespace Hazel ImGui::End(); ImGui::PopStyleVar(); } + + UI_ToolBar(); + ImGui::End(); } } @@ -417,4 +439,51 @@ namespace Hazel break; } } + + void EditorLayer::UI_ToolBar() + { + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 2)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(0, 0)); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); + auto& colors = ImGui::GetStyle().Colors; + auto& buttonHovered = colors[ImGuiCol_ButtonHovered]; + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(buttonHovered.x, buttonHovered.y, buttonHovered.z, 0.5f)); + auto& buttonActive = colors[ImGuiCol_ButtonActive]; + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(buttonActive.x, buttonActive.y, buttonActive.z, 0.5f)); + + + ImGui::Begin("##ToolBar", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse); + // ImGui::Begin("##ToolBar", nullptr); + + float size = ImGui::GetWindowHeight() - 10.0f; + Ref icon = m_SceneState == SceneState::Edit ? m_PlayIcon : m_StopIcon; + ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x * 0.5f - size * 0.5f); + ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x * 0.5f - (size * 0.5f)); + if (ImGui::ImageButton("toolbar", icon->GetRendererID(), ImVec2{size, size}, ImVec2{0, 0}, ImVec2{1, 1})) + { + if (m_SceneState == SceneState::Edit) + OnScenePlay(); + else if (m_SceneState == SceneState::Play) + OnSceneStop(); + + } + + + ImGui::PopStyleVar(2); + ImGui::PopStyleColor(3); + ImGui::End(); + } + + void EditorLayer::OnScenePlay() + { + m_SceneState = SceneState::Play; + m_ActiveScene->OnRuntimeStart(); + } + + void EditorLayer::OnSceneStop() + { + m_SceneState = SceneState::Edit; + m_ActiveScene->OnRuntimeStop(); + } } diff --git a/Sandbox/src/Editor/EditorLayer.h b/Sandbox/src/Editor/EditorLayer.h index eae573a..0c04033 100644 --- a/Sandbox/src/Editor/EditorLayer.h +++ b/Sandbox/src/Editor/EditorLayer.h @@ -24,18 +24,25 @@ namespace Hazel virtual void OnImGuiRender() override; virtual void OnEvent(SDL_Event& e) override; private: + void UI_ToolBar(); + + void OnScenePlay(); + void OnSceneStop(); + void SaveScene() const; void OpenScene(); void OpenScene(const std::filesystem::path& scenePath); void NewScene(); void ChangeOptMode(unsigned int mode); + private: OrthographicCameraController m_CameraController; Ref m_LogoTexture; Ref m_CheckerBoardTexture; + Ref m_ActiveScene; EditorCamera m_EditorCamera; @@ -53,7 +60,16 @@ namespace Hazel SceneHierachyPanel m_SceneHierachyPanel; ContentBroswerPanel m_ContentBroswerPanel; - int m_GizmoType = 0; + int m_GizmoType = -1; + + enum class SceneState + { + Edit = 0, Play = 1 + }; + + SceneState m_SceneState = SceneState::Edit; + + Ref m_PlayIcon, m_StopIcon; }; } diff --git a/Sandbox/src/Editor/Panels/SceneHierachyPanel.cpp b/Sandbox/src/Editor/Panels/SceneHierachyPanel.cpp index f5b7e86..e10a56a 100644 --- a/Sandbox/src/Editor/Panels/SceneHierachyPanel.cpp +++ b/Sandbox/src/Editor/Panels/SceneHierachyPanel.cpp @@ -251,15 +251,40 @@ namespace Hazel ImGui::OpenPopup("Add"); if (ImGui::BeginPopup("Add")) { - if (ImGui::MenuItem("Camera")) + if (!m_SelectionContext.HasComponent()) { - m_SelectionContext.AddComponent(); - ImGui::CloseCurrentPopup(); + if (ImGui::MenuItem("Camera")) + { + m_SelectionContext.AddComponent(); + ImGui::CloseCurrentPopup(); + } } - if (ImGui::MenuItem("Sprite")) + + if (!m_SelectionContext.HasComponent()) { - m_SelectionContext.AddComponent(); - ImGui::CloseCurrentPopup(); + if (ImGui::MenuItem("Sprite")) + { + m_SelectionContext.AddComponent(); + ImGui::CloseCurrentPopup(); + } + } + + if (!m_SelectionContext.HasComponent()) + { + if (ImGui::MenuItem("RigidBody 2D")) + { + m_SelectionContext.AddComponent(); + ImGui::CloseCurrentPopup(); + } + } + + if (!m_SelectionContext.HasComponent()) + { + if (ImGui::MenuItem("Box Collider 2D")) + { + m_SelectionContext.AddComponent(); + ImGui::CloseCurrentPopup(); + } } ImGui::EndPopup(); @@ -356,8 +381,48 @@ namespace Hazel ImGui::DragFloat("Tiling Color", &component.TilingFactor, 0.1f, 0.0f, 100.f); }); + + + DrawComponent("Rigidbody 2D", entity, [](auto& component) + { + static const char* bodyTypeStrings[] = {"Static", "Dynamic", "Kinematic"}; + + const char* currentBodyTypeString = bodyTypeStrings[(int)component.Type]; + if (ImGui::BeginCombo("Body Type", currentBodyTypeString)) + { + for (int i = 0; i < 3; i++) + { + const bool isSelected = currentBodyTypeString == bodyTypeStrings[i]; + if (ImGui::Selectable(bodyTypeStrings[i], isSelected)) + { + currentBodyTypeString = bodyTypeStrings[i]; + component.Type = (RigidBody2DComponent::BodyType)i; + } + + if (isSelected) + { + ImGui::SetItemDefaultFocus(); + } + } + ImGui::EndCombo(); + } + + ImGui::Checkbox("Fixed Rotation", &component.FixedRotation); + }); + + DrawComponent("Box Collider 2D", entity, [](auto& component) + { + ImGui::DragFloat2("Offset", glm::value_ptr(component.Offset)); + ImGui::DragFloat2("Size", glm::value_ptr(component.Size)); + + ImGui::DragFloat("Density", &component.Density, 0.01f, 0.0f); + ImGui::DragFloat("Friction", &component.Friction, 0.01f, 0.0f, 1.0f); + ImGui::DragFloat("Restitution", &component.Restitution, 0.01f, 0.0f, 1.0f); + ImGui::DragFloat("Restitution Threshold", &component.RestitutionThreshold, 0.01f, 0.0f); + }); } + void SceneHierachyPanel::SetSelectedEntity(const Entity entity) { m_SelectionContext = entity; diff --git a/Sandbox/src/SandboxApp.cpp b/Sandbox/src/SandboxApp.cpp index a090091..9712da3 100644 --- a/Sandbox/src/SandboxApp.cpp +++ b/Sandbox/src/SandboxApp.cpp @@ -10,7 +10,7 @@ namespace Hazel { public: HazelEditor() - : Application("Hazel Editor", 1600, 900) + : Application("Hazel Editor", 1920, 1080) { PushLayer(new EditorLayer()); }