Skip to content

Commit 14076ed

Browse files
committed
feat: improve animation
1 parent 5e56acd commit 14076ed

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/gui/mainwindow.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ void MainWindow::run()
123123
m_last_fps_capture_time += 1.0;
124124
}
125125

126-
process_glfw_window_inputs();
127-
ImGui_ImplGlfwGL3_NewFrame();
128-
129126
// Animation query point.
130127
if (m_animate_query_point)
131128
animate_query_point();
@@ -134,6 +131,9 @@ void MainWindow::run()
134131
if (m_closest_point_query)
135132
find_closest_point();
136133

134+
process_glfw_window_inputs();
135+
ImGui_ImplGlfwGL3_NewFrame();
136+
137137
imgui_draw();
138138
opengl_draw();
139139

@@ -351,12 +351,13 @@ void MainWindow::animate_query_point()
351351
{
352352
// Try to move the query point arround the model with some wiggle.
353353
const glm::vec3 towards_model = m_closest_point_pos - m_query_point_pos;
354-
const glm::vec3 somewhere_else = glm::cross(towards_model, glm::vec3(0.0f, 1.0f, 0.0f));
354+
const glm::vec3 fake_tangent = glm::cross(towards_model, glm::vec3(0.0f, 1.0f, 0.0f));
355355

356-
const float wiggle = std::sin(m_time_since_startup) * 0.5f;
356+
const float wiggle = std::sin(m_time_since_startup * 0.5f) * 0.5f;
357357

358358
m_query_point_pos += towards_model * wiggle * m_frame_delta_time;
359-
m_query_point_pos += somewhere_else * m_frame_delta_time;
359+
m_query_point_pos += fake_tangent * m_frame_delta_time;
360+
m_query_point_pos -= glm::cross(fake_tangent, towards_model) * wiggle * m_frame_delta_time;
360361
}
361362

362363
// GLFW Window callbacks.

0 commit comments

Comments
 (0)