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

# Conflicts:
#	src/Engine/Network/Client.cpp
#	src/Engine/Network/Server.cpp
#	src/Engine/Rendering/PickingPass.cpp
#	src/Game/Systems/PlayerSpawnSystem.cpp
This commit is contained in:
Jocke
2016-02-12 05:16:30 +01:00
58 changed files with 8174 additions and 898 deletions
+2 -2
View File
@@ -642,7 +642,7 @@ boost::optional<EntityAABB> AbsoluteAABBExplosionEffect(EntityWrapper& entity)
return aabb;
}
boost::optional<EntityAABB> EntityFirstHitByRay(const Ray& ray, std::vector<EntityAABB> entitiesPotentiallyHitSorted, float outDistance, glm::vec3& outIntersectPos)
boost::optional<EntityAABB> EntityFirstHitByRay(const Ray& ray, std::vector<EntityAABB> entitiesPotentiallyHitSorted, float& outDistance, glm::vec3& outIntersectPos)
{
for (EntityAABB& entityBox : entitiesPotentiallyHitSorted) {
if (!entityBox.Entity.HasComponent("Model")) {
@@ -667,7 +667,7 @@ boost::optional<EntityAABB> EntityFirstHitByRay(const Ray& ray, std::vector<Enti
return boost::none;
}
boost::optional<EntityAABB> EntityFirstHitByRay(const Ray& ray, Octree<EntityAABB>* octree, float outDistance, glm::vec3& outIntersectPos)
boost::optional<EntityAABB> EntityFirstHitByRay(const Ray& ray, Octree<EntityAABB>* octree, float& outDistance, glm::vec3& outIntersectPos)
{
std::vector<EntityAABB> outObjects;
octree->ObjectsPossiblyHitByRay(ray, outObjects);
@@ -65,7 +65,6 @@ void EntityFilePreprocessor::parseComponentInfo()
// Name
compInfo.Name = XS::ToString(element->getName());
bool brk = compInfo.Name == "HiddenForLocalPlayer";
// Known allocation
compInfo.Meta->Allocation = m_ComponentCounts[compInfo.Name];
// Annotation
+2 -1
View File
@@ -407,8 +407,9 @@ bool Client::OnInputCommand(const Events::InputCommand & e)
bool Client::OnPlayerDamage(const Events::PlayerDamage & e)
{
Packet packet(MessageType::OnPlayerDamage, m_SendPacketID);
packet.WritePrimitive(m_ClientIDToServerID.at(e.Inflictor.ID));
packet.WritePrimitive(m_ClientIDToServerID.at(e.Victim.ID));
packet.WritePrimitive(e.Damage);
packet.WritePrimitive(m_ClientIDToServerID.at(e.Player.ID));
m_Reliable.Send(packet);
return false;
}
+2 -1
View File
@@ -335,8 +335,9 @@ void Server::disconnect(PlayerID playerID)
void Server::parseOnPlayerDamage(Packet & packet)
{
Events::PlayerDamage e;
e.Inflictor = EntityWrapper(m_World, packet.ReadPrimitive<EntityID>());
e.Victim = EntityWrapper(m_World, packet.ReadPrimitive<EntityID>());
e.Damage = packet.ReadPrimitive<double>();
e.Player = EntityWrapper(m_World, packet.ReadPrimitive<EntityID>());
m_EventBroker->Publish(e);
//LOG_DEBUG("Server::parseOnPlayerDamage: Command is %s. Value is %f. PlayerID is %i.", e.DamageAmount, e.PlayerDamagedID, e.TypeOfDamage.c_str());
}
+17 -4
View File
@@ -34,19 +34,32 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
if (!(bool)animationComponent["Loop" + std::to_string(i)]) {
if (nextTime > animation->Duration) {
nextTime = animation->Duration;
Events::AnimationComplete e;
e.Entity = entity;
e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)];
m_EventBroker->Publish(e);
} else if (nextTime < 0) {
Events::AnimationComplete e;
e.Entity = entity;
e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)];
m_EventBroker->Publish(e);
nextTime = 0;
}
(double&)animationComponent["Speed" + std::to_string(i)] = 0.0;
Events::AnimationComplete e;
e.Entity = entity;
e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)];
m_EventBroker->Publish(e);
} else {
if (nextTime > animation->Duration) {
Events::AnimationComplete e;
e.Entity = entity;
e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)];
m_EventBroker->Publish(e);
nextTime -= animation->Duration;
} else if (nextTime < 0) {
Events::AnimationComplete e;
e.Entity = entity;
e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)];
m_EventBroker->Publish(e);
nextTime += animation->Duration;
}
}
+8 -8
View File
@@ -90,7 +90,7 @@ void DrawFinalPass::InitializeShaderPrograms()
GLERROR("Creating sprite program");
m_ForwardPlusSplatMapProgram = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapProgram");
m_ForwardPlusSplatMapProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
m_ForwardPlusSplatMapProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMap.frag.glsl")));
m_ForwardPlusSplatMapProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMapRGB.frag.glsl")));
m_ForwardPlusSplatMapProgram->Compile();
m_ForwardPlusSplatMapProgram->BindFragDataLocation(0, "sceneColor");
m_ForwardPlusSplatMapProgram->BindFragDataLocation(1, "bloomColor");
@@ -100,7 +100,7 @@ void DrawFinalPass::InitializeShaderPrograms()
m_ExplosionEffectSplatMapProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectSplatMapProgram");
m_ExplosionEffectSplatMapProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
m_ExplosionEffectSplatMapProgram->AddShader(std::shared_ptr<Shader>(new GeometryShader("Shaders/ExplosionEffect.geom.glsl")));
m_ExplosionEffectSplatMapProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMap.frag.glsl")));
m_ExplosionEffectSplatMapProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMapRGB.frag.glsl")));
m_ExplosionEffectSplatMapProgram->Compile();
m_ExplosionEffectSplatMapProgram->BindFragDataLocation(0, "sceneColor");
m_ExplosionEffectSplatMapProgram->BindFragDataLocation(1, "bloomColor");
@@ -128,7 +128,7 @@ void DrawFinalPass::InitializeShaderPrograms()
m_ExplosionEffectSplatMapSkinnedProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectSplatMapSkinnedProgram");
m_ExplosionEffectSplatMapSkinnedProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl")));
m_ExplosionEffectSplatMapSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMap.frag.glsl")));
m_ExplosionEffectSplatMapSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMapRGB.frag.glsl")));
m_ExplosionEffectSplatMapSkinnedProgram->Compile();
m_ExplosionEffectSplatMapSkinnedProgram->BindFragDataLocation(0, "sceneColor");
m_ExplosionEffectSplatMapSkinnedProgram->BindFragDataLocation(1, "bloomColor");
@@ -137,7 +137,7 @@ void DrawFinalPass::InitializeShaderPrograms()
m_ForwardPlusSplatMapSkinnedProgram = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapSkinnedProgram");
m_ForwardPlusSplatMapSkinnedProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl")));
m_ForwardPlusSplatMapSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMap.frag.glsl")));
m_ForwardPlusSplatMapSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMapRGB.frag.glsl")));
m_ForwardPlusSplatMapSkinnedProgram->Compile();
m_ForwardPlusSplatMapSkinnedProgram->BindFragDataLocation(0, "sceneColor");
m_ForwardPlusSplatMapSkinnedProgram->BindFragDataLocation(1, "bloomColor");
@@ -950,7 +950,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
//Bind 5 diffuse textures
std::string UniformName = "DiffuseUVRepeat";
for (unsigned int i = 0; i < 5; i++) {
for (unsigned int i = 0; i < 3; i++) {
glActiveTexture(texturePosition);
if (job->DiffuseTexture.size() > i && job->DiffuseTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[i]->Texture->m_Texture);
@@ -964,7 +964,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
//Bind 5 Normal textures
UniformName = "NormalUVRepeat";
for (unsigned int i = 0; i < 5; i++) {
for (unsigned int i = 0; i < 3; i++) {
glActiveTexture(texturePosition);
if (job->NormalTexture.size() > i && job->NormalTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[i]->Texture->m_Texture);
@@ -978,7 +978,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
//Bind 5 Specular textures
UniformName = "SpecularUVRepeat";
for (unsigned int i = 0; i < 5; i++) {
for (unsigned int i = 0; i < 3; i++) {
glActiveTexture(texturePosition);
if (job->SpecularTexture.size() > i && job->SpecularTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[i]->Texture->m_Texture);
@@ -992,7 +992,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
//Bind 5 Incandescence textures
UniformName = "GlowUVRepeat";
for (unsigned int i = 0; i < 5; i++) {
for (unsigned int i = 0; i < 3; i++) {
glActiveTexture(texturePosition);
if (job->IncandescenceTexture.size() > i && job->IncandescenceTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[i]->Texture->m_Texture);
+4 -4
View File
@@ -123,7 +123,7 @@ void PickingPass::Draw(RenderScene& scene)
}
}
for (auto &job : scene.Jobs.TransparentObjects) {
/* for (auto &job : scene.Jobs.TransparentObjects) {
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
int pickColor[2] = { m_ColorCounter[0], m_ColorCounter[1] };
@@ -176,7 +176,7 @@ void PickingPass::Draw(RenderScene& scene)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
}
}
}*/
for (auto &job : scene.Jobs.OpaqueShieldedObjects) {
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
@@ -234,7 +234,7 @@ void PickingPass::Draw(RenderScene& scene)
}
}
for (auto &job : scene.Jobs.TransparentShieldedObjects) {
/* for (auto &job : scene.Jobs.TransparentShieldedObjects) {
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
if (modelJob) {
@@ -298,7 +298,7 @@ void PickingPass::Draw(RenderScene& scene)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
}
}
}*/
m_PickingBuffer.Unbind();
GLERROR("PickingPass Error");
+1 -1
View File
@@ -277,8 +277,8 @@ void RawModelCustom::ReadMaterialTextureProperties(RawModelCustom::TextureProper
throw Resource::FailedLoadingException("Reading Material texture UVTiling failed");
}
memcpy(&texture.UVRepeat[0], fileData + offset, sizeof(glm::vec2));
offset += sizeof(glm::vec2);
}
offset += sizeof(glm::vec2);
}
void RawModelCustom::ReadAnimationFile(std::string filePath)
+24 -16
View File
@@ -47,16 +47,8 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
continue;
}
EntityWrapper entity(world, cSprite.EntityID);
// Only render children of a camera if that camera is currently active
if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) {
continue;
}
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
if (!isEntityVisible(entity)) {
continue;
}
@@ -85,6 +77,23 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
}
}
bool RenderSystem::isEntityVisible(EntityWrapper& entity)
{
// Only render children of a camera if that camera is currently active
if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) {
return false;
}
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
bool outOfBodyExperience = ResourceManager::Load<ConfigFile>("Config.ini")->Get<bool>("Debug.OutOfBodyExperience", false);
if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer)) && !outOfBodyExperience) {
return false;
}
return true;
}
bool RenderSystem::isChildOfACamera(EntityWrapper entity)
{
return entity.FirstParentWithComponent("Camera").Valid();
@@ -112,13 +121,7 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
continue;
}
// Only render children of a camera if that camera is currently active
if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) {
continue;
}
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
if ((entity.HasComponent("HiddenForLocalPlayer") || entity.FirstParentWithComponent("HiddenForLocalPlayer").Valid()) && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
if (!isEntityVisible(entity)) {
continue;
}
@@ -299,6 +302,11 @@ void RenderSystem::fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World*
continue;
}
EntityWrapper entity(world, textComponent.EntityID);
if (!isEntityVisible(entity)) {
continue;
}
Font* font;
try {
font = ResourceManager::Load<Font>(resource);