MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ advance_navigation()

MAYAFLUX_API void MayaFlux::Kinesis::advance_navigation ( NavigationState state)

Advance eye position by held movement flags against elapsed time.

Computes dt from state.last_tick, moves the eye along the current forward and right vectors by the flags that are set, and updates last_tick. Does not produce a ViewTransform. Use build_view_transform() after this when the matrices are needed separately from the eye update.

Parameters
stateNavigation state (eye and last_tick mutated by this call)

Definition at line 78 of file NavigationState.cpp.

79{
80 const auto now = std::chrono::steady_clock::now();
81 const float dt = std::chrono::duration<float>(now - st.last_tick).count();
82 st.last_tick = now;
83
84 const glm::vec3 forward {
85 std::cos(st.pitch) * std::sin(st.yaw),
86 std::sin(st.pitch),
87 std::cos(st.pitch) * std::cos(st.yaw)
88 };
89 const glm::vec3 right = glm::normalize(glm::cross(forward, glm::vec3(0.0F, 1.0F, 0.0F)));
90
91 const float step = st.move_speed * dt;
92
93 glm::vec3 candidate = st.eye;
94
95 if (st.forward_held)
96 candidate += forward * step;
97 if (st.back_held)
98 candidate -= forward * step;
99 if (st.left_held)
100 candidate -= right * step;
101 if (st.right_held)
102 candidate += right * step;
103 if (st.down_held)
104 candidate -= glm::vec3(0.0F, 1.0F, 0.0F) * step;
105 if (st.up_held)
106 candidate += glm::vec3(0.0F, 1.0F, 0.0F) * step;
107
108 st.eye = st.eye_constraint ? st.eye_constraint(candidate) : candidate;
109}

References MayaFlux::Kinesis::NavigationState::back_held, MayaFlux::Kinesis::NavigationState::down_held, MayaFlux::Kinesis::NavigationState::eye, MayaFlux::Kinesis::NavigationState::eye_constraint, MayaFlux::Kinesis::NavigationState::forward_held, MayaFlux::Kinesis::NavigationState::last_tick, MayaFlux::Kinesis::NavigationState::left_held, MayaFlux::Kinesis::NavigationState::move_speed, MayaFlux::Kinesis::NavigationState::pitch, MayaFlux::Kinesis::NavigationState::right_held, MayaFlux::Kinesis::NavigationState::up_held, and MayaFlux::Kinesis::NavigationState::yaw.

Referenced by compute_view_transform(), and MayaFlux::Nexus::Locus::invoke_perception().

+ Here is the caller graph for this function: