Commit 4b15f084 authored by Nicolas Van der Noot's avatar Nicolas Van der Noot
Browse files

past visu realtime constraints

parent 739a60ef
......@@ -175,7 +175,7 @@ void mbs_realtime_loop(Simu_realtime *realtime, double tsim)
}
#endif
// Java visualization
// 3D visualization
#ifdef VISU_3D
if (realtime->flag_visu)
{
......
......@@ -17,7 +17,8 @@
#include "mbs_project_fct_ptr.h"
// back in visualization period
#define PERIOD_BACK_IN_VISU 0.03 // [s]
#define PERIOD_BACK_IN_VISU 0.03 // [s]
#define INTERRUPT_BACK_IN_VISU 0.25 // [s]
// -- Structures -- //
......
......@@ -125,6 +125,9 @@ Realtime_visu* init_realtime_visu(void *realtime_options, MbsData* mbs_data)
visu->visu_past_flag = 0;
visu->t_visu_past = 0.0;
visu->t_last_past = 0.0;
visu->flag_t_last_past = 0;
visu->cur_tsim = t0;
......
......@@ -52,7 +52,9 @@ typedef struct Realtime_visu
int cur_viewpoint; ///< current viewpoint in simulation
int nb_viewpoint; ///< number of viewpoints
int visu_past_flag; ///< 1 to view what happened before, 0 otherwise
double t_visu_past; ///< requested time for past visualization
int flag_t_last_past; ///< 1 if 't_last_past' initialized, 0 otherwise
double t_visu_past; ///< requested time for past visualization [s]
double t_last_past; ///< last time the 'update_visu_past' was called [s]
int flag_buffer_round; ///< 1 if buffer already filled, 0 otherwise
int last_past_q_flag; ///< 1 if last visu was with past_q, 0 otherwise
......
......@@ -178,6 +178,8 @@ void update_visu_past(Simu_realtime *realtime, int flag_forward)
{
double simu_speed_factor;
double min_tsim, max_tsim;
double delta_t_visu;
double cur_t;
Realtime_visu *visu;
......@@ -189,14 +191,34 @@ void update_visu_past(Simu_realtime *realtime, int flag_forward)
// simulation speed
simu_speed_factor = get_simu_speed_factor(realtime->simu_speed_flag);
// delta time for update
cur_t = 1.0e-6 * t_usec(realtime->init_t_sec, realtime->init_t_usec);
if (!visu->flag_t_last_past)
{
visu->flag_t_last_past = 1;
delta_t_visu = PERIOD_BACK_IN_VISU;
}
else
{
delta_t_visu = cur_t - visu->t_last_past;
if (delta_t_visu <= 0.0 || delta_t_visu >= INTERRUPT_BACK_IN_VISU)
{
delta_t_visu = PERIOD_BACK_IN_VISU;
}
}
visu->t_last_past = cur_t;
// new 't_visu_part'
if (flag_forward)
{
visu->t_visu_past += simu_speed_factor * PERIOD_BACK_IN_VISU;
visu->t_visu_past += simu_speed_factor * delta_t_visu;
}
else
{
visu->t_visu_past -= simu_speed_factor * PERIOD_BACK_IN_VISU;
visu->t_visu_past -= simu_speed_factor * delta_t_visu;
}
// bounds
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment