-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref issue #11, 9 Renamed ParticleModule->ParticleSystem and particles…
…ystem->particlesystemComponent. Replaced the map<string,system> by vector<pair<particlecomponent,renderer> > in the module/system so that the renderer is bound to the particlecomponent not only by a string. Still have an implementation issue in the new system .cc file and didn<t update the renderer according to those changes yet. Draft of the rendering process in the stub_renderer class.
- Loading branch information
Showing
13 changed files
with
278 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,83 @@ | ||
/************************************************************************* | ||
* Copyright (c) 2016 François Trudel | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* Copyright (c) 2016 François Trudel | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
*************************************************************************/ | ||
#include "particle_system.hh" | ||
|
||
#include "default_dynamic.hh" | ||
#include <vector> | ||
#include <map> | ||
#include <string> | ||
|
||
namespace Gem { | ||
namespace Particle { | ||
System::System(std::size_t a_unMaxParticleCount) | ||
: m_pParticlePool(new Pool(a_unMaxParticleCount)) { | ||
m_vDynamics.push_back(std::make_unique<DefaultDynamic>()); | ||
namespace ParticleSystem { | ||
namespace { | ||
//TODO : Use pointers instead of raw entities!! | ||
|
||
// See if map is better here | ||
using ComponentsList = std::vector<std::pair<ParticleSystemComponent, Renderer> >; | ||
using Components = std::pair<ParticleSystemComponent, Renderer>; | ||
|
||
ComponentsList sub_systems; | ||
|
||
// Some helper accessors for readability | ||
ParticleSystemComponent& GetParticleComponent(Components& rhs) { return rhs.first; } | ||
Renderer& GetRenderingComponent(Components& rhs) { return rhs.second; } | ||
|
||
ParticleSystemComponent& GetParticleComponent(std::size_t rhs) { return sub_systems[rhs].first; } | ||
Renderer& GetRenderingComponent(std::size_t rhs) { return sub_systems[rhs].second; } | ||
} | ||
System::System(System&& other) | ||
: m_pParticlePool(std::move(other.m_pParticlePool)), | ||
m_vDynamics(std::move(other.m_vDynamics)), | ||
m_vSources(std::move(other.m_vSources)) { | ||
|
||
void Init() { | ||
} | ||
void System::Update(double a_dt){ | ||
for (auto& source : m_vSources) { | ||
source->Emit(a_dt, m_pParticlePool); | ||
} | ||
for (auto& dynamic : m_vDynamics) { | ||
dynamic->Update(a_dt, m_pParticlePool); | ||
|
||
void Terminate() { | ||
} | ||
|
||
void Update(double a_dt) { | ||
// TODO: This update could very well be | ||
// executed in parallel for each systems | ||
|
||
// Update each systems individually | ||
for (std::size_t i = 0; i < sub_systems.size(); ++i) { | ||
// TODO: Change this kind of iteration when the change toward pointers will be done | ||
GetParticleComponent(i).Update(a_dt); | ||
} | ||
} | ||
} /* namespace Particle */ | ||
} /* namespace Gem */ | ||
|
||
void GetSystemByName(const std::string& a_szSystemName) { | ||
/* | ||
TODO: | ||
Add accessors in the particlesystemcompoenent for the name | ||
change the parameeters of this function | ||
Do two function GetParticleComponentByName and GetRenderingComponentByName | ||
and adjust the return type with the corresponding funtion name | ||
*/ | ||
} | ||
|
||
void AddComponents(ParticleSystemComponent a_particleComponent, Renderer* a_renderer) { | ||
sub_systems.push_back( | ||
std::make_pair<ParticleSystemComponent,Renderer*>( | ||
a_particleComponent, a_renderer)); | ||
} | ||
|
||
void RemoveSystem(const std::string& a_szSystemName) { | ||
/* | ||
TODO: | ||
This could be necessary, i can see a use case, but this is not priority | ||
RemoveByName maybe | ||
*/ | ||
} | ||
} /* namespace ParticleSystem */ | ||
} /* namespace Particle */ | ||
} /* namespace Gem */ |
Oops, something went wrong.