Skip to content

Commit 47a58ce

Browse files
committed
Update marker sequence arguments to use std::span (#772)
Summary: Pull Request resolved: #772 Most save functions were using `const std::vector<std::vector<Marker>>&` for marker sequence argument. This diff updates it to `std::span<const std::vector<Marker>>` to be more general and consistent with code style guide. Reviewed By: jeongseok-meta Differential Revision: D86040408
1 parent 92cf282 commit 47a58ce

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

momentum/io/character_io.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void saveCharacter(
145145
const Character& character,
146146
const MatrixXf& motion,
147147
const VectorXf& offsets,
148-
const std::vector<std::vector<Marker>>& markerSequence,
148+
std::span<const std::vector<Marker>> markerSequence,
149149
float fps,
150150
const FileSaveOptions& options) {
151151
// Parse format from file extension
@@ -196,7 +196,7 @@ void saveCharacter(
196196
const filesystem::path& filename,
197197
const Character& character,
198198
std::span<const SkeletonState> skeletonStates,
199-
const std::vector<std::vector<Marker>>& markerSequence,
199+
std::span<const std::vector<Marker>> markerSequence,
200200
float fps,
201201
const FileSaveOptions& options) {
202202
// Parse format from file extension

momentum/io/character_io.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void saveCharacter(
7373
const Character& character,
7474
const MatrixXf& motion = MatrixXf(),
7575
const VectorXf& offsets = VectorXf(),
76-
const std::vector<std::vector<Marker>>& markerSequence = {},
76+
std::span<const std::vector<Marker>> markerSequence = {},
7777
float fps = 120.0f,
7878
const FileSaveOptions& options = FileSaveOptions());
7979

@@ -91,7 +91,7 @@ void saveCharacter(
9191
const filesystem::path& filename,
9292
const Character& character,
9393
std::span<const SkeletonState> skeletonStates = {},
94-
const std::vector<std::vector<Marker>>& markerSequence = {},
94+
std::span<const std::vector<Marker>> markerSequence = {},
9595
float fps = 120.0f,
9696
const FileSaveOptions& options = FileSaveOptions());
9797
} // namespace momentum

momentum/io/fbx/fbx_io.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ void prependNamespaceToAllNodes(::fbxsdk::FbxNode* node, const std::string& name
310310
// Create marker nodes under a "Markers" hierarchy and add animation for their translations
311311
std::vector<::fbxsdk::FbxNode*> createMarkerNodes(
312312
::fbxsdk::FbxScene* scene,
313-
const std::vector<std::vector<Marker>>& markerSequence,
313+
std::span<const std::vector<Marker>> markerSequence,
314314
const double framerate) {
315315
std::vector<::fbxsdk::FbxNode*> markerNodes;
316316

@@ -462,7 +462,7 @@ void saveFbxCommon(
462462
const bool skipActiveJointParamCheck,
463463
const FBXCoordSystemInfo& coordSystemInfo,
464464
bool permissive,
465-
const std::vector<std::vector<Marker>>& markerSequence,
465+
std::span<const std::vector<Marker>> markerSequence,
466466
std::string_view fbxNamespace) {
467467
// ---------------------------------------------
468468
// initialize FBX SDK and prepare for export
@@ -780,7 +780,7 @@ void saveFbx(
780780
const bool saveMesh,
781781
const FBXCoordSystemInfo& coordSystemInfo,
782782
bool permissive,
783-
const std::vector<std::vector<Marker>>& markerSequence,
783+
std::span<const std::vector<Marker>> markerSequence,
784784
std::string_view fbxNamespace) {
785785
CharacterParameters params;
786786
if (identity.size() == character.parameterTransform.numJointParameters()) {
@@ -834,7 +834,7 @@ void saveFbxWithJointParams(
834834
const bool saveMesh,
835835
const FBXCoordSystemInfo& coordSystemInfo,
836836
bool permissive,
837-
const std::vector<std::vector<Marker>>& markerSequence,
837+
std::span<const std::vector<Marker>> markerSequence,
838838
std::string_view fbxNamespace) {
839839
// Call the helper function to save FBX file with joint values.
840840
// Set skipActiveJointParamCheck=true to skip the active joint param check as the joint params are
@@ -860,7 +860,7 @@ void saveFbxWithSkeletonState(
860860
const bool saveMesh,
861861
const FBXCoordSystemInfo& coordSystemInfo,
862862
bool permissive,
863-
const std::vector<std::vector<Marker>>& markerSequence,
863+
std::span<const std::vector<Marker>> markerSequence,
864864
std::string_view fbxNamespace) {
865865
const size_t nFrames = skeletonStates.size();
866866
MatrixXf jointParams(character.parameterTransform.zero().v.size(), nFrames);

momentum/io/fbx/fbx_io.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void saveFbx(
7777
bool saveMesh = false,
7878
const FBXCoordSystemInfo& coordSystemInfo = FBXCoordSystemInfo(),
7979
bool permissive = false,
80-
const std::vector<std::vector<Marker>>& markerSequence = {},
80+
std::span<const std::vector<Marker>> markerSequence = {},
8181
std::string_view fbxNamespace = "");
8282

8383
/// Save a character with animation using joint parameters directly.
@@ -99,7 +99,7 @@ void saveFbxWithJointParams(
9999
bool saveMesh = false,
100100
const FBXCoordSystemInfo& coordSystemInfo = FBXCoordSystemInfo(),
101101
bool permissive = false,
102-
const std::vector<std::vector<Marker>>& markerSequence = {},
102+
std::span<const std::vector<Marker>> markerSequence = {},
103103
std::string_view fbxNamespace = "");
104104

105105
/// Save a character with animation using skeleton states directly.
@@ -121,7 +121,7 @@ void saveFbxWithSkeletonState(
121121
bool saveMesh = false,
122122
const FBXCoordSystemInfo& coordSystemInfo = FBXCoordSystemInfo(),
123123
bool permissive = false,
124-
const std::vector<std::vector<Marker>>& markerSequence = {},
124+
std::span<const std::vector<Marker>> markerSequence = {},
125125
std::string_view fbxNamespace = "");
126126

127127
/// Save a character model (skeleton and mesh) without animation.

momentum/io/fbx/fbx_io_openfbx_only.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void saveFbx(
5454
bool /* saveMesh */,
5555
const FBXCoordSystemInfo& /* coordSystemInfo */,
5656
bool /* permissive */,
57-
const std::vector<std::vector<Marker>>& /* markerSequence */,
57+
std::span<const std::vector<Marker>> /* markerSequence */,
5858
std::string_view /* fbxNamespace */) {
5959
MT_THROW(
6060
"FBX saving is not supported in OpenFBX-only mode. FBX loading is available via OpenFBX, but saving requires the full Autodesk FBX SDK.");
@@ -68,7 +68,7 @@ void saveFbxWithJointParams(
6868
bool /* saveMesh */,
6969
const FBXCoordSystemInfo& /* coordSystemInfo */,
7070
bool /* permissive */,
71-
const std::vector<std::vector<Marker>>& /* markerSequence */,
71+
std::span<const std::vector<Marker>> /* markerSequence */,
7272
std::string_view /* fbxNamespace */) {
7373
MT_THROW(
7474
"FBX saving is not supported in OpenFBX-only mode. FBX loading is available via OpenFBX, but saving requires the full Autodesk FBX SDK.");
@@ -82,7 +82,7 @@ void saveFbxWithSkeletonState(
8282
bool /* saveMesh */,
8383
const FBXCoordSystemInfo& /* coordSystemInfo */,
8484
bool /* permissive */,
85-
const std::vector<std::vector<Marker>>& /* markerSequence */,
85+
std::span<const std::vector<Marker>> /* markerSequence */,
8686
std::string_view /* fbxNamespace */) {
8787
MT_THROW(
8888
"FBX saving is not supported in OpenFBX-only mode. FBX loading is available via OpenFBX, but saving requires the full Autodesk FBX SDK.");

momentum/io/gltf/gltf_io.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ fx::gltf::Document makeCharacterDocument(
983983
const Character& character,
984984
const float fps,
985985
std::span<const SkeletonState> skeletonStates,
986-
const std::vector<std::vector<Marker>>& markerSequence,
986+
std::span<const std::vector<Marker>> markerSequence,
987987
bool embedResource,
988988
const GltfOptions& options) {
989989
GltfBuilder fileBuilder;
@@ -1218,7 +1218,7 @@ fx::gltf::Document makeCharacterDocument(
12181218
const float fps,
12191219
const MotionParameters& motion,
12201220
const IdentityParameters& offsets,
1221-
const std::vector<std::vector<Marker>>& markerSequence,
1221+
std::span<const std::vector<Marker>> markerSequence,
12221222
bool embedResource,
12231223
const GltfOptions& options) {
12241224
GltfBuilder fileBuilder;
@@ -1314,7 +1314,7 @@ void saveGltfCharacter(
13141314
const float fps,
13151315
const MotionParameters& motion,
13161316
const IdentityParameters& offsets,
1317-
const std::vector<std::vector<Marker>>& markerSequence,
1317+
std::span<const std::vector<Marker>> markerSequence,
13181318
const GltfFileFormat fileFormat,
13191319
const GltfOptions& options) {
13201320
constexpr auto kEmbedResources = false; // Don't embed resource for saving glb
@@ -1330,7 +1330,7 @@ void saveGltfCharacter(
13301330
const Character& character,
13311331
const float fps,
13321332
std::span<const SkeletonState> skeletonStates,
1333-
const std::vector<std::vector<Marker>>& markerSequence,
1333+
std::span<const std::vector<Marker>> markerSequence,
13341334
const GltfFileFormat fileFormat,
13351335
const GltfOptions& options) {
13361336
constexpr auto kEmbedResources = false; // Don't embed resource for saving glb
@@ -1346,7 +1346,7 @@ std::vector<std::byte> saveCharacterToBytes(
13461346
float fps,
13471347
const MotionParameters& motion,
13481348
const IdentityParameters& offsets,
1349-
const std::vector<std::vector<Marker>>& markerSequence,
1349+
std::span<const std::vector<Marker>> markerSequence,
13501350
const GltfOptions& options) {
13511351
constexpr auto kEmbedResources = false; // Don't embed resource for saving glb
13521352
fx::gltf::Document model = makeCharacterDocument(

momentum/io/gltf/gltf_io.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fx::gltf::Document makeCharacterDocument(
9696
float fps = 120.0f,
9797
const MotionParameters& motion = {},
9898
const IdentityParameters& offsets = {},
99-
const std::vector<std::vector<Marker>>& markerSequence = {},
99+
std::span<const std::vector<Marker>> markerSequence = {},
100100
bool embedResource = true,
101101
const GltfOptions& options = GltfOptions());
102102

@@ -112,7 +112,7 @@ void saveGltfCharacter(
112112
float fps = 120.0f,
113113
const MotionParameters& motion = {},
114114
const IdentityParameters& offsets = {},
115-
const std::vector<std::vector<Marker>>& markerSequence = {},
115+
std::span<const std::vector<Marker>> markerSequence = {},
116116
GltfFileFormat fileFormat = GltfFileFormat::Extension,
117117
const GltfOptions& options = GltfOptions());
118118

@@ -125,7 +125,7 @@ void saveGltfCharacter(
125125
const Character& character,
126126
float fps,
127127
std::span<const SkeletonState> skeletonStates,
128-
const std::vector<std::vector<Marker>>& markerSequence = {},
128+
std::span<const std::vector<Marker>> markerSequence = {},
129129
GltfFileFormat fileFormat = GltfFileFormat::Extension,
130130
const GltfOptions& options = GltfOptions());
131131

@@ -134,7 +134,7 @@ std::vector<std::byte> saveCharacterToBytes(
134134
float fps = 120.0f,
135135
const MotionParameters& motion = {},
136136
const IdentityParameters& offsets = {},
137-
const std::vector<std::vector<Marker>>& markerSequence = {},
137+
std::span<const std::vector<Marker>> markerSequence = {},
138138
const GltfOptions& options = GltfOptions());
139139

140140
} // namespace momentum

0 commit comments

Comments
 (0)