Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 10cd3bae40 | |||
| 8740e8b77a | |||
| bc227c3d61 | |||
| cca237b33f | |||
| 9bba9e493c | |||
| 2c9c374f51 | |||
| 25a7240962 | |||
| 99cdcdf289 | |||
| f1d78ae790 | |||
| bcc42a8cb7 | |||
| 041c409128 |
@@ -119,7 +119,7 @@ public:
|
|||||||
m_ExtraMemory.push_back((char*)malloc(m_Stride));
|
m_ExtraMemory.push_back((char*)malloc(m_Stride));
|
||||||
//We should preferably not enter here to avoid performance issues. Set more numMaxElements in constructor instead.
|
//We should preferably not enter here to avoid performance issues. Set more numMaxElements in constructor instead.
|
||||||
if (!DisableMemoryPool::Value) {
|
if (!DisableMemoryPool::Value) {
|
||||||
LOG_DEBUG("Allocated slots exceed Pool size, extra memory allocated dynamically. Pool size: %u, dynamic size: %u.", m_NumSlots, m_ExtraMemory.size());
|
//LOG_DEBUG("Allocated slots exceed Pool size, extra memory allocated dynamically. Pool size: %u, dynamic size: %u.", m_NumSlots, m_ExtraMemory.size());
|
||||||
}
|
}
|
||||||
return m_ExtraMemory.back();
|
return m_ExtraMemory.back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,6 +192,8 @@ bool FirstPersonInputController<EventContext>::OnLockMouse(const Events::LockMou
|
|||||||
|
|
||||||
template <typename EventContext>
|
template <typename EventContext>
|
||||||
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) {
|
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) {
|
||||||
|
ImGui::Text(std::to_string(m_AssaultDashCoolDownTimer).c_str());
|
||||||
|
|
||||||
m_AssaultDashDoubleTapDeltaTime += dt;
|
m_AssaultDashDoubleTapDeltaTime += dt;
|
||||||
m_AssaultDashCoolDownTimer -= dt;
|
m_AssaultDashCoolDownTimer -= dt;
|
||||||
//cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work)
|
//cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work)
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "Core/ConfigFile.h"
|
#include "Core/ConfigFile.h"
|
||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
#include "Core/EPlayerDamage.h"
|
#include "Core/EPlayerDamage.h"
|
||||||
#include "../Game/Events/EDoubleJump.h"
|
|
||||||
#include "Network/EInterpolate.h"
|
#include "Network/EInterpolate.h"
|
||||||
#include "Network/SnapshotFilter.h"
|
#include "Network/SnapshotFilter.h"
|
||||||
#include "Core/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
@@ -48,9 +47,7 @@ public:
|
|||||||
|
|
||||||
void Connect(std::string address, int port);
|
void Connect(std::string address, int port);
|
||||||
void Update() override;
|
void Update() override;
|
||||||
private:
|
|
||||||
UDPClient m_Unreliable;
|
|
||||||
TCPClient m_Reliable;
|
|
||||||
std::vector<Events::PlayerSpawned> m_PlayerSpawnEvents;
|
std::vector<Events::PlayerSpawned> m_PlayerSpawnEvents;
|
||||||
void parseSpawnEvents();
|
void parseSpawnEvents();
|
||||||
// Save for children
|
// Save for children
|
||||||
@@ -104,9 +101,9 @@ private:
|
|||||||
void parseEntityDeletion(Packet& packet);
|
void parseEntityDeletion(Packet& packet);
|
||||||
void parsePlayerDamage(Packet& packet);
|
void parsePlayerDamage(Packet& packet);
|
||||||
void parseComponentDeletion(Packet& packet);
|
void parseComponentDeletion(Packet& packet);
|
||||||
void parseDoubleJump(Packet& packet);
|
|
||||||
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||||
void parseSnapshot(Packet& packet);
|
void parseSnapshot(Packet& packet);
|
||||||
|
void UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD);
|
||||||
void identifyPacketLoss();
|
void identifyPacketLoss();
|
||||||
void hasServerTimedOut();
|
void hasServerTimedOut();
|
||||||
EntityID createPlayer();
|
EntityID createPlayer();
|
||||||
@@ -130,10 +127,11 @@ private:
|
|||||||
EventRelay<Client, Events::PlayerSpawned> m_EPlayerSpawned;
|
EventRelay<Client, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||||
bool OnPlayerSpawned(const Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(const Events::PlayerSpawned& e);
|
||||||
EventRelay< Client, Events::SearchForServers> m_ESearchForServers;
|
EventRelay< Client, Events::SearchForServers> m_ESearchForServers;
|
||||||
EventRelay<Client, Events::DoubleJump> m_EDoubleJump;
|
|
||||||
bool OnDoubleJump(Events::DoubleJump & e);
|
|
||||||
bool OnSearchForServers(const Events::SearchForServers& e);
|
bool OnSearchForServers(const Events::SearchForServers& e);
|
||||||
|
private:
|
||||||
|
UDPClient m_Unreliable;
|
||||||
UDPClient m_ServerlistRequest;
|
UDPClient m_ServerlistRequest;
|
||||||
|
TCPClient m_Reliable;
|
||||||
std::vector<ServerInfo> m_Serverlist;
|
std::vector<ServerInfo> m_Serverlist;
|
||||||
bool m_SearchingForServers = false;
|
bool m_SearchingForServers = false;
|
||||||
std::clock_t m_StartSearchTime;
|
std::clock_t m_StartSearchTime;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ enum class MessageType
|
|||||||
EntityDeleted,
|
EntityDeleted,
|
||||||
ComponentDeleted,
|
ComponentDeleted,
|
||||||
PlayerTransform,
|
PlayerTransform,
|
||||||
OnDoubleJump,
|
|
||||||
ServerlistRequest,
|
ServerlistRequest,
|
||||||
Invalid
|
Invalid
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Check if we are trying to add more than the package can fit.
|
// Check if we are trying to add more than the package can fit.
|
||||||
if (m_MaxPacketSize < m_Offset + sizeof(T)) {
|
if (m_MaxPacketSize < m_Offset + sizeof(T)) {
|
||||||
LOG_WARNING("Packet AddPrimitive(): You are trying to add more than we have allocated for! New size is %i bytes\n", m_MaxPacketSize*2);
|
//LOG_WARNING("Packet AddPrimitive(): You are trying to add more than we have allocated for! New size is %i bytes\n", m_MaxPacketSize*2);
|
||||||
resizeData();
|
resizeData();
|
||||||
}
|
}
|
||||||
memcpy(m_Data + m_Offset, &val, sizeof(T));
|
memcpy(m_Data + m_Offset, &val, sizeof(T));
|
||||||
@@ -35,7 +35,7 @@ public:
|
|||||||
T ReadPrimitive()
|
T ReadPrimitive()
|
||||||
{
|
{
|
||||||
if (m_Offset < m_ReturnDataOffset + sizeof(T)) {
|
if (m_Offset < m_ReturnDataOffset + sizeof(T)) {
|
||||||
LOG_WARNING("Packet PopFrontPrimitive(): You are trying to remove more than what exists in this packet!");
|
//LOG_WARNING("Packet PopFrontPrimitive(): You are trying to remove more than what exists in this packet!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
T returnValue;
|
T returnValue;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "Network/TCPServer.h"
|
#include "Network/TCPServer.h"
|
||||||
#include "Network/UDPServer.h"
|
#include "Network/UDPServer.h"
|
||||||
|
#include "Network/UDPClient.h" //LOL
|
||||||
#include "Network/MessageType.h"
|
#include "Network/MessageType.h"
|
||||||
#include "Network/PlayerDefinition.h"
|
#include "Network/PlayerDefinition.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
@@ -17,7 +18,6 @@
|
|||||||
#include "Core/EPlayerDamage.h"
|
#include "Core/EPlayerDamage.h"
|
||||||
#include "Network/EPlayerDisconnected.h"
|
#include "Network/EPlayerDisconnected.h"
|
||||||
#include "Core/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
#include "../Game/Events/EDoubleJump.h"
|
|
||||||
#include "Core/EEntityDeleted.h"
|
#include "Core/EEntityDeleted.h"
|
||||||
#include "Core/EComponentDeleted.h"
|
#include "Core/EComponentDeleted.h"
|
||||||
|
|
||||||
@@ -81,9 +81,8 @@ private:
|
|||||||
void parseOnInputCommand(Packet& packet);
|
void parseOnInputCommand(Packet& packet);
|
||||||
void parseClientPing();
|
void parseClientPing();
|
||||||
void parsePing();
|
void parsePing();
|
||||||
bool parseDoubleJump(Packet& packet);
|
void parseUDPConnect(Packet & packet);
|
||||||
void parseUDPConnect(Packet& packet);
|
void parseTCPConnect(Packet & packet);
|
||||||
void parseTCPConnect(Packet& packet);
|
|
||||||
void parseDisconnect();
|
void parseDisconnect();
|
||||||
void parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint);
|
void parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint);
|
||||||
bool shouldSendToClient(EntityWrapper childEntity);
|
bool shouldSendToClient(EntityWrapper childEntity);
|
||||||
|
|||||||
@@ -25,9 +25,10 @@ private:
|
|||||||
std::unique_ptr<boost::asio::ip::tcp::acceptor> acceptor;
|
std::unique_ptr<boost::asio::ip::tcp::acceptor> acceptor;
|
||||||
boost::shared_ptr<boost::asio::ip::tcp::socket> lastReceivedSocket;
|
boost::shared_ptr<boost::asio::ip::tcp::socket> lastReceivedSocket;
|
||||||
|
|
||||||
|
void handle_accept(boost::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
||||||
|
int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
||||||
|
const boost::system::error_code& error);
|
||||||
int readBuffer(PlayerDefinition& playerDefinition);
|
int readBuffer(PlayerDefinition& playerDefinition);
|
||||||
PlayerID getPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
|
||||||
boost::asio::ip::address address, unsigned short port);
|
|
||||||
int GetPort();
|
int GetPort();
|
||||||
std::string GetAddress();
|
std::string GetAddress();
|
||||||
int m_Port = 0;
|
int m_Port = 0;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
class DrawBloomPass
|
class DrawBloomPass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawBloomPass(IRenderer* renderer, ConfigFile* config);
|
DrawBloomPass(IRenderer* renderer /* ,Texture or finalpass*/ );
|
||||||
~DrawBloomPass() { }
|
~DrawBloomPass() { }
|
||||||
void InitializeTextures();
|
void InitializeTextures();
|
||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
@@ -23,34 +23,23 @@ public:
|
|||||||
void FillGaussianBuffer(FrameBuffer* fb);
|
void FillGaussianBuffer(FrameBuffer* fb);
|
||||||
|
|
||||||
void Draw(GLuint texture);
|
void Draw(GLuint texture);
|
||||||
void ChangeQuality(int quality);
|
|
||||||
|
|
||||||
void OnWindowResize();
|
void OnWindowResize();
|
||||||
|
|
||||||
//Getters
|
//Getters
|
||||||
//Return the blurred result of the texture that was sent into draw
|
//Return the blurred result of the texture that was sent into draw
|
||||||
GLuint GaussianTexture() const {
|
GLuint GaussianTexture() const { return m_GaussianTexture_vert; }
|
||||||
if (m_Quality == 0) {
|
|
||||||
return m_BlackTexture->m_Texture;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return m_GaussianTexture_vert;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
|
|
||||||
Texture* m_BlackTexture;
|
Texture* m_WhiteTexture;
|
||||||
Model* m_ScreenQuad;
|
Model* m_ScreenQuad;
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
ConfigFile* m_Config;
|
|
||||||
//const LightCullingPass* m_LightCullingPass
|
//const LightCullingPass* m_LightCullingPass
|
||||||
int m_Iterations = 7;
|
GLuint m_iterations = 9;
|
||||||
int m_Quality = 3;
|
|
||||||
|
|
||||||
GLuint m_GaussianTexture_horiz;
|
GLuint m_GaussianTexture_horiz;
|
||||||
GLuint m_GaussianTexture_vert;
|
GLuint m_GaussianTexture_vert;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "DrawFinalPassState.h"
|
#include "DrawFinalPassState.h"
|
||||||
#include "LightCullingPass.h"
|
#include "LightCullingPass.h"
|
||||||
#include "CubeMapPass.h"
|
#include "CubeMapPass.h"
|
||||||
#include "SSAOPass.h"
|
|
||||||
#include "FrameBuffer.h"
|
#include "FrameBuffer.h"
|
||||||
#include "ShaderProgram.h"
|
#include "ShaderProgram.h"
|
||||||
#include "Util/UnorderedMapVec2.h"
|
#include "Util/UnorderedMapVec2.h"
|
||||||
@@ -15,12 +14,12 @@
|
|||||||
class DrawFinalPass
|
class DrawFinalPass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass);
|
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass);
|
||||||
~DrawFinalPass() { }
|
~DrawFinalPass() { }
|
||||||
void InitializeTextures();
|
void InitializeTextures();
|
||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
void Draw(RenderScene& scene);
|
void Draw(RenderScene& scene, GLuint SSAOTexture);
|
||||||
void ClearBuffer();
|
void ClearBuffer();
|
||||||
void OnWindowResize();
|
void OnWindowResize();
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ private:
|
|||||||
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
|
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
|
||||||
|
|
||||||
void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene);
|
void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene);
|
||||||
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene, GLuint SSAOTexture);
|
||||||
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
@@ -72,7 +71,6 @@ private:
|
|||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
const LightCullingPass* m_LightCullingPass;
|
const LightCullingPass* m_LightCullingPass;
|
||||||
const CubeMapPass* m_CubeMapPass;
|
const CubeMapPass* m_CubeMapPass;
|
||||||
const SSAOPass* m_SSAOPass;
|
|
||||||
|
|
||||||
ShaderProgram* m_ForwardPlusProgram;
|
ShaderProgram* m_ForwardPlusProgram;
|
||||||
ShaderProgram* m_ExplosionEffectProgram;
|
ShaderProgram* m_ExplosionEffectProgram;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "../OpenGL.h"
|
#include "../OpenGL.h"
|
||||||
#include "../GLM.h"
|
#include "../GLM.h"
|
||||||
#include "../Core/Util/Rectangle.h"
|
#include "../Core/Util/Rectangle.h"
|
||||||
#include "../Core/ConfigFile.h"
|
|
||||||
#include "Util/ScreenCoords.h"
|
#include "Util/ScreenCoords.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "RenderQueue.h"
|
#include "RenderQueue.h"
|
||||||
|
|||||||
@@ -32,9 +32,8 @@ class Renderer : public IRenderer
|
|||||||
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
|
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Renderer(EventBroker* eventBroker, ConfigFile* config)
|
Renderer(EventBroker* eventBroker)
|
||||||
: m_EventBroker(eventBroker)
|
: m_EventBroker(eventBroker)
|
||||||
, m_Config(config)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
@@ -48,7 +47,6 @@ private:
|
|||||||
//----------------------Variables----------------------//
|
//----------------------Variables----------------------//
|
||||||
|
|
||||||
static std::unordered_map <GLFWwindow*, Renderer*> m_WindowToRenderer;
|
static std::unordered_map <GLFWwindow*, Renderer*> m_WindowToRenderer;
|
||||||
ConfigFile* m_Config;
|
|
||||||
|
|
||||||
EventBroker* m_EventBroker;
|
EventBroker* m_EventBroker;
|
||||||
TextPass* m_TextPass;
|
TextPass* m_TextPass;
|
||||||
@@ -63,8 +61,12 @@ private:
|
|||||||
int m_DebugTextureToDraw = 0;
|
int m_DebugTextureToDraw = 0;
|
||||||
int m_CubeMapTexture = 0;
|
int m_CubeMapTexture = 0;
|
||||||
bool m_ResizeWindow = false;
|
bool m_ResizeWindow = false;
|
||||||
int m_SSAO_Quality = 0;
|
float m_SSAO_Radius = 1.0f;
|
||||||
int m_GLOW_Quality = 2;
|
float m_SSAO_Bias = 0.05f;
|
||||||
|
float m_SSAO_Contrast = 1.5f;
|
||||||
|
float m_SSAO_IntensityScale = 1.0f;
|
||||||
|
int m_SSAO_NumOfSamples = 24;
|
||||||
|
int m_SSAO_NumOfTurns = 7;
|
||||||
|
|
||||||
PickingPass* m_PickingPass;
|
PickingPass* m_PickingPass;
|
||||||
LightCullingPass* m_LightCullingPass;
|
LightCullingPass* m_LightCullingPass;
|
||||||
|
|||||||
@@ -13,32 +13,18 @@
|
|||||||
class SSAOPass
|
class SSAOPass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SSAOPass(IRenderer* renderer, ConfigFile* config);
|
SSAOPass(IRenderer* rendere);
|
||||||
~SSAOPass() { };
|
~SSAOPass() {
|
||||||
|
delete m_DrawBloomPass;
|
||||||
void ChangeQuality(int quality);
|
};
|
||||||
|
|
||||||
void Draw(GLuint depthBuffer, Camera* camera);
|
void Draw(GLuint depthBuffer, Camera* camera);
|
||||||
void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int numOfTurns, int iterations, int quality);
|
void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns);
|
||||||
void ClearBuffer();
|
void ClearBuffer();
|
||||||
void OnWindowResize();
|
void OnWindowResize();
|
||||||
|
|
||||||
//Return the SSAO of the texture sent to Draw
|
//Return the SSAO of the texture sent to Draw
|
||||||
GLuint SSAOTexture() const {
|
GLuint SSAOTexture() const { return m_DrawBloomPass->GaussianTexture(); }
|
||||||
if (m_Quality == 0) {
|
|
||||||
return m_WhiteTexture->m_Texture;
|
|
||||||
} else {
|
|
||||||
return m_GaussianTexture_vert;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int TextureQuality() const {
|
|
||||||
if (m_Quality == 0) {
|
|
||||||
return 13;
|
|
||||||
} else {
|
|
||||||
return m_TextureQuality;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitializeTexture();
|
void InitializeTexture();
|
||||||
@@ -54,7 +40,6 @@ private:
|
|||||||
Model* m_ScreenQuad;
|
Model* m_ScreenQuad;
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
ConfigFile* m_Config;
|
|
||||||
|
|
||||||
float m_Radius;
|
float m_Radius;
|
||||||
float m_Bias;
|
float m_Bias;
|
||||||
@@ -62,11 +47,6 @@ private:
|
|||||||
float m_IntensityScale;
|
float m_IntensityScale;
|
||||||
int m_NumOfSamples;
|
int m_NumOfSamples;
|
||||||
int m_NumOfTurns;
|
int m_NumOfTurns;
|
||||||
int m_Iterations;
|
|
||||||
int m_TextureQuality;
|
|
||||||
int m_Quality = 0;
|
|
||||||
|
|
||||||
Texture* m_WhiteTexture;
|
|
||||||
|
|
||||||
GLuint m_SSAOTexture;
|
GLuint m_SSAOTexture;
|
||||||
FrameBuffer m_SSAOFramBuffer;
|
FrameBuffer m_SSAOFramBuffer;
|
||||||
@@ -74,16 +54,10 @@ private:
|
|||||||
GLuint m_SSAOViewSpaceZTexture;
|
GLuint m_SSAOViewSpaceZTexture;
|
||||||
FrameBuffer m_SSAOViewSpaceZFramBuffer;
|
FrameBuffer m_SSAOViewSpaceZFramBuffer;
|
||||||
|
|
||||||
GLuint m_GaussianTexture_horiz;
|
|
||||||
GLuint m_GaussianTexture_vert;
|
|
||||||
|
|
||||||
FrameBuffer m_GaussianFrameBuffer_horiz;
|
|
||||||
FrameBuffer m_GaussianFrameBuffer_vert;
|
|
||||||
|
|
||||||
ShaderProgram* m_SSAOProgram;
|
ShaderProgram* m_SSAOProgram;
|
||||||
ShaderProgram* m_SSAOViewSpaceZProgram;
|
ShaderProgram* m_SSAOViewSpaceZProgram;
|
||||||
ShaderProgram* m_GaussianProgram_horiz;
|
|
||||||
ShaderProgram* m_GaussianProgram_vert;
|
DrawBloomPass* m_DrawBloomPass;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -8,7 +8,7 @@ namespace Events
|
|||||||
|
|
||||||
struct DoubleJump : public Event
|
struct DoubleJump : public Event
|
||||||
{
|
{
|
||||||
EntityID entityID;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,14 +20,24 @@ public:
|
|||||||
private:
|
private:
|
||||||
EventRelay<AmmoPickupSystem, Events::TriggerTouch> m_ETriggerTouch;
|
EventRelay<AmmoPickupSystem, Events::TriggerTouch> m_ETriggerTouch;
|
||||||
bool OnTriggerTouch(Events::TriggerTouch& e);
|
bool OnTriggerTouch(Events::TriggerTouch& e);
|
||||||
|
EventRelay<AmmoPickupSystem, Events::TriggerLeave> m_ETriggerLeave;
|
||||||
|
bool OnTriggerLeave(Events::TriggerLeave& e);
|
||||||
|
|
||||||
struct NewAmmoPickup {
|
struct NewPickup {
|
||||||
glm::vec3 Pos;
|
glm::vec3 Pos;
|
||||||
double AmmoGain;
|
double AmmoGain;
|
||||||
double RespawnTimer;
|
double RespawnTimer;
|
||||||
double DecreaseThisRespawnTimer;
|
double DecreaseThisRespawnTimer;
|
||||||
EntityID parentID;
|
EntityID parentID;
|
||||||
|
bool isAmmoPickup;
|
||||||
};
|
};
|
||||||
std::vector<NewAmmoPickup> m_ETriggerTouchVector;
|
struct EntityAtMaxValuePickupStruct {
|
||||||
|
EntityWrapper player;
|
||||||
|
EntityWrapper pickup;
|
||||||
|
};
|
||||||
|
std::vector<NewPickup> m_ETriggerTouchVector;
|
||||||
|
std::vector<EntityAtMaxValuePickupStruct> m_PickupAtMaximum;
|
||||||
|
|
||||||
|
void DoPickup(EntityWrapper &player, EntityWrapper &trigger);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool m_NetworkEnabled;
|
bool m_NetworkEnabled;
|
||||||
|
|
||||||
// methods which will take care of specific events
|
// methods which will take care of specific events
|
||||||
EventRelay<HealthSystem, Events::PlayerDamage> m_EPlayerDamage;
|
EventRelay<HealthSystem, Events::PlayerDamage> m_EPlayerDamage;
|
||||||
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e);
|
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e);
|
||||||
EventRelay<HealthSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
|
EventRelay<HealthSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
|
||||||
@@ -37,6 +37,16 @@ private:
|
|||||||
|
|
||||||
//vector which will keep track of health changes
|
//vector which will keep track of health changes
|
||||||
std::vector<std::tuple<EntityID, double>> m_DeltaHealthVector;
|
std::vector<std::tuple<EntityID, double>> m_DeltaHealthVector;
|
||||||
|
struct DeadPlayers {
|
||||||
|
EntityWrapper playerEntity;
|
||||||
|
double timeSinceDeath;
|
||||||
|
DeadPlayers(EntityWrapper entity) : playerEntity(entity) {
|
||||||
|
timeSinceDeath = 0.0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::vector<DeadPlayers> m_DeadPlayers;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -34,13 +34,9 @@ private:
|
|||||||
glm::vec3 m_LastPosition = glm::vec3();
|
glm::vec3 m_LastPosition = glm::vec3();
|
||||||
// The logic for making the sound play when player is moving
|
// The logic for making the sound play when player is moving
|
||||||
void playerStep(double dt);
|
void playerStep(double dt);
|
||||||
// Spawn a hexagon at origin of an Entity
|
|
||||||
void spawnHexagon(EntityWrapper target);
|
|
||||||
|
|
||||||
EventRelay<PlayerMovementSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
EventRelay<PlayerMovementSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||||
EventRelay<PlayerMovementSystem, Events::DoubleJump> m_EDoubleJump;
|
|
||||||
bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e);
|
|
||||||
|
|
||||||
void updateMovementControllers(double dt);
|
void updateMovementControllers(double dt);
|
||||||
void updateVelocity(EntityWrapper player, double dt);
|
void updateVelocity(EntityWrapper player, double dt);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ private:
|
|||||||
{
|
{
|
||||||
int PlayerID;
|
int PlayerID;
|
||||||
ComponentInfo::EnumType Team;
|
ComponentInfo::EnumType Team;
|
||||||
|
double timeSinceDeath;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool m_NetworkEnabled = false;
|
bool m_NetworkEnabled = false;
|
||||||
@@ -40,4 +41,7 @@ private:
|
|||||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||||
EventRelay<PlayerSpawnSystem, Events::PlayerDeath> m_OnPlayerDeath;
|
EventRelay<PlayerSpawnSystem, Events::PlayerDeath> m_OnPlayerDeath;
|
||||||
bool OnPlayerDeath(Events::PlayerDeath& e);
|
bool OnPlayerDeath(Events::PlayerDeath& e);
|
||||||
|
|
||||||
|
std::vector<SpawnRequest> m_LatePlayersVector;
|
||||||
|
void CheckForLatePlayers(double dt);
|
||||||
};
|
};
|
||||||
@@ -37,36 +37,3 @@ ResourceLoading=true
|
|||||||
BGMVolume=1.0
|
BGMVolume=1.0
|
||||||
SFXVolume=1.0
|
SFXVolume=1.0
|
||||||
Announcer=female
|
Announcer=female
|
||||||
|
|
||||||
[SSAO]
|
|
||||||
Quality=0
|
|
||||||
|
|
||||||
[SSAO1]
|
|
||||||
Radius=1.0
|
|
||||||
Bias=0.02
|
|
||||||
Contrast=1.5
|
|
||||||
Intensity=1.0
|
|
||||||
NumSamples=8
|
|
||||||
NumTurns=3
|
|
||||||
NumIterations=5
|
|
||||||
TextureQuality=2
|
|
||||||
|
|
||||||
[SSAO2]
|
|
||||||
Radius=1.0
|
|
||||||
Bias=0.02
|
|
||||||
Contrast=1.5
|
|
||||||
Intensity=1.0
|
|
||||||
NumSamples=16
|
|
||||||
NumTurns=13
|
|
||||||
NumIterations=9
|
|
||||||
TextureQuality=1
|
|
||||||
|
|
||||||
[SSAO3]
|
|
||||||
Radius=1.0
|
|
||||||
Bias=0.02
|
|
||||||
Contrast=1.5
|
|
||||||
Intensity=1.0
|
|
||||||
NumSamples=24
|
|
||||||
NumTurns=17
|
|
||||||
NumIterations=13
|
|
||||||
TextureQuality=0
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -215,7 +215,8 @@
|
|||||||
</c:CapturePoint>
|
</c:CapturePoint>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models\Core\UnitCube.mesh</Resource>
|
<Resource>Models\Core\UnitCube.mesh</Resource>
|
||||||
<Color A="1" B="1" G="0.200000003" R="0"/>
|
<Color A="0.300000012" B="1" G="0" R="0"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Team>
|
<c:Team>
|
||||||
<Team>
|
<Team>
|
||||||
@@ -241,7 +242,8 @@
|
|||||||
</c:CapturePoint>
|
</c:CapturePoint>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models\Core\UnitCube.mesh</Resource>
|
<Resource>Models\Core\UnitCube.mesh</Resource>
|
||||||
<Color A="1" B="1" G="1" R="0"/>
|
<Color A="0.300000012" B="0" G="0" R="1"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Team>
|
<c:Team>
|
||||||
<Team>
|
<Team>
|
||||||
@@ -256,6 +258,25 @@
|
|||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
</Entity>
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AmmoPickup/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/PickUps/AmmoPickUp.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:RaptorCopter>
|
||||||
|
<Speed>8</Speed>
|
||||||
|
<Axis X="0" Y="0.100000001" Z="0"/>
|
||||||
|
</c:RaptorCopter>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1.86800003" Z="0"/>
|
||||||
|
<Scale X="0.600000024" Y="0.600000024" Z="0.600000024"/>
|
||||||
|
<Orientation X="0" Y="18741" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Trigger/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
|
|
||||||
</Entity>
|
</Entity>
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ uniform vec4 AmbientColor;
|
|||||||
uniform float FillPercentage;
|
uniform float FillPercentage;
|
||||||
uniform float GlowIntensity = 10;
|
uniform float GlowIntensity = 10;
|
||||||
uniform vec3 CameraPosition;
|
uniform vec3 CameraPosition;
|
||||||
uniform int SSAOQuality;
|
|
||||||
|
|
||||||
uniform vec2 DiffuseUVRepeat;
|
uniform vec2 DiffuseUVRepeat;
|
||||||
uniform vec2 NormalUVRepeat;
|
uniform vec2 NormalUVRepeat;
|
||||||
@@ -126,7 +125,7 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r;
|
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r;
|
||||||
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
|
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
|
||||||
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
|
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
|
||||||
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
|
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ uniform vec4 DiffuseColor;
|
|||||||
uniform vec4 FillColor;
|
uniform vec4 FillColor;
|
||||||
uniform vec4 Color;
|
uniform vec4 Color;
|
||||||
uniform vec4 AmbientColor;
|
uniform vec4 AmbientColor;
|
||||||
uniform int SSAOQuality;
|
|
||||||
|
|
||||||
//Get bineded at the same time as the textures
|
//Get bineded at the same time as the textures
|
||||||
uniform vec2 DiffuseUVRepeat1;
|
uniform vec2 DiffuseUVRepeat1;
|
||||||
@@ -178,7 +177,7 @@ vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r;
|
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r;
|
||||||
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
|
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
|
||||||
|
|
||||||
vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate);
|
vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate);
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
//Number of samples per pixel
|
//Number of samples per pixel
|
||||||
uniform int uNumOfSamples;
|
uniform int uNumOfSamples;
|
||||||
//#define uNumOfSamples (11)
|
//#define NUM_SAMPLES (11)
|
||||||
|
|
||||||
//Number of turns around the cirle
|
//Number of turns around the cirle
|
||||||
uniform int uNumOfTurns;
|
uniform int uNumOfTurns;
|
||||||
//#define uNumOfTurns (7)
|
//#define NUM_TURNS (7)
|
||||||
|
|
||||||
layout (binding = 0) uniform sampler2D ViewSpaceZ;
|
layout (binding = 0) uniform sampler2D ViewSpaceZ;
|
||||||
|
|
||||||
@@ -16,16 +16,15 @@ uniform float uProjScale;
|
|||||||
//#define ProjScale 500
|
//#define ProjScale 500
|
||||||
|
|
||||||
uniform float uRadius;
|
uniform float uRadius;
|
||||||
//#define uRadius 1.0f
|
//#define Radius 1.0f
|
||||||
|
|
||||||
uniform float uBias;
|
uniform float uBias;
|
||||||
//#define uBias 0.05f
|
//#define Bias 0.012f
|
||||||
|
|
||||||
uniform float uContrast;
|
uniform float uContrast;
|
||||||
//#define uContrast 1.5f
|
//#define IntensityDivR6 1
|
||||||
|
|
||||||
uniform float uIntensityScale;
|
uniform float uIntensityScale;
|
||||||
//#define uIntensityScale 1.0f
|
|
||||||
|
|
||||||
out float AO;
|
out float AO;
|
||||||
|
|
||||||
@@ -89,7 +88,13 @@ void main() {
|
|||||||
|
|
||||||
vec3 origin = getVSPosition(originScreenCoord);
|
vec3 origin = getVSPosition(originScreenCoord);
|
||||||
|
|
||||||
float radius = min(origin.z, uRadius);
|
float radius;
|
||||||
|
if(origin.z < uRadius){
|
||||||
|
radius = origin.z;
|
||||||
|
} else {
|
||||||
|
radius = uRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
vec3 originNormal = getVSFaceNormal(origin);
|
vec3 originNormal = getVSFaceNormal(origin);
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,7 @@
|
|||||||
|
|
||||||
layout (location = 0) in vec3 Position;
|
layout (location = 0) in vec3 Position;
|
||||||
|
|
||||||
out VertexData{
|
|
||||||
vec2 TextureCoordinate;
|
|
||||||
}Output;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = vec4(Position, 1.0);
|
gl_Position = vec4(Position, 1.0);
|
||||||
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
|
|
||||||
}
|
}
|
||||||
@@ -3,15 +3,11 @@
|
|||||||
layout (binding = 0) uniform sampler2D DepthBuffer;
|
layout (binding = 0) uniform sampler2D DepthBuffer;
|
||||||
uniform vec3 ClipInfo;
|
uniform vec3 ClipInfo;
|
||||||
|
|
||||||
in VertexData{
|
|
||||||
vec2 TextureCoordinate;
|
|
||||||
}Input;
|
|
||||||
|
|
||||||
out float depthLinear;
|
out float depthLinear;
|
||||||
//Just for Debug, should be depthLinear
|
//Just for Debug, should be depthLinear
|
||||||
//out vec4 fragmentColor;
|
//out vec4 fragmentColor;
|
||||||
void main() {
|
void main() {
|
||||||
float depthSample = texture2D(DepthBuffer, Input.TextureCoordinate).r;
|
float depthSample = texelFetch(DepthBuffer, ivec2(gl_FragCoord.xy), 0).r;
|
||||||
depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]);
|
depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]);
|
||||||
//float depthLinear = (NearClip) / ( -depthSample + 1.0f);
|
//float depthLinear = (NearClip) / ( -depthSample + 1.0f);
|
||||||
//fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f);
|
//fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f);
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ void Client::Connect(std::string address, int port)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Client::OnInputCommand);
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Client::OnInputCommand);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &Client::OnDoubleJump);
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ESearchForServers, &Client::OnSearchForServers);
|
EVENT_SUBSCRIBE_MEMBER(m_ESearchForServers, &Client::OnSearchForServers);
|
||||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
m_Address = address;
|
m_Address = address;
|
||||||
@@ -141,9 +140,6 @@ void Client::parseMessageType(Packet& packet)
|
|||||||
case MessageType::OnPlayerDamage:
|
case MessageType::OnPlayerDamage:
|
||||||
parsePlayerDamage(packet);
|
parsePlayerDamage(packet);
|
||||||
break;
|
break;
|
||||||
case MessageType::OnDoubleJump:
|
|
||||||
parseDoubleJump(packet);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -187,7 +183,7 @@ void Client::parsePing()
|
|||||||
m_IsConnected = true;
|
m_IsConnected = true;
|
||||||
// Time since last ping was received
|
// Time since last ping was received
|
||||||
m_DurationOfPingTime = 1000 * (std::clock() - m_StartPingTime) / static_cast<double>(CLOCKS_PER_SEC);
|
m_DurationOfPingTime = 1000 * (std::clock() - m_StartPingTime) / static_cast<double>(CLOCKS_PER_SEC);
|
||||||
LOG_INFO("%i: response time with ctime(ms): %f", m_PacketID, m_DurationOfPingTime);
|
//LOG_INFO("%i: response time with ctime(ms): %f", m_PacketID, m_DurationOfPingTime);
|
||||||
m_StartPingTime = std::clock();
|
m_StartPingTime = std::clock();
|
||||||
|
|
||||||
Packet packet(MessageType::Ping, m_SendPacketID);
|
Packet packet(MessageType::Ping, m_SendPacketID);
|
||||||
@@ -276,20 +272,6 @@ void Client::parseComponentDeletion(Packet & packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::parseDoubleJump(Packet & packet)
|
|
||||||
{
|
|
||||||
EntityID serverID = packet.ReadPrimitive<EntityID>();
|
|
||||||
if (!serverClientMapsHasEntity(serverID)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Events::DoubleJump e;
|
|
||||||
e.entityID = m_ServerIDToClientID.at(serverID);
|
|
||||||
// If player is local player do not publish to prevent infinite feedback loop
|
|
||||||
if (e.entityID != m_LocalPlayer.ID) {
|
|
||||||
m_EventBroker->Publish(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
|
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
|
||||||
{
|
{
|
||||||
for (auto field : componentInfo.FieldsInOrder) {
|
for (auto field : componentInfo.FieldsInOrder) {
|
||||||
@@ -366,7 +348,9 @@ void Client::parseSnapshot(Packet& packet)
|
|||||||
EntityWrapper localEntity(m_World, localEntityID);
|
EntityWrapper localEntity(m_World, localEntityID);
|
||||||
// Update entity
|
// Update entity
|
||||||
if (m_World->HasComponent(localEntityID, componentType)) {
|
if (m_World->HasComponent(localEntityID, componentType)) {
|
||||||
// TODO Fix memory leak here
|
if (localEntity.Name() == "CapturePointHUD") {
|
||||||
|
UpdateLocalCapturePointHUD(localEntity);
|
||||||
|
}
|
||||||
SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo);
|
SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo);
|
||||||
bool shouldApply = true;
|
bool shouldApply = true;
|
||||||
// Apply potential filter function
|
// Apply potential filter function
|
||||||
@@ -377,7 +361,6 @@ void Client::parseSnapshot(Packet& packet)
|
|||||||
ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType);
|
ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType);
|
||||||
memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride);
|
memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (localEntity != m_LocalPlayer && !localEntity.IsChildOf(m_LocalPlayer)) {
|
//if (localEntity != m_LocalPlayer && !localEntity.IsChildOf(m_LocalPlayer)) {
|
||||||
// updateFields(packet, componentInfo, localEntityID);
|
// updateFields(packet, componentInfo, localEntityID);
|
||||||
//} else {
|
//} else {
|
||||||
@@ -394,11 +377,7 @@ void Client::parseSnapshot(Packet& packet)
|
|||||||
if (serverParentID == EntityID_Invalid) {
|
if (serverParentID == EntityID_Invalid) {
|
||||||
newLocalEntityID = m_World->CreateEntity(EntityID_Invalid);
|
newLocalEntityID = m_World->CreateEntity(EntityID_Invalid);
|
||||||
} else {
|
} else {
|
||||||
if (serverClientMapsHasEntity(serverParentID)) {
|
newLocalEntityID = m_World->CreateEntity(m_ServerIDToClientID.at(serverParentID));
|
||||||
newLocalEntityID = m_World->CreateEntity(m_ServerIDToClientID.at(serverParentID));
|
|
||||||
} else {
|
|
||||||
newLocalEntityID = m_World->CreateEntity(EntityID_Invalid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
m_World->SetName(newLocalEntityID, serverEntityName);
|
m_World->SetName(newLocalEntityID, serverEntityName);
|
||||||
insertIntoServerClientMaps(serverEntityID, newLocalEntityID);
|
insertIntoServerClientMaps(serverEntityID, newLocalEntityID);
|
||||||
@@ -408,16 +387,26 @@ void Client::parseSnapshot(Packet& packet)
|
|||||||
}
|
}
|
||||||
// Parent logic
|
// Parent logic
|
||||||
// This should be enough beacause we know that the entities arives in pre-order (there will always be a parent)
|
// This should be enough beacause we know that the entities arives in pre-order (there will always be a parent)
|
||||||
if (serverParentID != EntityID_Invalid && serverClientMapsHasEntity(serverParentID)) {
|
if (serverParentID != EntityID_Invalid) {
|
||||||
EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID);
|
EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID);
|
||||||
if (m_World->GetParent(localEntityID) != m_ServerIDToClientID.at(serverParentID)) {
|
m_World->SetParent(localEntityID, m_ServerIDToClientID.at(serverParentID));
|
||||||
m_World->SetParent(localEntityID, m_ServerIDToClientID.at(serverParentID));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parseSpawnEvents();
|
parseSpawnEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Client::UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD)
|
||||||
|
{
|
||||||
|
//auto children = m_World->GetChildren(capturePointHUD.ID);
|
||||||
|
//for (auto it = children.first; it != children.second; it++) {
|
||||||
|
// it->first
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//EntityWrapper& localHUD = m_LocalPlayer.FirstChildByName("HUD").FirstChildByName("CapturePointHUD");
|
||||||
|
//m_World->GetComponentPools()
|
||||||
|
}
|
||||||
|
|
||||||
void Client::disconnect()
|
void Client::disconnect()
|
||||||
{
|
{
|
||||||
m_IsConnected = false;
|
m_IsConnected = false;
|
||||||
@@ -480,11 +469,6 @@ bool Client::OnPlayerDamage(const Events::PlayerDamage & e)
|
|||||||
if (e.Inflictor != m_LocalPlayer) {
|
if (e.Inflictor != m_LocalPlayer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Could this happen?
|
|
||||||
//if (!clientServerMapsHasEntity(e.Inflictor.ID)
|
|
||||||
// || !clientServerMapsHasEntity(e.Victim.ID)) {
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
Packet packet(MessageType::OnPlayerDamage, m_SendPacketID);
|
Packet packet(MessageType::OnPlayerDamage, m_SendPacketID);
|
||||||
packet.WritePrimitive(m_ClientIDToServerID.at(e.Inflictor.ID));
|
packet.WritePrimitive(m_ClientIDToServerID.at(e.Inflictor.ID));
|
||||||
@@ -519,7 +503,7 @@ void Client::parsePlayerDamage(Packet& packet)
|
|||||||
Events::PlayerDamage e;
|
Events::PlayerDamage e;
|
||||||
PlayerID victimID = packet.ReadPrimitive<EntityID>();
|
PlayerID victimID = packet.ReadPrimitive<EntityID>();
|
||||||
PlayerID inflictorID = packet.ReadPrimitive<EntityID>();
|
PlayerID inflictorID = packet.ReadPrimitive<EntityID>();
|
||||||
if (!serverClientMapsHasEntity(victimID) || !serverClientMapsHasEntity(inflictorID)) {
|
if(!serverClientMapsHasEntity(victimID) || !serverClientMapsHasEntity(inflictorID)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.Inflictor = EntityWrapper(m_World, m_ServerIDToClientID.at(victimID));
|
e.Inflictor = EntityWrapper(m_World, m_ServerIDToClientID.at(victimID));
|
||||||
@@ -531,17 +515,6 @@ void Client::parsePlayerDamage(Packet& packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::OnDoubleJump(Events::DoubleJump & e)
|
|
||||||
{
|
|
||||||
if (!clientServerMapsHasEntity(e.entityID) || e.entityID != m_LocalPlayer.ID) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Packet packet(MessageType::OnDoubleJump);
|
|
||||||
packet.WritePrimitive(m_ClientIDToServerID.at(e.entityID));
|
|
||||||
m_Reliable.Send(packet);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::sendLocalPlayerTransform()
|
void Client::sendLocalPlayerTransform()
|
||||||
{
|
{
|
||||||
if (!m_LocalPlayer.Valid()) {
|
if (!m_LocalPlayer.Valid()) {
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ Server::~Server()
|
|||||||
|
|
||||||
void Server::Update()
|
void Server::Update()
|
||||||
{
|
{
|
||||||
m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers);
|
PlayerDefinition pd;
|
||||||
|
|
||||||
|
m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers);
|
||||||
for (auto& kv : m_ConnectedPlayers) {
|
for (auto& kv : m_ConnectedPlayers) {
|
||||||
while (kv.second.TCPSocket->available()) {
|
while (kv.second.TCPSocket->available()) {
|
||||||
// Packet will get real data in receive
|
// Packet will get real data in receive
|
||||||
@@ -46,7 +47,6 @@ void Server::Update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerDefinition pd;
|
|
||||||
while (m_Unreliable.IsSocketAvailable()) {
|
while (m_Unreliable.IsSocketAvailable()) {
|
||||||
// Packet will get real data in receive
|
// Packet will get real data in receive
|
||||||
Packet packet(MessageType::Invalid);
|
Packet packet(MessageType::Invalid);
|
||||||
@@ -65,7 +65,7 @@ void Server::Update()
|
|||||||
PlayerDefinition localArea;
|
PlayerDefinition localArea;
|
||||||
localArea.Endpoint = boost::asio::ip::udp::endpoint();
|
localArea.Endpoint = boost::asio::ip::udp::endpoint();
|
||||||
m_ServerlistRequest.Receive(packet, localArea);
|
m_ServerlistRequest.Receive(packet, localArea);
|
||||||
if (packet.GetMessageType() == MessageType::ServerlistRequest) {
|
if(packet.GetMessageType() == MessageType::ServerlistRequest) {
|
||||||
packet.ReadPrimitive<int>(); // Pop size
|
packet.ReadPrimitive<int>(); // Pop size
|
||||||
packet.ReadPrimitive<int>(); // Pop MsgType
|
packet.ReadPrimitive<int>(); // Pop MsgType
|
||||||
packet.ReadPrimitive<int>(); // Pop packet ID
|
packet.ReadPrimitive<int>(); // Pop packet ID
|
||||||
@@ -76,7 +76,7 @@ void Server::Update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if players have disconnected
|
// Check if players have disconnected
|
||||||
for (int i = 0; i < m_PlayersToDisconnect.size(); i++) {
|
for (int i = 0; i < m_PlayersToDisconnect.size(); i++) {
|
||||||
disconnect(m_PlayersToDisconnect.at(i));
|
disconnect(m_PlayersToDisconnect.at(i));
|
||||||
}
|
}
|
||||||
m_PlayersToDisconnect.clear();
|
m_PlayersToDisconnect.clear();
|
||||||
@@ -136,10 +136,7 @@ void Server::parseMessageType(Packet& packet)
|
|||||||
parseOnPlayerDamage(packet);
|
parseOnPlayerDamage(packet);
|
||||||
break;
|
break;
|
||||||
case MessageType::PlayerTransform:
|
case MessageType::PlayerTransform:
|
||||||
parsePlayerTransform(packet);
|
parsePlayerTransform(packet);
|
||||||
break;
|
|
||||||
case MessageType::OnDoubleJump:
|
|
||||||
parseDoubleJump(packet);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -194,41 +191,43 @@ void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
|
|||||||
// HACK: Only sync players for now, since the map turned out to be TOO LARGE to send in one snapshot and Simon's computer shits itself
|
// HACK: Only sync players for now, since the map turned out to be TOO LARGE to send in one snapshot and Simon's computer shits itself
|
||||||
// HACK: Also checked CapturePointHUD for now. (this would get out of sync);
|
// HACK: Also checked CapturePointHUD for now. (this would get out of sync);
|
||||||
EntityWrapper childEntity(m_World, childEntityID);
|
EntityWrapper childEntity(m_World, childEntityID);
|
||||||
if (shouldSendToClient(childEntity)) {
|
if (!shouldSendToClient(childEntity)) {
|
||||||
// Write EntityID and parentsID and Entity name
|
continue;
|
||||||
packet.WritePrimitive(childEntityID);
|
}
|
||||||
packet.WritePrimitive(entityID);
|
|
||||||
packet.WriteString(m_World->GetName(childEntityID));
|
// Write EntityID and parentsID and Entity name
|
||||||
// Write components to child
|
packet.WritePrimitive(childEntityID);
|
||||||
int numberOfComponents = 0;
|
packet.WritePrimitive(entityID);
|
||||||
for (auto& i : worldComponentPools) {
|
packet.WriteString(m_World->GetName(childEntityID));
|
||||||
if (i.second->KnowsEntity(childEntityID)) {
|
// Write components to child
|
||||||
numberOfComponents++;
|
int numberOfComponents = 0;
|
||||||
}
|
for (auto& i : worldComponentPools) {
|
||||||
|
if (i.second->KnowsEntity(childEntityID)) {
|
||||||
|
numberOfComponents++;
|
||||||
}
|
}
|
||||||
// Write how many components should be read
|
}
|
||||||
packet.WritePrimitive(numberOfComponents);
|
// Write how many components should be read
|
||||||
for (auto& i : worldComponentPools) {
|
packet.WritePrimitive(numberOfComponents);
|
||||||
// If the entity exist in the pool
|
for (auto& i : worldComponentPools) {
|
||||||
if (i.second->KnowsEntity(childEntityID)) {
|
// If the entity exist in the pool
|
||||||
ComponentWrapper componentWrapper = i.second->GetByEntity(childEntityID);
|
if (i.second->KnowsEntity(childEntityID)) {
|
||||||
// ComponentType
|
ComponentWrapper componentWrapper = i.second->GetByEntity(childEntityID);
|
||||||
packet.WriteString(componentWrapper.Info.Name);
|
// ComponentType
|
||||||
// Loop through fields
|
packet.WriteString(componentWrapper.Info.Name);
|
||||||
for (auto& componentField : componentWrapper.Info.FieldsInOrder) {
|
// Loop through fields
|
||||||
ComponentInfo::Field_t fieldInfo = componentWrapper.Info.Fields.at(componentField);
|
for (auto& componentField : componentWrapper.Info.FieldsInOrder) {
|
||||||
if (fieldInfo.Type == "string") {
|
ComponentInfo::Field_t fieldInfo = componentWrapper.Info.Fields.at(componentField);
|
||||||
std::string& value = componentWrapper[componentField];
|
if (fieldInfo.Type == "string") {
|
||||||
packet.WriteString(value);
|
std::string& value = componentWrapper[componentField];
|
||||||
} else {
|
packet.WriteString(value);
|
||||||
packet.WriteData(componentWrapper.Data + fieldInfo.Offset, fieldInfo.Stride);
|
} else {
|
||||||
}
|
packet.WriteData(componentWrapper.Data + fieldInfo.Offset, fieldInfo.Stride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Go to to your children
|
// Go to to your children
|
||||||
addPlayersToPacket(packet, childEntityID);
|
addChildrenToPacket(packet, childEntityID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +455,8 @@ bool Server::OnInputCommand(const Events::InputCommand & e)
|
|||||||
}
|
}
|
||||||
isReadingData = !isReadingData;
|
isReadingData = !isReadingData;
|
||||||
m_SaveDataTimer = std::clock();
|
m_SaveDataTimer = std::clock();
|
||||||
} else if (e.Command == "KickPlayer" && e.Value > 0) {
|
}
|
||||||
|
else if (e.Command == "KickPlayer" && e.Value > 0) {
|
||||||
kick(0);
|
kick(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +507,7 @@ bool Server::OnPlayerDamage(const Events::PlayerDamage& e)
|
|||||||
packet.WritePrimitive(e.Damage);
|
packet.WritePrimitive(e.Damage);
|
||||||
reliableBroadcast(packet);
|
reliableBroadcast(packet);
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::parseClientPing()
|
void Server::parseClientPing()
|
||||||
@@ -536,12 +536,6 @@ void Server::parsePing()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Server::parseDoubleJump(Packet & packet)
|
|
||||||
{
|
|
||||||
reliableBroadcast(packet);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Server::parseOnInputCommand(Packet& packet)
|
void Server::parseOnInputCommand(Packet& packet)
|
||||||
{
|
{
|
||||||
PlayerID player = -1;
|
PlayerID player = -1;
|
||||||
@@ -601,15 +595,8 @@ void Server::parsePlayerTransform(Packet& packet)
|
|||||||
|
|
||||||
bool Server::shouldSendToClient(EntityWrapper childEntity)
|
bool Server::shouldSendToClient(EntityWrapper childEntity)
|
||||||
{
|
{
|
||||||
auto children = m_World->GetChildren(childEntity.ID);
|
|
||||||
for (auto it = children.first; it != children.second; it++) {
|
|
||||||
EntityWrapper child(m_World, it->second);
|
|
||||||
if(child.HasComponent("CapturePoint")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid()
|
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid()
|
||||||
|| childEntity.HasComponent("CapturePoint");
|
|| childEntity.HasComponent("CapturePoint") || childEntity.FirstParentWithComponent("CapturePoint").Valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerID Server::GetPlayerIDFromEndpoint()
|
PlayerID Server::GetPlayerIDFromEndpoint()
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ using namespace boost::asio::ip;
|
|||||||
TCPServer::TCPServer()
|
TCPServer::TCPServer()
|
||||||
{
|
{
|
||||||
acceptor = std::unique_ptr<tcp::acceptor>(new tcp::acceptor(m_IOService, tcp::endpoint(tcp::v4(), 27666)));
|
acceptor = std::unique_ptr<tcp::acceptor>(new tcp::acceptor(m_IOService, tcp::endpoint(tcp::v4(), 27666)));
|
||||||
// Make the acceptor non-blocking so we wont get stuck in AcceptNewConnections().
|
|
||||||
acceptor->non_blocking(true);
|
|
||||||
m_Port = GetPort();
|
m_Port = GetPort();
|
||||||
m_Address = GetAddress();
|
m_Address = GetAddress();
|
||||||
}
|
}
|
||||||
@@ -15,24 +13,14 @@ TCPServer::~TCPServer()
|
|||||||
|
|
||||||
void TCPServer::AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers)
|
void TCPServer::AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers)
|
||||||
{
|
{
|
||||||
boost::system::error_code error;
|
|
||||||
boost::shared_ptr<tcp::socket> newSocket = boost::shared_ptr<tcp::socket>(new tcp::socket(m_IOService));
|
boost::shared_ptr<tcp::socket> newSocket = boost::shared_ptr<tcp::socket>(new tcp::socket(m_IOService));
|
||||||
acceptor->accept(*newSocket, error);
|
m_IOService.poll();
|
||||||
// If no error occured add new tcp connection
|
acceptor->async_accept(*newSocket,
|
||||||
if (!error) {
|
boost::bind(&TCPServer::handle_accept, this, newSocket, boost::ref(nextPlayerID), boost::ref(connectedPlayers),
|
||||||
// Add tcp socket to connections
|
boost::asio::placeholders::error));
|
||||||
boost::asio::ip::tcp::no_delay option(true);
|
|
||||||
newSocket->set_option(option);
|
|
||||||
PlayerDefinition pd;
|
|
||||||
pd.StopTime = std::clock();
|
|
||||||
pd.TCPSocket = newSocket;
|
|
||||||
pd.TCPAddress = newSocket.get()->remote_endpoint().address();
|
|
||||||
pd.TCPPort = newSocket.get()->remote_endpoint().port();
|
|
||||||
connectedPlayers[nextPlayerID++] = pd;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerID TCPServer::getPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
PlayerID GetPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
||||||
boost::asio::ip::address address, unsigned short port)
|
boost::asio::ip::address address, unsigned short port)
|
||||||
{
|
{
|
||||||
for (auto& kv : connectedPlayers) {
|
for (auto& kv : connectedPlayers) {
|
||||||
@@ -44,6 +32,24 @@ PlayerID TCPServer::getPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefin
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TCPServer::handle_accept(boost::shared_ptr<tcp::socket> socket,
|
||||||
|
int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
||||||
|
const boost::system::error_code& error)
|
||||||
|
{
|
||||||
|
if (!error && GetPlayerIDFromEndpoint(connectedPlayers, socket->remote_endpoint().address(),
|
||||||
|
socket->remote_endpoint().port()) == -1) {
|
||||||
|
// Add tcp socket to connections
|
||||||
|
boost::asio::ip::tcp::no_delay option(true);
|
||||||
|
socket->set_option(option);
|
||||||
|
PlayerDefinition pd;
|
||||||
|
pd.StopTime = std::clock();
|
||||||
|
pd.TCPSocket = socket;
|
||||||
|
pd.TCPAddress = socket.get()->remote_endpoint().address();
|
||||||
|
pd.TCPPort = socket.get()->remote_endpoint().port();
|
||||||
|
connectedPlayers[nextPlayerID++] = pd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TCPServer::Send(Packet & packet, PlayerDefinition & playerDefinition)
|
void TCPServer::Send(Packet & packet, PlayerDefinition & playerDefinition)
|
||||||
{
|
{
|
||||||
packet.UpdateSize();
|
packet.UpdateSize();
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ void CubeMapPass::LoadTextures(std::string input)
|
|||||||
m_CubeMapTextures.push_back(img);
|
m_CubeMapTextures.push_back(img);
|
||||||
}
|
}
|
||||||
GenerateCubeMapTexture();
|
GenerateCubeMapTexture();
|
||||||
m_PreviusCubeMapTexture = input;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +1,19 @@
|
|||||||
#include "Rendering/DrawBloomPass.h"
|
#include "Rendering/DrawBloomPass.h"
|
||||||
|
|
||||||
DrawBloomPass::DrawBloomPass(IRenderer* renderer, ConfigFile* config)
|
DrawBloomPass::DrawBloomPass(IRenderer* renderer)
|
||||||
: m_Renderer(renderer)
|
|
||||||
, m_Config(config)
|
|
||||||
{
|
{
|
||||||
InitializeTextures();
|
m_Renderer = renderer;
|
||||||
|
|
||||||
ChangeQuality(m_Config->Get<int>("GLOW.Quality", 2));
|
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
||||||
|
|
||||||
|
InitializeTextures();
|
||||||
|
InitializeBuffers();
|
||||||
|
InitializeShaderPrograms();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBloomPass::InitializeTextures()
|
void DrawBloomPass::InitializeTextures()
|
||||||
{
|
{
|
||||||
m_BlackTexture = CommonFunctions::LoadTexture("Textures/Core/Black.png", false);
|
m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false);
|
||||||
}
|
|
||||||
|
|
||||||
void DrawBloomPass::ChangeQuality(int quality)
|
|
||||||
{
|
|
||||||
if (m_Quality == quality) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_Quality = quality;
|
|
||||||
|
|
||||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
|
||||||
|
|
||||||
if (m_Quality == 0) {
|
|
||||||
glDeleteTextures(1, &m_GaussianTexture_horiz);
|
|
||||||
glDeleteTextures(1, &m_GaussianTexture_vert);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeTextures();
|
|
||||||
InitializeBuffers();
|
|
||||||
InitializeShaderPrograms();
|
|
||||||
std::string qStr = std::to_string(m_Quality);
|
|
||||||
m_Iterations = m_Config->Get<float>("GLOW" + qStr + ".NumIterations", 0);
|
|
||||||
|
|
||||||
InitializeBuffers();
|
|
||||||
InitializeShaderPrograms();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBloomPass::InitializeShaderPrograms()
|
void DrawBloomPass::InitializeShaderPrograms()
|
||||||
@@ -63,25 +40,18 @@ void DrawBloomPass::InitializeBuffers()
|
|||||||
{
|
{
|
||||||
GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
|
|
||||||
if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) {
|
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0)));
|
||||||
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0)));
|
m_GaussianFrameBuffer_horiz.Generate();
|
||||||
}
|
|
||||||
m_GaussianFrameBuffer_horiz.Generate();
|
|
||||||
|
|
||||||
GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
|
|
||||||
if (m_GaussianFrameBuffer_vert.GetHandle() == 0) {
|
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0)));
|
||||||
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0)));
|
m_GaussianFrameBuffer_vert.Generate();
|
||||||
}
|
|
||||||
m_GaussianFrameBuffer_vert.Generate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DrawBloomPass::ClearBuffer()
|
void DrawBloomPass::ClearBuffer()
|
||||||
{
|
{
|
||||||
if (m_Quality == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GLERROR("PRE");
|
GLERROR("PRE");
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
m_GaussianFrameBuffer_horiz.Bind();
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
@@ -96,9 +66,6 @@ void DrawBloomPass::ClearBuffer()
|
|||||||
|
|
||||||
void DrawBloomPass::Draw(GLuint texture)
|
void DrawBloomPass::Draw(GLuint texture)
|
||||||
{
|
{
|
||||||
if (m_Quality == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GLERROR("DrawBloomPass::Draw: Pre");
|
GLERROR("DrawBloomPass::Draw: Pre");
|
||||||
|
|
||||||
DrawBloomPassState state;
|
DrawBloomPassState state;
|
||||||
@@ -117,7 +84,7 @@ void DrawBloomPass::Draw(GLuint texture)
|
|||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
//Iterate some times to make it more gaussian.
|
//Iterate some times to make it more gaussian.
|
||||||
for (int i = 1; i < m_Iterations; i++) {
|
for (int i = 1; i < m_iterations; i++) {
|
||||||
//Vertical pass
|
//Vertical pass
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
m_GaussianFrameBuffer_vert.Bind();
|
||||||
m_GaussianProgram_vert->Bind();
|
m_GaussianProgram_vert->Bind();
|
||||||
@@ -158,9 +125,6 @@ void DrawBloomPass::Draw(GLuint texture)
|
|||||||
|
|
||||||
void DrawBloomPass::OnWindowResize()
|
void DrawBloomPass::OnWindowResize()
|
||||||
{
|
{
|
||||||
if (m_Quality == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
m_GaussianFrameBuffer_vert.Generate();
|
m_GaussianFrameBuffer_vert.Generate();
|
||||||
GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
@@ -169,7 +133,6 @@ void DrawBloomPass::OnWindowResize()
|
|||||||
|
|
||||||
void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
||||||
{
|
{
|
||||||
glDeleteTextures(1, texture);
|
|
||||||
glGenTextures(1, texture);
|
glGenTextures(1, texture);
|
||||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "Rendering/DrawFinalPass.h"
|
#include "Rendering/DrawFinalPass.h"
|
||||||
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass)
|
|
||||||
: m_Renderer(renderer)
|
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass)
|
||||||
, m_LightCullingPass(lightCullingPass)
|
: m_Renderer(renderer)
|
||||||
, m_CubeMapPass(cubeMapPass)
|
, m_LightCullingPass(lightCullingPass)
|
||||||
, m_SSAOPass(ssaoPass)
|
, m_CubeMapPass(cubeMapPass)
|
||||||
{
|
{
|
||||||
//TODO: Make sure that uniforms are not sent into shader if not needed.
|
//TODO: Make sure that uniforms are not sent into shader if not needed.
|
||||||
m_ShieldPixelRate = 8;
|
m_ShieldPixelRate = 8;
|
||||||
@@ -162,20 +162,20 @@ void DrawFinalPass::InitializeShaderPrograms()
|
|||||||
|
|
||||||
m_FillDepthBufferProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgram");
|
m_FillDepthBufferProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgram");
|
||||||
m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBuffer.vert.glsl")));
|
m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBuffer.vert.glsl")));
|
||||||
// m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
|
m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
|
||||||
m_FillDepthBufferProgram->Compile();
|
m_FillDepthBufferProgram->Compile();
|
||||||
m_FillDepthBufferProgram->Link();
|
m_FillDepthBufferProgram->Link();
|
||||||
GLERROR("Creating DepthFill program");
|
GLERROR("Creating DepthFill program");
|
||||||
|
|
||||||
m_FillDepthBufferSkinnedProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgramSkinned");
|
m_FillDepthBufferSkinnedProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgramSkinned");
|
||||||
m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBufferSkinned.vert.glsl")));
|
m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBufferSkinned.vert.glsl")));
|
||||||
// m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
|
m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
|
||||||
m_FillDepthBufferSkinnedProgram->Compile();
|
m_FillDepthBufferSkinnedProgram->Compile();
|
||||||
m_FillDepthBufferSkinnedProgram->Link();
|
m_FillDepthBufferSkinnedProgram->Link();
|
||||||
GLERROR("Creating DepthFill program");
|
GLERROR("Creating DepthFill program");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::Draw(RenderScene& scene)
|
void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
|
||||||
{
|
{
|
||||||
GLERROR("Pre");
|
GLERROR("Pre");
|
||||||
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
||||||
@@ -191,10 +191,10 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
//Fill depth buffer
|
//Fill depth buffer
|
||||||
|
|
||||||
state->StencilMask(0x00);
|
state->StencilMask(0x00);
|
||||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture);
|
||||||
GLERROR("OpaqueObjects");
|
GLERROR("OpaqueObjects");
|
||||||
state->BlendFunc(GL_ONE, GL_ONE);
|
state->BlendFunc(GL_ONE, GL_ONE);
|
||||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture);
|
||||||
GLERROR("TransparentObjects");
|
GLERROR("TransparentObjects");
|
||||||
state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
DrawSprites(scene.Jobs.SpriteJob, scene);
|
DrawSprites(scene.Jobs.SpriteJob, scene);
|
||||||
@@ -210,11 +210,11 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
//Draw Opaque shielded objects
|
//Draw Opaque shielded objects
|
||||||
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||||
state->StencilMask(0x00);
|
state->StencilMask(0x00);
|
||||||
DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing
|
DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene, SSAOTexture); //might need changing
|
||||||
GLERROR("Shielded Opaque object");
|
GLERROR("Shielded Opaque object");
|
||||||
|
|
||||||
//Draw Transparen Shielded objects
|
//Draw Transparen Shielded objects
|
||||||
DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene); //might need changing
|
DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene, SSAOTexture); //might need changing
|
||||||
GLERROR("Shielded Transparent objects");
|
GLERROR("Shielded Transparent objects");
|
||||||
|
|
||||||
GLERROR("END");
|
GLERROR("END");
|
||||||
@@ -250,9 +250,9 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
stateLowRes->Enable(GL_DEPTH_TEST);
|
stateLowRes->Enable(GL_DEPTH_TEST);
|
||||||
stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF);
|
stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF);
|
||||||
stateLowRes->StencilMask(0x00);
|
stateLowRes->StencilMask(0x00);
|
||||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture);
|
||||||
GLERROR("OpaqueObjects");
|
GLERROR("OpaqueObjects");
|
||||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture);
|
||||||
GLERROR("TransparentObjects");
|
GLERROR("TransparentObjects");
|
||||||
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
@@ -340,7 +340,7 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm:
|
|||||||
GLERROR("MipMap Texture initialization failed");
|
GLERROR("MipMap Texture initialization failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene, GLuint SSAOTexture)
|
||||||
{
|
{
|
||||||
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
||||||
GLERROR("forwardHandle");
|
GLERROR("forwardHandle");
|
||||||
@@ -364,7 +364,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_SSAOPass->SSAOTexture());
|
glBindTexture(GL_TEXTURE_2D, SSAOTexture);
|
||||||
|
|
||||||
for (auto &job : jobs) {
|
for (auto &job : jobs) {
|
||||||
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
||||||
@@ -383,7 +383,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob);
|
BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob);
|
||||||
glActiveTexture(GL_TEXTURE5);
|
glActiveTexture(GL_TEXTURE5);
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
|
||||||
glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
|
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
|
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
|
||||||
@@ -401,7 +401,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
BindExplosionTextures(explosionHandle, explosionEffectJob);
|
BindExplosionTextures(explosionHandle, explosionEffectJob);
|
||||||
glActiveTexture(GL_TEXTURE5);
|
glActiveTexture(GL_TEXTURE5);
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
|
||||||
glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
|
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -463,7 +463,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
BindModelTextures(forwardSkinnedHandle, modelJob);
|
BindModelTextures(forwardSkinnedHandle, modelJob);
|
||||||
glActiveTexture(GL_TEXTURE5);
|
glActiveTexture(GL_TEXTURE5);
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
|
||||||
glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
|
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->AnimationOffset.animation != nullptr) {
|
if (modelJob->AnimationOffset.animation != nullptr) {
|
||||||
@@ -753,7 +753,6 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
|||||||
|
|
||||||
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
||||||
{
|
{
|
||||||
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
|
||||||
GLERROR("Bind 1 uniform");
|
GLERROR("Bind 1 uniform");
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||||
GLERROR("Bind 2 uniform");
|
GLERROR("Bind 2 uniform");
|
||||||
@@ -802,7 +801,6 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
|
|||||||
|
|
||||||
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
|
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
|
||||||
{
|
{
|
||||||
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
|
||||||
GLERROR("Bind 1 uniform");
|
GLERROR("Bind 1 uniform");
|
||||||
GLint Location_M = glGetUniformLocation(shaderHandle, "M");
|
GLint Location_M = glGetUniformLocation(shaderHandle, "M");
|
||||||
glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
|
|||||||
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
Enable(GL_DEPTH_TEST);
|
Enable(GL_DEPTH_TEST);
|
||||||
Enable(GL_CULL_FACE);
|
Enable(GL_CULL_FACE);
|
||||||
glDepthFunc(GL_LEQUAL);
|
|
||||||
Enable(GL_STENCIL_TEST);
|
Enable(GL_STENCIL_TEST);
|
||||||
StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||||
StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||||
|
|||||||
@@ -42,33 +42,33 @@ void FrameBuffer::Generate()
|
|||||||
GLERROR("PRE");
|
GLERROR("PRE");
|
||||||
|
|
||||||
std::vector<GLenum> attachments;
|
std::vector<GLenum> attachments;
|
||||||
if (m_BufferHandle == 0) {
|
|
||||||
glGenFramebuffers(1, &m_BufferHandle);
|
glGenFramebuffers(1, &m_BufferHandle);
|
||||||
}
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle);
|
||||||
GLERROR("1");
|
GLERROR("1");
|
||||||
|
|
||||||
for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) {
|
for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) {
|
||||||
switch ((*it)->m_ResourceType) {
|
switch ((*it)->m_ResourceType) {
|
||||||
case GL_TEXTURE_2D:
|
case GL_TEXTURE_2D:
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0);
|
||||||
GLERROR("FrameBuffer generate: glFramebufferTexture2D");
|
GLERROR("FrameBuffer generate: glFramebufferTexture2D");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case GL_RENDERBUFFER:
|
case GL_RENDERBUFFER:
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
||||||
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GLERROR("2");
|
GLERROR("2");
|
||||||
|
|
||||||
if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
|
if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
|
||||||
attachments.push_back((*it)->m_Attachment);
|
attachments.push_back((*it)->m_Attachment);
|
||||||
}
|
}
|
||||||
GLERROR("Attachment");
|
GLERROR("Attachment");
|
||||||
|
|
||||||
|
}
|
||||||
|
GLERROR("3");
|
||||||
|
|
||||||
}
|
|
||||||
GLERROR("3");
|
|
||||||
|
|
||||||
GLenum* bufferTextures = &attachments[0];
|
GLenum* bufferTextures = &attachments[0];
|
||||||
glDrawBuffers(attachments.size(), bufferTextures);
|
glDrawBuffers(attachments.size(), bufferTextures);
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ std::unordered_map<GLFWwindow*, Renderer*> Renderer::m_WindowToRenderer;
|
|||||||
|
|
||||||
void Renderer::Initialize()
|
void Renderer::Initialize()
|
||||||
{
|
{
|
||||||
m_SSAO_Quality = m_Config->Get<int>("SSAO.Quality", 0);
|
|
||||||
m_GLOW_Quality = m_Config->Get<int>("GLOW.Quality", 0);
|
|
||||||
InitializeWindow();
|
InitializeWindow();
|
||||||
|
|
||||||
InitializeRenderPasses();
|
InitializeRenderPasses();
|
||||||
@@ -109,7 +107,6 @@ void Renderer::Update(double dt)
|
|||||||
void Renderer::Draw(RenderFrame& frame)
|
void Renderer::Draw(RenderFrame& frame)
|
||||||
{
|
{
|
||||||
GLERROR("PRE");
|
GLERROR("PRE");
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion");
|
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion");
|
||||||
ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)");
|
ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)");
|
||||||
if(m_CubeMapTexture == 0) {
|
if(m_CubeMapTexture == 0) {
|
||||||
@@ -118,10 +115,13 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
m_CubeMapPass->LoadTextures("Sky");
|
m_CubeMapPass->LoadTextures("Sky");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SliderInt("SSAO Quality", &m_SSAO_Quality, 0, 3);
|
ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f);
|
||||||
ImGui::SliderInt("Glow Quality", &m_GLOW_Quality, 0, 3);
|
ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 0.1f);
|
||||||
m_SSAOPass->ChangeQuality(m_SSAO_Quality);
|
ImGui::SliderFloat("SSAO contrast", &m_SSAO_Contrast, 0.0f, 10.0f);
|
||||||
m_DrawBloomPass->ChangeQuality(m_GLOW_Quality);
|
ImGui::SliderFloat("SSAO IntensityScale", &m_SSAO_IntensityScale, 0.0f, 10.0f);
|
||||||
|
ImGui::SliderInt("SSAO Number of Samples", &m_SSAO_NumOfSamples, 2, 100);
|
||||||
|
ImGui::SliderInt("SSAO Number of Turns", &m_SSAO_NumOfTurns, 0, 50);
|
||||||
|
m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Contrast, m_SSAO_IntensityScale, m_SSAO_NumOfSamples, m_SSAO_NumOfTurns);
|
||||||
GLERROR("SSAO Settings");
|
GLERROR("SSAO Settings");
|
||||||
//clear buffer 0
|
//clear buffer 0
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
@@ -141,10 +141,10 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
GLERROR("Drawing pickingpass");
|
GLERROR("Drawing pickingpass");
|
||||||
PerformanceTimer::StopTimer("Renderer-Depth");
|
PerformanceTimer::StopTimer("Renderer-Depth");
|
||||||
}
|
}
|
||||||
PerformanceTimer::StartTimer("Renderer-AO generation");
|
PerformanceTimer::StartTimer("AO generation");
|
||||||
m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera);
|
m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera);
|
||||||
GLuint ao = m_SSAOPass->SSAOTexture();
|
GLuint ao = m_SSAOPass->SSAOTexture();
|
||||||
PerformanceTimer::StopTimer("Renderer-AO generation");
|
PerformanceTimer::StopTimer("AO generation");
|
||||||
for (auto scene : frame.RenderScenes){
|
for (auto scene : frame.RenderScenes){
|
||||||
|
|
||||||
PerformanceTimer::StartTimer("Renderer-Drawing PickingPass");
|
PerformanceTimer::StartTimer("Renderer-Drawing PickingPass");
|
||||||
@@ -159,7 +159,7 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling");
|
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling");
|
||||||
m_LightCullingPass->CullLights(*scene);
|
m_LightCullingPass->CullLights(*scene);
|
||||||
GLERROR("LightCulling");
|
GLERROR("LightCulling");
|
||||||
m_DrawFinalPass->Draw(*scene);
|
m_DrawFinalPass->Draw(*scene, ao);
|
||||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light");
|
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light");
|
||||||
GLERROR("Draw Geometry+Light");
|
GLERROR("Draw Geometry+Light");
|
||||||
//m_DrawScenePass->Draw(*scene);
|
//m_DrawScenePass->Draw(*scene);
|
||||||
@@ -248,10 +248,9 @@ void Renderer::InitializeRenderPasses()
|
|||||||
m_PickingPass = new PickingPass(this, m_EventBroker);
|
m_PickingPass = new PickingPass(this, m_EventBroker);
|
||||||
m_LightCullingPass = new LightCullingPass(this);
|
m_LightCullingPass = new LightCullingPass(this);
|
||||||
m_CubeMapPass = new CubeMapPass(this);
|
m_CubeMapPass = new CubeMapPass(this);
|
||||||
m_SSAOPass = new SSAOPass(this, m_Config);
|
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass);
|
||||||
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass);
|
|
||||||
m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
|
m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
|
||||||
m_DrawBloomPass = new DrawBloomPass(this, m_Config);
|
m_DrawBloomPass = new DrawBloomPass(this);
|
||||||
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
|
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
|
||||||
|
m_SSAOPass = new SSAOPass(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,130 +1,50 @@
|
|||||||
#include "Rendering/SSAOPass.h"
|
#include "Rendering/SSAOPass.h"
|
||||||
|
|
||||||
SSAOPass::SSAOPass(IRenderer* renderer, ConfigFile* config)
|
SSAOPass::SSAOPass(IRenderer* renderer)
|
||||||
: m_Renderer(renderer)
|
|
||||||
, m_Config(config)
|
|
||||||
{
|
{
|
||||||
m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false);
|
m_Renderer = renderer;
|
||||||
|
|
||||||
ChangeQuality(m_Config->Get<int>("SSAO.Quality", 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SSAOPass::ChangeQuality(int quality)
|
|
||||||
{
|
|
||||||
if (m_Quality == quality) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Quality = quality;
|
|
||||||
|
|
||||||
if (m_Quality == 0) {
|
|
||||||
glDeleteTextures(1, &m_SSAOTexture);
|
|
||||||
glDeleteTextures(1, &m_SSAOViewSpaceZTexture);
|
|
||||||
glDeleteTextures(1, &m_GaussianTexture_horiz);
|
|
||||||
glDeleteTextures(1, &m_GaussianTexture_vert);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string qStr = std::to_string(m_Quality);
|
|
||||||
Setting(
|
|
||||||
m_Config->Get<float>("SSAO" + qStr + ".Radius", 0.01),
|
|
||||||
m_Config->Get<float>("SSAO" + qStr + ".Bias", 0.012),
|
|
||||||
m_Config->Get<float>("SSAO" + qStr + ".Contrast", 1.0),
|
|
||||||
m_Config->Get<float>("SSAO" + qStr + ".Intensity", 1.0),
|
|
||||||
m_Config->Get<int>("SSAO" + qStr + ".NumSamples", 0),
|
|
||||||
m_Config->Get<int>("SSAO" + qStr + ".NumTurns", 0),
|
|
||||||
m_Config->Get<int>("SSAO" + qStr + ".NumIterations", 0),
|
|
||||||
m_Config->Get<int>("SSAO" + qStr + ".TextureQuality", 4)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
||||||
|
|
||||||
InitializeTexture();
|
InitializeTexture();
|
||||||
InitializeBuffer();
|
InitializeBuffer();
|
||||||
InitializeShaderProgram();
|
InitializeShaderProgram();
|
||||||
|
Setting(0.1f, 0.012f, 1.0f, 1.0f, 13, 7);
|
||||||
|
|
||||||
|
m_DrawBloomPass = new DrawBloomPass(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSAOPass::InitializeShaderProgram()
|
void SSAOPass::InitializeShaderProgram()
|
||||||
{
|
{
|
||||||
m_SSAOProgram = ResourceManager::Load<ShaderProgram>("##SSAOProgram");
|
m_SSAOProgram = ResourceManager::Load<ShaderProgram>("##SSAOProgram");
|
||||||
if (m_SSAOProgram->GetHandle() == 0) {
|
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
|
||||||
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
|
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAO.frag.glsl")));
|
||||||
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAO.frag.glsl")));
|
m_SSAOProgram->Compile();
|
||||||
m_SSAOProgram->Compile();
|
m_SSAOProgram->Link();
|
||||||
m_SSAOProgram->Link();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_SSAOViewSpaceZProgram = ResourceManager::Load<ShaderProgram>("##SSAOViewSpaceZProgram");
|
m_SSAOViewSpaceZProgram = ResourceManager::Load<ShaderProgram>("##SSAOViewSpaceZProgram");
|
||||||
if (m_SSAOViewSpaceZProgram->GetHandle() == 0) {
|
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
|
||||||
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
|
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl")));
|
||||||
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl")));
|
m_SSAOViewSpaceZProgram->Compile();
|
||||||
m_SSAOViewSpaceZProgram->Compile();
|
m_SSAOViewSpaceZProgram->Link();
|
||||||
m_SSAOViewSpaceZProgram->Link();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_GaussianProgram_horiz = ResourceManager::Load<ShaderProgram>("##GaussianProgramHoriz");
|
|
||||||
if (m_GaussianProgram_horiz->GetHandle() == 0) {
|
|
||||||
m_GaussianProgram_horiz->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_horiz.vert.glsl")));
|
|
||||||
m_GaussianProgram_horiz->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_horiz.frag.glsl")));
|
|
||||||
m_GaussianProgram_horiz->Compile();
|
|
||||||
m_GaussianProgram_horiz->Link();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_GaussianProgram_vert = ResourceManager::Load<ShaderProgram>("##GaussianProgramVert");
|
|
||||||
if (m_GaussianProgram_vert->GetHandle() == 0) {
|
|
||||||
m_GaussianProgram_vert->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_vert.vert.glsl")));
|
|
||||||
m_GaussianProgram_vert->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_vert.frag.glsl")));
|
|
||||||
m_GaussianProgram_vert->Compile();
|
|
||||||
m_GaussianProgram_vert->Link();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSAOPass::InitializeTexture() {
|
void SSAOPass::InitializeTexture() {
|
||||||
GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT);
|
GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R8, GL_RED, GL_FLOAT);
|
||||||
GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R32F, GL_RED, GL_FLOAT);
|
GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R32F, GL_RED, GL_FLOAT);
|
||||||
|
|
||||||
GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT);
|
|
||||||
GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSAOPass::InitializeBuffer()
|
void SSAOPass::InitializeBuffer()
|
||||||
{
|
{
|
||||||
if (m_SSAOFramBuffer.GetHandle() == 0) {
|
m_SSAOFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
m_SSAOFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0)));
|
m_SSAOFramBuffer.Generate();
|
||||||
}
|
|
||||||
m_SSAOFramBuffer.Generate();
|
|
||||||
|
|
||||||
|
|
||||||
if (m_SSAOViewSpaceZFramBuffer.GetHandle() == 0) {
|
|
||||||
m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0)));
|
|
||||||
}
|
|
||||||
m_SSAOViewSpaceZFramBuffer.Generate();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) {
|
|
||||||
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0)));
|
|
||||||
}
|
|
||||||
m_GaussianFrameBuffer_horiz.Generate();
|
|
||||||
|
|
||||||
|
|
||||||
if (m_GaussianFrameBuffer_vert.GetHandle() == 0) {
|
|
||||||
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0)));
|
|
||||||
}
|
|
||||||
m_GaussianFrameBuffer_vert.Generate();
|
|
||||||
|
|
||||||
|
m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
|
m_SSAOViewSpaceZFramBuffer.Generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSAOPass::ClearBuffer()
|
void SSAOPass::ClearBuffer()
|
||||||
{
|
{
|
||||||
if (m_Quality == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_SSAOFramBuffer.Bind();
|
m_SSAOFramBuffer.Bind();
|
||||||
glClearColor(1.f, 1.f, 1.f, 1.f);
|
glClearColor(1.f, 1.f, 1.f, 1.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
@@ -134,32 +54,19 @@ void SSAOPass::ClearBuffer()
|
|||||||
glClearColor(1.f, 1.f, 1.f, 1.f);
|
glClearColor(1.f, 1.f, 1.f, 1.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
m_SSAOViewSpaceZFramBuffer.Unbind();
|
m_SSAOViewSpaceZFramBuffer.Unbind();
|
||||||
|
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
|
||||||
glClearColor(1.f, 1.f, 1.f, 1.f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
m_GaussianFrameBuffer_horiz.Unbind();
|
|
||||||
|
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
|
||||||
glClearColor(1.f, 1.f, 1.f, 1.f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
m_GaussianFrameBuffer_vert.Unbind();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSAOPass::Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int numOfTurns, int iterations, int quality) {
|
void SSAOPass::Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns) {
|
||||||
m_Radius = radius;
|
m_Radius = radius;
|
||||||
m_Bias = bias;
|
m_Bias = bias;
|
||||||
m_Contrast = contrast;
|
m_Contrast = contrast;
|
||||||
m_IntensityScale = intensityScale;
|
m_IntensityScale = intensityScale;
|
||||||
m_NumOfSamples = numOfSamples;
|
m_NumOfSamples = numOfSamples;
|
||||||
m_NumOfTurns = numOfTurns;
|
m_NumOfTurns = NumOfTurns;
|
||||||
m_Iterations = iterations;
|
|
||||||
m_TextureQuality = quality;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
||||||
{
|
{
|
||||||
glDeleteTextures(1, texture);
|
|
||||||
glGenTextures(1, texture);
|
glGenTextures(1, texture);
|
||||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
||||||
@@ -172,10 +79,6 @@ void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filterin
|
|||||||
|
|
||||||
void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
||||||
{
|
{
|
||||||
if (m_Quality == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAOPassState state;
|
SSAOPassState state;
|
||||||
GLuint viewSpaceZPShaderHandle = m_SSAOViewSpaceZProgram->GetHandle();
|
GLuint viewSpaceZPShaderHandle = m_SSAOViewSpaceZProgram->GetHandle();
|
||||||
GLuint SSAOShaderHandle = m_SSAOProgram->GetHandle();
|
GLuint SSAOShaderHandle = m_SSAOProgram->GetHandle();
|
||||||
@@ -195,7 +98,6 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
|||||||
(-1.0f),
|
(-1.0f),
|
||||||
(+1.0f)
|
(+1.0f)
|
||||||
);*/
|
);*/
|
||||||
glViewport(0, 0, (m_Renderer->GetViewportSize().Width >> m_TextureQuality), (m_Renderer->GetViewportSize().Height >> m_TextureQuality)); //JOHAN TODO: Get this into state
|
|
||||||
glUniform3fv(glGetUniformLocation(viewSpaceZPShaderHandle, "ClipInfo"), 1, glm::value_ptr(clipInfo));
|
glUniform3fv(glGetUniformLocation(viewSpaceZPShaderHandle, "ClipInfo"), 1, glm::value_ptr(clipInfo));
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
glBindVertexArray(m_ScreenQuad->VAO);
|
||||||
@@ -205,9 +107,9 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
|||||||
|
|
||||||
glm::vec4 projInfo = glm::vec4(
|
glm::vec4 projInfo = glm::vec4(
|
||||||
((1.0 - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]),
|
((1.0 - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]),
|
||||||
(-2.0 / ((m_Renderer->GetViewportSize().Width >> m_TextureQuality) * camera->ProjectionMatrix()[0][0])),
|
(-2.0 / (m_Renderer->GetViewportSize().Width * camera->ProjectionMatrix()[0][0])),
|
||||||
((1.0 + camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]),
|
((1.0 + camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]),
|
||||||
(-2.0 / ((m_Renderer->GetViewportSize().Height >> m_TextureQuality) * camera->ProjectionMatrix()[1][1]))
|
(-2.0 / (m_Renderer->GetViewportSize().Height * camera->ProjectionMatrix()[1][1]))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -218,76 +120,26 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
|||||||
glBindTexture(GL_TEXTURE_2D, m_SSAOViewSpaceZTexture);
|
glBindTexture(GL_TEXTURE_2D, m_SSAOViewSpaceZTexture);
|
||||||
|
|
||||||
// How many pixel there are in a 1m long object 1m away from the camera
|
// How many pixel there are in a 1m long object 1m away from the camera
|
||||||
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uProjScale"), (m_Renderer->GetViewportSize().Height >> m_TextureQuality) / (-2.0f * glm::tan(camera->FOV() * 0.5f)));
|
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uProjScale"), m_Renderer->GetViewportSize().Height / (-2.0f * glm::tan(camera->FOV() * 0.5f)));
|
||||||
|
|
||||||
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uRadius"), m_Radius);
|
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uRadius"), m_Radius);
|
||||||
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uBias"), m_Bias);
|
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uBias"), m_Bias);
|
||||||
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uContrast"), m_Contrast);
|
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uContrast"), m_Contrast);
|
||||||
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uIntensityScale"), m_IntensityScale);
|
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uIntensityScale"), m_IntensityScale);
|
||||||
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfSamples"), m_NumOfSamples);
|
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfSamples"), m_NumOfSamples);
|
||||||
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfTurns"), m_NumOfTurns);
|
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfTurns"), m_NumOfTurns);;
|
||||||
|
|
||||||
glUniform4fv(glGetUniformLocation(SSAOShaderHandle, "uProjInfo"), 1, glm::value_ptr(projInfo));
|
glUniform4fv(glGetUniformLocation(SSAOShaderHandle, "uProjInfo"), 1, glm::value_ptr(projInfo));
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
|
|
||||||
DrawBloomPassState BloomState;
|
m_DrawBloomPass->ClearBuffer();
|
||||||
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
|
m_DrawBloomPass->Draw(m_SSAOTexture);
|
||||||
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
|
|
||||||
|
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
|
||||||
m_GaussianProgram_horiz->Bind();
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_SSAOTexture);
|
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
|
||||||
//Iterate some times to make it more gaussian.
|
|
||||||
for (int i = 1; i < m_Iterations; i++) {
|
|
||||||
//Vertical pass
|
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
|
||||||
m_GaussianProgram_vert->Bind();
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
|
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
|
||||||
//horizontal pass
|
|
||||||
|
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
|
||||||
m_GaussianProgram_horiz->Bind();
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert);
|
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
//final vertical gaussian after the iterations are done
|
|
||||||
|
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
|
||||||
m_GaussianProgram_vert->Bind();
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
|
||||||
|
|
||||||
glViewport(0, 0, (m_Renderer->GetViewportSize().Width), (m_Renderer->GetViewportSize().Height));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSAOPass::OnWindowResize() {
|
void SSAOPass::OnWindowResize() {
|
||||||
if (m_Quality == 0) {
|
m_DrawBloomPass->OnWindowResize();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeTexture();
|
InitializeTexture();
|
||||||
|
m_SSAOFramBuffer.Generate();
|
||||||
|
m_SSAOViewSpaceZFramBuffer.Generate();
|
||||||
}
|
}
|
||||||
+1
-1
@@ -54,7 +54,7 @@ Game::Game(int argc, char* argv[])
|
|||||||
m_EventBroker = new EventBroker();
|
m_EventBroker = new EventBroker();
|
||||||
|
|
||||||
// Create the renderer
|
// Create the renderer
|
||||||
m_Renderer = new Renderer(m_EventBroker, m_Config);
|
m_Renderer = new Renderer(m_EventBroker);
|
||||||
m_Renderer->SetFullscreen(m_Config->Get<bool>("Video.Fullscreen", false));
|
m_Renderer->SetFullscreen(m_Config->Get<bool>("Video.Fullscreen", false));
|
||||||
m_Renderer->SetVSYNC(m_Config->Get<bool>("Video.VSYNC", false));
|
m_Renderer->SetVSYNC(m_Config->Get<bool>("Video.VSYNC", false));
|
||||||
m_Renderer->SetResolution(Rectangle::Rectangle(
|
m_Renderer->SetResolution(Rectangle::Rectangle(
|
||||||
|
|||||||
@@ -4,18 +4,20 @@ AmmoPickupSystem::AmmoPickupSystem(SystemParams params)
|
|||||||
: System(params)
|
: System(params)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch);
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &AmmoPickupSystem::OnTriggerLeave);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AmmoPickupSystem::Update(double dt)
|
void AmmoPickupSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it)
|
for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it)
|
||||||
{
|
{
|
||||||
auto& ammoPickupPosition = *it;
|
auto& somePickup = *it;
|
||||||
|
|
||||||
//set the double timer value (value 3)
|
//set the double timer value (value 3)
|
||||||
ammoPickupPosition.DecreaseThisRespawnTimer -= dt;
|
somePickup.DecreaseThisRespawnTimer -= dt;
|
||||||
if (ammoPickupPosition.DecreaseThisRespawnTimer < 0.0) {
|
if (somePickup.DecreaseThisRespawnTimer < 0.0) {
|
||||||
//spawn and delete the vector item
|
//spawn and delete the vector item
|
||||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/AmmoPickup.xml");
|
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/" + somePickup.isAmmoPickup ? "AmmoPickup.xml" : "HealthPickup.xml");
|
||||||
EntityFileParser parser(entityFile);
|
EntityFileParser parser(entityFile);
|
||||||
EntityID ammoPickupID = parser.MergeEntities(m_World);
|
EntityID ammoPickupID = parser.MergeEntities(m_World);
|
||||||
|
|
||||||
@@ -25,17 +27,34 @@ void AmmoPickupSystem::Update(double dt)
|
|||||||
m_EventBroker->Publish(ePickupSpawned);
|
m_EventBroker->Publish(ePickupSpawned);
|
||||||
|
|
||||||
//set values from the old entity to the new entity
|
//set values from the old entity to the new entity
|
||||||
auto& newAmmoPickupEntity = EntityWrapper(m_World, ammoPickupID);
|
auto& newPickupEntity = EntityWrapper(m_World, ammoPickupID);
|
||||||
newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos;
|
newPickupEntity["Transform"]["Position"] = somePickup.Pos;
|
||||||
newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain;
|
if (somePickup.isAmmoPickup) {
|
||||||
newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer;
|
newPickupEntity["AmmoPickup"]["AmmoGain"] = somePickup.AmmoGain;
|
||||||
m_World->SetParent(newAmmoPickupEntity.ID, ammoPickupPosition.parentID);
|
newPickupEntity["AmmoPickup"]["RespawnTimer"] = somePickup.RespawnTimer;
|
||||||
|
} else {
|
||||||
|
newPickupEntity["HealthPickup"]["HealthGain"] = somePickup.AmmoGain;
|
||||||
|
newPickupEntity["HealthPickup"]["RespawnTimer"] = somePickup.RespawnTimer;
|
||||||
|
}
|
||||||
|
m_World->SetParent(newPickupEntity.ID, somePickup.parentID);
|
||||||
|
|
||||||
//erase the current element (AmmoPickupPosition)
|
//erase the current element (somePickup)
|
||||||
m_ETriggerTouchVector.erase(it);
|
m_ETriggerTouchVector.erase(it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//still touching AmmoPickupAtMaxHealthAmmo?
|
||||||
|
for (auto& it = m_PickupAtMaximum.begin(); it != m_PickupAtMaximum.end(); ++it) {
|
||||||
|
if (!it->player.Valid() || !it->pickup.Valid()) {
|
||||||
|
m_PickupAtMaximum.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((int)it->player["AssaultWeapon"]["Ammo"] < (int)it->player["AssaultWeapon"]["MaxAmmo"]) {
|
||||||
|
DoPickup(it->player, it->pickup);
|
||||||
|
m_PickupAtMaximum.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -44,36 +63,59 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e)
|
|||||||
if (e.Entity != LocalPlayer) {
|
if (e.Entity != LocalPlayer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!e.Trigger.HasComponent("AmmoPickup") && !e.Trigger.HasComponent("HealthPickup")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//TODO: add other weapontypes
|
//TODO: add other weapontypes
|
||||||
if (!e.Entity.HasComponent("AssaultWeapon")) {
|
if (!e.Entity.HasComponent("AssaultWeapon")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!e.Trigger.HasComponent("AmmoPickup")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int maxWeaponAmmo = (int)e.Entity["AssaultWeapon"]["MaxAmmo"];
|
int maxWeaponAmmo = (int)e.Entity["AssaultWeapon"]["MaxAmmo"];
|
||||||
int& currentAmmo = (int)e.Entity["AssaultWeapon"]["Ammo"];
|
int& currentAmmo = (int)e.Entity["AssaultWeapon"]["Ammo"];
|
||||||
|
|
||||||
int ammoGiven = 0.01*(double)e.Trigger["AmmoPickup"]["AmmoGain"] * maxWeaponAmmo;
|
|
||||||
//cant pick up ammopacks if you are already at MaxAmmo
|
//cant pick up ammopacks if you are already at MaxAmmo
|
||||||
if (currentAmmo >= maxWeaponAmmo) {
|
if (currentAmmo >= maxWeaponAmmo) {
|
||||||
|
m_PickupAtMaximum.push_back({ e.Entity, e.Trigger });
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
DoPickup(e.Entity, e.Trigger);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//personEntered = e.Entity, thingEntered = e.Trigger
|
bool AmmoPickupSystem::OnTriggerLeave(Events::TriggerLeave& e) {
|
||||||
|
//triggerleave erases possible AmmoPickupAtMaxHealthAmmo
|
||||||
|
for (auto& it = m_PickupAtMaximum.begin(); it != m_PickupAtMaximum.end(); ++it) {
|
||||||
|
if (it->pickup.ID == e.Trigger.ID && it->player.ID == e.Entity.ID) {
|
||||||
|
m_PickupAtMaximum.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void AmmoPickupSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) {
|
||||||
|
auto& weaponEntity = player["AssaultWeapon"];
|
||||||
|
auto& pickup = trigger["AmmoPickup"];
|
||||||
|
auto& gain = pickup["AmmoGain"];
|
||||||
|
int maxValue = (int)weaponEntity["MaxAmmo"];
|
||||||
|
int& currentValue = (int)weaponEntity["Ammo"];
|
||||||
|
|
||||||
|
//cant pick up if you are already at max
|
||||||
|
if (currentValue >= maxValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int increaseGiven = 0.01*(double)gain * maxValue;
|
||||||
Events::AmmoPickup ePlayerAmmoPickup;
|
Events::AmmoPickup ePlayerAmmoPickup;
|
||||||
ePlayerAmmoPickup.AmmoGain = ammoGiven;
|
ePlayerAmmoPickup.AmmoGain = increaseGiven;
|
||||||
ePlayerAmmoPickup.Player = e.Entity;
|
ePlayerAmmoPickup.Player = player;
|
||||||
m_EventBroker->Publish(ePlayerAmmoPickup);
|
m_EventBroker->Publish(ePlayerAmmoPickup);
|
||||||
//immediately give the player the ammo
|
//immediately give the player the ammo
|
||||||
currentAmmo = std::min(currentAmmo + ammoGiven, maxWeaponAmmo);
|
currentValue = std::min(currentValue + increaseGiven, maxValue);
|
||||||
|
|
||||||
//copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object)
|
//copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object)
|
||||||
//we need to copy all values since each value can be different for each ammoPickup
|
//we need to copy all values since each value can be different for each ammoPickup
|
||||||
m_ETriggerTouchVector.push_back({ e.Trigger["Transform"]["Position"], e.Trigger["AmmoPickup"]["AmmoGain"],
|
m_ETriggerTouchVector.push_back({ trigger["Transform"]["Position"], gain,
|
||||||
e.Trigger["AmmoPickup"]["RespawnTimer"], e.Trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
|
pickup["RespawnTimer"], pickup["RespawnTimer"], m_World->GetParent(trigger.ID) , true });
|
||||||
|
|
||||||
//delete the ammopickup
|
//delete the ammopickup
|
||||||
m_World->DeleteEntity(e.Trigger.ID);
|
m_World->DeleteEntity(trigger.ID);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,9 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
|||||||
, PureSystem("CapturePoint")
|
, PureSystem("CapturePoint")
|
||||||
{
|
{
|
||||||
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
||||||
if (!IsClient) {
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,9 +16,6 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
|||||||
//NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt
|
//NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt
|
||||||
void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt)
|
void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt)
|
||||||
{
|
{
|
||||||
if (IsClient) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_WinnerWasFound) {
|
if (m_WinnerWasFound) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -156,12 +151,12 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
int currentTeam = 0;
|
int currentTeam = 0;
|
||||||
bool canCapture = false;
|
bool canCapture = false;
|
||||||
if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside == 0) {
|
if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside == 0) {
|
||||||
timerDeltaChange = redTeamPlayersStandingInside*dt;
|
timerDeltaChange = 3*redTeamPlayersStandingInside*dt;
|
||||||
currentTeam = redTeam;
|
currentTeam = redTeam;
|
||||||
canCapture = nextPossibleCapturePoint["Red"] == capturePointNumber;
|
canCapture = nextPossibleCapturePoint["Red"] == capturePointNumber;
|
||||||
}
|
}
|
||||||
if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside > 0) {
|
if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside > 0) {
|
||||||
timerDeltaChange = -blueTeamPlayersStandingInside*dt;
|
timerDeltaChange = -3*blueTeamPlayersStandingInside*dt;
|
||||||
currentTeam = blueTeam;
|
currentTeam = blueTeam;
|
||||||
canCapture = nextPossibleCapturePoint["Blue"] == capturePointNumber;
|
canCapture = nextPossibleCapturePoint["Blue"] == capturePointNumber;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,16 +14,35 @@ HealthSystem::HealthSystem(SystemParams params)
|
|||||||
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cHealth, double dt)
|
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cHealth, double dt)
|
||||||
{
|
{
|
||||||
double& health = cHealth["Health"];
|
double& health = cHealth["Health"];
|
||||||
if (health <= 0.0) {
|
int healthInt = (int)health;
|
||||||
|
//update struct
|
||||||
|
for (auto& iter = m_DeadPlayers.begin(); iter < m_DeadPlayers.end(); iter++)
|
||||||
|
{
|
||||||
|
iter->timeSinceDeath += dt;
|
||||||
|
if (iter->timeSinceDeath > 2.0f || !iter->playerEntity.Valid()) {
|
||||||
|
m_DeadPlayers.erase(iter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (healthInt <= 0) {
|
||||||
|
for (auto deadPlayer : m_DeadPlayers)
|
||||||
|
{
|
||||||
|
if (deadPlayer.playerEntity.ID == entity.ID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG_INFO("-> health <= 0");
|
||||||
Events::PlayerDeath ePlayerDeath;
|
Events::PlayerDeath ePlayerDeath;
|
||||||
ePlayerDeath.Player = entity;
|
ePlayerDeath.Player = entity;
|
||||||
m_EventBroker->Publish(ePlayerDeath);
|
m_EventBroker->Publish(ePlayerDeath);
|
||||||
|
m_DeadPlayers.emplace_back(entity);
|
||||||
//Note: we will delete the entity in PlayerDeathSystem
|
//Note: we will delete the entity in PlayerDeathSystem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
|
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
|
||||||
{
|
{
|
||||||
|
LOG_INFO("<- on player damage");
|
||||||
if (!IsServer && m_NetworkEnabled || !e.Victim.Valid()) {
|
if (!IsServer && m_NetworkEnabled || !e.Victim.Valid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -31,6 +50,7 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
|
|||||||
ComponentWrapper cHealth = e.Victim["Health"];
|
ComponentWrapper cHealth = e.Victim["Health"];
|
||||||
double& health = cHealth["Health"];
|
double& health = cHealth["Health"];
|
||||||
health -= e.Damage;
|
health -= e.Damage;
|
||||||
|
LOG_INFO("-> health onplayerdam");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,9 +54,13 @@ void KillFeedSystem::Update(double dt)
|
|||||||
|
|
||||||
bool KillFeedSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
bool KillFeedSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
||||||
{
|
{
|
||||||
|
LOG_INFO("<- killfeed death");
|
||||||
|
|
||||||
KillFeedInfo kfInfo;
|
KillFeedInfo kfInfo;
|
||||||
|
|
||||||
if (e.Player.HasComponent("Team")) {
|
if (e.Player.HasComponent("Team")) {
|
||||||
|
LOG_INFO("- killfeed death");
|
||||||
|
|
||||||
int red = e.Player["Team"].Enum("Team", "Red");
|
int red = e.Player["Team"].Enum("Team", "Red");
|
||||||
int blue = e.Player["Team"].Enum("Team", "Blue");
|
int blue = e.Player["Team"].Enum("Team", "Blue");
|
||||||
|
|
||||||
@@ -70,6 +74,7 @@ bool KillFeedSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
|||||||
m_DeathQueue.push_back(kfInfo);
|
m_DeathQueue.push_back(kfInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOG_INFO("-> killfeed death");
|
||||||
|
|
||||||
|
|
||||||
if(m_DeathQueue.size() > 3) {
|
if(m_DeathQueue.size() > 3) {
|
||||||
|
|||||||
@@ -8,18 +8,27 @@ PlayerDeathSystem::PlayerDeathSystem(SystemParams params)
|
|||||||
|
|
||||||
void PlayerDeathSystem::Update(double dt)
|
void PlayerDeathSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerDeathSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
bool PlayerDeathSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
||||||
{
|
{
|
||||||
|
LOG_INFO("<- deathsystem: valid player");
|
||||||
|
|
||||||
if (!e.Player.Valid()) {
|
if (!e.Player.Valid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
LOG_INFO("-> deathsystem: valid player");
|
||||||
|
|
||||||
|
LOG_INFO("<- create effect");
|
||||||
|
|
||||||
createDeathEffect(e.Player);
|
createDeathEffect(e.Player);
|
||||||
|
|
||||||
// Delete player
|
LOG_INFO("-> create effect");
|
||||||
m_World->DeleteEntity(e.Player.ID);
|
|
||||||
|
if (!IsClient || !ResourceManager::Load<ConfigFile>("Config.ini")->Get("Networking.StartNetwork", false)) {
|
||||||
|
m_World->DeleteEntity(e.Player.ID);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -32,6 +41,8 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
|
|||||||
EntityID deathEffectID = parser.MergeEntities(m_World);
|
EntityID deathEffectID = parser.MergeEntities(m_World);
|
||||||
EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID);
|
EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID);
|
||||||
|
|
||||||
|
LOG_INFO("<- effect camera");
|
||||||
|
|
||||||
//components that we need from player
|
//components that we need from player
|
||||||
auto playerModel = player.FirstChildByName("PlayerModel");
|
auto playerModel = player.FirstChildByName("PlayerModel");
|
||||||
if (!playerModel.Valid()) {
|
if (!playerModel.Valid()) {
|
||||||
@@ -42,6 +53,7 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
|
|||||||
}
|
}
|
||||||
auto playerEntityModel = playerModel["Model"];
|
auto playerEntityModel = playerModel["Model"];
|
||||||
auto playerEntityAnimation = playerModel["Animation"];
|
auto playerEntityAnimation = playerModel["Animation"];
|
||||||
|
LOG_INFO("-> effect camera");
|
||||||
|
|
||||||
//copy the data from player to explosioneffectmodel
|
//copy the data from player to explosioneffectmodel
|
||||||
playerEntityModel.Copy(deathEffectEW["Model"]);
|
playerEntityModel.Copy(deathEffectEW["Model"]);
|
||||||
@@ -57,11 +69,15 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
|
|||||||
//effect,camera is relative to playersPosition
|
//effect,camera is relative to playersPosition
|
||||||
//deathEffectEW["ExplosionEffect"]["ExplosionOrigin"] = glm::vec3(0, 0, 0);
|
//deathEffectEW["ExplosionEffect"]["ExplosionOrigin"] = glm::vec3(0, 0, 0);
|
||||||
|
|
||||||
|
LOG_INFO("<- localplayer");
|
||||||
//camera (with lifetime) behind the player
|
//camera (with lifetime) behind the player
|
||||||
if (player == LocalPlayer) {
|
if (player == LocalPlayer) {
|
||||||
auto cam = deathEffectEW.FirstChildByName("Camera");
|
auto cam = deathEffectEW.FirstChildByName("Camera");
|
||||||
Events::SetCamera eSetCamera;
|
Events::SetCamera eSetCamera;
|
||||||
eSetCamera.CameraEntity = cam;
|
eSetCamera.CameraEntity = cam;
|
||||||
m_EventBroker->Publish(eSetCamera);
|
m_EventBroker->Publish(eSetCamera);
|
||||||
|
LOG_INFO("in localplayer");
|
||||||
}
|
}
|
||||||
|
LOG_INFO("-> localplayer");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ PlayerMovementSystem::PlayerMovementSystem(SystemParams params)
|
|||||||
: System(params)
|
: System(params)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerMovementSystem::~PlayerMovementSystem()
|
PlayerMovementSystem::~PlayerMovementSystem()
|
||||||
@@ -37,6 +36,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
|||||||
if (!player.Valid()) {
|
if (!player.Valid()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aim pitch
|
// Aim pitch
|
||||||
EntityWrapper cameraEntity = player.FirstChildByName("Camera");
|
EntityWrapper cameraEntity = player.FirstChildByName("Camera");
|
||||||
if (cameraEntity.Valid()) {
|
if (cameraEntity.Valid()) {
|
||||||
@@ -122,14 +122,15 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
|||||||
if (isOnGround) {
|
if (isOnGround) {
|
||||||
controller->SetDoubleJumping(false);
|
controller->SetDoubleJumping(false);
|
||||||
} else {
|
} else {
|
||||||
// If IsServer and network is off this will not work
|
|
||||||
if (IsClient) {
|
if (IsClient) {
|
||||||
//put a hexagon at the players feet
|
//put a hexagon at the players feet
|
||||||
spawnHexagon(player);
|
auto hexagonEffect = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml");
|
||||||
|
EntityFileParser parser(hexagonEffect);
|
||||||
|
EntityID hexagonEffectID = parser.MergeEntities(m_World);
|
||||||
|
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
|
||||||
|
hexagonEW["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"];
|
||||||
controller->SetDoubleJumping(true);
|
controller->SetDoubleJumping(true);
|
||||||
// Publish event for client to listen to
|
|
||||||
Events::DoubleJump e;
|
Events::DoubleJump e;
|
||||||
e.entityID = player.ID;
|
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -294,26 +295,3 @@ bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e)
|
|
||||||
{
|
|
||||||
// If entity does not exist, exit
|
|
||||||
if (!EntityWrapper(m_World, e.entityID).Valid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// If entity IsLocalPlayer, exit
|
|
||||||
if (e.entityID == m_LocalPlayer.ID) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
spawnHexagon(EntityWrapper(m_World, e.entityID));
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerMovementSystem::spawnHexagon(EntityWrapper target)
|
|
||||||
{
|
|
||||||
//put a hexagon at the entitys... feet?
|
|
||||||
auto hexagonEffect = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml");
|
|
||||||
EntityFileParser parser(hexagonEffect);
|
|
||||||
EntityID hexagonEffectID = parser.MergeEntities(m_World);
|
|
||||||
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
|
|
||||||
hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"];
|
|
||||||
}
|
|
||||||
@@ -15,6 +15,11 @@ PlayerSpawnSystem::PlayerSpawnSystem(SystemParams params)
|
|||||||
|
|
||||||
void PlayerSpawnSystem::Update(double dt)
|
void PlayerSpawnSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
|
CheckForLatePlayers(dt);
|
||||||
|
for (auto& spawnReqs : m_SpawnRequests)
|
||||||
|
{
|
||||||
|
spawnReqs.timeSinceDeath += dt;
|
||||||
|
}
|
||||||
//Increase timer.
|
//Increase timer.
|
||||||
m_Timer += dt;
|
m_Timer += dt;
|
||||||
if (m_Timer < m_RespawnTime) {
|
if (m_Timer < m_RespawnTime) {
|
||||||
@@ -35,6 +40,10 @@ void PlayerSpawnSystem::Update(double dt)
|
|||||||
|
|
||||||
int numSpawnedPlayers = 0;
|
int numSpawnedPlayers = 0;
|
||||||
for (auto& req : m_SpawnRequests) {
|
for (auto& req : m_SpawnRequests) {
|
||||||
|
if (req.timeSinceDeath < 2.5f) {
|
||||||
|
m_LatePlayersVector.push_back(req);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (auto& cPlayerSpawn : *playerSpawns) {
|
for (auto& cPlayerSpawn : *playerSpawns) {
|
||||||
EntityWrapper spawner(m_World, cPlayerSpawn.EntityID);
|
EntityWrapper spawner(m_World, cPlayerSpawn.EntityID);
|
||||||
if (!spawner.HasComponent("Spawner")) {
|
if (!spawner.HasComponent("Spawner")) {
|
||||||
@@ -111,6 +120,8 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e)
|
|||||||
SpawnRequest req;
|
SpawnRequest req;
|
||||||
req.PlayerID = e.PlayerID;
|
req.PlayerID = e.PlayerID;
|
||||||
req.Team = (ComponentInfo::EnumType)e.Value;
|
req.Team = (ComponentInfo::EnumType)e.Value;
|
||||||
|
//set timeSinceDeath > 2.5f since we are force-spawning
|
||||||
|
req.timeSinceDeath = 3.0f;
|
||||||
m_SpawnRequests.push_back(req);
|
m_SpawnRequests.push_back(req);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -134,7 +145,7 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
|||||||
playerName["Text"]["Content"] = e.PlayerName;
|
playerName["Text"]["Content"] = e.PlayerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsClient) {
|
if (m_NetworkEnabled && !IsClient) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +175,8 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
|||||||
|
|
||||||
bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
||||||
{
|
{
|
||||||
|
LOG_INFO("<- spawnsystem death");
|
||||||
|
|
||||||
//Only spawn request if network is disabled or we are server.
|
//Only spawn request if network is disabled or we are server.
|
||||||
if (!IsServer && m_NetworkEnabled) {
|
if (!IsServer && m_NetworkEnabled) {
|
||||||
return false;
|
return false;
|
||||||
@@ -177,6 +190,8 @@ bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_INFO("- spawnsystem death");
|
||||||
|
|
||||||
if (m_PlayerIDs.count(e.Player.ID) == 0) {
|
if (m_PlayerIDs.count(e.Player.ID) == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -184,7 +199,52 @@ bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
|||||||
SpawnRequest req;
|
SpawnRequest req;
|
||||||
req.PlayerID = m_PlayerIDs.at(e.Player.ID);
|
req.PlayerID = m_PlayerIDs.at(e.Player.ID);
|
||||||
req.Team = cTeam["Team"];
|
req.Team = cTeam["Team"];
|
||||||
|
req.timeSinceDeath = 0.0f;
|
||||||
m_SpawnRequests.push_back(req);
|
m_SpawnRequests.push_back(req);
|
||||||
|
LOG_INFO("-> spawnsystem death");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
void PlayerSpawnSystem::CheckForLatePlayers(double dt) {
|
||||||
|
for (size_t i = 0; i < m_LatePlayersVector.size(); i++)
|
||||||
|
{
|
||||||
|
auto& req = m_LatePlayersVector[i];
|
||||||
|
req.timeSinceDeath += dt;
|
||||||
|
if (req.timeSinceDeath > 2.5f) {
|
||||||
|
//good but, this will only spawn them in the next cycle - i.e. not immediately
|
||||||
|
//m_SpawnRequests.push_back(spawnReq);
|
||||||
|
|
||||||
|
//insta spawn
|
||||||
|
auto playerSpawns = m_World->GetComponents("PlayerSpawn");
|
||||||
|
for (auto& cPlayerSpawn : *playerSpawns) {
|
||||||
|
EntityWrapper spawner(m_World, cPlayerSpawn.EntityID);
|
||||||
|
if (!spawner.HasComponent("Spawner")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the spawner has a team affiliation, check it
|
||||||
|
if (spawner.HasComponent("Team")) {
|
||||||
|
if ((int)spawner["Team"]["Team"] != req.Team) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn the player!
|
||||||
|
EntityWrapper player = SpawnerSystem::Spawn(spawner, EntityWrapper::Invalid, "Player");
|
||||||
|
// Set the player team affiliation
|
||||||
|
player["Team"]["Team"] = req.Team;
|
||||||
|
|
||||||
|
// Publish a PlayerSpawned event
|
||||||
|
Events::PlayerSpawned e;
|
||||||
|
e.PlayerID = req.PlayerID;
|
||||||
|
e.Player = player;
|
||||||
|
e.Spawner = spawner;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//end insta spawn
|
||||||
|
m_LatePlayersVector.erase(m_LatePlayersVector.begin() + i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -386,7 +386,7 @@ bool AssaultWeaponBehaviour::shoot(double damage)
|
|||||||
|
|
||||||
// Check for friendly fire
|
// Check for friendly fire
|
||||||
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) {
|
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) {
|
||||||
return false;
|
damage = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deal damage!
|
// Deal damage!
|
||||||
|
|||||||
Reference in New Issue
Block a user