Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bdcb33d992 | |||
| f26b24ef6b | |||
| b0e9cd3965 | |||
| 5e747f53db | |||
| 3a213be679 | |||
| 4e6ff16e58 |
@@ -19,7 +19,6 @@ public:
|
||||
virtual const glm::vec3 Rotation() const { return m_Rotation; }
|
||||
virtual bool Jumping() const { return m_Jumping; }
|
||||
virtual bool Crouching() const { return m_Crouching; }
|
||||
virtual bool CrouchingLastFrame() const { return m_CrouchingLastFrame; }
|
||||
virtual bool DoubleJumping() const { return m_DoubleJumping; }
|
||||
virtual void SetDoubleJumping(bool isDoubleJumping) {
|
||||
m_DoubleJumping = isDoubleJumping;
|
||||
@@ -45,7 +44,6 @@ protected:
|
||||
bool m_Jumping = false;
|
||||
bool m_DoubleJumping = false;
|
||||
bool m_Crouching = false;
|
||||
bool m_CrouchingLastFrame = false;
|
||||
//assault dash membervariables - needed to calculate the doubletap- and dashlogic
|
||||
double m_AssaultDashDoubleTapDeltaTime = 0.0;
|
||||
//i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable),
|
||||
@@ -84,7 +82,6 @@ void FirstPersonInputController<EventContext>::Reset()
|
||||
{
|
||||
m_Rotation = glm::vec3(0.f, 0.f, 0.f);
|
||||
m_Jumping = false;
|
||||
m_CrouchingLastFrame = m_Crouching;
|
||||
}
|
||||
|
||||
template <typename EventContext>
|
||||
|
||||
@@ -63,7 +63,8 @@ private:
|
||||
|
||||
GLuint m_DepthMap;
|
||||
FrameBuffer m_DepthBuffer;
|
||||
ShaderProgram* m_ShadowProgram;
|
||||
ShaderProgram* m_ShadowProgram;
|
||||
ShaderProgram* m_ShadowProgramSkinned;
|
||||
|
||||
std::array<glm::mat4, MAX_SPLITS> m_LightProjection;
|
||||
std::array<glm::mat4, MAX_SPLITS> m_LightView;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
#include "Network/EPlayerDisconnected.h"
|
||||
|
||||
class SpectatorCameraSystem : public ImpureSystem
|
||||
{
|
||||
@@ -17,6 +18,8 @@ private:
|
||||
|
||||
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
|
||||
bool OnInputCommand(const Events::InputCommand& e);
|
||||
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
|
||||
bool OnDisconnect(const Events::PlayerDisconnected& e);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -29,4 +29,6 @@ K=TakeDamage,1500
|
||||
F2=PerformanceTimingResetAllTimers
|
||||
F3=PerformanceTimingCreateExcelData
|
||||
Comma=SwapToClassPick
|
||||
Period=SwapToTeamPick
|
||||
Period=SwapToTeamPick
|
||||
Enter=PickClass,1
|
||||
F5=DisconnectFromServer
|
||||
@@ -0,0 +1,29 @@
|
||||
#version 430
|
||||
|
||||
uniform mat4 M;
|
||||
uniform mat4 V;
|
||||
uniform mat4 P;
|
||||
uniform mat4 Bones[100];
|
||||
|
||||
layout (location = 0) in vec3 Position;
|
||||
layout (location = 4) in vec2 TextureCoords;
|
||||
layout(location = 5) in vec4 BoneIndices;
|
||||
layout(location = 6) in vec4 BoneWeights;
|
||||
|
||||
out VertexData{
|
||||
vec2 TextureCoordinate;
|
||||
}Output;
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 boneTransform = mat4(1);
|
||||
if(BoneWeights[0] > 0.0f){
|
||||
boneTransform = BoneWeights[0] * Bones[int(BoneIndices[0])]
|
||||
+ BoneWeights[1] * Bones[int(BoneIndices[1])]
|
||||
+ BoneWeights[2] * Bones[int(BoneIndices[2])]
|
||||
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
||||
}
|
||||
|
||||
gl_Position = P * V * M * boneTransform * vec4(Position, 1.0);
|
||||
Output.TextureCoordinate = TextureCoords;
|
||||
}
|
||||
@@ -470,7 +470,6 @@ bool AABBvsTriangle(const AABB& box,
|
||||
}
|
||||
|
||||
glm::vec3 cornerResolution = (1+t) * diagonal;
|
||||
cornerResolution = glm::dot(cornerResolution, triNormal) * triNormal;
|
||||
//Overwrite the smallest resolution if cornerResolution is smaller.
|
||||
float lenSq = glm::length2(cornerResolution);
|
||||
if (lenSq < resolveShortest.DistanceSq) {
|
||||
|
||||
@@ -88,11 +88,12 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
||||
glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity);
|
||||
|
||||
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
|
||||
bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end();
|
||||
bool isOnGround = (bool)cPhysics["IsOnGround"];
|
||||
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
|
||||
if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
|
||||
//Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector.
|
||||
(glm::vec3&)cTransform["Position"] += resolutionVector;
|
||||
(glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector;
|
||||
boxA = *Collision::EntityAbsoluteAABB(entity);
|
||||
cPhysics["Velocity"] = inOutVelocity;
|
||||
if (isOnGround) {
|
||||
|
||||
@@ -47,6 +47,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
|
||||
Enable();
|
||||
} else {
|
||||
Disable();
|
||||
m_EventBroker->Publish(Events::UnlockMouse());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Network/Client.h"
|
||||
#include "Network/EPlayerDisconnected.h"
|
||||
using namespace boost::asio::ip;
|
||||
|
||||
Client::Client(World* world, EventBroker* eventBroker)
|
||||
@@ -224,7 +225,7 @@ void Client::parseServerlist(Packet& packet)
|
||||
void Client::parseKick()
|
||||
{
|
||||
LOG_WARNING("You have been kicked from the server.");
|
||||
m_IsConnected = false;
|
||||
disconnect();
|
||||
}
|
||||
|
||||
void Client::parseSpawnEvents()
|
||||
@@ -464,6 +465,10 @@ void Client::disconnect()
|
||||
Packet packet(MessageType::Disconnect, m_SendPacketID);
|
||||
m_Reliable.Send(packet);
|
||||
m_Reliable.Disconnect();
|
||||
Events::PlayerDisconnected e;
|
||||
e.Entity = m_LocalPlayer.ID;
|
||||
e.PlayerID = -1;
|
||||
m_EventBroker->Publish(e);
|
||||
createMainMenu();
|
||||
}
|
||||
|
||||
|
||||
@@ -127,12 +127,12 @@ void AnimationSystem::UpdateAnimations(double dt)
|
||||
void AnimationSystem::UpdateWeights(double dt)
|
||||
{
|
||||
for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) {
|
||||
LOG_INFO("%s", it->first.Name().c_str());
|
||||
it->second.PrintQueue();
|
||||
/* LOG_INFO("%s", it->first.Name().c_str());
|
||||
it->second.PrintQueue();*/
|
||||
|
||||
if(it->second.HasActiveBlendJob()) {
|
||||
AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob();
|
||||
LOG_INFO("%s", blendJob.RootNode.Name().c_str());
|
||||
//LOG_INFO("%s", blendJob.RootNode.Name().c_str());
|
||||
std::shared_ptr<BlendTree> blendTree = it->second.GetBlendTree();
|
||||
if (blendTree != nullptr) {
|
||||
if (blendJob.Duration != 0.0) {
|
||||
|
||||
@@ -219,7 +219,7 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
m_PickingSkinnedProgram->Bind();
|
||||
lastShader = m_PickingSkinnedProgram->GetHandle();
|
||||
}
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||
|
||||
std::vector<glm::mat4> frameBones;
|
||||
|
||||
@@ -156,7 +156,12 @@ void ShadowPass::InitializeShaderPrograms()
|
||||
m_ShadowProgram->BindFragDataLocation(0, "ShadowMap");
|
||||
m_ShadowProgram->Link();
|
||||
|
||||
|
||||
m_ShadowProgramSkinned = ResourceManager::Load<ShaderProgram>("#ShadowProgramSkinned");
|
||||
m_ShadowProgramSkinned->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ShadowSkinned.vert.glsl")));
|
||||
m_ShadowProgramSkinned->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Shadow.frag.glsl")));
|
||||
m_ShadowProgramSkinned->Compile();
|
||||
m_ShadowProgramSkinned->BindFragDataLocation(0, "ShadowMap");
|
||||
m_ShadowProgramSkinned->Link();
|
||||
}
|
||||
|
||||
void ShadowPass::ClearBuffer()
|
||||
@@ -212,8 +217,7 @@ void ShadowPass::Draw(RenderScene & scene)
|
||||
|
||||
ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle());
|
||||
|
||||
m_ShadowProgram->Bind();
|
||||
GLuint shaderHandle = m_ShadowProgram->GetHandle();
|
||||
|
||||
glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight);
|
||||
|
||||
for (int i = 0; i < m_CurrentNrOfSplits; i++) {
|
||||
@@ -221,7 +225,11 @@ void ShadowPass::Draw(RenderScene & scene)
|
||||
|
||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i);
|
||||
|
||||
|
||||
GLuint shaderHandle;
|
||||
|
||||
for (auto &job : scene.Jobs.DirectionalLight) {
|
||||
|
||||
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
|
||||
|
||||
if (directionalLightJob) {
|
||||
@@ -232,9 +240,19 @@ void ShadowPass::Draw(RenderScene & scene)
|
||||
//RadiusToLightspace(m_shadowFrusta[i]);
|
||||
m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[LEFT], m_shadowFrusta[i].LRBT[RIGHT], m_shadowFrusta[i].LRBT[BOTTOM], m_shadowFrusta[i].LRBT[TOP], m_NearFarPlane[NEAR], m_NearFarPlane[FAR]);
|
||||
|
||||
|
||||
m_ShadowProgram->Bind();
|
||||
shaderHandle = m_ShadowProgram->GetHandle();
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i]));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i]));
|
||||
|
||||
m_ShadowProgramSkinned->Bind();
|
||||
shaderHandle = m_ShadowProgramSkinned->GetHandle();
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i]));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i]));
|
||||
|
||||
|
||||
|
||||
GLERROR("ShadowLight ERROR");
|
||||
|
||||
for (auto &objectJob : scene.Jobs.OpaqueObjects) {
|
||||
@@ -245,6 +263,23 @@ void ShadowPass::Draw(RenderScene & scene)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(modelJob->Model->IsSkinned()) {
|
||||
m_ShadowProgramSkinned->Bind();
|
||||
shaderHandle = m_ShadowProgramSkinned->GetHandle();
|
||||
|
||||
std::vector<glm::mat4> frameBones;
|
||||
if (modelJob->BlendTree != nullptr) {
|
||||
frameBones = modelJob->BlendTree->GetFinalPose();
|
||||
} else {
|
||||
frameBones = modelJob->Skeleton->GetTPose();
|
||||
}
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
|
||||
} else {
|
||||
m_ShadowProgram->Bind();
|
||||
shaderHandle = m_ShadowProgram->GetHandle();
|
||||
}
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), 1.f);
|
||||
|
||||
@@ -265,6 +300,23 @@ void ShadowPass::Draw(RenderScene & scene)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (modelJob->Model->IsSkinned()) {
|
||||
m_ShadowProgramSkinned->Bind();
|
||||
shaderHandle = m_ShadowProgramSkinned->GetHandle();
|
||||
|
||||
std::vector<glm::mat4> frameBones;
|
||||
if (modelJob->BlendTree != nullptr) {
|
||||
frameBones = modelJob->BlendTree->GetFinalPose();
|
||||
} else {
|
||||
frameBones = modelJob->Skeleton->GetTPose();
|
||||
}
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
|
||||
} else {
|
||||
m_ShadowProgram->Bind();
|
||||
shaderHandle = m_ShadowProgram->GetHandle();
|
||||
}
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a);
|
||||
|
||||
|
||||
@@ -264,11 +264,6 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
size = glm::vec3(1.f, 1.f, 1.f);
|
||||
} else {
|
||||
size = glm::vec3(1.f, 1.6f, 1.f);
|
||||
if (controller->CrouchingLastFrame() && isOnGround) {
|
||||
// The collision should resolve this anyway, but
|
||||
// this is more reliable, since the box gets larger.
|
||||
((glm::vec3&)cTransform["Position"]).y += 0.3f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ SpectatorCameraSystem::SpectatorCameraSystem(SystemParams params)
|
||||
, m_PickedTeam(-1)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
|
||||
}
|
||||
|
||||
void SpectatorCameraSystem::Update(double dt)
|
||||
@@ -87,4 +88,17 @@ bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool SpectatorCameraSystem::OnDisconnect(const Events::PlayerDisconnected& e)
|
||||
{
|
||||
// If local player gets disconnected, they should be set to
|
||||
// the spectator camera next time a map loads that has one.
|
||||
if (e.Entity == LocalPlayer.ID) {
|
||||
m_CamSetToTeamPick = false;
|
||||
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
|
||||
Events::UnlockMouse unlock;
|
||||
m_EventBroker->Publish(unlock);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user