Fixed imgui error caused by merge

This commit is contained in:
Diren D Bharwani 2023-03-04 13:50:10 +08:00
parent 15bbf6892f
commit a691d2ff28
1 changed files with 50 additions and 52 deletions

View File

@ -338,7 +338,7 @@ namespace SHADE
ImGui::PushID(SHFamilyID<SHComponent>::GetID<SHColliderComponent>());
std::vector<const char*> collisionTagNames(SHCollisionTag::NUM_LAYERS);
//Fetch tag names
for (int i{}; i < SHCollisionTag::NUM_LAYERS; ++i)
for(int i{}; i < SHCollisionTag::NUM_LAYERS; ++i)
{
collisionTagNames[i] = SHCollisionTagMatrix::GetTagName(i).c_str();
}
@ -362,11 +362,11 @@ namespace SHADE
SHCollisionShape* shape = component->GetCollisionShape(i);
auto cursorPos = ImGui::GetCursorPos();
if (shape->GetType() == SHCollisionShape::Type::BOX)
{
SHEditorWidgets::BeginPanel(std::format("{} Box #{}", ICON_FA_CUBE, i).data(), { ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y });
auto* box = reinterpret_cast<SHBox*>(shape);
SHEditorWidgets::DragVec3
(
@ -387,73 +387,71 @@ namespace SHADE
else if (shape->GetType() == SHCollisionShape::Type::CAPSULE)
{
//}
}
{
SHEditorWidgets::CheckBox("Is Trigger", [shape] { return shape->IsTrigger(); }, [shape](bool value) { shape->SetIsTrigger(value); });
SHEditorWidgets::ComboBox("Tag", collisionTagNames, [shape]{return SHCollisionTagMatrix::GetTagIndex(shape->GetCollisionTag().GetName());}, [shape](int const& value){shape->SetCollisionTag(SHCollisionTagMatrix::GetTag(value));});
if(ImGui::CollapsingHeader("Physics Material"))
{
SHEditorWidgets::CheckBox("Is Trigger", [shape] { return shape->IsTrigger(); }, [shape](bool value) { shape->SetIsTrigger(value); });
SHEditorWidgets::ComboBox("Tag", collisionTagNames, [shape] {return SHCollisionTagMatrix::GetTagIndex(shape->GetCollisionTag().GetName()); }, [shape](int const& value) {shape->SetCollisionTag(SHCollisionTagMatrix::GetTag(value)); });
if (ImGui::CollapsingHeader("Physics Material"))
{
SHEditorWidgets::DragFloat("Friction", [shape] { return shape->GetFriction(); }, [shape](float value) { shape->SetFriction(value); }, "Friction", 0.05f, 0.0f, 1.0f);
SHEditorWidgets::DragFloat("Bounciness", [shape] { return shape->GetBounciness(); }, [shape](float value) { shape->SetBounciness(value); }, "Bounciness", 0.05f, 0.0f, 1.0f);
SHEditorWidgets::DragFloat("Mass Density", [shape] { return shape->GetDensity(); }, [shape](float value) { shape->SetDensity(value); }, "Mass Density", 0.1f, 0.0f);
}
SHEditorWidgets::BeginPanel("Offsets", { ImGui::GetContentRegionAvail().x, 30.0f });
SHEditorWidgets::DragVec3("Position", { "X", "Y", "Z" }, [&shape] {return shape->GetPositionOffset(); }, [&shape](SHVec3 const& vec) {shape->SetPositionOffset(vec); });
SHEditorWidgets::DragVec3("Rotation", { "X", "Y", "Z" },
[&shape]
{
auto offset = shape->GetRotationOffset();
return offset;
},
[&shape](SHVec3 const& vec)
{
shape->SetRotationOffset(vec);
}, true);
SHEditorWidgets::EndPanel();
SHEditorWidgets::DragFloat("Friction", [shape] { return shape->GetFriction(); }, [shape](float value) { shape->SetFriction(value); }, "Friction", 0.05f, 0.0f, 1.0f);
SHEditorWidgets::DragFloat("Bounciness", [shape] { return shape->GetBounciness(); }, [shape](float value) { shape->SetBounciness(value); }, "Bounciness", 0.05f, 0.0f, 1.0f);
SHEditorWidgets::DragFloat("Mass Density", [shape] { return shape->GetDensity(); }, [shape](float value) { shape->SetDensity(value); }, "Mass Density", 0.1f, 0.0f);
}
if (ImGui::Button(std::format("{} Remove Collider #{}", ICON_MD_REMOVE, i).data()))
SHEditorWidgets::BeginPanel("Offsets",{ ImGui::GetContentRegionAvail().x, 30.0f });
SHEditorWidgets::DragVec3("Position", { "X", "Y", "Z" }, [&shape] {return shape->GetPositionOffset(); }, [&shape](SHVec3 const& vec) {shape->SetPositionOffset(vec); });
SHEditorWidgets::DragVec3("Rotation", { "X", "Y", "Z" },
[&shape]
{
colliderToDelete = i;
}
auto offset = shape->GetRotationOffset();
return offset;
},
[&shape](SHVec3 const& vec)
{
shape->SetRotationOffset(vec);
}, true);
SHEditorWidgets::EndPanel();
ImGui::PopID();
}
if (colliderToDelete.has_value())
if (ImGui::Button(std::format("{} Remove Collider #{}", ICON_MD_REMOVE, i).data()))
{
component->GetCollider()->RemoveCollisionShape(colliderToDelete.value());
colliderToDelete = i;
}
ImGui::EndChild();
// TODO: Handle differences between composite & hull collider
if (ImGui::BeginMenu("Add Collider"))
SHEditorWidgets::EndPanel();
ImGui::PopID();
}
if (colliderToDelete.has_value())
{
component->GetCollider()->RemoveCollisionShape(colliderToDelete.value());
}
ImGui::EndChild();
// TODO: Handle differences between composite & hull collider
if (ImGui::BeginMenu("Add Collider"))
{
int newColl = -1;
if (ImGui::Selectable("Box Collider"))
{
int newColl = -1;
if (ImGui::Selectable("Box Collider"))
{
auto* compositeCollider = reinterpret_cast<SHCompositeCollider* const>(component->GetCollider());
compositeCollider->AddBoxCollisionShape(SHVec3::One);
}
if (ImGui::Selectable("Sphere Collider"))
{
auto* compositeCollider = reinterpret_cast<SHCompositeCollider* const>(component->GetCollider());
compositeCollider->AddSphereCollisionShape(1.0f);
}
ImGui::EndMenu();
auto* compositeCollider = reinterpret_cast<SHCompositeCollider* const>(component->GetCollider());
compositeCollider->AddBoxCollisionShape(SHVec3::One);
}
if (ImGui::Selectable("Sphere Collider"))
{
auto* compositeCollider = reinterpret_cast<SHCompositeCollider* const>(component->GetCollider());
compositeCollider->AddSphereCollisionShape(1.0f);
}
ImGui::EndMenu();
}
}
else
{
DrawContextMenu(component);
}
ImGui::PopID();
}