Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3ab844cc4 | |||
| 03493df213 | |||
| 0869afd529 | |||
| 56a13d03fc | |||
| dad18a200f | |||
| d6e3a47182 | |||
| 038a706e28 | |||
| bdcb33d992 | |||
| 8a8c375d3a | |||
| 8936b3d6c3 | |||
| 8a3564ad49 | |||
| 9581e9ac84 | |||
| 9cc8124847 | |||
| a369c26a28 |
@@ -84,6 +84,18 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix);
|
const glm::mat4& modelMatrix);
|
||||||
|
|
||||||
|
enum Output
|
||||||
|
{
|
||||||
|
OutContained,
|
||||||
|
OutSeparated,
|
||||||
|
OutIntersecting
|
||||||
|
};
|
||||||
|
//Detects intersection and containment.
|
||||||
|
Output AABBvsTrianglesWContainment(const AABB& box,
|
||||||
|
const RawModel::Vertex* modelVertices,
|
||||||
|
const std::vector<unsigned int>& modelIndices,
|
||||||
|
const glm::mat4& modelMatrix);
|
||||||
|
|
||||||
//Return true if the boxes are intersecting.
|
//Return true if the boxes are intersecting.
|
||||||
bool AABBVsAABB(const AABB& a, const AABB& b);
|
bool AABBVsAABB(const AABB& a, const AABB& b);
|
||||||
//Return true if the boxes are intersecting.
|
//Return true if the boxes are intersecting.
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
#include "../GLM.h"
|
#include "../GLM.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "EntityWrapper.h"
|
#include "EntityWrapper.h"
|
||||||
#include "System.h"
|
|
||||||
|
|
||||||
namespace Transform
|
namespace Transform
|
||||||
{
|
{
|
||||||
|
|
||||||
|
glm::mat4 AbsoluteTransformation(EntityWrapper entity);
|
||||||
glm::vec3 AbsolutePosition(EntityWrapper entity);
|
glm::vec3 AbsolutePosition(EntityWrapper entity);
|
||||||
glm::vec3 AbsolutePosition(World* world, EntityID entity);
|
glm::vec3 AbsolutePosition(World* world, EntityID entity);
|
||||||
glm::vec3 AbsoluteOrientationEuler(EntityWrapper entity);
|
glm::vec3 AbsoluteOrientationEuler(EntityWrapper entity);
|
||||||
@@ -20,16 +20,6 @@ glm::mat4 ModelMatrix(EntityWrapper entity);
|
|||||||
glm::mat4 ModelMatrix(EntityID entity, World* world);
|
glm::mat4 ModelMatrix(EntityID entity, World* world);
|
||||||
glm::vec3 TransformPoint(const glm::vec3& point, const glm::mat4& matrix);
|
glm::vec3 TransformPoint(const glm::vec3& point, const glm::mat4& matrix);
|
||||||
|
|
||||||
class ClearCache : public ImpureSystem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ClearCache(SystemParams params)
|
|
||||||
: System(params)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
virtual void Update(double dt) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -47,6 +47,7 @@ private:
|
|||||||
// Utility functions
|
// Utility functions
|
||||||
EntityWrapper importEntity(EntityWrapper parent, boost::filesystem::path filePath);
|
EntityWrapper importEntity(EntityWrapper parent, boost::filesystem::path filePath);
|
||||||
void setWidgetMode(EditorGUI::WidgetMode mode);
|
void setWidgetMode(EditorGUI::WidgetMode mode);
|
||||||
|
bool isAnyParentMissingTransform(EntityID entityID);
|
||||||
|
|
||||||
// GUI callbacks
|
// GUI callbacks
|
||||||
void OnEntitySelected(EntityWrapper entity);
|
void OnEntitySelected(EntityWrapper entity);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public:
|
|||||||
virtual const glm::vec3 Rotation() const { return m_Rotation; }
|
virtual const glm::vec3 Rotation() const { return m_Rotation; }
|
||||||
virtual bool Jumping() const { return m_Jumping; }
|
virtual bool Jumping() const { return m_Jumping; }
|
||||||
virtual bool Crouching() const { return m_Crouching; }
|
virtual bool Crouching() const { return m_Crouching; }
|
||||||
|
virtual bool CrouchingLastFrame() const { return m_CrouchingLastFrame; }
|
||||||
virtual bool DoubleJumping() const { return m_DoubleJumping; }
|
virtual bool DoubleJumping() const { return m_DoubleJumping; }
|
||||||
virtual void SetDoubleJumping(bool isDoubleJumping) {
|
virtual void SetDoubleJumping(bool isDoubleJumping) {
|
||||||
m_DoubleJumping = isDoubleJumping;
|
m_DoubleJumping = isDoubleJumping;
|
||||||
@@ -44,6 +45,7 @@ protected:
|
|||||||
bool m_Jumping = false;
|
bool m_Jumping = false;
|
||||||
bool m_DoubleJumping = false;
|
bool m_DoubleJumping = false;
|
||||||
bool m_Crouching = false;
|
bool m_Crouching = false;
|
||||||
|
bool m_CrouchingLastFrame = false;
|
||||||
//assault dash membervariables - needed to calculate the doubletap- and dashlogic
|
//assault dash membervariables - needed to calculate the doubletap- and dashlogic
|
||||||
double m_AssaultDashDoubleTapDeltaTime = 0.0;
|
double m_AssaultDashDoubleTapDeltaTime = 0.0;
|
||||||
//i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable),
|
//i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable),
|
||||||
@@ -82,6 +84,7 @@ void FirstPersonInputController<EventContext>::Reset()
|
|||||||
{
|
{
|
||||||
m_Rotation = glm::vec3(0.f, 0.f, 0.f);
|
m_Rotation = glm::vec3(0.f, 0.f, 0.f);
|
||||||
m_Jumping = false;
|
m_Jumping = false;
|
||||||
|
m_CrouchingLastFrame = m_Crouching;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename EventContext>
|
template <typename EventContext>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
|
#include "Network/EPlayerDisconnected.h"
|
||||||
|
|
||||||
class SpectatorCameraSystem : public ImpureSystem
|
class SpectatorCameraSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
@@ -17,6 +18,8 @@ private:
|
|||||||
|
|
||||||
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
|
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
|
||||||
bool OnInputCommand(const Events::InputCommand& e);
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
|
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
|
||||||
|
bool OnDisconnect(const Events::PlayerDisconnected& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -29,4 +29,6 @@ K=TakeDamage,1500
|
|||||||
F2=PerformanceTimingResetAllTimers
|
F2=PerformanceTimingResetAllTimers
|
||||||
F3=PerformanceTimingCreateExcelData
|
F3=PerformanceTimingCreateExcelData
|
||||||
Comma=SwapToClassPick
|
Comma=SwapToClassPick
|
||||||
Period=SwapToTeamPick
|
Period=SwapToTeamPick
|
||||||
|
Enter=PickClass,1
|
||||||
|
F5=DisconnectFromServer
|
||||||
@@ -360,7 +360,14 @@ constexpr bool FaceIsGround(float faceNormalY)
|
|||||||
//An array containing 3 int pairs { 0, 2 }, { 0, 1 }, { 1, 2 }
|
//An array containing 3 int pairs { 0, 2 }, { 0, 1 }, { 1, 2 }
|
||||||
constexpr std::array<std::pair<int, int>, 3> dimensionPairs({ std::pair<int, int>(0, 2), std::pair<int, int>(0, 1), std::pair<int, int>(1, 2) });
|
constexpr std::array<std::pair<int, int>, 3> dimensionPairs({ std::pair<int, int>(0, 2), std::pair<int, int>(0, 1), std::pair<int, int>(1, 2) });
|
||||||
|
|
||||||
bool AABBvsTriangle(const AABB& box,
|
enum class BoxTriRes
|
||||||
|
{
|
||||||
|
Front,
|
||||||
|
Behind,
|
||||||
|
Intersect
|
||||||
|
};
|
||||||
|
|
||||||
|
BoxTriRes AABBvsTriangle(const AABB& box,
|
||||||
const std::array<glm::vec3, 3>& triPos,
|
const std::array<glm::vec3, 3>& triPos,
|
||||||
const glm::vec3& originalBoxVelocity,
|
const glm::vec3& originalBoxVelocity,
|
||||||
float verticalStepHeight,
|
float verticalStepHeight,
|
||||||
@@ -374,7 +381,7 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
//Less checks, and we should be able to walk out from models if we are trapped inside.
|
//Less checks, and we should be able to walk out from models if we are trapped inside.
|
||||||
glm::vec3 triNormal = glm::cross(triPos[1] - triPos[0], triPos[2] - triPos[0]);
|
glm::vec3 triNormal = glm::cross(triPos[1] - triPos[0], triPos[2] - triPos[0]);
|
||||||
if (!vectorHasLength(triNormal) || (glm::dot(triNormal, originalBoxVelocity) > 0)) {
|
if (!vectorHasLength(triNormal) || (glm::dot(triNormal, originalBoxVelocity) > 0)) {
|
||||||
return false;
|
return BoxTriRes::Behind;
|
||||||
}
|
}
|
||||||
triNormal = glm::normalize(triNormal);
|
triNormal = glm::normalize(triNormal);
|
||||||
|
|
||||||
@@ -409,6 +416,9 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
const glm::vec3& min = box.MinCorner();
|
const glm::vec3& min = box.MinCorner();
|
||||||
const glm::vec3& max = box.MaxCorner();
|
const glm::vec3& max = box.MaxCorner();
|
||||||
|
|
||||||
|
// If there is no intersection, whether the box center is in front of or behind the triangle.
|
||||||
|
BoxTriRes noIntersection = glm::dot(triNormal, origin - triPos[0]) > 0 ? BoxTriRes::Front : BoxTriRes::Behind;
|
||||||
|
|
||||||
//For each projection in xy-, xz-, and yx-planes.
|
//For each projection in xy-, xz-, and yx-planes.
|
||||||
for (std::pair<int, int> dim : dimensionPairs) {
|
for (std::pair<int, int> dim : dimensionPairs) {
|
||||||
//2D Triangle.
|
//2D Triangle.
|
||||||
@@ -426,7 +436,7 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
bool pushedFromTriangleLine;
|
bool pushedFromTriangleLine;
|
||||||
//if projections don't overlap, return false.
|
//if projections don't overlap, return false.
|
||||||
if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector, resolutionDist, pushedFromTriangleLine)) {
|
if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector, resolutionDist, pushedFromTriangleLine)) {
|
||||||
return false;
|
return noIntersection;
|
||||||
} else if (resolveCollision) {
|
} else if (resolveCollision) {
|
||||||
//Overwrite the smallest resolution if this is smaller.
|
//Overwrite the smallest resolution if this is smaller.
|
||||||
if (resolutionDist < resolveShortest.DistanceSq) {
|
if (resolutionDist < resolveShortest.DistanceSq) {
|
||||||
@@ -462,14 +472,15 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
float t = glm::dot(triNormal, triPos[0] - origin) / glm::dot(triNormal, diagonal);
|
float t = glm::dot(triNormal, triPos[0] - origin) / glm::dot(triNormal, diagonal);
|
||||||
//If intersection point between plane and diagonal is within the box.
|
//If intersection point between plane and diagonal is within the box.
|
||||||
if (glm::abs(t) > 1) {
|
if (glm::abs(t) > 1) {
|
||||||
return false;
|
return noIntersection;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resolveCollision) {
|
if (!resolveCollision) {
|
||||||
return true;
|
return BoxTriRes::Intersect;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 cornerResolution = (1+t) * diagonal;
|
glm::vec3 cornerResolution = (1+t) * diagonal;
|
||||||
|
cornerResolution = glm::dot(cornerResolution, triNormal) * triNormal;
|
||||||
//Overwrite the smallest resolution if cornerResolution is smaller.
|
//Overwrite the smallest resolution if cornerResolution is smaller.
|
||||||
float lenSq = glm::length2(cornerResolution);
|
float lenSq = glm::length2(cornerResolution);
|
||||||
if (lenSq < resolveShortest.DistanceSq) {
|
if (lenSq < resolveShortest.DistanceSq) {
|
||||||
@@ -498,7 +509,7 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
case ResolveDimZ:
|
case ResolveDimZ:
|
||||||
//If we get here, the resolution is along one coordinate axis.
|
//If we get here, the resolution is along one coordinate axis.
|
||||||
//set velocity to 0 in y if it is along y-axis.
|
//set velocity to 0 in y if it is along y-axis.
|
||||||
return true;
|
return BoxTriRes::Intersect;
|
||||||
case Line:
|
case Line:
|
||||||
projNorm = glm::normalize(outResolution);
|
projNorm = glm::normalize(outResolution);
|
||||||
break;
|
break;
|
||||||
@@ -533,10 +544,10 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
boxVelocity = boxVelocity - glm::dot(boxVelocity, projNorm) * projNorm;
|
boxVelocity = boxVelocity - glm::dot(boxVelocity, projNorm) * projNorm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return BoxTriRes::Intersect;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AABBvsTriangles(const AABB& box,
|
Output AABBvsTriangles(const AABB& box,
|
||||||
const RawModel::Vertex* modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix,
|
const glm::mat4& modelMatrix,
|
||||||
@@ -546,8 +557,8 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
glm::vec3& outResolutionVector,
|
glm::vec3& outResolutionVector,
|
||||||
bool resolveCollision)
|
bool resolveCollision)
|
||||||
{
|
{
|
||||||
bool hit = false;
|
bool intersect = false;
|
||||||
|
Output out = Output::OutContained;
|
||||||
bool everHitTheGround = false;
|
bool everHitTheGround = false;
|
||||||
AABB newBox = box;
|
AABB newBox = box;
|
||||||
outResolutionVector = glm::vec3(0.f);
|
outResolutionVector = glm::vec3(0.f);
|
||||||
@@ -560,20 +571,27 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
};
|
};
|
||||||
glm::vec3 outVec;
|
glm::vec3 outVec;
|
||||||
bool collideWithGround = isOnGround;
|
bool collideWithGround = isOnGround;
|
||||||
if (AABBvsTriangle(newBox, triVertices, originalBoxVelocity, verticalStepHeight, collideWithGround, boxVelocity, outVec, resolveCollision)) {
|
switch (AABBvsTriangle(newBox, triVertices, originalBoxVelocity, verticalStepHeight, collideWithGround, boxVelocity, outVec, resolveCollision)) {
|
||||||
hit = true;
|
case Collision::BoxTriRes::Front:
|
||||||
|
out = Output::OutSeparated;
|
||||||
|
break;
|
||||||
|
case Collision::BoxTriRes::Intersect:
|
||||||
|
intersect = true;
|
||||||
outResolutionVector += outVec;
|
outResolutionVector += outVec;
|
||||||
newBox = AABB::FromOriginSize(newBox.Origin() + outVec, newBox.Size());
|
newBox = AABB::FromOriginSize(newBox.Origin() + outVec, newBox.Size());
|
||||||
if (collideWithGround) {
|
if (collideWithGround) {
|
||||||
everHitTheGround = isOnGround = true;
|
everHitTheGround = isOnGround = true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!everHitTheGround) {
|
if (!everHitTheGround) {
|
||||||
isOnGround = false;
|
isOnGround = false;
|
||||||
}
|
}
|
||||||
return hit;
|
return intersect ? Output::OutIntersecting : out;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AABBvsTriangles(const AABB& box,
|
bool AABBvsTriangles(const AABB& box,
|
||||||
@@ -593,13 +611,31 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
verticalStepHeight,
|
verticalStepHeight,
|
||||||
isOnGround,
|
isOnGround,
|
||||||
outResolutionVector,
|
outResolutionVector,
|
||||||
true);
|
true) == Output::OutIntersecting;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AABBvsTriangles(const AABB& box,
|
bool AABBvsTriangles(const AABB& box,
|
||||||
const RawModel::Vertex* modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix)
|
const glm::mat4& modelMatrix)
|
||||||
|
{
|
||||||
|
glm::vec3 vel, outres;
|
||||||
|
bool g;
|
||||||
|
return AABBvsTriangles(box,
|
||||||
|
modelVertices,
|
||||||
|
modelIndices,
|
||||||
|
modelMatrix,
|
||||||
|
vel,
|
||||||
|
0.f,
|
||||||
|
g,
|
||||||
|
outres,
|
||||||
|
false) == Output::OutIntersecting;
|
||||||
|
}
|
||||||
|
|
||||||
|
Output AABBvsTrianglesWContainment(const AABB& box,
|
||||||
|
const RawModel::Vertex* modelVertices,
|
||||||
|
const std::vector<unsigned int>& modelIndices,
|
||||||
|
const glm::mat4& modelMatrix)
|
||||||
{
|
{
|
||||||
glm::vec3 vel, outres;
|
glm::vec3 vel, outres;
|
||||||
bool g;
|
bool g;
|
||||||
@@ -621,7 +657,7 @@ boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity, bool takeM
|
|||||||
ComponentWrapper& cAABB = entity["AABB"];
|
ComponentWrapper& cAABB = entity["AABB"];
|
||||||
modelSpaceBox = EntityAABB::FromOriginSize((glm::vec3)cAABB["Origin"], (glm::vec3)cAABB["Size"]);
|
modelSpaceBox = EntityAABB::FromOriginSize((glm::vec3)cAABB["Origin"], (glm::vec3)cAABB["Size"]);
|
||||||
} else if (entity.HasComponent("Model")) {
|
} else if (entity.HasComponent("Model")) {
|
||||||
const std::string& res = entity["Model"]["Resource"];
|
std::string res = entity["Model"]["Resource"];
|
||||||
if (res.empty()) {
|
if (res.empty()) {
|
||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
@@ -638,7 +674,7 @@ boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity, bool takeM
|
|||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 modelMat = Transform::ModelMatrix(entity);
|
glm::mat4 modelMat = Transform::AbsoluteTransformation(entity);
|
||||||
glm::vec3 mini(INFINITY);
|
glm::vec3 mini(INFINITY);
|
||||||
glm::vec3 maxi(-INFINITY);
|
glm::vec3 maxi(-INFINITY);
|
||||||
glm::vec3 maxCorner = modelSpaceBox.MaxCorner();
|
glm::vec3 maxCorner = modelSpaceBox.MaxCorner();
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
bool hit;
|
bool hit;
|
||||||
float dist;
|
float dist;
|
||||||
if (boxB.Entity.HasComponent("Model")) {
|
if (boxB.Entity.HasComponent("Model")) {
|
||||||
|
if (!((bool)boxB.Entity["Model"]["Visible"])) {
|
||||||
|
// Don't collide against invisible models.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
RawModel* model;
|
RawModel* model;
|
||||||
std::string res = (std::string)boxB.Entity["Model"]["Resource"];
|
std::string res = (std::string)boxB.Entity["Model"]["Resource"];
|
||||||
try {
|
try {
|
||||||
@@ -77,7 +81,11 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) {
|
if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) {
|
||||||
//Here we know boxB is a entity with Collideable, AABB, and Model.
|
// Here we know boxB is a entity with Collideable, AABB, and Model.
|
||||||
|
if (!((bool)boxB.Entity["Model"]["Visible"])) {
|
||||||
|
// Don't collide against invisible models.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
RawModel* model;
|
RawModel* model;
|
||||||
try {
|
try {
|
||||||
model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]);
|
model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]);
|
||||||
@@ -88,12 +96,11 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity);
|
glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity);
|
||||||
|
|
||||||
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
|
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"];
|
bool isOnGround = (bool)cPhysics["IsOnGround"];
|
||||||
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
|
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
|
||||||
if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
|
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.
|
//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"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector;
|
(glm::vec3&)cTransform["Position"] += resolutionVector;
|
||||||
boxA = *Collision::EntityAbsoluteAABB(entity);
|
boxA = *Collision::EntityAbsoluteAABB(entity);
|
||||||
cPhysics["Velocity"] = inOutVelocity;
|
cPhysics["Velocity"] = inOutVelocity;
|
||||||
if (isOnGround) {
|
if (isOnGround) {
|
||||||
|
|||||||
@@ -10,6 +10,16 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RawModel* triggerModel = nullptr;
|
||||||
|
glm::mat4 triggerModelMat;
|
||||||
|
if (triggerEntity.HasComponent("Model")) {
|
||||||
|
try {
|
||||||
|
triggerModel = ResourceManager::Load<RawModel, true>(triggerEntity["Model"]["Resource"]);
|
||||||
|
triggerModelMat = Transform::ModelMatrix(triggerEntity);
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_OctreeOut.clear();
|
m_OctreeOut.clear();
|
||||||
m_Octree->ObjectsInSameRegion(*triggerBox, m_OctreeOut);
|
m_Octree->ObjectsInSameRegion(*triggerBox, m_OctreeOut);
|
||||||
|
|
||||||
@@ -22,7 +32,17 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
|||||||
if (colliderFitsInTrigger) {
|
if (colliderFitsInTrigger) {
|
||||||
completelyInsideBox = AABB::FromOriginSize((*triggerBox).Origin(), (*triggerBox).Size() - 2.0f * colliderBox.Size());
|
completelyInsideBox = AABB::FromOriginSize((*triggerBox).Origin(), (*triggerBox).Size() - 2.0f * colliderBox.Size());
|
||||||
}
|
}
|
||||||
if (colliderFitsInTrigger && Collision::AABBVsAABB(completelyInsideBox, colliderBox)) {
|
|
||||||
|
// We know the entity is inside the trigger box, but perhaps not the model yet.
|
||||||
|
Collision::Output out = triggerModel == nullptr
|
||||||
|
? Collision::Output::OutContained
|
||||||
|
: Collision::AABBvsTrianglesWContainment(
|
||||||
|
colliderBox,
|
||||||
|
triggerModel->Vertices(),
|
||||||
|
triggerModel->m_Indices,
|
||||||
|
triggerModelMat);
|
||||||
|
|
||||||
|
if (colliderFitsInTrigger && Collision::AABBVsAABB(completelyInsideBox, colliderBox) && out == Collision::Output::OutContained) {
|
||||||
// Entity is completely inside the trigger.
|
// Entity is completely inside the trigger.
|
||||||
// If it was only touching before, it is erased.
|
// If it was only touching before, it is erased.
|
||||||
m_EntitiesTouchingTrigger[triggerEntity].erase(colliderEntity);
|
m_EntitiesTouchingTrigger[triggerEntity].erase(colliderEntity);
|
||||||
@@ -32,7 +52,8 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
|||||||
completeSet.insert(colliderEntity);
|
completeSet.insert(colliderEntity);
|
||||||
publish<Events::TriggerEnter>(colliderEntity, triggerEntity);
|
publish<Events::TriggerEnter>(colliderEntity, triggerEntity);
|
||||||
}
|
}
|
||||||
} else {
|
continue;
|
||||||
|
} else if (out != Collision::Output::OutSeparated) {
|
||||||
// Entity is only touching the trigger.
|
// Entity is only touching the trigger.
|
||||||
auto& touchSet = m_EntitiesTouchingTrigger[triggerEntity];
|
auto& touchSet = m_EntitiesTouchingTrigger[triggerEntity];
|
||||||
auto& completeSet = m_EntitiesCompletelyInTrigger[triggerEntity];
|
auto& completeSet = m_EntitiesCompletelyInTrigger[triggerEntity];
|
||||||
@@ -47,17 +68,17 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
|||||||
touchSet.insert(colliderEntity);
|
touchSet.insert(colliderEntity);
|
||||||
}
|
}
|
||||||
// Else, it was touching the trigger last frame too and nothing is done.
|
// Else, it was touching the trigger last frame too and nothing is done.
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Entity is not touching the trigger,
|
|
||||||
// Throw event if it was previously.
|
|
||||||
if (throwLeaveIfWasInTrigger(m_EntitiesTouchingTrigger[triggerEntity], colliderEntity, triggerEntity)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// This only occurs if the entity was completely inside the trigger one frame,
|
|
||||||
// then completely outside the trigger, e.g. when dying and respawning.
|
|
||||||
throwLeaveIfWasInTrigger(m_EntitiesCompletelyInTrigger[triggerEntity], colliderEntity, triggerEntity);
|
|
||||||
}
|
}
|
||||||
|
// Only get here if entity is not touching the trigger,
|
||||||
|
// throw event if it was touching previously.
|
||||||
|
if (throwLeaveIfWasInTrigger(m_EntitiesTouchingTrigger[triggerEntity], colliderEntity, triggerEntity)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// This only occurs if the entity was completely inside the trigger one frame,
|
||||||
|
// then completely outside the trigger, e.g. when dying and respawning.
|
||||||
|
throwLeaveIfWasInTrigger(m_EntitiesCompletelyInTrigger[triggerEntity], colliderEntity, triggerEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
#include "Core/Transform.h"
|
#include "Core/Transform.h"
|
||||||
|
|
||||||
static std::unordered_map<EntityWrapper, glm::mat4> MatrixCache;
|
glm::mat4 Transform::AbsoluteTransformation(EntityWrapper entity)
|
||||||
|
{
|
||||||
|
glm::mat4 t = glm::mat4(1.f);
|
||||||
|
|
||||||
|
while (entity.Valid()) {
|
||||||
|
t = glm::translate((glm::vec3&)entity["Transform"]["Position"]) * glm::toMat4(glm::quat((glm::vec3&)entity["Transform"]["Orientation"])) * glm::scale((glm::vec3&)entity["Transform"]["Scale"]) * t;
|
||||||
|
entity = entity.Parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 Transform::AbsolutePosition(EntityWrapper entity)
|
glm::vec3 Transform::AbsolutePosition(EntityWrapper entity)
|
||||||
{
|
{
|
||||||
@@ -70,36 +80,24 @@ glm::vec3 Transform::AbsoluteScale(World* world, EntityID entity)
|
|||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::mat4 Transform::ModelMatrix(EntityWrapper entity)
|
||||||
|
{
|
||||||
|
return ModelMatrix(entity.ID, entity.World);
|
||||||
|
}
|
||||||
|
|
||||||
glm::mat4 Transform::ModelMatrix(EntityID entity, World* world)
|
glm::mat4 Transform::ModelMatrix(EntityID entity, World* world)
|
||||||
{
|
{
|
||||||
return ModelMatrix(EntityWrapper(world, entity));
|
return AbsoluteTransformation(EntityWrapper(world, entity));
|
||||||
|
|
||||||
|
//glm::vec3 position = Transform::AbsolutePosition(world, entity);
|
||||||
|
//glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
|
||||||
|
//glm::vec3 scale = Transform::AbsoluteScale(world, entity);
|
||||||
|
|
||||||
|
//glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale);
|
||||||
|
//return modelMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 Transform::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
|
glm::vec3 Transform::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
|
||||||
{
|
{
|
||||||
return glm::vec3(matrix * glm::vec4(point.x, point.y, point.z, 1));
|
return glm::vec3(matrix * glm::vec4(point.x, point.y, point.z, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 Transform::ModelMatrix(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
auto cacheIt = MatrixCache.find(entity);
|
|
||||||
if (cacheIt != MatrixCache.end()) {
|
|
||||||
return cacheIt->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
ComponentWrapper cTransform = entity["Transform"];
|
|
||||||
glm::mat4 t = glm::translate((const glm::vec3&)cTransform["Position"]) * glm::toMat4(glm::quat((const glm::vec3&)cTransform["Orientation"])) * glm::scale((const glm::vec3&)cTransform["Scale"]);
|
|
||||||
|
|
||||||
EntityWrapper parent = entity.Parent();
|
|
||||||
if (parent.Valid()) {
|
|
||||||
t = ModelMatrix(parent) * t;
|
|
||||||
}
|
|
||||||
|
|
||||||
MatrixCache[entity] = t;
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Transform::ClearCache::Update(double dt)
|
|
||||||
{
|
|
||||||
MatrixCache.clear();
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "Editor/EditorWidgetSystem.h"
|
#include "Editor/EditorWidgetSystem.h"
|
||||||
#include "Core/EntityFile.h"
|
#include "Core/EntityFile.h"
|
||||||
|
|
||||||
EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame* renderFrame)
|
EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame* renderFrame)
|
||||||
: System(params)
|
: System(params)
|
||||||
, m_Renderer(renderer)
|
, m_Renderer(renderer)
|
||||||
, m_RenderFrame(renderFrame)
|
, m_RenderFrame(renderFrame)
|
||||||
@@ -14,7 +14,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
|
|||||||
m_EditorWorldSystemPipeline->AddSystem<UniformScaleSystem>(0);
|
m_EditorWorldSystemPipeline->AddSystem<UniformScaleSystem>(0);
|
||||||
m_EditorWorldSystemPipeline->AddSystem<EditorWidgetSystem>(0, m_Renderer);
|
m_EditorWorldSystemPipeline->AddSystem<EditorWidgetSystem>(0, m_Renderer);
|
||||||
m_EditorWorldSystemPipeline->AddSystem<EditorRenderSystem>(1, m_Renderer, m_RenderFrame);
|
m_EditorWorldSystemPipeline->AddSystem<EditorRenderSystem>(1, m_Renderer, m_RenderFrame);
|
||||||
|
|
||||||
m_EditorCamera = importEntity(EntityWrapper(m_EditorWorld, EntityID_Invalid), "Schema/Entities/Empty.xml");
|
m_EditorCamera = importEntity(EntityWrapper(m_EditorWorld, EntityID_Invalid), "Schema/Entities/Empty.xml");
|
||||||
m_ActualCamera = m_EditorCamera;
|
m_ActualCamera = m_EditorCamera;
|
||||||
m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform");
|
m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform");
|
||||||
@@ -47,6 +47,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
|
|||||||
Enable();
|
Enable();
|
||||||
} else {
|
} else {
|
||||||
Disable();
|
Disable();
|
||||||
|
m_EventBroker->Publish(Events::UnlockMouse());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +72,9 @@ void EditorSystem::Update(double dt)
|
|||||||
m_EditorStats->Draw(actualDelta);
|
m_EditorStats->Draw(actualDelta);
|
||||||
|
|
||||||
if (m_CurrentSelection.Valid() && m_Widget.Valid()) {
|
if (m_CurrentSelection.Valid() && m_Widget.Valid()) {
|
||||||
|
if (isAnyParentMissingTransform(m_CurrentSelection.ID)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
(glm::vec3&)m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection);
|
(glm::vec3&)m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection);
|
||||||
if (m_WidgetSpace == EditorGUI::WidgetSpace::Local) {
|
if (m_WidgetSpace == EditorGUI::WidgetSpace::Local) {
|
||||||
(glm::vec3&)m_Widget["Transform"]["Orientation"] = Transform::AbsoluteOrientationEuler(m_CurrentSelection);
|
(glm::vec3&)m_Widget["Transform"]["Orientation"] = Transform::AbsoluteOrientationEuler(m_CurrentSelection);
|
||||||
@@ -78,7 +82,6 @@ void EditorSystem::Update(double dt)
|
|||||||
(glm::vec3&)m_Widget["Transform"]["Orientation"] = glm::vec3(0, 0, 0);
|
(glm::vec3&)m_Widget["Transform"]["Orientation"] = glm::vec3(0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_EditorWorldSystemPipeline->Update(actualDelta);
|
m_EditorWorldSystemPipeline->Update(actualDelta);
|
||||||
|
|
||||||
ComponentWrapper& cameraTransform = m_EditorCamera["Transform"];
|
ComponentWrapper& cameraTransform = m_EditorCamera["Transform"];
|
||||||
@@ -202,6 +205,9 @@ bool EditorSystem::OnMousePress(const Events::MousePress& e)
|
|||||||
bool EditorSystem::OnWidgetDelta(const Events::WidgetDelta& e)
|
bool EditorSystem::OnWidgetDelta(const Events::WidgetDelta& e)
|
||||||
{
|
{
|
||||||
if (m_CurrentSelection.Valid()) {
|
if (m_CurrentSelection.Valid()) {
|
||||||
|
if (isAnyParentMissingTransform(m_CurrentSelection.ID)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (m_WidgetSpace == EditorGUI::WidgetSpace::Global) {
|
if (m_WidgetSpace == EditorGUI::WidgetSpace::Global) {
|
||||||
glm::quat parentOrientation;
|
glm::quat parentOrientation;
|
||||||
glm::vec3 parentScale(1.f);
|
glm::vec3 parentScale(1.f);
|
||||||
@@ -308,3 +314,15 @@ void EditorSystem::setWidgetMode(EditorGUI::WidgetMode mode)
|
|||||||
|
|
||||||
m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection.World, m_CurrentSelection.ID);
|
m_Widget["Transform"]["Position"] = Transform::AbsolutePosition(m_CurrentSelection.World, m_CurrentSelection.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EditorSystem::isAnyParentMissingTransform(EntityID entityID)
|
||||||
|
{
|
||||||
|
EntityWrapper entity(m_World, entityID);
|
||||||
|
while (entity.Parent().Valid()) {
|
||||||
|
if (!entity.HasComponent("Transform")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
entity = entity.Parent();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "Network/Client.h"
|
#include "Network/Client.h"
|
||||||
|
#include "Network/EPlayerDisconnected.h"
|
||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
|
|
||||||
Client::Client(World* world, EventBroker* eventBroker)
|
Client::Client(World* world, EventBroker* eventBroker)
|
||||||
@@ -224,7 +225,7 @@ void Client::parseServerlist(Packet& packet)
|
|||||||
void Client::parseKick()
|
void Client::parseKick()
|
||||||
{
|
{
|
||||||
LOG_WARNING("You have been kicked from the server.");
|
LOG_WARNING("You have been kicked from the server.");
|
||||||
m_IsConnected = false;
|
disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::parseSpawnEvents()
|
void Client::parseSpawnEvents()
|
||||||
@@ -464,6 +465,10 @@ void Client::disconnect()
|
|||||||
Packet packet(MessageType::Disconnect, m_SendPacketID);
|
Packet packet(MessageType::Disconnect, m_SendPacketID);
|
||||||
m_Reliable.Send(packet);
|
m_Reliable.Send(packet);
|
||||||
m_Reliable.Disconnect();
|
m_Reliable.Disconnect();
|
||||||
|
Events::PlayerDisconnected e;
|
||||||
|
e.Entity = m_LocalPlayer.ID;
|
||||||
|
e.PlayerID = -1;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
createMainMenu();
|
createMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
||||||
bool outOfBodyExperience = false; // ResourceManager::Load<ConfigFile>("Config.ini")->Get<bool>("Debug.OutOfBodyExperience", false); // APPARENTLY THIS IS REALLY SLOW
|
bool outOfBodyExperience = ResourceManager::Load<ConfigFile>("Config.ini")->Get<bool>("Debug.OutOfBodyExperience", false);
|
||||||
if (
|
if (
|
||||||
(entity.HasComponent("HiddenForLocalPlayer") || entity.FirstParentWithComponent("HiddenForLocalPlayer").Valid())
|
(entity.HasComponent("HiddenForLocalPlayer") || entity.FirstParentWithComponent("HiddenForLocalPlayer").Valid())
|
||||||
&& (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))
|
&& (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))
|
||||||
|
|||||||
+1
-4
@@ -42,6 +42,7 @@
|
|||||||
#include "Game/Systems/StartSystem.h"
|
#include "Game/Systems/StartSystem.h"
|
||||||
#include "Rendering/TextureSprite.h"
|
#include "Rendering/TextureSprite.h"
|
||||||
|
|
||||||
|
|
||||||
Game::Game(int argc, char* argv[])
|
Game::Game(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
parseArgs(argc, argv);
|
parseArgs(argc, argv);
|
||||||
@@ -158,8 +159,6 @@ Game::Game(int argc, char* argv[])
|
|||||||
m_SystemPipeline->AddSystem<StartSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<StartSystem>(updateOrderLevel);
|
||||||
// Populate Octree with collidables
|
// Populate Octree with collidables
|
||||||
++updateOrderLevel;
|
++updateOrderLevel;
|
||||||
m_SystemPipeline->AddSystem<Transform::ClearCache>(updateOrderLevel);
|
|
||||||
++updateOrderLevel;
|
|
||||||
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
|
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
|
||||||
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player");
|
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player");
|
||||||
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
|
||||||
@@ -175,8 +174,6 @@ Game::Game(int argc, char* argv[])
|
|||||||
++updateOrderLevel;
|
++updateOrderLevel;
|
||||||
m_SystemPipeline->AddSystem<FillFrustumOctreeSystem>(updateOrderLevel, m_OctreeFrustrumCulling);
|
m_SystemPipeline->AddSystem<FillFrustumOctreeSystem>(updateOrderLevel, m_OctreeFrustrumCulling);
|
||||||
++updateOrderLevel;
|
++updateOrderLevel;
|
||||||
m_SystemPipeline->AddSystem<Transform::ClearCache>(updateOrderLevel);
|
|
||||||
++updateOrderLevel;
|
|
||||||
m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling);
|
m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling);
|
||||||
++updateOrderLevel;
|
++updateOrderLevel;
|
||||||
m_SystemPipeline->AddSystem<EditorSystem>(updateOrderLevel, m_Renderer, m_RenderFrame);
|
m_SystemPipeline->AddSystem<EditorSystem>(updateOrderLevel, m_Renderer, m_RenderFrame);
|
||||||
|
|||||||
@@ -264,6 +264,11 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
|||||||
size = glm::vec3(1.f, 1.f, 1.f);
|
size = glm::vec3(1.f, 1.f, 1.f);
|
||||||
} else {
|
} else {
|
||||||
size = glm::vec3(1.f, 1.6f, 1.f);
|
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)
|
, m_PickedTeam(-1)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectatorCameraSystem::Update(double dt)
|
void SpectatorCameraSystem::Update(double dt)
|
||||||
@@ -87,4 +88,17 @@ bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
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