Added config flag Debug.OutOfBodyExperience that allows you to spawn and view a player from a third person perspective, without the active camera being changed.

This commit is contained in:
2016-02-11 23:45:30 +01:00
parent 44a73ef883
commit b761439c84
5 changed files with 34 additions and 17 deletions
+4
View File
@@ -18,6 +18,7 @@
#include "../Core/EPlayerSpawned.h"
#include "../Core/Octree.h"
#include "../Collision/EntityAABB.h"
#include "../Core/ConfigFile.h"
class RenderSystem : public ImpureSystem
{
@@ -48,6 +49,9 @@ private:
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs);
void fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
bool isEntityVisible(EntityWrapper& entity);
bool isChildOfACamera(EntityWrapper entity);
bool isChildOfCurrentCamera(EntityWrapper entity);
};
+2
View File
@@ -4,6 +4,8 @@ LoadMap=
; if true -> Pool allocation is not used when calling Allocate/Free, just use regular dynamic allocation.
; if false -> Use pool allocation.
DisableMemoryPool=false
EditorEnabled=false
OutOfBodyExperience=false
[Editor]
CameraSpeed=3
+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);
+2 -1
View File
@@ -88,7 +88,8 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
// Set the camera to the correct entity
EntityWrapper cameraEntity = e.Player.FirstChildByName("Camera");
if (cameraEntity.Valid()) {
bool outOfBodyExperience = ResourceManager::Load<ConfigFile>("Config.ini")->Get<bool>("Debug.OutOfBodyExperience", false);
if (cameraEntity.Valid() && !outOfBodyExperience) {
Events::SetCamera e;
e.CameraEntity = cameraEntity;
m_EventBroker->Publish(e);
+2
View File
@@ -22,7 +22,9 @@ MKLINK "%DeployLocation%\Schema\" "resources\Schema" /J
RMDIR /S /Q "%DeployLocation%\Shaders"
MKLINK "%DeployLocation%\Shaders\" "resources\Shaders" /J
:: Configuration files
DEL "%DeployLocation%\DefaultConfig.ini"
MKLINK "%DeployLocation%\DefaultConfig.ini" "resources\DefaultConfig.ini" /H
DEL "%DeployLocation%\DefaultInput.ini"
MKLINK "%DeployLocation%\DefaultInput.ini" "resources\DefaultInput.ini" /H
:: Platform specific binaries