Merge remote-tracking branch 'origin/master' into water

Conflicts:
	include/Core/Engine.h
	include/Physics/PhysicsSystem.h
	include/Sound/SoundSystem.h
	src/game/Physics/PhysicsSystem.cpp
	src/game/Sound/SoundSystem.cpp
PS:min teori i förra commiten var sann
This commit is contained in:
Stiffly
2015-10-07 18:34:36 +02:00
75 changed files with 9561 additions and 2755 deletions
+53 -19
View File
@@ -29,32 +29,26 @@ dd::BaseEventRelay::~BaseEventRelay()
void dd::EventBroker::Unsubscribe(BaseEventRelay &relay) // ?
{
auto contextIt = m_ContextRelays.find(relay.m_ContextTypeName);
if (contextIt == m_ContextRelays.end())
return;
auto eventRelays = contextIt->second;
auto itpair = eventRelays.equal_range(relay.m_EventTypeName);
for (auto it = itpair.first; it != itpair.second; ++it)
{
if (it->second == &relay)
{
relay.m_Broker = nullptr;
eventRelays.erase(it);
break;
}
if (m_IsProcessing) {
m_RelaysToUnsubscribe.push_back(&relay);
} else {
unsubscribeImmediate(relay);
}
}
void dd::EventBroker::Subscribe(BaseEventRelay &relay)
{
relay.m_Broker = this;
m_ContextRelays[relay.m_ContextTypeName].insert(std::make_pair(relay.m_EventTypeName, &relay));
if (m_IsProcessing) {
m_RelaysToSubscribe.push_back(&relay);
} else {
subscribeImmediate(relay);
}
}
int dd::EventBroker::Process(std::string contextTypeName)
{
m_IsProcessing = true;
auto it = m_ContextRelays.find(contextTypeName);
if (it == m_ContextRelays.end())
return 0;
@@ -68,14 +62,29 @@ int dd::EventBroker::Process(std::string contextTypeName)
std::shared_ptr<Event> event = pair.second;
auto itpair = relays.equal_range(eventTypeName);
for (auto it2 = itpair.first; it2 != itpair.second; ++it2)
for (auto it2 = itpair.first; it2 != itpair.second; it2++)
{
auto relay = it2->second;
std::string name = it2->first;
BaseEventRelay* relay = it2->second;
relay->Receive(event);
eventsProcessed++;
}
}
m_IsProcessing = false;
// Process pending subscriptions
for (auto& r : m_RelaysToSubscribe) {
subscribeImmediate(*r);
}
m_RelaysToSubscribe.clear();
// Process pending unsubscriptions
for (auto& r : m_RelaysToUnsubscribe) {
unsubscribeImmediate(*r);
}
m_RelaysToUnsubscribe.clear();
return eventsProcessed;
}
@@ -83,4 +92,29 @@ void dd::EventBroker::Swap()
{
std::swap(m_EventQueueRead, m_EventQueueWrite);
m_EventQueueWrite->clear();
}
void dd::EventBroker::subscribeImmediate(dd::BaseEventRelay& relay)
{
relay.m_Broker = this;
m_ContextRelays[relay.m_ContextTypeName].insert(std::make_pair(relay.m_EventTypeName, &relay));
}
void dd::EventBroker::unsubscribeImmediate(dd::BaseEventRelay& relay)
{
auto contextIt = m_ContextRelays.find(relay.m_ContextTypeName);
if (contextIt == m_ContextRelays.end()) {
return;
}
auto eventRelays = contextIt->second;
auto itpair = eventRelays.equal_range(relay.m_EventTypeName);
for (auto it = itpair.first; it != itpair.second; ++it) {
if (it->second == &relay) {
relay.m_Broker = nullptr;
eventRelays.erase(it);
break;
}
}
}
+3 -3
View File
@@ -263,7 +263,7 @@ void dd::OBJ::ParseMaterial()
ParseColorMap(currentLine, ss, prefix, arg, colorMap);
}
// HACK: Should we really have to specify the full path here?
// HACK: Should we really have to specify the full FilePath here?
colorMap.FileName = (m_MaterialPath.branch_path() / colorMap.FileName).string();
currentMaterial->DiffuseTexture = colorMap;
continue;
@@ -280,7 +280,7 @@ void dd::OBJ::ParseMaterial()
ParseColorMap(currentLine, ss, prefix, arg, colorMap);
}
// HACK: Should we really have to specify the full path here?
// HACK: Should we really have to specify the full FilePath here?
colorMap.FileName = (m_MaterialPath.branch_path() / colorMap.FileName).string();
currentMaterial->SpecularMap = colorMap;
continue;
@@ -297,7 +297,7 @@ void dd::OBJ::ParseMaterial()
ParseBumpMap(currentLine, ss, prefix, arg, bumpMap);
}
// HACK: Should we really have to specify the full path here?
// HACK: Should we really have to specify the full FilePath here?
bumpMap.FileName = (m_MaterialPath.branch_path() / bumpMap.FileName).string();
currentMaterial->NormalMap = bumpMap;
continue;
+1 -1
View File
@@ -163,7 +163,7 @@ void dd::World::Initialize()
}
}
int dd::World::CommitEntity(EntityID entity)
void dd::World::CommitEntity(EntityID entity)
{
for (auto pair : m_Systems)
{