Compare commits

..

1 Commits

Author SHA1 Message Date
Jace 0516794db6 Separating RawModel from Model 2016-03-13 14:47:11 +01:00
38 changed files with 4905 additions and 5067 deletions
+1 -1
Submodule assets updated: 504752c949...bc6e7df04c
+6 -6
View File
@@ -48,13 +48,13 @@ bool RayVsTriangle(const Ray& ray,
bool trueOnNegativeDistance = false);
//Return true if the ray hits any of the triangles in the model. Stops checking when a hit is detected.
bool RayVsModel(const Ray& ray,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix);
//Return true if the ray hits any of the triangles in the model.
//Also returns the position of the intersection point. Will loop through all the whole model indices.
bool RayVsModel(const Ray& ray,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix,
glm::vec3& outHitPosition);
@@ -62,7 +62,7 @@ bool RayVsModel(const Ray& ray,
//Also returns the distance from the ray origin to the closest
//intersection point, and the barycentric u,v-coordinates. Will loop through all the whole model indices.
bool RayVsModel(const Ray& ray,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix,
float& outDistance,
@@ -70,7 +70,7 @@ bool RayVsModel(const Ray& ray,
float& outVCoord);
bool AABBvsTriangles(const AABB& box,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix,
glm::vec3& boxVelocity,
@@ -80,7 +80,7 @@ bool AABBvsTriangles(const AABB& box,
//Detects collision, but does not resolve.
bool AABBvsTriangles(const AABB& box,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix);
@@ -92,7 +92,7 @@ enum Output
};
//Detects intersection and containment.
Output AABBvsTrianglesWContainment(const AABB& box,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix);
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef Events_Captured_h__
#define Events_Captured_h__
#ifndef ECaptured_h__
#define ECaptured_h__
#include "EventBroker.h"
#include "../Core/Entity.h"
+22 -26
View File
@@ -10,32 +10,28 @@
#include <boost/asio.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/MessageType.h"
#include "Network/PlayerDefinition.h"
#include "Network/UDPClient.h"
#include "Network/TCPClient.h"
#include "Network/SnapshotDefinitions.h"
#include "Network/EDisplayServerlist.h"
#include "Network/EConnectRequest.h"
#include "Network/EPlayerDisconnected.h"
#include "Network/ESearchForServers.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/EConnectRequest.h"
class Client : public Network
{
public:
@@ -44,7 +40,7 @@ public:
~Client();
void Connect(std::string address, int port);
void Update(double dt) override;
void Update() override;
private:
UDPClient m_Unreliable;
TCPClient m_Reliable;
@@ -78,10 +74,10 @@ private:
// Network logic
PlayerDefinition m_PlayerDefinitions[8];
SnapshotDefinitions m_NextSnapshot;
double m_DurationOfPingTime = 0;
double m_StartPingTime = 0;
double m_TimeSinceSentInputs = 0;
double m_SendInputInterval = 0.033;
double m_DurationOfPingTime;
std::clock_t m_StartPingTime;
std::clock_t m_TimeSinceSentInputs;
unsigned int m_SendInputIntervalMs;
std::vector<Events::InputCommand> m_InputCommandBuffer;
// Private member functions
@@ -104,7 +100,6 @@ private:
void parseDoubleJump(Packet& packet);
void parseDashEffect(Packet& packet);
void parseAmmoPickup(Packet& packet);
void parseRemoveWorld(Packet& packet);
void InterpolateFields(Packet& packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
void parseSnapshot(Packet& packet);
void identifyPacketLoss();
@@ -114,6 +109,7 @@ private:
void sendLocalPlayerTransform();
void becomePlayer();
void displayServerlist();
void removeWorld();
void createMainMenu();
// Mapping Logic
// Returns if local EntityID exist in map
@@ -142,8 +138,8 @@ private:
UDPClient m_ServerlistRequest;
std::vector<ServerInfo> m_Serverlist;
bool m_SearchingForServers = false;
double m_TimeSearched = 0;
double m_SearchingTime = 0.2; // Config I guess
std::clock_t m_StartSearchTime;
double m_SearchingTime = 200; // Config I guess
};
#endif
-1
View File
@@ -23,7 +23,6 @@ enum class MessageType
OnDashEffect,
ServerlistRequest,
AmmoPickup,
RemoveWorld,
Invalid
};
+1 -2
View File
@@ -22,7 +22,7 @@ public:
Network(World* world, EventBroker* eventBroker);
virtual ~Network() { };
virtual void Update(double dt) = 0;
virtual void Update() = 0;
protected:
World* m_World;
@@ -40,7 +40,6 @@ protected:
void saveToFile();
void updateNetworkData();
void popNetworkSegmentOfHeader(Packet& packet);
void removeWorld();
};
#endif
+8 -16
View File
@@ -11,7 +11,6 @@
#include "Network/MessageType.h"
#include "Network/PlayerDefinition.h"
#include "Core/World.h"
#include "Core/EntityFile.h"
#include "Core/EventBroker.h"
#include "../Network/Network.h"
#include "Input/EInputCommand.h"
@@ -25,8 +24,6 @@
#include "Core/EPlayerDeath.h"
#include "Network/EPlayerConnected.h"
#include "Network/EKillDeath.h"
#include "Core/EWin.h"
#include "Game/Events/EReset.h"
class Server : public Network
{
@@ -34,7 +31,7 @@ public:
Server(World* world, EventBroker* eventBroker, int port);
~Server();
void Update(double dt) override;
void Update() override;
private:
// Network channels
@@ -44,7 +41,6 @@ private:
// dont forget to set these in the childrens receive logic
boost::asio::ip::address m_Address;
int m_Port = 27666;
bool m_GameIsOver = false;
// Sending messages to client logic
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
std::vector<PlayerID> m_PlayersToDisconnect;
@@ -52,14 +48,14 @@ private:
char readBuffer[BUFFERSIZE] = { 0 };
size_t bytesRead = 0;
// time for previouse message
double previousPingMessage = 0;
double previousSnapshotMessage = 0;
double timeOutTimer = 0;
std::clock_t previousePingMessage = std::clock();
std::clock_t previousSnapshotMessage = std::clock();
std::clock_t timOutTimer = std::clock();
// How often we send messages (seconds)
double pingInterval = 1;
double snapshotInterval = 0.05;
double checkTimeOutInterval = 0.1;
// How often we send messages (milliseconds)
float pingIntervalMs;
float snapshotInterval;
int checkTimeOutInterval = 100;
int m_NextPlayerID = 0;
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
//Timers
@@ -75,7 +71,6 @@ private:
void reliableBroadcast(Packet& packet);
void unreliableBroadcast(Packet& packet);
void sendSnapshot();
void createWorldSnapshot(Packet& packet);
void addPlayersToPacket(Packet& packet, EntityID entityID);
void addChildrenToPacket(Packet& packet, EntityID entityID);
void addInputCommandsToPacket(Packet& packet);
@@ -88,7 +83,6 @@ private:
void kick(PlayerID player);
PlayerID getPlayerIDFromEndpoint();
PlayerID getPlayerIDFromEntityID(EntityID entityID);
void resetMap();
void parsePlayerTransform(Packet& packet);
void parseOnInputCommand(Packet& packet);
void parseClientPing();
@@ -116,8 +110,6 @@ private:
bool OnAmmoPickup(const Events::AmmoPickup& e);
EventRelay<Server, Events::PlayerDeath> m_EPlayerDeath;
bool OnPlayerDeath(const Events::PlayerDeath& e);
EventRelay<Server, Events::Win> m_EWin;
bool OnWin(const Events::Win& e);
};
#endif
+12 -6
View File
@@ -16,15 +16,18 @@ private:
public:
~Model();
const std::vector<RawModel::MaterialProperties>& MaterialGroups() const { return m_RawModel->m_Materials; }
const glm::mat4& Matrix() const { return m_RawModel->m_Matrix; }
const RawModel::Vertex* Vertices() const { return m_RawModel->Vertices(); }
unsigned int NumberOfVertices() const { return m_RawModel->NumVertices(); }
const std::vector<RawModel::MaterialProperties>& MaterialGroups() const { return m_Materials; }
//const RawModel::Vertex* Vertices() const { return m_RawModel->Vertices(); }
unsigned int NumberOfVertices() const { return m_Vertices.size(); }
const AABB& Box() const { return m_Box; }
bool IsSkinned() const { return m_RawModel->IsSkinned(); }
bool IsSkinned() const { return m_IsSkinned; }
GLuint VAO;
GLuint ElementBuffer;
RawModel* m_RawModel;
//RawModel* m_RawModel;
Skeleton* m_Skeleton = nullptr;
std::vector<glm::vec3> m_Vertices;
std::vector<unsigned int> m_Indices;
private:
AABB m_Box;
@@ -34,6 +37,9 @@ private:
GLuint TangentNormalsBuffer;
GLuint BiTangentNormalsBuffer;
GLuint TextureCoordBuffer;
std::vector<RawModel::MaterialProperties> m_Materials;
bool m_IsSkinned;
};
#endif
+1 -1
View File
@@ -105,7 +105,7 @@ struct ModelJob : RenderJob
IsShielded = isShielded;
if (model->IsSkinned()) {
Skeleton = Model->m_RawModel->m_Skeleton;
Skeleton = Model->m_Skeleton;
if (Skeleton != nullptr) {
+2 -5
View File
@@ -13,6 +13,7 @@
#include <boost/filesystem/path.hpp>
#include <boost/endian/buffers.hpp>
#include "../Common.h"
#include "../GLM.h"
#include "../Core/ResourceManager.h"
@@ -20,14 +21,10 @@
#include "Skeleton.h"
#include "ShaderProgram.h"
#include "boost\endian\buffers.hpp"
class RawModelCustom : public Resource
{
friend class ResourceManager;
friend class Model;
protected:
RawModelCustom(std::string fileName);
-16
View File
@@ -1,16 +0,0 @@
#ifndef Events_Reset_h__
#define Events_Reset_h__
#include "Core/EventBroker.h"
#include "Core/EntityWrapper.h"
namespace Events
{
struct Reset : Event
{
};
}
#endif
@@ -9,7 +9,6 @@
#include "Engine/Collision/ETrigger.h"
#include "Core/ECaptured.h"
#include "Core/EWin.h"
#include "Game/Events/EReset.h"
#include <tuple>
#include <vector>
@@ -24,7 +23,6 @@ public:
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override;
private:
void Init();
//methods which will take care of specific events
EventRelay<CapturePointSystem, Events::TriggerTouch> m_ETriggerTouch;
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e);
@@ -32,8 +30,6 @@ private:
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e);
EventRelay<CapturePointSystem, Events::Captured> m_ECaptured;
bool CapturePointSystem::OnCaptured(const Events::Captured& e);
EventRelay<CapturePointSystem, Events::Reset> m_EReset;
bool CapturePointSystem::OnReset(const Events::Reset& e);
void ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner);
bool m_WinnerWasFound = false;
-6
View File
@@ -8,8 +8,6 @@
#include "Core/EPlayerSpawned.h"
#include "Network/EPlayerConnected.h"
#include "Network/EPlayerDisconnected.h"
#include "Game/Events/EReset.h"
#include "Engine/Input/EInputCommand.h"
#include "GLM.h"
class ScoreScreenSystem : public PureSystem
@@ -27,10 +25,6 @@ public:
bool OnPlayerConnected(const Events::PlayerConnected& e);
EventRelay<ScoreScreenSystem, Events::PlayerDisconnected> m_EPlayerDisconnected;
bool OnPlayerDisconnected(const Events::PlayerDisconnected& e);
EventRelay<ScoreScreenSystem, Events::Reset> m_EReset;
bool OnReset(const Events::Reset& e);
EventRelay<ScoreScreenSystem, Events::InputCommand> m_EInputCommand;
bool OnInputCommand(const Events::InputCommand& e);
private:
struct PlayerData {
+1
View File
@@ -8,6 +8,7 @@
#include "Events/ESpawnerSpawn.h"
#include "Core/TransformSystem.h"
#include "Core/EntityFile.h"
#include "Rendering/Model.h"
class SpawnerSystem : public System
{
@@ -4,7 +4,6 @@
#include "Core/System.h"
#include "Input/EInputCommand.h"
#include "Network/EPlayerDisconnected.h"
#include "Game/Events/EReset.h"
class SpectatorCameraSystem : public ImpureSystem
{
@@ -16,14 +15,11 @@ public:
private:
int m_PickedTeam;
bool m_CamSetToTeamPick;
void reset();
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
bool OnInputCommand(const Events::InputCommand& e);
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
bool OnDisconnect(const Events::PlayerDisconnected& e);
EventRelay<SpectatorCameraSystem, Events::Reset> m_EReset;
bool OnReset(const Events::Reset& e);
};
#endif
@@ -2,5 +2,4 @@
<CapturePointGameMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePointGameMode.xsd">
<RespawnTime>0.0</RespawnTime>
<MaxRespawnTime>8.0</MaxRespawnTime>
<ResetCountdown>10.0</ResetCountdown>
</CapturePointGameMode>
@@ -12,9 +12,6 @@
<xs:element name="MaxRespawnTime" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Players will be spawned when RespawnTime reaches this.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="ResetCountdown" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>The map will be reset when time reaches 0.</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
File diff suppressed because it is too large Load Diff
+17 -17
View File
@@ -146,14 +146,14 @@ bool RayVsTriangle(const Ray& ray,
}
bool RayVsModel(const Ray& ray,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix)
{
for (int i = 0; i < modelIndices.size();) {
glm::vec3 v0 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
glm::vec3 v1 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
glm::vec3 v2 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
glm::vec3 v0 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
glm::vec3 v1 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
glm::vec3 v2 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
if (RayVsTriangle(ray, v0, v1, v2)) {
return true;
}
@@ -194,7 +194,7 @@ bool RayVsTriangle(const Ray& ray,
}
bool RayVsModel(const Ray& ray,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix,
float& outDistance,
@@ -204,9 +204,9 @@ bool RayVsModel(const Ray& ray,
outDistance = INFINITY;
bool hit = false;
for (int i = 0; i < modelIndices.size();) {
glm::vec3 v0 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
glm::vec3 v1 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
glm::vec3 v2 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
glm::vec3 v0 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
glm::vec3 v1 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
glm::vec3 v2 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
float dist = outDistance;
float u;
float v;
@@ -221,7 +221,7 @@ bool RayVsModel(const Ray& ray,
}
bool RayVsModel(const Ray& ray,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix,
glm::vec3& outHitPosition)
@@ -548,7 +548,7 @@ BoxTriRes AABBvsTriangle(const AABB& box,
}
Output AABBvsTriangles(const AABB& box,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix,
glm::vec3& boxVelocity,
@@ -565,9 +565,9 @@ Output AABBvsTriangles(const AABB& box,
glm::vec3 originalBoxVelocity(boxVelocity);
for (int i = 0; i < modelIndices.size(); ) {
std::array<glm::vec3, 3> triVertices = {
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix),
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix),
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix)
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix),
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix),
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix)
};
glm::vec3 outVec;
bool collideWithGround = isOnGround;
@@ -595,7 +595,7 @@ Output AABBvsTriangles(const AABB& box,
}
bool AABBvsTriangles(const AABB& box,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix,
glm::vec3& boxVelocity,
@@ -615,7 +615,7 @@ bool AABBvsTriangles(const AABB& box,
}
bool AABBvsTriangles(const AABB& box,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix)
{
@@ -633,7 +633,7 @@ bool AABBvsTriangles(const AABB& box,
}
Output AABBvsTrianglesWContainment(const AABB& box,
const RawModel::Vertex* modelVertices,
const std::vector<glm::vec3>& modelVertices,
const std::vector<unsigned int>& modelIndices,
const glm::mat4& modelMatrix)
{
@@ -741,7 +741,7 @@ boost::optional<EntityAABB> EntityFirstHitByRay(const Ray& ray, std::vector<Enti
continue;
}
float u, v;
if (RayVsModel(ray, model->Vertices(), model->m_RawModel->m_Indices, TransformSystem::ModelMatrix(entityBox.Entity), outDistance, u, v)) {
if (RayVsModel(ray, model->m_Vertices, model->m_Indices, TransformSystem::ModelMatrix(entityBox.Entity), outDistance, u, v)) {
outIntersectPos = ray.Origin() + outDistance * ray.Direction();
return entityBox;
}
+6 -6
View File
@@ -41,15 +41,15 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
// Don't collide against invisible models.
continue;
}
RawModel* model;
Model* model;
std::string res = (std::string)boxB.Entity["Model"]["Resource"];
try {
model = ResourceManager::Load<RawModel, true>(res);
model = ResourceManager::Load<Model, true>(res);
} catch (const std::exception&) {
continue;
}
float u, v;
hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, TransformSystem::ModelMatrix(boxB.Entity), dist, u, v);
hit = Collision::RayVsModel(ray, model->m_Vertices, model->m_Indices, TransformSystem::ModelMatrix(boxB.Entity), dist, u, v);
} else {
hit = Collision::RayVsAABB(ray, boxB, dist);
}
@@ -86,9 +86,9 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
// Don't collide against invisible models.
continue;
}
RawModel* model;
Model* model;
try {
model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]);
model = ResourceManager::Load<Model, true>(boxB.Entity["Model"]["Resource"]);
} catch (const std::exception&) {
continue;
}
@@ -98,7 +98,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
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)) {
if (Collision::AABBvsTriangles(boxA, model->m_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.
(Field<glm::vec3>)cTransform["Position"] += resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity);
+3 -3
View File
@@ -10,11 +10,11 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
return;
}
RawModel* triggerModel = nullptr;
Model* triggerModel = nullptr;
glm::mat4 triggerModelMat;
if (triggerEntity.HasComponent("Model")) {
try {
triggerModel = ResourceManager::Load<RawModel, true>(triggerEntity["Model"]["Resource"]);
triggerModel = ResourceManager::Load<Model, true>(triggerEntity["Model"]["Resource"]);
triggerModelMat = TransformSystem::ModelMatrix(triggerEntity);
} catch (const std::exception&) {
}
@@ -38,7 +38,7 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
? Collision::Output::OutContained
: Collision::AABBvsTrianglesWContainment(
colliderBox,
triggerModel->Vertices(),
triggerModel->m_Vertices,
triggerModel->m_Indices,
triggerModelMat);
+22 -31
View File
@@ -1,5 +1,5 @@
#include "Network/Client.h"
#include "Network/EPlayerDisconnected.h"
using namespace boost::asio::ip;
Client::Client(World* world, EventBroker* eventBroker)
@@ -12,7 +12,7 @@ Client::Client(World* world, EventBroker* eventBroker)
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
m_PlayerName = config->Get<std::string>("Networking.Name", "Raptorcopter");
m_SendInputInterval = config->Get<int>("Networking.SendInputIntervalMs", 33) / 1000.0;
m_SendInputIntervalMs = config->Get<int>("Networking.SendInputIntervalMs", 33);
LOG_INFO("Client initialized");
m_ServerlistRequest.Connect(m_PlayerName, "192.168.1.255", 32554);
@@ -48,7 +48,7 @@ void Client::Connect(std::string address, int port)
}
}
void Client::Update(double dt)
void Client::Update()
{
m_EventBroker->Process<Client>();
while (m_Unreliable.IsSocketAvailable()) {
@@ -85,9 +85,7 @@ void Client::Update(double dt)
}
if (m_SearchingForServers) {
m_TimeSearched += dt;
if (m_SearchingTime < m_TimeSearched) {
m_TimeSearched = 0;
if (m_SearchingTime < (1000* (std::clock() - m_StartSearchTime) / (double)CLOCKS_PER_SEC)) {
m_SearchingForServers = false;
//displayServerlist();
Events::DisplayServerlist e;
@@ -98,25 +96,16 @@ void Client::Update(double dt)
if (m_IsConnected) {
// Don't send 1 input in 1 packet, bunch em up.
m_TimeSinceSentInputs += dt;
if (m_SendInputInterval < m_TimeSinceSentInputs) {
if (m_SendInputIntervalMs < (1000 * (std::clock() - m_TimeSinceSentInputs) / (double)CLOCKS_PER_SEC)) {
sendInputCommands();
m_TimeSinceSentInputs = 0;
m_TimeSinceSentInputs = std::clock();
}
// HACK: Send absolute player positions for now to avoid desync until we have reliable messages
sendLocalPlayerTransform();
hasServerTimedOut();
}
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();
}
//Network::Update();
}
void Client::parseMessageType(Packet& packet)
@@ -170,9 +159,6 @@ void Client::parseMessageType(Packet& packet)
case MessageType::AmmoPickup:
parseAmmoPickup(packet);
break;
case MessageType::RemoveWorld:
parseRemoveWorld(packet);
break;
default:
break;
}
@@ -204,7 +190,7 @@ void Client::parseTCPConnect(Packet& packet)
packet.WritePrimitive(m_PlayerID);
m_Unreliable.Send(packet);
// LOG_INFO("Sent UDP Connect Server");
// LOG_INFO("Sent UDP Connect Server");
}
void Client::parsePlayerConnected(Packet & packet)
@@ -350,13 +336,6 @@ void Client::parseAmmoPickup(Packet & packet)
m_EventBroker->Publish(e);
}
void Client::parseRemoveWorld(Packet & packet)
{
removeWorld();
Events::Reset e;
m_EventBroker->Publish(e);
}
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
{
for (auto field : componentInfo.FieldsInOrder) {
@@ -604,7 +583,7 @@ bool Client::OnConnectRequest(const Events::ConnectRequest& e)
bool Client::OnSearchForServers(const Events::SearchForServers& e)
{
m_SearchingForServers = true;
m_TimeSearched = 0;
m_StartSearchTime = std::clock();
m_Serverlist.clear();
Packet packet(MessageType::ServerlistRequest);
m_ServerlistRequest.Broadcast(packet, 13); // TODO: Config
@@ -684,7 +663,6 @@ void Client::hasServerTimedOut()
if (timeSincePing > m_TimeoutMs) {
// Clear everything and go to menu.
LOG_INFO("Server has timed out, returning to menu, Beep Boop.");
ImGui::OpenPopup("Disconnected");
disconnect();
}
}
@@ -728,6 +706,19 @@ void Client::displayServerlist()
}
}
void Client::removeWorld()
{
std::vector<EntityID> childrenToBeDeleted;
auto rootEntites = m_World->GetDirectChildren(EntityID_Invalid);
for (auto it = rootEntites.first; it != rootEntites.second; it++) {
childrenToBeDeleted.push_back(it->second);
}
for (int i = 0; i < childrenToBeDeleted.size(); ++i) {
m_World->DeleteEntity(childrenToBeDeleted[i]);
}
}
void Client::createMainMenu()
{
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/StartMenu.xml");
+1 -13
View File
@@ -9,7 +9,7 @@ Network::Network(World* world, EventBroker* eventBroker)
m_TimeoutMs = config->Get<int>("Networking.TimeoutMs", 20000);
}
void Network::Update(double dt)
void Network::Update()
{
updateNetworkData();
}
@@ -92,15 +92,3 @@ void Network::popNetworkSegmentOfHeader(Packet & packet)
packet.ReadPrimitive<int>();
packet.ReadPrimitive<int>();
}
void Network::removeWorld()
{
std::vector<EntityID> childrenToBeDeleted;
auto rootEntites = m_World->GetDirectChildren(EntityID_Invalid);
for (auto it = rootEntites.first; it != rootEntites.second; it++) {
childrenToBeDeleted.push_back(it->second);
}
for (int i = 0; i < childrenToBeDeleted.size(); ++i) {
m_World->DeleteEntity(childrenToBeDeleted[i]);
}
}
+15 -62
View File
@@ -5,8 +5,8 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
, m_ServerlistRequest(13)
{
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
snapshotInterval = config->Get<float>("Networking.SnapshotInterval", 0.05);
pingInterval = config->Get<float>("Networking.PingIntervalMs", 1000) / 1000.0;
snapshotInterval = 1000 * config->Get<float>("Networking.SnapshotInterval", 0.05f);
pingIntervalMs = config->Get<float>("Networking.PingIntervalMs", 1000);
m_ServerName = config->Get<std::string>("Networking.Name", "Unnamed");
// Subscribe to events
@@ -17,7 +17,6 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Server::OnPlayerDamage);
EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &Server::OnAmmoPickup);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &Server::OnPlayerDeath);
EVENT_SUBSCRIBE_MEMBER(m_EWin, &Server::OnWin);
// BindWW
if (port == 0) {
port = config->Get<float>("Networking.Port", 27666);
@@ -31,7 +30,7 @@ Server::~Server()
}
void Server::Update(double dt)
void Server::Update()
{
m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers);
@@ -87,44 +86,26 @@ void Server::Update(double dt)
}
m_PlayersToDisconnect.clear();
std::clock_t currentTime = std::clock();
// Send snapshot
previousSnapshotMessage += dt;
if (snapshotInterval < previousSnapshotMessage) {
if (snapshotInterval < (1000 * (currentTime - previousSnapshotMessage) / (double)CLOCKS_PER_SEC)) {
sendSnapshot();
previousSnapshotMessage = 0;
previousSnapshotMessage = currentTime;
}
// Send pings each
previousPingMessage += dt;
if (pingInterval < previousPingMessage) {
if (pingIntervalMs < (1000 * (currentTime - previousePingMessage) / (double)CLOCKS_PER_SEC)) {
sendPing();
previousPingMessage = 0;
previousePingMessage = currentTime;
}
// Time out logic
timeOutTimer += dt;
if (checkTimeOutInterval < timeOutTimer) {
if (checkTimeOutInterval < (1000 * (currentTime - timOutTimer) / (double)CLOCKS_PER_SEC)) {
checkForTimeOuts();
timeOutTimer = 0;
timOutTimer = currentTime;
}
m_EventBroker->Process<Server>();
if (isReadingData) {
Network::Update(dt);
}
if (m_GameIsOver) {
auto pool = m_World->GetComponents("CapturePointGameMode");
if (pool != nullptr && pool->size() > 0) {
// Take the first CapturePointGameMode component found.
ComponentWrapper& modeComponent = *pool->begin();
// Decrease timer.
Field<double> timer = modeComponent["ResetCountdown"];
timer -= dt;
if (timer < 0) {
resetMap();
}
} else {
resetMap();
}
Network::Update();
}
}
@@ -183,7 +164,7 @@ void Server::reliableBroadcast(Packet& packet)
void Server::unreliableBroadcast(Packet& packet)
{
m_Unreliable.SendToConnectedPlayers(packet, m_ConnectedPlayers);
m_Unreliable.SendToConnectedPlayers(packet, m_ConnectedPlayers);
}
// Send snapshot fields
@@ -192,16 +173,10 @@ void Server::sendSnapshot()
Packet packet(MessageType::Snapshot);
addInputCommandsToPacket(packet);
addPlayersToPacket(packet, EntityID_Invalid);
//addChildrenToPacket(packet, EntityID_Invalid);
unreliableBroadcast(packet);
}
// Send snapshot fields
void Server::createWorldSnapshot(Packet& packet)
{
addInputCommandsToPacket(packet);
addChildrenToPacket(packet, EntityID_Invalid);
}
void Server::addInputCommandsToPacket(Packet& packet)
{
// Number of input commands
@@ -404,7 +379,8 @@ void Server::parseTCPConnect(Packet & packet)
m_Reliable.Send(connnectPacket, m_ConnectedPlayers.at(playerID));
Packet firstSnapshot(MessageType::Snapshot);
createWorldSnapshot(firstSnapshot);
addInputCommandsToPacket(firstSnapshot);
addChildrenToPacket(firstSnapshot, EntityID_Invalid);
m_Reliable.Send(firstSnapshot);
// Send notification that a player has connected
@@ -566,13 +542,6 @@ bool Server::OnPlayerDeath(const Events::PlayerDeath& e)
return false;
}
bool Server::OnWin(const Events::Win & e)
{
// Postpone the gameover reset
m_GameIsOver = true;
return true;
}
void Server::parseClientPing()
{
LOG_INFO("%i: Parsing ping", m_PacketID);
@@ -694,20 +663,4 @@ PlayerID Server::getPlayerIDFromEntityID(EntityID entityID)
}
}
return -1;
}
void Server::resetMap()
{
m_GameIsOver = false;
Events::Reset reset;
m_EventBroker->Publish(reset);
Packet removeMap(MessageType::RemoveWorld);
reliableBroadcast(removeMap);
removeWorld();
// Hardcoded for now.
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/CP_Rocky2.xml");
entityFile->MergeInto(m_World);
Packet newWorld(MessageType::Snapshot);
createWorldSnapshot(newWorld);
reliableBroadcast(newWorld);
}
+5 -5
View File
@@ -37,7 +37,7 @@ void AnimationSystem::CreateBlendTrees()
continue;;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
Skeleton* skeleton = model->m_Skeleton;
if (skeleton == nullptr) {
continue;
}
@@ -79,7 +79,7 @@ void AnimationSystem::UpdateAnimations(double dt)
return;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
Skeleton* skeleton = model->m_Skeleton;
if (skeleton == nullptr) {
return;
}
@@ -175,7 +175,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
return false;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
Skeleton* skeleton = model->m_Skeleton;
if (skeleton == nullptr) {
return false;
}
@@ -294,7 +294,7 @@ bool AnimationSystem::OnEntityDeleted(Events::EntityDeleted& e)
return false;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
Skeleton* skeleton = model->m_Skeleton;
if (skeleton == nullptr) {
return false;
}
@@ -325,7 +325,7 @@ bool AnimationSystem::OnSetBlendWeight(Events::SetBlendWeight& e)
return false;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
Skeleton* skeleton = model->m_Skeleton;
if (skeleton == nullptr) {
return false;
}
+3 -3
View File
@@ -22,7 +22,7 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob)
return;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
Skeleton* skeleton = model->m_Skeleton;
if (skeleton == nullptr) {
return;
}
@@ -130,7 +130,7 @@ bool AutoBlendQueue::HasActiveBlendJob()
return HasActiveBlendJob();
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
Skeleton* skeleton = model->m_Skeleton;
if (skeleton == nullptr) {
m_BlendQueue.pop_front();
return HasActiveBlendJob();
@@ -173,7 +173,7 @@ std::shared_ptr<BlendTree> AutoBlendQueue::GetBlendTree()
return nullptr;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
Skeleton* skeleton = model->m_Skeleton;
if (skeleton == nullptr) {
return nullptr;
}
@@ -26,7 +26,7 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp
return;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
Skeleton* skeleton = model->m_Skeleton;
if(skeleton == nullptr) {
return;
+1 -1
View File
@@ -530,7 +530,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
std::vector<glm::mat4> frameBones;
if (modelJob->BlendTree != nullptr) {
frameBones = modelJob->BlendTree->GetFinalPose();
} else {
} else if (modelJob->Skeleton != nullptr) {
frameBones = modelJob->Skeleton->GetTPose();
}
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
+15 -3
View File
@@ -2,8 +2,10 @@
Model::Model(std::string fileName)
{
//fileName = "Models/Core/ScreenQuad.mesh";
//Try loading the model asyncronously, if it throws any exceptions then let it propagate back to caller.
m_RawModel = ResourceManager::Load<RawModel, true>(fileName);
auto m_RawModel = ResourceManager::Load<RawModel, true>(fileName);
//throw FailedLoadingException("Test");
for (auto& materialProperty : m_RawModel->m_Materials) {
switch (materialProperty.type) {
@@ -99,14 +101,24 @@ Model::Model(std::string fileName)
glm::vec3 mini(INFINITY);
glm::vec3 maxi(-INFINITY);
for (unsigned int i = 0; i < m_RawModel->NumVertices(); i++) {
const auto& v = m_RawModel->Vertices()[i];
mini = glm::min(mini, v.Position);
maxi = glm::max(maxi, v.Position);
}
m_Box = AABB(mini, maxi);
//m_Skeleton = m_RawModel->m_Skeleton;
delete m_RawModel->m_Skeleton;
m_Materials = m_RawModel->m_Materials;
//m_Indices = m_RawModel->m_Indices;
m_IsSkinned = m_RawModel->IsSkinned();
// Copy vertex positions for collisions later
for (auto& v : m_RawModel->m_Vertices) {
//m_Vertices.push_back(v.Position);
}
ResourceManager::Release("RawModel", fileName);
}
Model::~Model()
+1 -1
View File
@@ -110,7 +110,7 @@ void PickingPass::Draw(RenderScene& scene)
std::vector<glm::mat4> frameBones;
if (modelJob->BlendTree != nullptr) {
frameBones = modelJob->BlendTree->GetFinalPose();
} else {
} else if (modelJob->Skeleton != nullptr) {
frameBones = modelJob->Skeleton->GetTPose();
}
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
+7 -6
View File
@@ -493,12 +493,13 @@ void RawModelCustom::ReadAnimationKeyFrame(std::size_t& offset, char* fileData,
RawModelCustom::~RawModelCustom()
{
if (m_Skeleton != nullptr) {
delete m_Skeleton;
}
for (auto material : m_Materials) {
delete material.material;
}
// Ownership of skeleton and materials get transferred to Model
// if (m_Skeleton != nullptr) {
// delete m_Skeleton;
// }
//for (auto material : m_Materials) {
// delete material.material;
//}
}
#endif
+1 -1
View File
@@ -270,7 +270,7 @@ void ShadowPass::Draw(RenderScene & scene)
std::vector<glm::mat4> frameBones;
if (modelJob->BlendTree != nullptr) {
frameBones = modelJob->BlendTree->GetFinalPose();
} else {
} else if (modelJob->Skeleton != nullptr) {
frameBones = modelJob->Skeleton->GetTPose();
}
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
+2 -2
View File
@@ -232,10 +232,10 @@ void Game::Tick()
PerformanceTimer::StartTimerAndStopPrevious("Network");
m_EventBroker->Process<MultiplayerSnapshotFilter>();
if (m_NetworkClient != nullptr) {
m_NetworkClient->Update(dt);
m_NetworkClient->Update();
}
if (m_NetworkServer != nullptr) {
m_NetworkServer->Update(dt);
m_NetworkServer->Update();
}
//m_SoundManager->Update(dt);
+4 -31
View File
@@ -10,26 +10,8 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
EVENT_SUBSCRIBE_MEMBER(m_EReset, &CapturePointSystem::OnReset);
Init();
}
}
void CapturePointSystem::Init()
{
m_WinnerWasFound = false;
//need to track these variables for the captureSystem to work as per design!
m_RedTeamNextPossibleCapturePoint = m_NotACapturePoint;
m_BlueTeamNextPossibleCapturePoint = m_NotACapturePoint;
m_RedTeamHomeCapturePoint = m_NotACapturePoint;
m_BlueTeamHomeCapturePoint = m_NotACapturePoint;
m_NumberOfCapturePoints = 0;
m_ResetTimers = false;
m_RecentlyCapturedNeedNextCapturePointNow = false;
m_CapturePointNumberToEntityMap.clear();
//vectors which will keep track of enter/leave changes
m_ETriggerTouchVector.clear();
m_ETriggerLeaveVector.clear();
}
//here all capturepoints will update their component
@@ -42,9 +24,6 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
if (m_WinnerWasFound) {
return;
}
if (!capturePointEntity.Valid()) {
return;
}
const int capturePointNumber = cCapturePoint["CapturePointNumber"];
const bool hasTeamComponent = capturePointEntity.HasComponent("Team");
@@ -81,7 +60,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
}
//if we havent received all capturepoints yet, just return
if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints > m_CapturePointNumberToEntityMap.size()) {
if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints != m_CapturePointNumberToEntityMap.size()) {
m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity));
return;
}
@@ -253,10 +232,10 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
}
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner)
{
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner) {
(Field<bool>)capturePointModels["Model"]["Visible"] = isOwner;
for (auto& capModel : capturePointModels.ChildrenWithComponent("Transform")) {
for (auto& capModel : capturePointModels.ChildrenWithComponent("Transform"))
{
if (capModel.HasComponent("Model")) {
(Field<bool>)capModel["Model"]["Visible"] = isOwner;
}
@@ -290,9 +269,3 @@ bool CapturePointSystem::OnCaptured(const Events::Captured& e)
m_ResetTimers = true;
return true;
}
bool CapturePointSystem::OnReset(const Events::Reset& e)
{
Init();
return true;
}
-24
View File
@@ -9,8 +9,6 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params)
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &ScoreScreenSystem::OnPlayerSpawn);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerConnected, &ScoreScreenSystem::OnPlayerConnected);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDisconnected, &ScoreScreenSystem::OnPlayerDisconnected);
EVENT_SUBSCRIBE_MEMBER(m_EReset, &ScoreScreenSystem::OnReset);
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &ScoreScreenSystem::OnInputCommand);
}
void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt)
@@ -158,25 +156,3 @@ bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e
m_DisconnectedIdentities.push_back(e.PlayerID);
return 0;
}
bool ScoreScreenSystem::OnReset(const Events::Reset & e)
{
for (auto& it : m_PlayerIdentities) {
it.second.Deaths = 0;
it.second.Kills = 0;
it.second.Team = 1;
it.second.Player = EntityWrapper::Invalid;
}
return true;
}
bool ScoreScreenSystem::OnInputCommand(const Events::InputCommand & e)
{
if (e.Command != "PickTeam" || e.PlayerID == -1 || e.Value == 0) {
return false;
}
m_PlayerIdentities.at(e.PlayerID).Team = e.Value;
return true;
}
+3 -3
View File
@@ -103,15 +103,15 @@ bool SpawnerSystem::spawnedEntityIsColliding(EntityWrapper spawnedEntity, Entity
if (!spawnedBox.Entity.HasComponent("Model")) {
return true;
}
RawModel* model = nullptr;
Model* model = nullptr;
try {
model = ResourceManager::Load<RawModel, true>(otherEntity["Model"]["Resource"]);
model = ResourceManager::Load<Model, true>(otherEntity["Model"]["Resource"]);
} catch (const std::exception&) {
}
if (model != nullptr && Collision::AABBvsTriangles(
spawnedBox,
model->Vertices(),
model->m_Vertices,
model->m_Indices,
TransformSystem::ModelMatrix(otherEntity))) {
return true;
+4 -16
View File
@@ -9,7 +9,6 @@ SpectatorCameraSystem::SpectatorCameraSystem(SystemParams params)
{
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
EVENT_SUBSCRIBE_MEMBER(m_EReset, &SpectatorCameraSystem::OnReset);
}
void SpectatorCameraSystem::Update(double dt)
@@ -28,14 +27,6 @@ void SpectatorCameraSystem::Update(double dt)
}
}
void SpectatorCameraSystem::reset()
{
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);
}
bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
{
// Only the client should do this, and only if player is not spawned.
@@ -104,13 +95,10 @@ 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) {
reset();
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;
}
bool SpectatorCameraSystem::OnReset(const Events::Reset & e)
{
reset();
return true;
}
+6 -6
View File
@@ -108,7 +108,7 @@ bool Material::findColorTexture(MaterialNode& material_node, MFnDependencyNode&
return true;
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
MGlobal::displayInfo(MString() + "found color splat map");
MGlobal::displayInfo(MString() + "find splat map");
return findSplatTextures(material_node, material_node.ColorMaps, MFnDependencyNode(AllConnections[i].node()));
}
}
@@ -162,9 +162,9 @@ bool Material::findNormalTexture(MaterialNode& material_node, MFnDependencyNode&
material_node.NormalMaps.push_back(newTexture);
return true;
} else if (AllBumpConnections[j].node().hasFn(MFn::kLayeredTexture)) {
MGlobal::displayInfo(MString() + "found normal splat map");
return findSplatTextures(material_node, material_node.NormalMaps, MFnDependencyNode(AllBumpConnections[j].node()));
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
MGlobal::displayInfo(MString() + "find splat map");
return findSplatTextures(material_node, material_node.NormalMaps, MFnDependencyNode(AllConnections[i].node()));
}
}
}
@@ -218,7 +218,7 @@ bool Material::findSpecularTexture(MaterialNode& material_node, MFnDependencyNod
material_node.type = MaterialNode::MaterialType::SingleTextures;
return true;
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
MGlobal::displayInfo(MString() + "found specular splat map");
MGlobal::displayInfo(MString() + "find splat map");
return findSplatTextures(material_node, material_node.SpecularMaps, MFnDependencyNode(AllConnections[i].node()));
}
}
@@ -270,7 +270,7 @@ bool Material::findIncandescenceTexture(MaterialNode& material_node, MFnDependen
return true;
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
MGlobal::displayInfo(MString() + "found incandescens splat map");
MGlobal::displayInfo(MString() + "find splat map");
return findSplatTextures(material_node, material_node.IncandescenceMaps, MFnDependencyNode(AllConnections[i].node()));
}
}