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

# Conflicts:
#	resources/Schema/Types/Entity.xsd
This commit is contained in:
stiffly
2016-01-15 16:25:32 +01:00
46 changed files with 1306 additions and 347 deletions
+43 -11
View File
@@ -90,20 +90,51 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World
continue;
}
Model* model = ResourceManager::Load<::Model>(resource);
if (model == nullptr) {
model = ResourceManager::Load<::Model>("Models/Core/Error.obj");
Model* model;
try {
model = ResourceManager::Load<::Model, true>(resource);
} catch (const Resource::StillLoadingException&) {
//continue;
model = ResourceManager::Load<::Model>("Models/Core/UnitRaptor.obj");
} catch (const std::exception&) {
try {
model = ResourceManager::Load<::Model>("Models/Core/Error.obj");
} catch (const std::exception&) {
continue;
}
}
glm::mat4 modelMatrix = Transform::ModelMatrix(modelComponent.EntityID, world);
for (auto texGroup : model->TextureGroups) {
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(model, m_Camera, modelMatrix, texGroup, modelComponent, world));
for (auto matGroup : model->MaterialGroups()) {
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(model, m_Camera, modelMatrix, matGroup, modelComponent, world));
jobs.push_back(modelJob);
}
}
}
void RenderSystem::fillLight(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
{
auto pointLights = world->GetComponents("PointLight");
if (pointLights == nullptr) {
return;
}
for (auto& pointlightC : *pointLights) {
bool visible = pointlightC["Visible"];
if (!visible) {
continue;
}
auto transformC = world->GetComponent(pointlightC.EntityID, "Transform");
if (&transformC == nullptr) {
return;
}
std::shared_ptr<PointLightJob> pointLightJob = std::shared_ptr<PointLightJob>(new PointLightJob(transformC, pointlightC, m_World));
jobs.push_back(pointLightJob);
}
}
bool RenderSystem::OnInputCommand(const Events::InputCommand& e)
{
if (e.Command == "SwitchCamera" && e.Value > 0) {
@@ -124,11 +155,12 @@ void RenderSystem::Update(World* world, double dt)
//Only supports opaque geometry atm
m_RenderFrame->Clear();
RenderScene rs;
rs.Camera = m_Camera;
rs.Viewport = Rectangle(1280, 720);
fillModels(rs.ForwardJobs, world);
m_RenderFrame->Add(rs);
RenderScene scene;
scene.Camera = m_Camera;
scene.Viewport = Rectangle(1280, 720);
fillModels(scene.ForwardJobs, world);
fillLight(scene.PointLightJobs, world);
m_RenderFrame->Add(scene);
}