Skip to content

Commit

Permalink
Merge branch 'main' into feature_frame-definition-in-meshimporter
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Nov 16, 2023
2 parents 996f7b4 + 39507b7 commit a888b1b
Show file tree
Hide file tree
Showing 170 changed files with 1,713 additions and 1,070 deletions.
11 changes: 5 additions & 6 deletions src/OpenSimCreator/Graphics/CustomRenderingOptionFlags.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <oscar/Shims/Cpp23/utility.hpp>
#include <oscar/Utils/CStringView.hpp>
#include <oscar/Utils/EnumHelpers.hpp>

Expand All @@ -20,22 +21,20 @@ namespace osc
Default = DrawFloor | Shadows | DrawSelectionRims,
};

constexpr bool operator&(CustomRenderingOptionFlags a, CustomRenderingOptionFlags b)
constexpr bool operator&(CustomRenderingOptionFlags lhs, CustomRenderingOptionFlags rhs)
{
using Underlying = std::underlying_type_t<CustomRenderingOptionFlags>;
return (static_cast<Underlying>(a) & static_cast<Underlying>(b)) != 0;
return (osc::to_underlying(lhs) & osc::to_underlying(rhs)) != 0;
}

constexpr void SetOption(CustomRenderingOptionFlags& flags, CustomRenderingOptionFlags flag, bool v)
{
using Underlying = std::underlying_type_t<CustomRenderingOptionFlags>;
if (v)
{
flags = static_cast<CustomRenderingOptionFlags>(static_cast<Underlying>(flags) | static_cast<Underlying>(flag));
flags = static_cast<CustomRenderingOptionFlags>(osc::to_underlying(flags) | osc::to_underlying(flag));
}
else
{
flags = static_cast<CustomRenderingOptionFlags>(static_cast<Underlying>(flags) & ~static_cast<Underlying>(flag));
flags = static_cast<CustomRenderingOptionFlags>(osc::to_underlying(flags) & ~osc::to_underlying(flag));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/OpenSimCreator/Graphics/OpenSimDecorationOptionFlags.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "OpenSimDecorationOptionFlags.hpp"

#include <oscar/Shims/Cpp23/utility.hpp>

#include <algorithm>
#include <array>
#include <cstddef>
Expand Down Expand Up @@ -79,14 +81,12 @@ void osc::SetIthOption(OpenSimDecorationOptionFlags& flags, size_t i, bool v)

void osc::SetOption(OpenSimDecorationOptionFlags& flags, OpenSimDecorationOptionFlags flag, bool v)
{
using Underlying = std::underlying_type_t<OpenSimDecorationOptionFlags>;

if (v)
{
flags = static_cast<OpenSimDecorationOptionFlags>(static_cast<Underlying>(flags) | static_cast<Underlying>(flag));
flags = static_cast<OpenSimDecorationOptionFlags>(osc::to_underlying(flags) | osc::to_underlying(flag));
}
else
{
flags = static_cast<OpenSimDecorationOptionFlags>(static_cast<Underlying>(flags) & ~static_cast<Underlying>(flag));
flags = static_cast<OpenSimDecorationOptionFlags>(osc::to_underlying(flags) & ~osc::to_underlying(flag));
}
}
6 changes: 3 additions & 3 deletions src/OpenSimCreator/Graphics/OpenSimDecorationOptionFlags.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <oscar/Shims/Cpp23/utility.hpp>
#include <oscar/Utils/CStringView.hpp>
#include <oscar/Utils/EnumHelpers.hpp>

Expand All @@ -25,10 +26,9 @@ namespace osc
Default = ShouldShowPointToPointSprings,
};

constexpr bool operator&(OpenSimDecorationOptionFlags a, OpenSimDecorationOptionFlags b) noexcept
constexpr bool operator&(OpenSimDecorationOptionFlags lhs, OpenSimDecorationOptionFlags rhs)
{
using Underlying = std::underlying_type_t<OpenSimDecorationOptionFlags>;
return (static_cast<Underlying>(a) & static_cast<Underlying>(b)) != 0;
return (osc::to_underlying(lhs) & osc::to_underlying(rhs)) != 0;
}

struct OpenSimDecorationOptionMetadata final {
Expand Down
12 changes: 5 additions & 7 deletions src/OpenSimCreator/Graphics/OverlayDecorationOptionFlags.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <oscar/Shims/Cpp23/utility.hpp>
#include <oscar/Utils/CStringView.hpp>
#include <oscar/Utils/EnumHelpers.hpp>

Expand All @@ -23,23 +24,20 @@ namespace osc
Default = None,
};

constexpr bool operator&(OverlayDecorationOptionFlags a, OverlayDecorationOptionFlags b)
constexpr bool operator&(OverlayDecorationOptionFlags lhs, OverlayDecorationOptionFlags rhs)
{
using Underlying = std::underlying_type_t<OverlayDecorationOptionFlags>;
return (static_cast<Underlying>(a) & static_cast<Underlying>(b)) != 0;
return (osc::to_underlying(lhs) & osc::to_underlying(rhs)) != 0;
}

constexpr void SetOption(OverlayDecorationOptionFlags& flags, OverlayDecorationOptionFlags flag, bool v)
{
using Underlying = std::underlying_type_t<OverlayDecorationOptionFlags>;

if (v)
{
flags = static_cast<OverlayDecorationOptionFlags>(static_cast<Underlying>(flags) | static_cast<Underlying>(flag));
flags = static_cast<OverlayDecorationOptionFlags>(osc::to_underlying(flags) | osc::to_underlying(flag));
}
else
{
flags = static_cast<OverlayDecorationOptionFlags>(static_cast<Underlying>(flags) & ~static_cast<Underlying>(flag));
flags = static_cast<OverlayDecorationOptionFlags>(osc::to_underlying(flags) & ~osc::to_underlying(flag));
}
}

Expand Down
12 changes: 5 additions & 7 deletions src/OpenSimCreator/Outputs/ComponentOutputExtractor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <OpenSimCreator/Outputs/VirtualOutputExtractor.hpp>

#include <oscar/Shims/Cpp23/utility.hpp>
#include <oscar/Utils/ClonePtr.hpp>
#include <oscar/Utils/CStringView.hpp>

Expand All @@ -10,7 +11,6 @@
#include <optional>
#include <span>
#include <string>
#include <type_traits>

namespace OpenSim { class AbstractOutput; }
namespace OpenSim { class Component; }
Expand All @@ -30,16 +30,14 @@ namespace osc
Default = None,
};

constexpr OutputSubfield operator|(OutputSubfield a, OutputSubfield b) noexcept
constexpr OutputSubfield operator|(OutputSubfield lhs, OutputSubfield rhs)
{
using Ut = std::underlying_type_t<OutputSubfield>;
return static_cast<OutputSubfield>(static_cast<Ut>(a) | static_cast<Ut>(b));
return static_cast<OutputSubfield>(osc::to_underlying(lhs) | osc::to_underlying(rhs));
}

constexpr bool operator&(OutputSubfield a, OutputSubfield b) noexcept
constexpr bool operator&(OutputSubfield lhs, OutputSubfield rhs)
{
using Ut = std::underlying_type_t<OutputSubfield>;
return (static_cast<Ut>(a) & static_cast<Ut>(b)) != 0;
return (osc::to_underlying(lhs) & osc::to_underlying(rhs)) != 0;
}

std::optional<CStringView> GetOutputSubfieldLabel(OutputSubfield);
Expand Down
1 change: 1 addition & 0 deletions src/OpenSimCreator/Platform/RecentFiles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace osc
class RecentFiles final {
public:
RecentFiles();
RecentFiles(RecentFiles&&) noexcept = default;
RecentFiles(RecentFiles const&) = delete;
RecentFiles& operator=(RecentFiles const&) = delete;
RecentFiles& operator=(RecentFiles&&) noexcept = delete;
Expand Down
6 changes: 3 additions & 3 deletions src/OpenSimCreator/Registry/ComponentRegistry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ namespace osc
{
}

value_type const* begin() const noexcept
value_type const* begin() const
{
auto const& base = static_cast<ComponentRegistryBase const&>(*this);
return static_cast<value_type const*>(base.begin());
}

value_type const* end() const noexcept
value_type const* end() const
{
auto const& base = static_cast<ComponentRegistryBase const&>(*this);
return static_cast<value_type const*>(base.end());
}

value_type const& operator[](size_t i) const noexcept
value_type const& operator[](size_t i) const
{
auto const& base = static_cast<ComponentRegistryBase const&>(*this);
return static_cast<value_type const&>(base[i]);
Expand Down
12 changes: 6 additions & 6 deletions src/OpenSimCreator/Registry/ComponentRegistryBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@ namespace osc
public:
using value_type = ComponentRegistryEntryBase;

CStringView name() const noexcept
CStringView name() const
{
return m_Name;
}

CStringView description() const noexcept
CStringView description() const
{
return m_Description;
}

value_type const* begin() const noexcept
value_type const* begin() const
{
return m_Entries.data();
}

value_type const* end() const noexcept
value_type const* end() const
{
return m_Entries.data() + m_Entries.size();
}

size_t size() const noexcept
size_t size() const
{
return m_Entries.size();
}

value_type const& operator[](size_t i) const noexcept
value_type const& operator[](size_t i) const
{
return m_Entries[i];
}
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSimCreator/Registry/ComponentRegistryEntry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace osc
{
}

T const& prototype() const noexcept
T const& prototype() const
{
auto const& base = static_cast<ComponentRegistryEntryBase const&>(*this);
return static_cast<T const&>(base.prototype());
Expand Down
6 changes: 3 additions & 3 deletions src/OpenSimCreator/Registry/ComponentRegistryEntryBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ namespace osc
std::shared_ptr<OpenSim::Component const>
);

CStringView name() const noexcept
CStringView name() const
{
return m_Name;
}

CStringView description() const noexcept
CStringView description() const
{
return m_Description;
}

OpenSim::Component const& prototype() const noexcept
OpenSim::Component const& prototype() const
{
return *m_Prototype;
}
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSimCreator/Simulation/SimulationClock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace osc
using duration = std::chrono::duration<rep, period>;
using time_point = std::chrono::time_point<SimulationClock>;

static time_point start() noexcept
static time_point start()
{
return time_point(duration{0.0});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include <oscar/Shims/Cpp23/utility.hpp>

#include <cstdint>
#include <type_traits>

namespace osc
{
Expand All @@ -12,20 +13,18 @@ namespace osc
Default = CapturesMouseInputs,
};

constexpr bool operator&(ModelEditorViewerPanelLayerFlags a, ModelEditorViewerPanelLayerFlags b) noexcept
constexpr bool operator&(ModelEditorViewerPanelLayerFlags lhs, ModelEditorViewerPanelLayerFlags rhs)
{
using T = std::underlying_type_t<ModelEditorViewerPanelLayerFlags>;
return static_cast<T>(a) & static_cast<T>(b);
return osc::to_underlying(lhs) & osc::to_underlying(rhs);
}

constexpr ModelEditorViewerPanelLayerFlags operator|(ModelEditorViewerPanelLayerFlags a, ModelEditorViewerPanelLayerFlags b) noexcept
constexpr ModelEditorViewerPanelLayerFlags operator|(ModelEditorViewerPanelLayerFlags lhs, ModelEditorViewerPanelLayerFlags rhs)
{
using T = std::underlying_type_t<ModelEditorViewerPanelLayerFlags>;
return static_cast<ModelEditorViewerPanelLayerFlags>(static_cast<T>(a) | static_cast<T>(b));
return static_cast<ModelEditorViewerPanelLayerFlags>(osc::to_underlying(lhs) | osc::to_underlying(rhs));
}

constexpr ModelEditorViewerPanelLayerFlags& operator|=(ModelEditorViewerPanelLayerFlags& a, ModelEditorViewerPanelLayerFlags b) noexcept
constexpr ModelEditorViewerPanelLayerFlags& operator|=(ModelEditorViewerPanelLayerFlags& lhs, ModelEditorViewerPanelLayerFlags rhs)
{
return a = a | b;
return lhs = lhs | rhs;
}
}
4 changes: 2 additions & 2 deletions src/OpenSimCreator/UI/Panels/ModelMusclePlotPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ namespace
};

// plot data points are naturally ordered by their independent (X) variable
bool operator<(PlotDataPoint const& a, PlotDataPoint const& b)
bool operator<(PlotDataPoint const& lhs, PlotDataPoint const& rhs)
{
return a.x < b.x;
return lhs.x < rhs.x;
}

// virtual interface to a thing that can receive datapoints from a plotter
Expand Down
20 changes: 10 additions & 10 deletions src/OpenSimCreator/UI/Panels/NavigatorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,47 +43,47 @@ namespace
m_Data[m_Size++] = v;
}

T const* begin() const noexcept {
T const* begin() const {
return m_Data.data();
}

T* begin() noexcept {
T* begin() {
return m_Data.data();
}

T const* end() const noexcept {
T const* end() const {
return m_Data.data() + m_Size;
}

T* end() noexcept {
T* end() {
return m_Data.data() + m_Size;
}

size_t size() const noexcept {
size_t size() const {
return m_Size;
}

ptrdiff_t sizei() const noexcept {
ptrdiff_t sizei() const {
return static_cast<ptrdiff_t>(m_Size);
}

bool empty() const noexcept {
bool empty() const {
return m_Size == 0;
}

void resize(size_t newsize) noexcept {
void resize(size_t newsize) {
m_Size = newsize;
}

void clear() noexcept {
void clear() {
m_Size = 0;
}

T& operator[](size_t idx) {
return m_Data[idx];
}

T const& operator[](size_t i) const noexcept {
T const& operator[](size_t i) const {
return m_Data[i];
}

Expand Down
2 changes: 1 addition & 1 deletion src/OpenSimCreator/UI/Tabs/Experimental/MeshHittestTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class osc::MeshHittestTab::Impl final {

// public API (PIMPL)

osc::CStringView osc::MeshHittestTab::id() noexcept
osc::CStringView osc::MeshHittestTab::id()
{
return "OpenSim/Experimental/MeshHittest";
}
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSimCreator/UI/Tabs/Experimental/MeshHittestTab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace osc
{
class MeshHittestTab final : public Tab {
public:
static CStringView id() noexcept;
static CStringView id();

explicit MeshHittestTab(ParentPtr<TabHost> const&);
MeshHittestTab(MeshHittestTab const&) = delete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class osc::RendererGeometryShaderTab::Impl final {

// public API (PIMPL)

osc::CStringView osc::RendererGeometryShaderTab::id() noexcept
osc::CStringView osc::RendererGeometryShaderTab::id()
{
return "OpenSim/Experimental/GeometryShader";
}
Expand Down
Loading

0 comments on commit a888b1b

Please sign in to comment.