Cogs.Core
PhysicsExtension.cpp
1#include "ExtensionRegistry.h"
2#include "EntityDefinitions.h"
3
4#include "Context.h"
5#include "Services/Services.h"
6
7#include "PhysicsManager.h"
8
9#include "RigidBodySystem.h"
10#include "TriggerSystem.h"
11#include "CollisionSystem.h"
12#include "ConstraintSystem.h"
13#include "GhostSystem.h"
14
15namespace Cogs
16{
17 namespace Core
18 {
20 {
21 PhysicsExtension() { ExtensionRegistry::add(this, COGS_CORE_VERSION_STRING); }
22
23 bool initializeStatic() override final
24 {
25 CollisionComponent::registerType();
26 PlaneCollisionComponent::registerType();
27 SphereCollisionComponent::registerType();
28 BoxCollisionComponent::registerType();
29 CapsuleCollisionComponent::registerType();
30 CylinderCollisionComponent::registerType();
31 EmptyCollisionComponent::registerType();
32 MeshCollisionComponent::registerType();
33
37
38 ConstraintComponent::registerType();
39 FixedConstraintComponent::registerType();
40 HingeConstraintComponent::registerType();
41 SpringConstraintComponent::registerType();
42 GenericConstraintComponent::registerType();
43
44 Reflection::TypeDatabase::createType<SizeT>();
45 CollisionDetail::registerType();
46 Reflection::TypeDatabase::createType<PhysicsManager>();
47 return true;
48 }
49
50 bool initialize(Context * context) override final
51 {
52 ExtensionRegistry::registerExtensionSystem<RigidBodySystem>(context, SystemPriority::PreTransform, 128);
53 ExtensionRegistry::registerExtensionSystem<TriggerSystem>(context, SystemPriority::PreTransform, 128);
54 ExtensionRegistry::registerExtensionSystem<GhostSystem>(context, SystemPriority::PreTransform, 128);
55
56 ExtensionRegistry::registerExtensionSystem<PlaneCollisionSystem>(context, SystemPriority::PreTransform, 128);
57 ExtensionRegistry::registerExtensionSystem<SphereCollisionSystem>(context, SystemPriority::PreTransform, 128);
58 ExtensionRegistry::registerExtensionSystem<BoxCollisionSystem>(context, SystemPriority::PreTransform, 128);
59 ExtensionRegistry::registerExtensionSystem<CapsuleCollisionSystem>(context, SystemPriority::PreTransform, 128);
60 ExtensionRegistry::registerExtensionSystem<CylinderCollisionSystem>(context, SystemPriority::PreTransform, 128);
61 ExtensionRegistry::registerExtensionSystem<EmptyCollisionSystem>(context, SystemPriority::PreTransform, 128);
62 ExtensionRegistry::registerExtensionSystem<MeshCollisionSystem>(context, SystemPriority::PreTransform, 128);
63
64 ExtensionRegistry::registerExtensionSystem<FixedConstraintSystem>(context, SystemPriority::PreTransform, 16);
65 ExtensionRegistry::registerExtensionSystem<HingeConstraintSystem>(context, SystemPriority::PreTransform, 16);
66 ExtensionRegistry::registerExtensionSystem<SpringConstraintSystem>(context, SystemPriority::PreTransform, 16);
67 ExtensionRegistry::registerExtensionSystem<GenericConstraintSystem>(context, SystemPriority::PreTransform, 16);
68
69 manager = context->services->registerService<PhysicsManager>(context);
70
71 return true;
72 }
73
74 const char * getExtensionKey() const final { return "Physics"; }
75
76 PhysicsManager * manager;
77 } physicsExtensionInstance;
78 }
79}
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
static void add(Extension *extension, StringView version)
Adds the given extension to the registry, ensuring the initialization methods are called at appropria...
static void registerType()
Register the type in the type system.
static void registerType()
Register the type in the type system.
static void registerType()
Register the type in the type system.
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
Defines an extension to Cogs.Core and provides methods to override in order to initialize extension c...
bool initializeStatic() override final
Initialize extension statically.
const char * getExtensionKey() const final
Get the extensions unique key, used to check for extension presence and retrieve extension specific d...
bool initialize(Context *context) override final
Initialize extension for the given context.
@ PreTransform
Run before transformations are updated.
Definition: Engine.h:50