Cogs.Core
Extensions
Physics
Source
RigidBodySystem.h
1
#pragma once
2
#ifdef _WIN32
3
#pragma warning(push)
4
#pragma warning(disable: 4127)
// conditional expression is constant
5
#pragma warning(disable: 5033)
// 'register' is no longer a supported storage class
6
#endif
7
#include <btBulletDynamicsCommon.h>
8
#ifdef _WIN32
9
#pragma warning(pop)
10
#endif
11
12
#include "EntityDefinition.h"
13
#include "Systems/ComponentSystem.h"
14
15
#include "RigidBodyComponent.h"
16
17
#include "Services/TaskManager.h"
18
19
namespace
Cogs
20
{
21
namespace
Core
22
{
23
class
PhysicsManager;
24
25
struct
SharedRigidBodyData
26
{
27
WeakEntityPtr
entity;
28
bool
contact =
false
;
29
bool
trigger =
false
;
30
};
31
32
struct
RigidBodyData
33
{
34
std::unique_ptr<btRigidBody> rigidBody;
35
btCollisionShape * collisionShape;
36
std::unique_ptr<btMotionState> motionState;
37
std::unique_ptr<SharedRigidBodyData> shared;
38
glm::vec3 scale;
39
glm::vec3 lastPosition;
40
bool
kinematic;
41
};
42
43
class
RigidBodySystem
:
public
ComponentSystemWithDataPool
<RigidBodyComponent, RigidBodyData>
44
{
45
using
base
=
ComponentSystemWithDataPool<RigidBodyComponent, RigidBodyData>
;
46
public
:
47
RigidBodySystem
(
Memory::Allocator
* allocator,
Cogs::SizeType
capacity) :
ComponentSystemWithDataPool
(allocator, capacity) {}
48
49
void
preUpdate
(
Context
*
context
)
final
;
50
void
update
(
Context
*
context
)
final
;
51
void
postUpdate
(
Context
*
context
)
final
;
52
53
void
destroyComponent
(
ComponentHandle
component)
final
;
54
};
55
56
void
updateMassProperties(
RigidBodyData
& data,
float
mass,
const
glm::vec3 & scale);
57
}
58
}
Cogs::Core::ComponentSystemBase::context
Context * context
Pointer to the Context instance the system lives in.
Definition:
ComponentSystem.h:136
Cogs::Core::ComponentSystemBase::postUpdate
void postUpdate()
Perform post update logic in the system.
Definition:
ComponentSystem.h:77
Cogs::Core::ComponentSystemBase::update
void update()
Updates the system state to that of the current frame.
Definition:
ComponentSystem.h:65
Cogs::Core::ComponentSystemBase::preUpdate
void preUpdate()
Run the pre-update method of the system.
Definition:
ComponentSystem.h:57
Cogs::Core::ComponentSystemWithDataPool
Component system with parallel data per component stored in a pool similar to how the components them...
Definition:
ComponentSystem.h:365
Cogs::Core::Context
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition:
Context.h:83
Cogs::Core::RigidBodySystem
Definition:
RigidBodySystem.h:44
Cogs::Core::RigidBodySystem::destroyComponent
void destroyComponent(ComponentHandle component) final
Definition:
RigidBodySystem.cpp:238
Cogs::Memory::Allocator
Base allocator implementation.
Definition:
Allocator.h:30
Cogs::Core::WeakEntityPtr
std::weak_ptr< ComponentModel::Entity > WeakEntityPtr
Weak Smart pointer for Entity access.
Definition:
EntityPtr.h:18
Cogs
Contains all Cogs related functionality.
Definition:
FieldSetter.h:23
Cogs::SizeType
ComponentIndex SizeType
Type used to track the size of pools.
Definition:
Component.h:19
Cogs::ComponentModel::ComponentHandle
Handle to a Component instance.
Definition:
Component.h:67
Cogs::Core::RigidBodyData
Definition:
RigidBodySystem.h:33
Cogs::Core::SharedRigidBodyData
Definition:
RigidBodySystem.h:26
Generated by
1.9.6