Merge branch 'master' of https://github.com/teamfisk/TacticalZ
This commit is contained in:
+1
-1
Submodule assets updated: 504752c949...6ffc1ab82a
@@ -10,30 +10,31 @@
|
|||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/shared_array.hpp>
|
#include <boost/shared_array.hpp>
|
||||||
|
|
||||||
|
#include "Core/World.h"
|
||||||
|
#include "Core/EntityFile.h"
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
#include "Core/ConfigFile.h"
|
||||||
|
#include "Core/EPlayerDeath.h"
|
||||||
|
#include "Core/EPlayerDamage.h"
|
||||||
|
#include "Core/EPlayerSpawned.h"
|
||||||
|
#include "Core/EAmmoPickup.h"
|
||||||
|
#include "Game/Events/EDoubleJump.h"
|
||||||
|
#include "Game/Events/EDashAbility.h"
|
||||||
|
#include "Game/Events/EReset.h"
|
||||||
|
#include "Input/EInputCommand.h"
|
||||||
|
#include "imgui/imgui.h"
|
||||||
#include "Network/Network.h"
|
#include "Network/Network.h"
|
||||||
#include "Network/MessageType.h"
|
#include "Network/MessageType.h"
|
||||||
#include "Network/PlayerDefinition.h"
|
#include "Network/PlayerDefinition.h"
|
||||||
#include "Network/UDPClient.h"
|
#include "Network/UDPClient.h"
|
||||||
#include "Network/TCPClient.h"
|
#include "Network/TCPClient.h"
|
||||||
#include "Network/SnapshotDefinitions.h"
|
#include "Network/SnapshotDefinitions.h"
|
||||||
#include "Core/World.h"
|
|
||||||
#include "Core/EntityFile.h"
|
|
||||||
#include "Core/EventBroker.h"
|
|
||||||
#include "Core/ConfigFile.h"
|
|
||||||
#include "Core/EPlayerDeath.h"
|
|
||||||
#include "Input/EInputCommand.h"
|
|
||||||
#include "Core/EPlayerDamage.h"
|
|
||||||
#include "../Game/Events/EDoubleJump.h"
|
|
||||||
#include "Network/EInterpolate.h"
|
|
||||||
#include "Network/SnapshotFilter.h"
|
|
||||||
#include "Core/EPlayerSpawned.h"
|
|
||||||
#include "Core/EAmmoPickup.h"
|
|
||||||
#include "Network/ESearchForServers.h"
|
|
||||||
#include "../Game/Events/EDashAbility.h"
|
|
||||||
#include "Network/EDisplayServerlist.h"
|
#include "Network/EDisplayServerlist.h"
|
||||||
#include "Network/EConnectRequest.h"
|
#include "Network/EConnectRequest.h"
|
||||||
#include "Network/EPlayerDisconnected.h"
|
#include "Network/EPlayerDisconnected.h"
|
||||||
#include "Game/Events/EReset.h"
|
#include "Network/ESearchForServers.h"
|
||||||
|
#include "Network/EInterpolate.h"
|
||||||
|
#include "Network/SnapshotFilter.h"
|
||||||
|
|
||||||
class Client : public Network
|
class Client : public Network
|
||||||
{
|
{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,162 +0,0 @@
|
|||||||
#include "Core/TransformSystem.h"
|
|
||||||
|
|
||||||
std::unordered_map<EntityWrapper, glm::vec3> TransformSystem::PositionCache;
|
|
||||||
std::unordered_map<EntityWrapper, glm::quat> TransformSystem::OrientationCache;
|
|
||||||
std::unordered_map<EntityWrapper, glm::vec3> TransformSystem::ScaleCache;
|
|
||||||
std::unordered_map<EntityWrapper, glm::mat4> TransformSystem::MatrixCache;
|
|
||||||
|
|
||||||
int TransformSystem::RecalculatedPositions = 0;
|
|
||||||
int TransformSystem::RecalculatedOrientations = 0;
|
|
||||||
int TransformSystem::RecalculatedScales = 0;
|
|
||||||
|
|
||||||
TransformSystem::TransformSystem(SystemParams params)
|
|
||||||
: System(params)
|
|
||||||
{
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EEntityDeleted, &TransformSystem::OnEntityDeleted);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TransformSystem::OnEntityDeleted(const Events::EntityDeleted& e)
|
|
||||||
{
|
|
||||||
// Clean up deleted entity
|
|
||||||
PositionCache.erase(e.DeletedEntity);
|
|
||||||
OrientationCache.erase(e.DeletedEntity);
|
|
||||||
ScaleCache.erase(e.DeletedEntity);
|
|
||||||
MatrixCache.erase(e.DeletedEntity);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//glm::mat4 Transform::AbsoluteTransformation(EntityWrapper entity)
|
|
||||||
//{
|
|
||||||
// glm::mat4 t = glm::mat4(1.f);
|
|
||||||
//
|
|
||||||
// while (entity.Valid()) {
|
|
||||||
// t = glm::translate((const glm::vec3&)entity["Transform"]["Position"]) * glm::toMat4(glm::quat((const glm::vec3&)entity["Transform"]["Orientation"])) * glm::scale((const glm::vec3&)entity["Transform"]["Scale"]) * t;
|
|
||||||
// entity = entity.Parent();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return t;
|
|
||||||
//}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::AbsolutePosition(World* world, EntityID entity)
|
|
||||||
{
|
|
||||||
return TransformSystem::AbsolutePosition(EntityWrapper(world, entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::AbsolutePosition(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
if (!entity.Valid()) {
|
|
||||||
return glm::vec3();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto cacheIt = PositionCache.find(entity);
|
|
||||||
ComponentWrapper cTransform = entity["Transform"];
|
|
||||||
ComponentWrapper::SubscriptProxy cTransformPosition = cTransform["Position"];
|
|
||||||
if (cacheIt != PositionCache.end() && !cTransformPosition.Dirty(DirtySetType::Transform)) {
|
|
||||||
return cacheIt->second;
|
|
||||||
} else {
|
|
||||||
EntityWrapper parent = entity.Parent();
|
|
||||||
// Calculate position
|
|
||||||
glm::vec3 position = AbsolutePosition(parent) + TransformSystem::AbsoluteOrientation(parent) * (TransformSystem::AbsoluteScale(parent) * (const glm::vec3&)cTransformPosition);
|
|
||||||
// Cache it
|
|
||||||
PositionCache[entity] = position;
|
|
||||||
RecalculatedPositions++;
|
|
||||||
// Unset dirty flag
|
|
||||||
cTransformPosition.SetDirty(DirtySetType::Transform, false);
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::AbsoluteOrientationEuler(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
glm::vec3 orientation;
|
|
||||||
|
|
||||||
while (entity.Valid()) {
|
|
||||||
ComponentWrapper transform = entity["Transform"];
|
|
||||||
orientation += (Field<glm::vec3>)transform["Orientation"];
|
|
||||||
entity = entity.Parent();
|
|
||||||
}
|
|
||||||
|
|
||||||
return orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::quat TransformSystem::AbsoluteOrientation(World* world, EntityID entity)
|
|
||||||
{
|
|
||||||
return TransformSystem::AbsoluteOrientation(EntityWrapper(world, entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::quat TransformSystem::AbsoluteOrientation(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
if (!entity.Valid()) {
|
|
||||||
return glm::quat();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto cacheIt = OrientationCache.find(entity);
|
|
||||||
ComponentWrapper cTransform = entity["Transform"];
|
|
||||||
ComponentWrapper::SubscriptProxy cTransformOrientation = cTransform["Orientation"];
|
|
||||||
if (cacheIt != OrientationCache.end() && !cTransformOrientation.Dirty(DirtySetType::Transform)) {
|
|
||||||
return cacheIt->second;
|
|
||||||
} else {
|
|
||||||
EntityWrapper parent = entity.Parent();
|
|
||||||
// Calculate orientation
|
|
||||||
glm::quat orientation = AbsoluteOrientation(parent) * glm::quat((const glm::vec3&)cTransformOrientation);
|
|
||||||
// Cache it
|
|
||||||
OrientationCache[entity] = orientation;
|
|
||||||
RecalculatedOrientations++;
|
|
||||||
// Unset dirty flag
|
|
||||||
cTransformOrientation.SetDirty(DirtySetType::Transform, false);
|
|
||||||
return orientation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::AbsoluteScale(World* world, EntityID entity)
|
|
||||||
{
|
|
||||||
return TransformSystem::AbsoluteScale(EntityWrapper(world, entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::AbsoluteScale(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
if (!entity.Valid()) {
|
|
||||||
return glm::vec3(1.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto cacheIt = ScaleCache.find(entity);
|
|
||||||
ComponentWrapper cTransform = entity["Transform"];
|
|
||||||
ComponentWrapper::SubscriptProxy cTransformScale = cTransform["Scale"];
|
|
||||||
if (cacheIt != ScaleCache.end() && !cTransformScale.Dirty(DirtySetType::Transform)) {
|
|
||||||
return cacheIt->second;
|
|
||||||
} else {
|
|
||||||
EntityWrapper parent = entity.Parent();
|
|
||||||
// Calculate scale
|
|
||||||
glm::vec3 scale = AbsoluteScale(parent) * (const glm::vec3&)cTransformScale;
|
|
||||||
// Cache it
|
|
||||||
ScaleCache[entity] = scale;
|
|
||||||
RecalculatedPositions++;
|
|
||||||
// Unset dirty flag
|
|
||||||
cTransformScale.SetDirty(DirtySetType::Transform, false);
|
|
||||||
return scale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::mat4 TransformSystem::ModelMatrix(EntityID entityID, World* world)
|
|
||||||
{
|
|
||||||
return ModelMatrix(EntityWrapper(world, entityID));
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::mat4 TransformSystem::ModelMatrix(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
auto cacheIt = MatrixCache.find(entity);
|
|
||||||
ComponentWrapper cTransform = entity["Transform"];
|
|
||||||
bool isDirty = cTransform["Position"].Dirty(DirtySetType::Transform) || cTransform["Orientation"].Dirty(DirtySetType::Transform) || cTransform["Scale"].Dirty(DirtySetType::Transform);
|
|
||||||
if (cacheIt != MatrixCache.end() && !isDirty) {
|
|
||||||
return cacheIt->second;
|
|
||||||
} else {
|
|
||||||
glm::mat4 matrix = glm::translate(AbsolutePosition(entity)) * glm::toMat4(AbsoluteOrientation(entity)) * glm::scale(AbsoluteScale(entity));
|
|
||||||
MatrixCache[entity] = matrix;
|
|
||||||
return matrix;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
|
|
||||||
{
|
|
||||||
return glm::vec3(matrix * glm::vec4(point.x, point.y, point.z, 1));
|
|
||||||
}
|
|
||||||
@@ -108,7 +108,15 @@ void Client::Update(double dt)
|
|||||||
|
|
||||||
hasServerTimedOut();
|
hasServerTimedOut();
|
||||||
}
|
}
|
||||||
//Network::Update();
|
|
||||||
|
if (ImGui::BeginPopupModal("Disconnected", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
|
ImGui::Text("You have been disconnected from server.\n\n");
|
||||||
|
ImGui::SetCursorPosX(ImGui::GetContentRegionAvailWidth() - 120);
|
||||||
|
if (ImGui::Button("OK", ImVec2(120, 0))) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::parseMessageType(Packet& packet)
|
void Client::parseMessageType(Packet& packet)
|
||||||
@@ -196,7 +204,7 @@ void Client::parseTCPConnect(Packet& packet)
|
|||||||
packet.WritePrimitive(m_PlayerID);
|
packet.WritePrimitive(m_PlayerID);
|
||||||
m_Unreliable.Send(packet);
|
m_Unreliable.Send(packet);
|
||||||
|
|
||||||
// LOG_INFO("Sent UDP Connect Server");
|
// LOG_INFO("Sent UDP Connect Server");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::parsePlayerConnected(Packet & packet)
|
void Client::parsePlayerConnected(Packet & packet)
|
||||||
@@ -676,6 +684,7 @@ void Client::hasServerTimedOut()
|
|||||||
if (timeSincePing > m_TimeoutMs) {
|
if (timeSincePing > m_TimeoutMs) {
|
||||||
// Clear everything and go to menu.
|
// Clear everything and go to menu.
|
||||||
LOG_INFO("Server has timed out, returning to menu, Beep Boop.");
|
LOG_INFO("Server has timed out, returning to menu, Beep Boop.");
|
||||||
|
ImGui::OpenPopup("Disconnected");
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,6 +362,11 @@ void RenderSystem::fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntityWrapper entity(world, pointlightC.EntityID);
|
||||||
|
if (!isEntityVisible(entity)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<PointLightJob> pointLightJob = std::shared_ptr<PointLightJob>(new PointLightJob(transformC, pointlightC, m_World));
|
std::shared_ptr<PointLightJob> pointLightJob = std::shared_ptr<PointLightJob>(new PointLightJob(transformC, pointlightC, m_World));
|
||||||
jobs.push_back(pointLightJob);
|
jobs.push_back(pointLightJob);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,11 @@ bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
|||||||
// TODO: 1 Signifies spectator, should probably have real enum here later.
|
// TODO: 1 Signifies spectator, should probably have real enum here later.
|
||||||
// Spectators should never end up at the class select, instead put them at the SpectatorCamera.
|
// Spectators should never end up at the class select, instead put them at the SpectatorCamera.
|
||||||
if (swapToClass && m_PickedTeam != 1) {
|
if (swapToClass && m_PickedTeam != 1) {
|
||||||
camName = "PickClassCamera";
|
if (m_PickedTeam == 2) {
|
||||||
|
camName = "PickClassCameraRed";
|
||||||
|
} else if (m_PickedTeam == 3) {
|
||||||
|
camName = "PickClassCameraBlue";
|
||||||
|
}
|
||||||
} else if (e.Command == "SwapToTeamPick") {
|
} else if (e.Command == "SwapToTeamPick") {
|
||||||
camName = "PickTeamCamera";
|
camName = "PickTeamCamera";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user