add smooth moving/looking in viewer#1013
Conversation
erikwijmans
left a comment
There was a problem hiding this comment.
The downside of this approach is that unless the agent is super fast (like it is now) it has the effect of doing the same thing as disabling sliding, which makes human control much rougher (the agent will get stuck on any little thing). One way around this is to instead of taking lots of little steps, still take the big steps but interpolate the agent between the current state and the next state. Magnum does already have quat slerp for us so it should be fairly straight forward.
jturner65
left a comment
There was a problem hiding this comment.
Added a few change requests. Nice first PR :)
| if (keysPressed[KeyEvent::Key::A]) { | ||
| defaultAgent_->act("moveLeft"); | ||
| } | ||
| if (keysPressed[KeyEvent::Key::D]) { | ||
| defaultAgent_->act("moveRight"); | ||
| } | ||
| if (keysPressed[KeyEvent::Key::S]) { | ||
| defaultAgent_->act("moveBackward"); | ||
| } | ||
| if (keysPressed[KeyEvent::Key::W]) { | ||
| defaultAgent_->act("moveForward"); | ||
| } | ||
| if (keysPressed[KeyEvent::Key::X]) { | ||
| defaultAgent_->act("moveDown"); | ||
| } | ||
| if (keysPressed[KeyEvent::Key::Z]) { | ||
| defaultAgent_->act("moveUp"); | ||
| } |
There was a problem hiding this comment.
recAgentLocation() should be called in here, as in the original movement cases. At the end of this section, if any of the movement actions have executed (if the agent's location has changed in any way), recAgentLocation() should be called.
aclegg3
left a comment
There was a problem hiding this comment.
Overall, these changes feel great. They seem to work well with low FPS also. Happy to approve once other concerns are addressed. 👍
| } | ||
| if (keysPressed[KeyEvent::Key::Down]) { | ||
| defaultAgent_->act("lookDown"); | ||
| } |
There was a problem hiding this comment.
These (arrow key turning/looking) feel a bit sluggish compared to the linear movement speed currently.
I'm actually not finding this to be the case in practice. If you reduce the |
I tried this branch just now and I think the sliding feels good. For example, if you walk almost straight at a wall, you slide very slowly, but if you walk almost parallel to the wall (slightly into it), you walk almost full speed. |
|
Yeah, seems like a 10x reduction in speed is enough to not make it feel speedy but not enough to effectively disable sliding. Disregard the comment above :) |
| } | ||
|
|
||
| void Viewer::moveAndLook(int repetitions) { | ||
| if (repetitions <= 2) {repetitions = 1;} // for visual smoothness, for small deviations around 60fps, we default to repetitions=1. |
There was a problem hiding this comment.
We discussed offline and agreed this isn't necessary, so I expect you'll remove this line.
| simulator_->stepWorld(1.0 / 60.0); | ||
| timeSinceLastSimulation = 0.0; | ||
| simulateSingleStep_ = false; | ||
| int repetitionsToPerform = timeSinceLastSimulation * 60.0; |
There was a problem hiding this comment.
Let's rename this "60" magic number: constexpr float agentActionsPerSecond = 60.0f. And lets rename repetitionsToPerform to numAgentActions.
jturner65
left a comment
There was a problem hiding this comment.
Very close. Just one more change, please.
Motivation and Context
Previously, the viewer controls to move and look-around moved the agent in discrete steps, and multiple controls could not be used at the same time. To rationalize this, holding "W" in the viewer had the same effect as doing so in a text editor: the agent moves forward once, pauses, and then stutters forward.
To obtain smoother movement and looking-around, this feature does 3 things:
How Has This Been Tested
Only ad-hoc testing so far. I am concerned that physics may behave slightly differently around pauses (spacebar) and frame-by-frame stepping (.) now, since a minor change was made here. I believe that this was a slight fix, but I don't fully understand the original code, so I could have misinterpreted the situation.
Types of changes
Checklist