Make box on entity commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#ifndef DAYDREAM_CPHYSICS_H
|
||||
#define DAYDREAM_CPHYSICS_H
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Physics: public Component
|
||||
{
|
||||
//idk if anything should be here :)
|
||||
bool Static = true;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CPHYSICS_H
|
||||
@@ -1,39 +1,56 @@
|
||||
#ifndef DAYDREAM_PHYSICSSYSTEM_H
|
||||
#define DAYDREAM_PHYSICSSYSTEM_H
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/CBoxShape.h"
|
||||
#include "Core/Physics/CPhysics.h"
|
||||
#include <Box2D/Box2D.h>
|
||||
#include <Core/CTransform.h>
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems {
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
//KOLLA http://box2d.org/manual.pdf p52 Pre-Solve Event
|
||||
|
||||
class PhysicsSystem : public System {
|
||||
class PhysicsSystem : public System
|
||||
{
|
||||
public:
|
||||
PhysicsSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker) {}
|
||||
|
||||
~PhysicsSystem();
|
||||
|
||||
void Initialize();
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
void Initialize() override;
|
||||
|
||||
// Called once per system every tick
|
||||
void Update(double dt);
|
||||
void Update(double dt) override;
|
||||
// Called once for every entity in the world every tick
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent);
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
// Called when components are committed to an entity
|
||||
void OnEntityCommit(EntityID entity);
|
||||
void OnEntityCommit(EntityID entity) override;
|
||||
|
||||
// Called when an entity is removed
|
||||
void OnEntityRemoved(EntityID entity);
|
||||
void OnEntityRemoved(EntityID entity) override;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
b2Vec2 m_Gravity;
|
||||
b2World* m_PhysicsWorld;
|
||||
float m_TimeStep;
|
||||
int m_VelocityIterations, m_PositionIterations;
|
||||
|
||||
std::unordered_map<EntityID, b2Body*> m_Bodies;
|
||||
|
||||
void CreateBody(EntityID entity);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user