Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualirlanrobson

Posted 07 February 2014 - 12:34 PM

Well I've read probably most of the Component Based Architeture articles but I need to know if I'm getting somewhere.
The Sync Struct is the data needed for the System works. When a new entity is created the method adds the specific components to the
corresponding system. The System (logically) operates one and modifies other (on that specific case).
 

class Actor;
class RigidBody;

struct PhysicsSync {
Actor* actor;
RigidBody* body;
};

class PhysicsSystem {
public:

void Update(float dt)
{
this->CheckCollisions();
for (size_t i = 0; i < sync.size(); ++i) {
sync[i].body->Update(dt); //temp (not updates itself)
sync[i].actor->SetTransform(sync[i].body->BuildTransform()); //temp (not builds itself)
}
} 
void PushSync(Actor* _actor, RigidBody* _body)  
{ 
PhysicsSync target; 
target.actor = _actor; 
target.body = _body; 
sync.push_back(target); 
}

void RemoveSync(Actor* actor, RigidBody* _body)  
{  
//...
}

void ClearSync() { sync.clear(); } 

private: 
void CheckCollisions(); 
std::vector<PhysicsSync> sync; 
};

If I'm correct the trickiest part now It's find some way of implementing a flexible and simple event/messaging system.

 

I think that with this approach one of the things that I can do is...

struct ResponseSync { //collision response
Entity* entity; //assuming that component holds a owner pointer 
RigidBody* 
}

Basically the ResponseSync takes the form of a Event/Message.


#2irlanrobson

Posted 07 February 2014 - 12:30 PM

Well I've read probably most of the Component Based Architeture articles but I need to know if I'm getting somewhere.
The Sync Struct is the data needed for the System works. When a new entity is created the method adds the specific components to the
corresponding system. The System (logically) operates one and modifies other (on that specific case).
 

class Actor;
class RigidBody;

struct PhysicsSync {
Actor* actor;
RigidBody* body;
};

class PhysicsSystem {
public:

void Update(float dt)
{
this->CheckCollisions();
for (size_t i = 0; i < sync.size(); ++i) {
sync[i].body->Update(dt); //temp (not updates itself)
sync[i].actor->SetTransform(sync[i].body->BuildTransform()); //temp (not builds itself)
}
} 
void PushSync(Actor* _actor, RigidBody* _body)  
{ 
PhysicsSync target; 
target.actor = _actor; 
target.body = _body; 
sync.push_back(target); 
}

void RemoveSync(Actor* actor, RigidBody* _body)  
{  
//...
}

void ClearSync() { sync.clear(); } 

private: 
void CheckCollisions(); 
std::vector<PhysicsSync> sync; 
};

If I'm correct the trickiest part now It's find some way of implementing a flexible and simple event/messaging system.

 

I think that with this approach one of the things that I can do is:

struct ResponseSync { //collision response
Entity* entity; //assuming that component holds a owner pointer 
RigidBody* 
}

#1irlanrobson

Posted 07 February 2014 - 12:25 PM

Well I've read probably most of the Component Based Architeture articles but I need to know if I'm getting somewhere.
The Sync Struct is the data needed for the System works. When a new entity is created the method adds the specific components to the
corresponding system. The System (logically) operates one and modifies other (on that specific case).
 

class Actor;
class RigidBody;

struct PhysicsSync {
Actor* actor;
RigidBody* body;
};

class PhysicsSystem {
public:

void Update(float dt)
{
this->CheckCollisions();
for (size_t i = 0; i < sync.size(); ++i) {
sync[i].body->Update(dt); //temp (not updates itself)
sync[i].actor->SetTransform(sync[i].body->BuildTransform()); //temp (not builds itself)
}
} 
void PushSync(Actor* _actor, RigidBody* _body)  
{ 
PhysicsSync target; 
target.actor = _actor; 
target.body = _body; 
sync.push_back(target); 
}

void RemoveSync(Actor* actor, RigidBody* _body)  
{  
//...
}

void ClearSync() { sync.clear(); } 

private: 
void CheckCollisions(); 
std::vector<PhysicsSync> sync; 
};

?

 


PARTNERS