Skip to content

Commit

Permalink
Merge branch 'main' into feature_new-modelwarping-config
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Jul 2, 2024
2 parents 44bb680 + aa57d02 commit 3cde6f1
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 57 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Internal: Third-party dependencies were updated to their latest versions, where applicable
- Internal: `AppConfig` was dropped and all uses of it were converted to `AppSettings` (#893)
- Internal: `AppSettingValue` was refactored into a `Variant` (#789)
- Internal: Added runtime-checked pointer classes (`LifetimedPtr`, `LifetimeWatcher`,
`ScopedLifetime`, `SharedLifetimeBlock`, `WatchableLifetime`)
- Internal: Added barebones `TemporaryFile` class (handy for testing IO-related code)


## [0.5.12] - 2024/04/29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void osc::ActionSaveLandmarksToCSV(
lm::LandmarkCSVFlags flags)
{
const std::optional<std::filesystem::path> maybeCSVPath =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv");
promp_user_for_file_save_location_add_extension_if_necessary("csv");
if (!maybeCSVPath)
{
return; // user didn't select a save location
Expand Down Expand Up @@ -281,7 +281,7 @@ void osc::ActionSaveNonParticipatingLandmarksToCSV(
lm::LandmarkCSVFlags flags)
{
const std::optional<std::filesystem::path> maybeCSVPath =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv");
promp_user_for_file_save_location_add_extension_if_necessary("csv");
if (!maybeCSVPath)
{
return; // user didn't select a save location
Expand All @@ -307,7 +307,7 @@ void osc::ActionSaveNonParticipatingLandmarksToCSV(
void osc::ActionSavePairedLandmarksToCSV(const TPSDocument& doc, lm::LandmarkCSVFlags flags)
{
const std::optional<std::filesystem::path> maybeCSVPath =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv");
promp_user_for_file_save_location_add_extension_if_necessary("csv");
if (!maybeCSVPath)
{
return; // user didn't select a save location
Expand Down Expand Up @@ -361,7 +361,7 @@ void osc::ActionSavePairedLandmarksToCSV(const TPSDocument& doc, lm::LandmarkCSV
void osc::ActionTrySaveMeshToObjFile(const Mesh& mesh, ObjWriterFlags flags)
{
const std::optional<std::filesystem::path> maybeSavePath =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("obj");
promp_user_for_file_save_location_add_extension_if_necessary("obj");
if (!maybeSavePath)
{
return; // user didn't select a save location
Expand Down Expand Up @@ -394,7 +394,7 @@ void osc::ActionTrySaveMeshToObjFile(const Mesh& mesh, ObjWriterFlags flags)
void osc::ActionTrySaveMeshToStlFile(const Mesh& mesh)
{
const std::optional<std::filesystem::path> maybeSTLPath =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("stl");
promp_user_for_file_save_location_add_extension_if_necessary("stl");
if (!maybeSTLPath)
{
return; // user didn't select a save location
Expand Down Expand Up @@ -424,7 +424,7 @@ void osc::ActionSaveWarpedNonParticipatingLandmarksToCSV(
TPSResultCache& cache,
lm::LandmarkCSVFlags flags)
{
const auto maybeCSVPath = PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv");
const auto maybeCSVPath = promp_user_for_file_save_location_add_extension_if_necessary("csv");
if (!maybeCSVPath)
{
return; // user didn't select a save location
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSimCreator/Documents/Model/UndoableModelActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace

std::optional<std::filesystem::path> PromptSaveOneFile()
{
return PromptUserForFileSaveLocationAndAddExtensionIfNecessary("osim");
return promp_user_for_file_save_location_add_extension_if_necessary("osim");
}

bool IsAnExampleFile(const std::filesystem::path& path)
Expand Down Expand Up @@ -2293,7 +2293,7 @@ bool osc::ActionImportLandmarks(

bool osc::ActionExportModelGraphToDotviz(const UndoableModelStatePair& model)
{
if (auto p = PromptUserForFileSaveLocationAndAddExtensionIfNecessary("dot")) {
if (auto p = promp_user_for_file_save_location_add_extension_if_necessary("dot")) {
if (std::ofstream of{*p}) {
WriteComponentTopologyGraphAsDotViz(model.getModel(), of);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace osc::mi
bool exportAsModelGraphAsOsimFile()
{
const std::optional<std::filesystem::path> maybeExportPath =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("osim");
promp_user_for_file_save_location_add_extension_if_necessary("osim");

if (!maybeExportPath)
{
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSimCreator/UI/MeshImporter/MeshImporterTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost {
{
// prompt user for a save location
const std::optional<std::filesystem::path> maybeUserSaveLocation =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("obj");
promp_user_for_file_save_location_add_extension_if_necessary("obj");
if (!maybeUserSaveLocation)
{
return; // user didn't select a save location
Expand Down Expand Up @@ -1395,7 +1395,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost {
{
// prompt user for a save location
const std::optional<std::filesystem::path> maybeUserSaveLocation =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("stl");
promp_user_for_file_save_location_add_extension_if_necessary("stl");
if (!maybeUserSaveLocation)
{
return; // user didn't select a save location
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSimCreator/UI/ModelEditor/ExportPointsPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ namespace
bool shouldExportPointsWithAbsPathNames)
{
// prompt user to select a save location
const std::optional<std::filesystem::path> saveLoc = PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv");
const std::optional<std::filesystem::path> saveLoc = promp_user_for_file_save_location_add_extension_if_necessary("csv");
if (!saveLoc) {
return ExportStepReturn::UserCancelled;
}
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSimCreator/UI/ModelEditor/ModelMusclePlotPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ namespace
void ActionPromptUserToSavePlotToCSV(const OpenSim::Coordinate& coord, const PlotParameters& params, const Plot& plot)
{
const std::optional<std::filesystem::path> maybeCSVPath =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv");
promp_user_for_file_save_location_add_extension_if_necessary("csv");

if (maybeCSVPath)
{
Expand Down Expand Up @@ -1437,7 +1437,7 @@ namespace
void ActionPromptUserToSavePlotLinesToCSV(const OpenSim::Coordinate& coord, const PlotParameters& params, const PlotLines& lines)
{
const std::optional<std::filesystem::path> maybeCSVPath =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv");
promp_user_for_file_save_location_add_extension_if_necessary("csv");

if (maybeCSVPath)
{
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSimCreator/UI/PerformanceAnalyzerTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class osc::PerformanceAnalyzerTab::Impl final {
{
// try prompt user for save location
const std::optional<std::filesystem::path> maybeCSVPath =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv");
promp_user_for_file_save_location_add_extension_if_necessary("csv");

if (!maybeCSVPath) {
return; // user probably cancelled out
Expand Down
6 changes: 3 additions & 3 deletions src/OpenSimCreator/UI/Shared/BasicWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace
void TryPromptUserToSaveAsDAE(std::span<const SceneDecoration> scene)
{
std::optional<std::filesystem::path> maybeDAEPath =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("dae");
promp_user_for_file_save_location_add_extension_if_necessary("dae");

if (!maybeDAEPath)
{
Expand Down Expand Up @@ -200,7 +200,7 @@ namespace
{
// prompt user for a save location
const std::optional<std::filesystem::path> maybeUserSaveLocation =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("obj");
promp_user_for_file_save_location_add_extension_if_necessary("obj");
if (!maybeUserSaveLocation)
{
return; // user didn't select a save location
Expand Down Expand Up @@ -248,7 +248,7 @@ namespace
{
// prompt user for a save location
const std::optional<std::filesystem::path> maybeUserSaveLocation =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("stl");
promp_user_for_file_save_location_add_extension_if_necessary("stl");
if (!maybeUserSaveLocation)
{
return; // user didn't select a save location
Expand Down
2 changes: 1 addition & 1 deletion src/OpenSimCreator/UI/Simulation/ISimulatorUIAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace
{
// prompt user for save location
std::optional<std::filesystem::path> path =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv");
promp_user_for_file_save_location_add_extension_if_necessary("csv");
if (not path) {
return std::nullopt; // user probably cancelled out
}
Expand Down
22 changes: 11 additions & 11 deletions src/oscar/Platform/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,26 +182,26 @@ std::vector<std::filesystem::path> osc::prompt_user_to_select_files(
#endif
}

std::optional<std::filesystem::path> osc::PromptUserForFileSaveLocationAndAddExtensionIfNecessary(
std::optional<CStringView> maybeExtension,
std::optional<CStringView> maybeInitialDirectoryToOpen)
std::optional<std::filesystem::path> osc::promp_user_for_file_save_location_add_extension_if_necessary(
std::optional<CStringView> maybe_extension,
std::optional<CStringView> maybe_initial_directory_to_open)
{
#ifdef EMSCRIPTEN
static_cast<void>(maybeExtension);
static_cast<void>(maybeInitialDirectoryToOpen);
static_cast<void>(maybe_extension);
static_cast<void>(maybe_initial_directory_to_open);
return std::nullopt;
#else
if (maybeExtension)
if (maybe_extension)
{
OSC_ASSERT(!contains(*maybeExtension, ',') && "can only provide one extension to this implementation!");
OSC_ASSERT(!contains(*maybe_extension, ',') && "can only provide one extension to this implementation!");
}

auto [path, result] = [&]()
{
nfdchar_t* ptr = nullptr;
const nfdresult_t res = NFD_SaveDialog(
maybeExtension ? maybeExtension->c_str() : nullptr,
maybeInitialDirectoryToOpen ? maybeInitialDirectoryToOpen->c_str() : nullptr,
maybe_extension ? maybe_extension->c_str() : nullptr,
maybe_initial_directory_to_open ? maybe_initial_directory_to_open->c_str() : nullptr,
&ptr
);
return std::pair<std::unique_ptr<nfdchar_t, decltype(::free)*>, nfdresult_t>
Expand All @@ -219,15 +219,15 @@ std::optional<std::filesystem::path> osc::PromptUserForFileSaveLocationAndAddExt
static_assert(std::is_same_v<nfdchar_t, char>);
auto p = std::filesystem::weakly_canonical(path.get());

if (maybeExtension)
if (maybe_extension)
{
// ensure that the user-selected path is tested against '.$EXTENSION' (#771)
//
// the caller only provides the extension without the dot (this is what
// NFD requires) but the user may have manually wrote a string that is
// suffixed with the dot-less version of the extension (e.g. "somecsv")

const std::string fullExtension = std::string{"."} + *maybeExtension;
const std::string fullExtension = std::string{"."} + *maybe_extension;
if (!std::string_view{path.get()}.ends_with(fullExtension)) {
p += fullExtension;
}
Expand Down
2 changes: 1 addition & 1 deletion src/oscar/Platform/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace osc
//
// returns std::nullopt if the user doesn't select a file; otherwise, returns the user-selected save location--including the extension--if
// the user selects a location
std::optional<std::filesystem::path> PromptUserForFileSaveLocationAndAddExtensionIfNecessary(
std::optional<std::filesystem::path> promp_user_for_file_save_location_add_extension_if_necessary(
std::optional<CStringView> maybeExtension = std::nullopt,
std::optional<CStringView> maybeInitialDirectoryToOpen = std::nullopt
);
Expand Down
2 changes: 1 addition & 1 deletion src/oscar/UI/Tabs/ScreenshotTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class osc::ScreenshotTab::Impl final : public StandardTabImpl {
void action_try_save_annotated_screenshot()
{
const std::optional<std::filesystem::path> maybe_image_path =
PromptUserForFileSaveLocationAndAddExtensionIfNecessary("png");
promp_user_for_file_save_location_add_extension_if_necessary("png");

if (maybe_image_path) {
std::ofstream fout{*maybe_image_path, std::ios_base::binary};
Expand Down
8 changes: 4 additions & 4 deletions tests/testoscar/Formats/TestDAE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

using namespace osc;

TEST(write_as_dae, WorksForEmptyScene)
TEST(write_as_dae, works_for_empty_scene)
{
DAEMetadata metadata{TESTOSCAR_APPNAME_STRING, TESTOSCAR_APPNAME_STRING};

Expand All @@ -22,7 +22,7 @@ TEST(write_as_dae, WorksForEmptyScene)
ASSERT_FALSE(ss.str().empty());
}

TEST(write_as_dae, WorksForNonEmptyScene)
TEST(write_as_dae, works_for_nonempty_scene)
{
DAEMetadata metadata{TESTOSCAR_APPNAME_STRING, TESTOSCAR_APPNAME_STRING};

Expand All @@ -34,7 +34,7 @@ TEST(write_as_dae, WorksForNonEmptyScene)
ASSERT_FALSE(ss.str().empty());
}

TEST(write_as_dae, SetAuthorWritesAuthorToOutput)
TEST(write_as_dae, set_author_writes_author_to_output)
{
DAEMetadata metadata{TESTOSCAR_APPNAME_STRING, TESTOSCAR_APPNAME_STRING};
metadata.author = "TestThis";
Expand All @@ -45,7 +45,7 @@ TEST(write_as_dae, SetAuthorWritesAuthorToOutput)
ASSERT_TRUE(contains(ss.str(), metadata.author));
}

TEST(write_as_dae, SetAuthoringToolsWritesAuthoringToolToOutput)
TEST(write_as_dae, set_authoring_tool_writes_authoring_tool_to_output)
{
DAEMetadata metadata{TESTOSCAR_APPNAME_STRING, TESTOSCAR_APPNAME_STRING};
metadata.authoring_tool = "TestThis";
Expand Down
6 changes: 3 additions & 3 deletions tests/testoscar/Formats/TestImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@

using namespace osc;

TEST(Image, LoadTexture2DFromImageRespectsSRGBColorSpace)
TEST(Image, load_texture2D_from_image_respects_sRGB_color_space)
{
const auto path = std::filesystem::path{OSC_TESTING_RESOURCES_DIR} / "awesomeface.png";
const Texture2D loaded_texture = load_texture2D_from_image(ResourceStream{path}, ColorSpace::sRGB);

ASSERT_EQ(loaded_texture.color_space(), ColorSpace::sRGB);
}

TEST(Image, LoadTexture2DFromImageRespectsLinearColorSpace)
TEST(Image, load_texture2D_from_image_respects_linear_color_space)
{
const auto path = std::filesystem::path{OSC_TESTING_RESOURCES_DIR} / "awesomeface.png";
const Texture2D loaded_texture = load_texture2D_from_image(ResourceStream{path}, ColorSpace::Linear);

ASSERT_EQ(loaded_texture.color_space(), ColorSpace::Linear);
}

TEST(Image, CanLoadAndThenWriteImage)
TEST(Image, can_load_and_then_write_an_image)
{
const auto path = std::filesystem::path{OSC_TESTING_RESOURCES_DIR} / "awesomeface.png";
const Texture2D loaded_texture = load_texture2D_from_image(ResourceStream{path}, ColorSpace::Linear);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
using namespace osc;
using namespace osc::detail;

TEST(stride_of, WorksAsExpected)
TEST(stride_of, works_as_expected)
{
static_assert(stride_of(VertexAttributeFormat::Float32x2) == 2*sizeof(float));
}

TEST(num_components_in, WorksAsExpected)
TEST(num_components_in, works_as_expected)
{
static_assert(num_components_in(VertexAttributeFormat::Float32x3) == 3);
}

TEST(component_size, WorksAsExpected)
TEST(component_size, works_as_expected)
{
static_assert(component_size(VertexAttributeFormat::Float32x3) == sizeof(float));
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using namespace osc;
using namespace osc::detail;

TEST(VertexAttributeFormatList, EveryEntryInTheListHasAnAssociatedTraitsObject)
TEST(VertexAttributeFormatList, every_entry_in_the_list_has_an_associated_VertexAttributeFormatTraits_implementation)
{
[[maybe_unused]] auto ary = []<VertexAttributeFormat... Formats>(OptionList<VertexAttributeFormat, Formats...>)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using namespace osc;
using namespace osc::detail;

TEST(default_format, WorksAsExpected)
TEST(default_format, works_as_expected)
{
static_assert(default_format(VertexAttribute::Position) == VertexAttributeFormat::Float32x3);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using namespace osc;
using namespace osc::detail;

TEST(VertexAttributeList, EveryEntryInTheListHasAnAssociatedTraitsObject)
TEST(VertexAttributeList, every_entry_has_an_associted_VertexAttributeTraits_implementation)
{
[[maybe_unused]] constexpr auto ary = []<VertexAttribute... Attributes>(OptionList<VertexAttribute, Attributes...>)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/testoscar/Graphics/Scene/TestSceneCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

using namespace osc;

TEST(SceneCache, GetBVHOnEmptyMeshReturnsEmptyBVH)
TEST(SceneCache, get_bvh_on_empty_mesh_returns_empty_bvh)
{
SceneCache c;
Mesh m;
const BVH& bvh = c.get_bvh(m);
ASSERT_TRUE(bvh.empty());
}

TEST(SceneCache, GetBVHOnNonEmptyMeshReturnsExpectedRootNode)
TEST(SceneCache, get_bvh_on_nonempty_mesh_returns_expected_root_node)
{
const auto pyramid = std::to_array<Vec3>({
{-1.0f, -1.0f, 0.0f}, // base: bottom-left
Expand Down
Loading

0 comments on commit 3cde6f1

Please sign in to comment.