添加box2d库
This commit is contained in:
@ -251,15 +251,40 @@ namespace Hazel
|
||||
ImGui::OpenPopup("Add");
|
||||
if (ImGui::BeginPopup("Add"))
|
||||
{
|
||||
if (ImGui::MenuItem("Camera"))
|
||||
if (!m_SelectionContext.HasComponent<CameraComponent>())
|
||||
{
|
||||
m_SelectionContext.AddComponent<CameraComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
if (ImGui::MenuItem("Camera"))
|
||||
{
|
||||
m_SelectionContext.AddComponent<CameraComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
if (ImGui::MenuItem("Sprite"))
|
||||
|
||||
if (!m_SelectionContext.HasComponent<SpriteRendererComponent>())
|
||||
{
|
||||
m_SelectionContext.AddComponent<SpriteRendererComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
if (ImGui::MenuItem("Sprite"))
|
||||
{
|
||||
m_SelectionContext.AddComponent<SpriteRendererComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_SelectionContext.HasComponent<RigidBody2DComponent>())
|
||||
{
|
||||
if (ImGui::MenuItem("RigidBody 2D"))
|
||||
{
|
||||
m_SelectionContext.AddComponent<RigidBody2DComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_SelectionContext.HasComponent<BoxCollider2DComponent>())
|
||||
{
|
||||
if (ImGui::MenuItem("Box Collider 2D"))
|
||||
{
|
||||
m_SelectionContext.AddComponent<BoxCollider2DComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
@ -356,8 +381,48 @@ namespace Hazel
|
||||
|
||||
ImGui::DragFloat("Tiling Color", &component.TilingFactor, 0.1f, 0.0f, 100.f);
|
||||
});
|
||||
|
||||
|
||||
DrawComponent<RigidBody2DComponent>("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<BoxCollider2DComponent>("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;
|
||||
|
||||
Reference in New Issue
Block a user