RigidBodyCollider2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: RigidBodyCollider2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 2-D rigid body collider class.
6 > Created Time: 2017/06/23
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_RIGID_BODY_COLLIDER2_H
10 #define CUBBYFLOW_RIGID_BODY_COLLIDER2_H
11 
13 
14 namespace CubbyFlow
15 {
22  class RigidBodyCollider2 final : public Collider2
23  {
24  public:
25  class Builder;
26 
29 
31  double angularVelocity = 0.0;
32 
34  explicit RigidBodyCollider2(const Surface2Ptr& surface);
35 
37  RigidBodyCollider2(const Surface2Ptr& surface,
38  const Vector2D& linearVelocity, double angularVelocity);
39 
41  Vector2D VelocityAt(const Vector2D& point) const override;
42 
44  static Builder GetBuilder();
45  };
46 
48  using RigidBodyCollider2Ptr = std::shared_ptr<RigidBodyCollider2>;
49 
54  {
55  public:
57  Builder& WithSurface(const Surface2Ptr& surface);
58 
61 
64 
66  RigidBodyCollider2 Build() const;
67 
70 
71  private:
72  Surface2Ptr m_surface;
73  Vector2D m_linearVelocity{ 0, 0 };
74  double m_angularVelocity = 0.0;
75  };
76 }
77 
78 #endif
Builder & WithLinearVelocity(const Vector2D &linearVelocity)
Returns builder with linear velocity.
std::shared_ptr< RigidBodyCollider2 > RigidBodyCollider2Ptr
Shared pointer for the RigidBodyCollider2 type.
Definition: RigidBodyCollider2.h:48
static Builder GetBuilder()
Returns builder fox RigidBodyCollider2.
Builder & WithSurface(const Surface2Ptr &surface)
Returns builder with surface.
2-D rigid body collider class.
Definition: RigidBodyCollider2.h:22
Vector2D VelocityAt(const Vector2D &point) const override
Returns the velocity of the collider at given point.
Definition: pybind11Utils.h:24
RigidBodyCollider2 Build() const
Builds RigidBodyCollider2.
double angularVelocity
Angular velocity of the rigid body.
Definition: RigidBodyCollider2.h:31
RigidBodyCollider2Ptr MakeShared() const
Builds shared pointer of RigidBodyCollider2 instance.
2-D vector class.
Definition: Vector2.h:26
RigidBodyCollider2(const Surface2Ptr &surface)
Constructs a collider with a surface.
Builder & WithAngularVelocity(double angularVelocity)
Returns builder with angular velocity.
Abstract base class for generic collider object.
Definition: Collider2.h:27
std::shared_ptr< Surface2 > Surface2Ptr
Shared pointer for the Surface2 type.
Definition: Surface2.h:100
Vector2D linearVelocity
Linear velocity of the rigid body.
Definition: RigidBodyCollider2.h:25
Front-end to create RigidBodyCollider2 objects step by step.
Definition: RigidBodyCollider2.h:53