Skip to content

Commit

Permalink
Fix issues found by clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Jul 29, 2024
1 parent d1ed2b0 commit 6bd26d9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/OpenSimCreator/Documents/MeshWarper/TPSDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
osc::TPSDocument::TPSDocument() :
sourceMesh{SphereGeometry{1.0f, 16, 16}},
destinationMesh{CylinderGeometry{1.0f, 1.0f, 2.0f, 16}},
blendingFactor{1.0f}
blendingFactor{1.0f},
recalculateNormals{false}
{}
8 changes: 4 additions & 4 deletions src/OpenSimCreator/UI/ModelEditor/SelectGeometryPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace
}},
});

constexpr auto c_GeomNames = std::to_array(
constexpr auto c_GeomNames = std::to_array<CStringView>(
{
"Brick",
"Sphere",
Expand Down Expand Up @@ -116,10 +116,10 @@ class osc::SelectGeometryPopup::Impl final : public StandardPopup {
ui::draw_separator();
ui::draw_dummy({0.0f, 2.0f});

int item = -1;
if (ui::draw_combobox("##premade", &item, c_GeomNames.data(), static_cast<int>(c_GeomNames.size())))
size_t item = 0;
if (ui::draw_combobox("##premade", &item, c_GeomNames))
{
const auto& ctor = c_GeomCtors.at(static_cast<size_t>(item));
const auto& ctor = c_GeomCtors.at(item);
m_Result = ctor();
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/OpenSimCreator/UI/Shared/ModelSelectionGizmo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <oscar/Maths/Vec4.h>
#include <oscar/Maths/VecFunctions.h>
#include <oscar/Platform/Log.h>
#include <oscar/Shims/Cpp23/utility.h>
#include <oscar/UI/oscimgui.h>
#include <oscar/Utils/Assertions.h>
#include <oscar/Utils/ScopeGuard.h>
Expand All @@ -40,7 +39,6 @@
#include <type_traits>
#include <utility>

namespace cpp23 = osc::cpp23;
using namespace osc;

// common/virtual manipulator data/APIs
Expand Down
15 changes: 5 additions & 10 deletions src/oscar/UI/oscimgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ bool osc::ui::is_mouse_clicked(ImGuiMouseButton button, bool repeat)

bool osc::ui::is_mouse_clicked(ImGuiMouseButton button, ImGuiID owner_id, ImGuiInputFlags flags)
{
return ImGui::IsMouseClicked(button, owner_id, flags);
return ImGui::IsMouseClicked(button, flags, owner_id);
}

bool osc::ui::is_mouse_released(ImGuiMouseButton button)
Expand Down Expand Up @@ -382,11 +382,6 @@ void osc::ui::end_combobox()
ImGui::EndCombo();
}

bool osc::ui::draw_combobox(CStringView label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items)
{
return ImGui::Combo(label.c_str(), current_item, items, items_count, popup_max_height_in_items);
}

bool osc::ui::begin_listbox(CStringView label)
{
return ImGui::BeginListBox(label.c_str());
Expand Down Expand Up @@ -1962,15 +1957,15 @@ bool osc::ui::draw_gizmo_mode_selector(Gizmo& gizmo)

bool osc::ui::draw_gizmo_mode_selector(GizmoMode& mode)
{
constexpr auto mode_labels = std::to_array({ "local", "global" });
constexpr auto mode_labels = std::to_array<CStringView>({ "local", "global" });
constexpr auto modes = std::to_array<GizmoMode, 2>({ GizmoMode::Local, GizmoMode::World });

bool rv = false;
int current_mode = static_cast<int>(std::distance(rgs::begin(modes), rgs::find(modes, mode)));
size_t current_mode = std::distance(rgs::begin(modes), rgs::find(modes, mode));
ui::push_style_var(ImGuiStyleVar_FrameRounding, 0.0f);
ui::set_next_item_width(ui::calc_text_size(mode_labels[0]).x + 40.0f);
if (ui::draw_combobox("##modeselect", &current_mode, mode_labels.data(), static_cast<int>(mode_labels.size()))) {
mode = modes.at(static_cast<size_t>(current_mode));
if (ui::draw_combobox("##modeselect", &current_mode, mode_labels)) {
mode = modes.at(current_mode);
rv = true;
}
ui::pop_style_var();
Expand Down
2 changes: 0 additions & 2 deletions src/oscar/UI/oscimgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ namespace osc::ui
bool begin_combobox(CStringView label, CStringView preview_value, ImGuiComboFlags flags = 0);
void end_combobox();

bool draw_combobox(CStringView label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1);

bool begin_listbox(CStringView label);
void end_listbox();

Expand Down
2 changes: 1 addition & 1 deletion tests/TestOpenSimCreator/docs/TestDocumentationModels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TEST(DocumentationModels, CanAllBeLoadedAndInitializedWithoutThrowingAnException
OpenSimDecorationOptions options;

std::filesystem::path docSourcesDir{OSC_DOCS_SOURCES_DIR};
for_each_file_with_extensions_recursive(docSourcesDir, [&cache, &options](std::filesystem::path osim)
for_each_file_with_extensions_recursive(docSourcesDir, [&cache, &options](const std::filesystem::path& osim)
{
// load + initialize the documentation model
UndoableModelStatePair model{osim};
Expand Down

0 comments on commit 6bd26d9

Please sign in to comment.