Engine
net_force_accumulator.h
1 #ifndef NET_FORCE_ACCUMULATOR_H
2 #define NET_FORCE_ACCUMULATOR_H
3 
4 #include <vector>
5 #include <memory>
6 #include <physics_entity.h>
7 #include <constant_force.h>
8 #include <gravity_force.h>
9 #include <linear_drag_force.h>
10 #include <unordered_map>
11 #include <spring.h>
12 #include <spring_force.h>
13 
15 {
16  private:
17  std::vector<ConstantForceGenerator> m_constant_forces;
18  GravityForceGenerator m_gravity_force;
19  bool gravity_on;
20  LinearDragForceGenerator m_drag_force;
21  bool drag_on;
22  SpringForceGenerator m_spring_force;
23  std::unordered_map<GLint, Spring> m_springs; // maps spring id to spring
24  std::unordered_map<GLint,std::vector<GLint>> m_entity_spring_map; // maps physics id to springs it is a part of (by id)
25 
26  public:
27 
32 
37  void AddConstantForce(Vector3Gf a);
38 
43  void EnableGravity(bool enable);
44 
49  void EnableDrag(bool enable);
50 
55  void SetDragCoeff(GLfloat beta);
56 
61  void AddSpring(Spring spring);
62 
69  void ComputeNetForce(
70  const std::vector<std::shared_ptr<PhysicsEntity>> &entity_ptrs,
71  const std::shared_ptr<PhysicsEntity> entity_ptr,
72  Vector3Gf &force) const;
73 
82  const std::vector<std::shared_ptr<PhysicsEntity>> &entity_ptrs,
83  const std::shared_ptr<PhysicsEntity> entity_ptr,
84  Eigen::Matrix<GLfloat,3,3> &dFdx,
85  Eigen::Matrix<GLfloat,3,3> &dFdv) const;
86 
87 
88 };
89 
90 #endif
Computes a simple linear drag force on the provided entity.
Definition: linear_drag_force.h:12
void EnableDrag(bool enable)
Definition: net_force_accumulator.cpp:19
void ComputeNetForceJacobian(const std::vector< std::shared_ptr< PhysicsEntity >> &entity_ptrs, const std::shared_ptr< PhysicsEntity > entity_ptr, Eigen::Matrix< GLfloat, 3, 3 > &dFdx, Eigen::Matrix< GLfloat, 3, 3 > &dFdv) const
Definition: net_force_accumulator.cpp:91
Computes graviational force of attraction between 2 entities.
Definition: gravity_force.h:10
void AddSpring(Spring spring)
Definition: net_force_accumulator.cpp:29
data structure that represents a spring
Definition: spring.h:10
void EnableGravity(bool enable)
Definition: net_force_accumulator.cpp:14
void AddConstantForce(Vector3Gf a)
Definition: net_force_accumulator.cpp:9
void SetDragCoeff(GLfloat beta)
Definition: net_force_accumulator.cpp:24
void ComputeNetForce(const std::vector< std::shared_ptr< PhysicsEntity >> &entity_ptrs, const std::shared_ptr< PhysicsEntity > entity_ptr, Vector3Gf &force) const
Definition: net_force_accumulator.cpp:36
Computes the spring force resulting from 2 entities being connected by a spring.
Definition: spring_force.h:13
Definition: net_force_accumulator.h:14
NetForceAccumulator()
Definition: net_force_accumulator.cpp:4