forked from ipc-sim/rigid-ipc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimState.hpp
55 lines (39 loc) · 1.46 KB
/
SimState.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include <nlohmann/json.hpp>
#include <memory> // shared_ptr
#include <physics/simulation_problem.hpp>
#include <solvers/optimization_solver.hpp>
namespace ccd {
class SimState {
public:
SimState();
bool load_scene(const std::string& filename);
bool reload_scene();
bool load_simulation(const nlohmann::json& args);
bool init(const nlohmann::json& args);
void simulation_step();
bool solve_collision();
void collision_resolution_step();
void save_simulation(const std::string& filename);
void save_simulation_step();
void run_simulation(const std::string& fout);
const nlohmann::json& get_config() { return args; }
nlohmann::json get_active_config();
// CCD
// ----------------------------------------------
std::shared_ptr<physics::SimulationProblem> problem_ptr;
double m_timestep_size;
bool m_step_had_collision; ///< last step had a collision
bool m_step_has_collision; ///< last step failed to solve collisions
bool m_step_has_intersections; ///< last step resulted in intersections
bool m_solve_collisions; ///< solve collisions automatically on the step
int m_num_simulation_steps; ///< counts simulation steps
int m_max_simulation_steps;
std::string scene_file;
nlohmann::json args;
protected:
bool m_dirty_constraints;
std::vector<Eigen::MatrixXd> vertices_sequence;
std::vector<nlohmann::json> state_sequence;
};
} // namespace ccd