Skip to content

Commit 603c851

Browse files
Remove bool flag for jump_to commands
1 parent 537f127 commit 603c851

19 files changed

Lines changed: 88 additions & 48 deletions

doc/libf3d/06-MIGRATION.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ The callback takes an argument of type `f3d::interactor::interactor_state_t` all
2727
## F3D_PLUGINS_PATH
2828

2929
When running F3D, it was possible to specify the path for loading plugins using the environment variable `F3D_PLUGINS_PATH`. This variable has been removed in favor of the CLI option `--plugins-path` which is more secure.
30+
31+
## Animation jump commands
32+
33+
The `jump_to_frame` and `jump_to_keyframe` commands no longer take a second boolean argument to control whether the jump is relative or absolute. They now always perform an absolute jump and take a single index argument.
34+
35+
To perform a relative jump, use the new dedicated `jump_to_frame_relative` and `jump_to_keyframe_relative` commands, which take a single offset argument.
36+
37+
So `jump_to_frame 10 false` becomes `jump_to_frame 10`, and `jump_to_frame 1 true` becomes `jump_to_frame_relative 1`. Likewise `jump_to_keyframe 4 false` becomes `jump_to_keyframe 4`, and `jump_to_keyframe 1 true` becomes `jump_to_keyframe_relative 1`.

doc/user/07-COMMANDS.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,37 @@ Supports `front`, `top`, `right`, `back`, `bottom`, `left`, `isometric` argument
7575

7676
`toggle_animation_backward`: A specific command to start/stop the animation backward. No argument.
7777

78-
`jump_to_frame`: A specific command to load an animation at a specific frame, takes a number and a boolean as arguments.
78+
`jump_to_frame`: A specific command to load an animation at a specific frame, takes a frame index as argument.
7979
eg:
8080

81-
- `jump_to_frame 1 true` jump to next frame.
82-
- `jump_to_frame -1 true` jump to previous frame.
83-
- `jump_to_frame 0 false` jump to frame 0.
84-
- `jump_to_frame 1 false` jump to frame 1.
85-
- `jump_to_frame 10 false` jump to frame 10.
86-
- `jump_to_frame -1 false` jump to last frame.
87-
- `jump_to_frame -2 false` jump to second last frame.
81+
- `jump_to_frame 0` jump to frame 0.
82+
- `jump_to_frame 1` jump to frame 1.
83+
- `jump_to_frame 10` jump to frame 10.
84+
- `jump_to_frame -1` jump to last frame.
85+
- `jump_to_frame -2` jump to second last frame.
8886

89-
`jump_to_keyframe`: A specific command to load an animation at a specific keyframe, takes a number and a boolean as arguments.
87+
`jump_to_frame_relative`: A specific command to move the animation by a number of frames relative to the current frame, takes a frame offset as argument.
88+
eg:
89+
90+
- `jump_to_frame_relative 1` jump to next frame.
91+
- `jump_to_frame_relative -1` jump to previous frame.
92+
93+
`jump_to_keyframe`: A specific command to load an animation at a specific keyframe, takes a keyframe index as argument.
94+
When jumping to a keyframe, the target keyframe index is adjusted to stay within the total number of available keyframes, avoiding invalid keyframe access.
95+
eg:
96+
97+
- `jump_to_keyframe 0` jump to animation start frame.
98+
- `jump_to_keyframe 1` jump to keyframe 1.
99+
- `jump_to_keyframe 10` jump to keyframe 10.
100+
101+
`jump_to_keyframe_relative`: A specific command to move the animation by a number of keyframes relative to the current keyframe, takes a keyframe offset as argument.
90102
When jumping between keyframes, the target keyframe index is adjusted to stay within the total number of available keyframes, avoiding invalid keyframe access.
91103
eg:
92104

93-
- `jump_to_keyframe 1 true` jump to next keyframe.
94-
- `jump_to_keyframe -1 true` jump to previous keyframe.
95-
- `jump_to_keyframe 0 true` jump to closest keyframe.
96-
- `jump_to_keyframe 0 false` jump to animation start frame.
97-
- `jump_to_keyframe 1 false` jump to keyframe 1.
98-
- `jump_to_keyframe 10 false` jump to keyframe 10.
99-
- `jump_to_keyframe 10 true` jump 10 keyframes ahead.
105+
- `jump_to_keyframe_relative 0` jump to closest keyframe.
106+
- `jump_to_keyframe_relative 1` jump to next keyframe.
107+
- `jump_to_keyframe_relative -1` jump to previous keyframe.
108+
- `jump_to_keyframe_relative 10` jump 10 keyframes ahead.
100109

101110
This command is currently supported only by the following readers :
102111

library/src/interactor_impl.cxx

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,15 +1112,28 @@ interactor& interactor_impl::initCommands()
11121112
},
11131113
command_documentation_t{ "roll_camera value", "roll the camera on its side" });
11141114

1115-
this->addCommand("jump_to_frame",
1115+
this->addCommand(
1116+
"jump_to_frame",
11161117
[&](const std::vector<std::string>& args)
11171118
{
1118-
check_args(args, 2, "jump_to_frame");
1119+
check_args(args, 1, "jump_to_frame");
11191120
const int frame = options::parse<int>(args[0]);
1120-
const bool relative = options::parse<bool>(args[1]);
11211121
this->Internals->AnimationManager->SetDeltaTime(this->Internals->CallbackDeltaTime);
1122-
this->Internals->AnimationManager->JumpToFrame(frame, relative);
1123-
});
1122+
this->Internals->AnimationManager->JumpToFrame(frame, false);
1123+
},
1124+
command_documentation_t{ "jump_to_frame index", "load animation at a specific frame" });
1125+
1126+
this->addCommand(
1127+
"jump_to_frame_relative",
1128+
[&](const std::vector<std::string>& args)
1129+
{
1130+
check_args(args, 1, "jump_to_frame_relative");
1131+
const int frame = options::parse<int>(args[0]);
1132+
this->Internals->AnimationManager->SetDeltaTime(this->Internals->CallbackDeltaTime);
1133+
this->Internals->AnimationManager->JumpToFrame(frame, true);
1134+
},
1135+
command_documentation_t{
1136+
"jump_to_frame_relative offset", "move animation a number of frames forward or backward" });
11241137

11251138
this->addCommand(
11261139
"elevation_camera",
@@ -1307,12 +1320,22 @@ interactor& interactor_impl::initCommands()
13071320
"jump_to_keyframe",
13081321
[&](const std::vector<std::string>& args)
13091322
{
1310-
check_args(args, 2, "jump_to_keyframe");
1311-
int keyframe = options::parse<int>(args[0]);
1312-
bool relative = options::parse<bool>(args[1]);
1313-
this->Internals->AnimationManager->JumpToKeyFrame(keyframe, relative);
1323+
check_args(args, 1, "jump_to_keyframe");
1324+
const int keyframe = options::parse<int>(args[0]);
1325+
this->Internals->AnimationManager->JumpToKeyFrame(keyframe, false);
1326+
},
1327+
command_documentation_t{ "jump_to_keyframe index", "jump to a specific animation keyframe" });
1328+
1329+
this->addCommand(
1330+
"jump_to_keyframe_relative",
1331+
[&](const std::vector<std::string>& args)
1332+
{
1333+
check_args(args, 1, "jump_to_keyframe_relative");
1334+
const int keyframe = options::parse<int>(args[0]);
1335+
this->Internals->AnimationManager->JumpToKeyFrame(keyframe, true);
13141336
},
1315-
command_documentation_t{ "jump_to_keyframe", "Jump to animation's key frame" });
1337+
command_documentation_t{
1338+
"jump_to_keyframe_relative offset", "move a number of keyframes forward or backward" });
13161339

13171340
this->addCommand(
13181341
"toggle_animation", [&](const std::vector<std::string>&) { this->toggleAnimation(); },
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
jump_to_frame 25 true
2-
jump_to_frame 25 true
3-
jump_to_frame 25 true
4-
jump_to_frame 25 true
1+
jump_to_frame_relative 25
2+
jump_to_frame_relative 25
3+
jump_to_frame_relative 25
4+
jump_to_frame_relative 25
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
jump_to_keyframe 4 false
1+
jump_to_keyframe 4
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
jump_to_keyframe 14 false
1+
jump_to_keyframe 14
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
jump_to_keyframe 0 true
1+
jump_to_keyframe_relative 0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
jump_to_frame 0 false
1+
jump_to_frame 0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
jump_to_keyframe 1 false
1+
jump_to_keyframe 1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
jump_to_keyframe 17 false
1+
jump_to_keyframe 17

0 commit comments

Comments
 (0)