Hymn to Beauty
C++ 3D Engine
Trigger.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4#include <map>
5#include <memory>
6
8
9namespace Physics {
10class Shape;
11class TriggerObserver;
12
15class Trigger {
16 friend class ::PhysicsManager;
17
18 private:
19 // Construct a trigger with world transform |transform|.
20 explicit Trigger(const btTransform& transform);
21
22 // Process observers against the trigger volume, passing the world
23 // in which rigid bodies reside.
24 void Process(btCollisionWorld& world);
25
26 // Get access to a particular observer of the trigger to work with
27 // it in a user-defined way. If the observer is not present, one
28 // will be created.
29 void ForObserver(btCollisionObject* body, const std::function<void(TriggerObserver&)>& fun);
30
31 void SetCollisionShape(std::shared_ptr<Shape> shape);
32 void SetPosition(const btVector3& position);
33
34 private:
35 std::unique_ptr<btCollisionObject> trigger = nullptr;
36 std::shared_ptr<Shape> shape = nullptr;
37 std::vector<std::unique_ptr<TriggerObserver>> observers;
38};
39} // namespace Physics
Definition: Trigger.hpp:15
Definition: TriggerObserver.hpp:16
Updates the physics of the world.
Definition: PhysicsManager.hpp:28
Definition: IShapeEditor.hpp:7