Compare commits

...

10 Commits

Author SHA1 Message Date
verysecrethero 45a92b362f DoubleJumping now in InputController instead. 2016-02-02 15:10:11 +01:00
verysecrethero 2085d9ec9e Merge remote-tracking branch 'origin/master' into DoubleJump 2016-02-02 14:22:00 +01:00
Jace 0e5f6da9a9 Merge pull request #73 from teamfisk/CapturePointFixBranch
Several changes/fixes based on the latest broken refactoring in master
2016-02-02 13:22:03 +01:00
verysecrethero 42b52a6766 Several changes/fixes based on the latest broken refactoring.
Fixed Simon's mistake in CapturePointLogic. William fixed so TriggerSystem works again with CapturePoints.
2016-02-02 11:37:22 +01:00
Jace 9090be8acf Merge branch 'Warnings-Simon' 2016-02-01 17:53:55 +01:00
Jace a3d4eb65d5 Fixes #66 warnings 2016-02-01 17:53:01 +01:00
Jace 9b2a4be707 Merge pull request #71 from teamfisk/Warnings-Adam
Warnings adam
2016-02-01 17:52:18 +01:00
stiffly 5474a18753 #68 Fixed warning in SoundSystem.cpp 2016-02-01 17:15:51 +01:00
Adam Byléhn ca8b7cbee8 Merge pull request #65 from teamfisk/EditorUsefulness
Editor usefulness
2016-02-01 16:13:37 +01:00
verysecrethero 0c97ce7a4a You can now DoubleJump! 2016-01-29 10:12:49 +01:00
29 changed files with 296 additions and 85 deletions
@@ -9,9 +9,9 @@
class CollidableOctreeSystem : public ImpureSystem, public PureSystem class CollidableOctreeSystem : public ImpureSystem, public PureSystem
{ {
public: public:
CollidableOctreeSystem(World* world, EventBroker* eventBroker, Octree<EntityAABB>* octree) CollidableOctreeSystem(World* world, EventBroker* eventBroker, Octree<EntityAABB>* octree, const std::string& componentType)
: System(world, eventBroker) : System(world, eventBroker)
, PureSystem("Collidable") , PureSystem(componentType)
, m_Octree(octree) , m_Octree(octree)
{ } { }
+1 -1
View File
@@ -81,7 +81,7 @@ class ComponentWrapperFactory
{ {
public: public:
ComponentWrapperFactory() = default; ComponentWrapperFactory() = default;
ComponentWrapperFactory(std::string componentTypeName, std::size_t allocation = 0) ComponentWrapperFactory(std::string componentTypeName, unsigned int allocation = 0)
{ {
m_ComponentInfo.Name = componentTypeName; m_ComponentInfo.Name = componentTypeName;
m_ComponentInfo.Meta->Allocation = allocation; m_ComponentInfo.Meta->Allocation = allocation;
+1 -1
View File
@@ -143,7 +143,7 @@ private:
~EntityFile(); ~EntityFile();
public: public:
static std::size_t GetTypeStride(std::string typeName); static unsigned int GetTypeStride(std::string typeName);
static void WriteAttributeData(char* outData, const ComponentInfo::Field_t& field, const std::map<std::string, std::string>& attributes); static void WriteAttributeData(char* outData, const ComponentInfo::Field_t& field, const std::map<std::string, std::string>& attributes);
static void WriteValueData(char* outData, const ComponentInfo::Field_t& field, const char* valueData); static void WriteValueData(char* outData, const ComponentInfo::Field_t& field, const char* valueData);
+1 -1
View File
@@ -149,7 +149,7 @@ template<typename T>
template<typename Box> template<typename Box>
void Octree<T>::ObjectsInSameRegion(const Box& box, std::vector<T>& outObjects) void Octree<T>::ObjectsInSameRegion(const Box& box, std::vector<T>& outObjects)
{ {
//static_assert(std::is_base_of<AABB, Box>::value, "template argument type Box in Octree<T>::ObjectsInSameRegion must be a subclass of AABB."); static_assert(std::is_base_of<AABB, Box>::value, "template argument type Box in Octree<T>::ObjectsInSameRegion must be a subclass of AABB.");
falsifyObjectChecks(); falsifyObjectChecks();
m_Root->ObjectsInSameRegion(box, outObjects); m_Root->ObjectsInSameRegion(box, outObjects);
} }
+2 -2
View File
@@ -42,7 +42,7 @@ enum class FileWatcher::FileEventFlags
}; };
inline FileWatcher::FileEventFlags operator|(FileWatcher::FileEventFlags a, FileWatcher::FileEventFlags b) { return static_cast<FileWatcher::FileEventFlags>(static_cast<int>(a) | static_cast<int>(b)); } inline FileWatcher::FileEventFlags operator|(FileWatcher::FileEventFlags a, FileWatcher::FileEventFlags b) { return static_cast<FileWatcher::FileEventFlags>(static_cast<int>(a) | static_cast<int>(b)); }
inline bool operator&(FileWatcher::FileEventFlags a, FileWatcher::FileEventFlags b) { return static_cast<int>(a)& static_cast<int>(b); } inline bool operator&(FileWatcher::FileEventFlags a, FileWatcher::FileEventFlags b) { return (static_cast<int>(a) & static_cast<int>(b)) != 0; }
class FileWatcher::Worker class FileWatcher::Worker
{ {
@@ -54,7 +54,7 @@ public:
private: private:
struct FileInfo struct FileInfo
{ {
int Size; std::size_t Size;
std::time_t Timestamp; std::time_t Timestamp;
}; };
@@ -23,7 +23,7 @@ public:
m_SpeedMultiplier = m_Config->Get<float>("Editor.CameraSpeed", 3.f); m_SpeedMultiplier = m_Config->Get<float>("Editor.CameraSpeed", 3.f);
} }
virtual const glm::vec3 Movement() const override { return m_Movement * m_SpeedMultiplier; } virtual const glm::vec3 Movement() const override { return m_Movement * static_cast<float>(m_SpeedMultiplier); }
void Enable() { m_Enabled = true; } void Enable() { m_Enabled = true; }
void Disable() { m_Enabled = false; } void Disable() { m_Enabled = false; }
@@ -69,7 +69,7 @@ public:
protected: protected:
ConfigFile* m_Config; ConfigFile* m_Config;
bool m_Enabled = false; bool m_Enabled = false;
float m_SpeedMultiplier = 1.f; double m_SpeedMultiplier = 1.f;
EventRelay<EventContext, Events::MousePress> m_EMousePress; EventRelay<EventContext, Events::MousePress> m_EMousePress;
bool OnMousePress(const Events::MousePress& e) bool OnMousePress(const Events::MousePress& e)
@@ -105,7 +105,7 @@ protected:
return false; return false;
} }
m_SpeedMultiplier += e.DeltaY * (0.1f * m_SpeedMultiplier); m_SpeedMultiplier += e.DeltaY * (0.1 * m_SpeedMultiplier);
m_Config->Set("Editor.CameraSpeed", m_SpeedMultiplier); m_Config->Set("Editor.CameraSpeed", m_SpeedMultiplier);
m_Config->SaveToDisk(); m_Config->SaveToDisk();
return true; return true;
@@ -15,7 +15,11 @@ 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 DoubleJumping() const { return m_DoubleJumping; }
virtual void SetDoubleJumping(bool isDoubleJumping) {
m_DoubleJumping = isDoubleJumping;
}
void LockMouse(); void LockMouse();
void UnlockMouse(); void UnlockMouse();
virtual bool OnCommand(const Events::InputCommand& e) override; virtual bool OnCommand(const Events::InputCommand& e) override;
@@ -27,8 +31,9 @@ protected:
glm::vec3 m_Rotation; glm::vec3 m_Rotation;
glm::vec3 m_Movement; glm::vec3 m_Movement;
bool m_Jumping = false; bool m_Jumping = false;
bool m_DoubleJumping = false;
bool m_Crouching = false; bool m_Crouching = false;
EventRelay<EventContext, Events::LockMouse> m_ELockMouse; EventRelay<EventContext, Events::LockMouse> m_ELockMouse;
bool OnLockMouse(const Events::LockMouse& e); bool OnLockMouse(const Events::LockMouse& e);
EventRelay<EventContext, Events::UnlockMouse> m_EUnlockMouse; EventRelay<EventContext, Events::UnlockMouse> m_EUnlockMouse;
@@ -36,7 +41,7 @@ protected:
}; };
template <typename EventContext> template <typename EventContext>
FirstPersonInputController<EventContext>::FirstPersonInputController(EventBroker* eventBroker, int playerID) FirstPersonInputController<EventContext>::FirstPersonInputController(EventBroker* eventBroker, int playerID)
: InputController(eventBroker) : InputController(eventBroker)
, m_PlayerID(playerID) , m_PlayerID(playerID)
{ {
@@ -113,14 +118,14 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
template <typename EventContext> template <typename EventContext>
bool FirstPersonInputController<EventContext>::OnUnlockMouse(const Events::UnlockMouse& e) bool FirstPersonInputController<EventContext>::OnUnlockMouse(const Events::UnlockMouse& e)
{ {
m_MouseLocked = false; m_MouseLocked = false;
return true; return true;
} }
template <typename EventContext> template <typename EventContext>
bool FirstPersonInputController<EventContext>::OnLockMouse(const Events::LockMouse& e) bool FirstPersonInputController<EventContext>::OnLockMouse(const Events::LockMouse& e)
{ {
m_MouseLocked = true; m_MouseLocked = true;
return true; return true;
} }
+11 -11
View File
@@ -75,21 +75,21 @@ private:
void ReadMeshFile(std::string filePath); void ReadMeshFile(std::string filePath);
void ReadMeshFileHeader(unsigned int& offset, char* fileData, unsigned int& fileByteSize); void ReadMeshFileHeader(std::size_t& offset, char* fileData);
void ReadMesh(unsigned int& offset, char* fileData, unsigned int& fileByteSize); void ReadMesh(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadVertices(unsigned int& offset, char* fileData, unsigned int& fileByteSize); void ReadVertices(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadIndices(unsigned int& offset, char* fileData, unsigned int& fileByteSize); void ReadIndices(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadMaterialFile(std::string filePath); void ReadMaterialFile(std::string filePath);
void ReadMaterials(unsigned int &offset, char* fileData, unsigned int& fileByteSize); void ReadMaterials(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadMaterialSingle(unsigned int &offset, char* fileData, unsigned int& fileByteSize); void ReadMaterialSingle(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadAnimationFile(std::string filePath); void ReadAnimationFile(std::string filePath);
void ReadAnimationBindPoses(unsigned int &offset, char* fileData, unsigned int& fileByteSize); void ReadAnimationBindPoses(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadAnimationJoint(unsigned int &offset, char* fileData, unsigned int& fileByteSize); void ReadAnimationJoint(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadAnimationClips(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int numberOfClips); void ReadAnimationClips(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int numberOfClips);
void ReadAnimationClipSingle(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int clipIndex); void ReadAnimationClipSingle(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int clipIndex);
void ReadAnimationKeyFrame(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int numberOfJoints, Skeleton::Animation& animation); void ReadAnimationKeyFrame(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int numberOfJoints, Skeleton::Animation& animation);
//void CreateSkeleton(std::vector<std::tuple<std::string, glm::mat4>> &boneInfo, std::map<std::string, int> &boneNameMapping, aiNode* node, int parentID); //void CreateSkeleton(std::vector<std::tuple<std::string, glm::mat4>> &boneInfo, std::map<std::string, int> &boneNameMapping, aiNode* node, int parentID);
}; };
+1
View File
@@ -51,6 +51,7 @@ private:
GUI::Frame* m_FrameStack; GUI::Frame* m_FrameStack;
World* m_World; World* m_World;
Octree<EntityAABB>* m_OctreeCollision; Octree<EntityAABB>* m_OctreeCollision;
Octree<EntityAABB>* m_OctreeTrigger;
Octree<EntityAABB>* m_OctreeFrustrumCulling; Octree<EntityAABB>* m_OctreeFrustrumCulling;
SystemPipeline* m_SystemPipeline; SystemPipeline* m_SystemPipeline;
RenderFrame* m_RenderFrame; RenderFrame* m_RenderFrame;
+1 -1
View File
@@ -6,7 +6,7 @@
<xs:element name="CapturePoint"> <xs:element name="CapturePoint">
<xs:annotation> <xs:annotation>
<xs:documentation>A Capture Point. Add a Team Component to specify who currently owns it</xs:documentation> <xs:documentation>A Capture Point. Make sure to update the HomePoint,CapturePointNumber,Team for each</xs:documentation>
</xs:annotation> </xs:annotation>
<xs:complexType> <xs:complexType>
<xs:all> <xs:all>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:AABB/>
<c:CapturePoint/>
<c:Model>
<Resource>C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh</Resource>
</c:Model>
<c:Team/>
<c:Transform/>
<c:Trigger/>
</Components>
<Children/>
</Entity>
@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform>
<Position X="0.340887427" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:AABB/>
<c:CapturePoint>
<HomePointForTeam>
<Red/>
</HomePointForTeam>
</c:CapturePoint>
<c:Model>
<Resource>C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh</Resource>
<Color A="1" B="0" G="0.200000003" R="1"/>
</c:Model>
<c:Team>
<Team>
<Red/>
</Team>
</c:Team>
<c:Transform>
<Position X="6.60000038" Y="0" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:AABB/>
<c:CapturePoint>
<CapturePointNumber>1</CapturePointNumber>
</c:CapturePoint>
<c:Model>
<Resource>C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh</Resource>
<Color A="1" B="1" G="1" R="0"/>
</c:Model>
<c:Team/>
<c:Transform>
<Position X="4.46673203" Y="0" Z="3.50259304"/>
</c:Transform>
<c:Trigger/>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:AABB/>
<c:CapturePoint>
<CapturePointNumber>2</CapturePointNumber>
</c:CapturePoint>
<c:Model>
<Resource>C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh</Resource>
<Color A="1" B="1" G="0.200000003" R="0"/>
</c:Model>
<c:Team>
<Team>
<Blue/>
</Team>
</c:Team>
<c:Transform>
<Position X="3.00000024" Y="0" Z="0.113596022"/>
</c:Transform>
<c:Trigger/>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:AABB/>
<c:CapturePoint>
<CapturePointNumber>3</CapturePointNumber>
</c:CapturePoint>
<c:Model>
<Resource>C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh</Resource>
<Color A="1" B="1" G="0.200000003" R="0"/>
</c:Model>
<c:Team>
<Team>
<Blue/>
</Team>
</c:Team>
<c:Transform>
<Position X="1.75382805" Y="0" Z="0.0895374417"/>
</c:Transform>
<c:Trigger/>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:AABB/>
<c:CapturePoint>
<HomePointForTeam>
<Blue/>
</HomePointForTeam>
<CapturePointNumber>4</CapturePointNumber>
</c:CapturePoint>
<c:Model>
<Resource>C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh</Resource>
<Color A="1" B="1" G="0.200000003" R="0"/>
</c:Model>
<c:Team>
<Team>
<Blue/>
</Team>
</c:Team>
<c:Transform>
<Position X="0.56674248" Y="0" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:AABB/>
<c:Health/>
<c:Model>
<Resource>C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitCube.mesh</Resource>
</c:Model>
<c:Player/>
<c:Team>
<Team>
<Blue/>
</Team>
</c:Team>
<c:Transform>
<Position X="4.29100037" Y="-0.08556436" Z="1.29717529"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:AABB/>
<c:Health/>
<c:Model>
<Resource>C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitCube.mesh</Resource>
</c:Model>
<c:Player/>
<c:Team>
<Team>
<Red/>
</Team>
</c:Team>
<c:Transform>
<Position X="5.43557501" Y="0.888866663" Z="1.55849135"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Model>
<Resource>C:\Users\123456\Workspace\TacticalZ\assets\Models\DummyScene.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="-0.600000024" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+3 -3
View File
@@ -76,18 +76,18 @@ bool TriggerSystem::throwLeaveIfWasInTrigger(std::unordered_set<EntityWrapper>&
bool TriggerSystem::OnTouch(const Events::TriggerTouch &event) bool TriggerSystem::OnTouch(const Events::TriggerTouch &event)
{ {
LOG_INFO("Player entity %i touched trigger entity %i.", event.Entity, event.Trigger); LOG_INFO("Player entity %i touched trigger entity %i.", event.Entity.ID, event.Trigger.ID);
return true; return true;
} }
bool TriggerSystem::OnEnter(const Events::TriggerEnter &event) bool TriggerSystem::OnEnter(const Events::TriggerEnter &event)
{ {
LOG_INFO("Player entity %i entered trigger entity %i.", event.Entity, event.Trigger); LOG_INFO("Player entity %i entered trigger entity %i.", event.Entity.ID, event.Trigger.ID);
return true; return true;
} }
bool TriggerSystem::OnLeave(const Events::TriggerLeave &event) bool TriggerSystem::OnLeave(const Events::TriggerLeave &event)
{ {
LOG_INFO("Player entity %i left trigger entity %i.", event.Entity, event.Trigger); LOG_INFO("Player entity %i left trigger entity %i.", event.Entity.ID, event.Trigger.ID);
return true; return true;
} }
+2 -2
View File
@@ -40,9 +40,9 @@ void EntityFile::setReaderFeatures(xercesc::SAX2XMLReader* reader)
reader->setFeature(XMLUni::fgXercesCalculateSrcOfs, true); reader->setFeature(XMLUni::fgXercesCalculateSrcOfs, true);
} }
std::size_t EntityFile::GetTypeStride(std::string typeName) unsigned int EntityFile::GetTypeStride(std::string typeName)
{ {
std::map<std::string, size_t> typeStrides{ std::map<std::string, unsigned int> typeStrides{
{ "bool", sizeof(bool) }, { "bool", sizeof(bool) },
{ "int", sizeof(int) }, { "int", sizeof(int) },
{ "float", sizeof(float) }, { "float", sizeof(float) },
+1 -1
View File
@@ -114,7 +114,7 @@ void EntityFilePreprocessor::parseComponentInfo()
std::string baseType = XS::ToString(elementDeclaration->getTypeDefinition()->getBaseType()->getName()); std::string baseType = XS::ToString(elementDeclaration->getTypeDefinition()->getBaseType()->getName());
std::string effectiveType = type; std::string effectiveType = type;
size_t stride = EntityFile::GetTypeStride(type); unsigned int stride = EntityFile::GetTypeStride(type);
if (stride == 0) { if (stride == 0) {
stride = EntityFile::GetTypeStride(baseType); stride = EntityFile::GetTypeStride(baseType);
if (stride == 0) { if (stride == 0) {
+1 -1
View File
@@ -218,7 +218,7 @@ void InputManager::PublishGamepadAxisIfChanged(int gamepadID, Gamepad::Axis axis
void InputManager::PublishGamepadButtonIfChanged(int gamepadID, Gamepad::Button button) void InputManager::PublishGamepadButtonIfChanged(int gamepadID, Gamepad::Button button)
{ {
bool currentState = m_CurrentGamepadButtonState[gamepadID][static_cast<int>(button)]; bool currentState = m_CurrentGamepadButtonState[gamepadID][static_cast<int>(button)];
float lastState = m_LastGamepadButtonState[gamepadID][static_cast<int>(button)]; bool lastState = m_LastGamepadButtonState[gamepadID][static_cast<int>(button)];
if (currentState != lastState) { if (currentState != lastState) {
if (currentState == true) { if (currentState == true) {
Events::GamepadButtonDown e; Events::GamepadButtonDown e;
+5 -5
View File
@@ -69,7 +69,7 @@ void EditorGUI::drawTools()
} else if (m_CurrentWidgetSpace == WidgetSpace::Local) { } else if (m_CurrentWidgetSpace == WidgetSpace::Local) {
spaceTexture = tryLoadTexture("Textures/Icons/Local.png"); spaceTexture = tryLoadTexture("Textures/Icons/Local.png");
} }
if (ImGui::ImageButton((void*)spaceTexture, ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { if (ImGui::ImageButton(reinterpret_cast<void*>(spaceTexture), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) {
toggleWidgetSpace(); toggleWidgetSpace();
} }
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered()) {
@@ -85,14 +85,14 @@ void EditorGUI::drawTools()
// Play button // Play button
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Play.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (!m_Paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) { if (ImGui::ImageButton(reinterpret_cast<void*>(tryLoadTexture("Textures/Icons/Play.png")), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (!m_Paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) {
Events::Resume e; Events::Resume e;
e.World = m_World; e.World = m_World;
m_EventBroker->Publish(e); m_EventBroker->Publish(e);
} }
// Pause button // Pause button
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::ImageButton((void*)tryLoadTexture("Textures/Icons/Pause.png"), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (m_Paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) { if (ImGui::ImageButton(reinterpret_cast<void*>(tryLoadTexture("Textures/Icons/Pause.png")), ImVec2(24, 24), ImVec2(0, 1), ImVec2(1, 0), -1, ImVec4(0, 0, 0, 0), (m_Paused) ? ImVec4(0, 1, 0, 1) : ImVec4(1, 1, 1, 1))) {
Events::Pause e; Events::Pause e;
e.World = m_World; e.World = m_World;
m_EventBroker->Publish(e); m_EventBroker->Publish(e);
@@ -262,7 +262,7 @@ void EditorGUI::drawComponents(EntityWrapper entity)
// Draw combo box // Draw combo box
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() - 10.f); ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() - 10.f);
int selectedItem = -1; int selectedItem = -1;
if (ImGui::Combo("", &selectedItem, componentTypes.data(), componentTypes.size(), componentTypes.size())) { if (ImGui::Combo("", &selectedItem, componentTypes.data(), static_cast<int>(componentTypes.size()), static_cast<int>(componentTypes.size()))) {
if (selectedItem != -1) { if (selectedItem != -1) {
if (m_OnComponentAttach != nullptr) { if (m_OnComponentAttach != nullptr) {
std::string chosenComponentType(componentTypes.at(selectedItem)); std::string chosenComponentType(componentTypes.at(selectedItem));
@@ -565,7 +565,7 @@ void EditorGUI::createWidgetToolButton(WidgetMode mode)
break; break;
} }
if (ImGui::ImageButton( if (ImGui::ImageButton(
(void*)texture, reinterpret_cast<void*>(texture),
ImVec2(24, 24), ImVec2(24, 24),
ImVec2(0, 1), ImVec2(0, 1),
ImVec2(1, 0), ImVec2(1, 0),
+3 -3
View File
@@ -80,9 +80,9 @@ bool EditorRenderSystem::OnSetCamera(Events::SetCamera& e)
{ {
ComponentWrapper cTransform = e.CameraEntity["Transform"]; ComponentWrapper cTransform = e.CameraEntity["Transform"];
ComponentWrapper cCamera = e.CameraEntity["Camera"]; ComponentWrapper cCamera = e.CameraEntity["Camera"];
m_EditorCamera->SetFOV((double)cCamera["FOV"]); m_EditorCamera->SetFOV(static_cast<float>((double)cCamera["FOV"]));
m_EditorCamera->SetNearClip((double)cCamera["NearClip"]); m_EditorCamera->SetNearClip(static_cast<float>((double)cCamera["NearClip"]));
m_EditorCamera->SetFarClip((double)cCamera["FarClip"]); m_EditorCamera->SetFarClip(static_cast<float>((double)cCamera["FarClip"]));
m_EditorCamera->SetPosition(cTransform["Position"]); m_EditorCamera->SetPosition(cTransform["Position"]);
m_EditorCamera->SetOrientation(glm::quat((const glm::vec3&)cTransform["Orientation"])); m_EditorCamera->SetOrientation(glm::quat((const glm::vec3&)cTransform["Orientation"]));
m_CurrentCamera = e.CameraEntity; m_CurrentCamera = e.CameraEntity;
+2 -2
View File
@@ -98,7 +98,7 @@ bool MouseInputHandler::OnMouseMove(const Events::MouseMove& e)
Events::InputCommand ic; Events::InputCommand ic;
ic.PlayerID = -1; ic.PlayerID = -1;
std::tie(ic.Command, ic.Value) = it->second; std::tie(ic.Command, ic.Value) = it->second;
ic.Value *= e.DeltaX; ic.Value *= static_cast<float>(e.DeltaX);
m_InputProxy->Publish(ic); m_InputProxy->Publish(ic);
} }
} }
@@ -109,7 +109,7 @@ bool MouseInputHandler::OnMouseMove(const Events::MouseMove& e)
Events::InputCommand ic; Events::InputCommand ic;
ic.PlayerID = -1; ic.PlayerID = -1;
std::tie(ic.Command, ic.Value) = it->second; std::tie(ic.Command, ic.Value) = it->second;
ic.Value *= e.DeltaY; ic.Value *= static_cast<float>(e.DeltaY);
m_InputProxy->Publish(ic); m_InputProxy->Publish(ic);
} }
} }
+4 -4
View File
@@ -134,8 +134,8 @@ bool ImGuiRenderPass::OnMouseRelease(const Events::MouseRelease& e)
bool ImGuiRenderPass::OnMouseMove(const Events::MouseMove& e) bool ImGuiRenderPass::OnMouseMove(const Events::MouseMove& e)
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
io.MousePos.x = e.X; io.MousePos.x = static_cast<float>(e.X);
io.MousePos.y = e.Y; io.MousePos.y = static_cast<float>(e.Y);
return true; return true;
} }
@@ -271,7 +271,7 @@ bool ImGuiRenderPass::createFontsTexture()
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
// Store our identifier // Store our identifier
io.Fonts->TexID = (void*)g_FontTexture; io.Fonts->TexID = reinterpret_cast<void*>(g_FontTexture);
// Restore state // Restore state
glBindTexture(GL_TEXTURE_2D, last_texture); glBindTexture(GL_TEXTURE_2D, last_texture);
@@ -291,7 +291,7 @@ void ImGuiRenderPass::newFrame()
io.DisplaySize = ImVec2((float)w, (float)h); io.DisplaySize = ImVec2((float)w, (float)h);
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h); io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
io.DeltaTime = g_DeltaTime; io.DeltaTime = static_cast<float>(g_DeltaTime);
io.KeyCtrl = glfwGetKey(g_Window, GLFW_KEY_LEFT_CONTROL) || glfwGetKey(g_Window, GLFW_KEY_RIGHT_CONTROL); io.KeyCtrl = glfwGetKey(g_Window, GLFW_KEY_LEFT_CONTROL) || glfwGetKey(g_Window, GLFW_KEY_RIGHT_CONTROL);
io.KeyShift = glfwGetKey(g_Window, GLFW_KEY_LEFT_SHIFT) || glfwGetKey(g_Window, GLFW_KEY_RIGHT_SHIFT); io.KeyShift = glfwGetKey(g_Window, GLFW_KEY_LEFT_SHIFT) || glfwGetKey(g_Window, GLFW_KEY_RIGHT_SHIFT);
+2 -2
View File
@@ -71,12 +71,12 @@ PNG::PNG(std::string path)
png_read_update_info(png_ptr, info_ptr); png_read_update_info(png_ptr, info_ptr);
} }
unsigned int row_bytes = png_get_rowbytes(png_ptr, info_ptr); std::size_t row_bytes = png_get_rowbytes(png_ptr, info_ptr);
this->Data = new unsigned char[height * row_bytes]; this->Data = new unsigned char[height * row_bytes];
png_bytep* row_pointers = new png_bytep[height]; png_bytep* row_pointers = new png_bytep[height];
// Point each row to the continuous data array // Point each row to the continuous data array
for (int i = 0; i < height; ++i) { for (unsigned int i = 0; i < height; ++i) {
// Invert Y for OpenGL // Invert Y for OpenGL
row_pointers[height - 1 - i] = this->Data + i * row_bytes; row_pointers[height - 1 - i] = this->Data + i * row_bytes;
} }
+25 -24
View File
@@ -22,42 +22,42 @@ void RawModelCustom::ReadMeshFile(std::string filePath)
if (!in.is_open()) { if (!in.is_open()) {
throw Resource::FailedLoadingException("Open mesh file failed"); throw Resource::FailedLoadingException("Open mesh file failed");
} }
unsigned int fileByteSize = in.tellg(); unsigned int fileByteSize = static_cast<unsigned int>(in.tellg());
in.seekg(0, std::ios_base::beg); in.seekg(0, std::ios_base::beg);
fileData = new char[fileByteSize]; fileData = new char[fileByteSize];
in.read(fileData, fileByteSize); in.read(fileData, fileByteSize);
in.close(); in.close();
unsigned int offset = 0; std::size_t offset = 0;
if (fileByteSize > 0) { if (fileByteSize > 0) {
ReadMeshFileHeader(offset, fileData, fileByteSize); ReadMeshFileHeader(offset, fileData);
ReadMesh(offset, fileData, fileByteSize); ReadMesh(offset, fileData, fileByteSize);
} }
delete fileData; delete fileData;
} }
void RawModelCustom::ReadMeshFileHeader(unsigned int& offset, char* fileData, unsigned int& fileByteSize) void RawModelCustom::ReadMeshFileHeader(std::size_t& offset, char* fileData)
{ {
#ifdef BOOST_LITTLE_ENDIAN #ifdef BOOST_LITTLE_ENDIAN
m_Vertices.resize(*(unsigned int*)(fileData + offset)); m_Vertices.resize(static_cast<std::size_t>(*(unsigned int*)(fileData + offset)));
offset += sizeof(unsigned int); offset += sizeof(unsigned int);
m_Indices.resize(*(unsigned int*)(fileData + offset)); m_Indices.resize(static_cast<std::size_t>(*(unsigned int*)(fileData + offset)));
offset += sizeof(unsigned int); offset += sizeof(unsigned int);
#else #else
#endif #endif
} }
void RawModelCustom::ReadMesh(unsigned int& offset, char* fileData, unsigned int& fileByteSize) void RawModelCustom::ReadMesh(std::size_t& offset, char* fileData, const unsigned int& fileByteSize)
{ {
ReadVertices(offset, fileData, fileByteSize); ReadVertices(offset, fileData, fileByteSize);
ReadIndices(offset, fileData, fileByteSize); ReadIndices(offset, fileData, fileByteSize);
} }
void RawModelCustom::ReadVertices(unsigned int& offset, char* fileData, unsigned int& fileByteSize) void RawModelCustom::ReadVertices(std::size_t& offset, char* fileData, const unsigned int& fileByteSize)
{ {
#ifdef BOOST_LITTLE_ENDIAN #ifdef BOOST_LITTLE_ENDIAN
if (offset + m_Vertices.size() * sizeof(Vertex) > fileByteSize) { if (offset + m_Vertices.size() * sizeof(Vertex) > fileByteSize) {
throw Resource::FailedLoadingException("Reading vertices failed"); throw Resource::FailedLoadingException("Reading vertices failed");
} }
@@ -67,7 +67,7 @@ void RawModelCustom::ReadVertices(unsigned int& offset, char* fileData, unsigned
#endif #endif
} }
void RawModelCustom::ReadIndices(unsigned int& offset, char* fileData, unsigned int& fileByteSize) void RawModelCustom::ReadIndices(std::size_t& offset, char* fileData, const unsigned int& fileByteSize)
{ {
#ifdef BOOST_LITTLE_ENDIAN #ifdef BOOST_LITTLE_ENDIAN
if (offset + m_Indices.size() * sizeof(unsigned int) > fileByteSize) { if (offset + m_Indices.size() * sizeof(unsigned int) > fileByteSize) {
@@ -90,35 +90,36 @@ void RawModelCustom::ReadMaterialFile(std::string filePath)
if (!in.is_open()) { if (!in.is_open()) {
throw Resource::FailedLoadingException("Open material file failed"); throw Resource::FailedLoadingException("Open material file failed");
} }
unsigned int fileByteSize = in.tellg();
unsigned int fileByteSize = static_cast<unsigned int>(in.tellg());
in.seekg(0, std::ios_base::beg); in.seekg(0, std::ios_base::beg);
fileData = new char[fileByteSize]; fileData = new char[fileByteSize];
in.read(fileData, fileByteSize); in.read(fileData, fileByteSize);
in.close(); in.close();
unsigned int offset = 0; std::size_t offset = 0;
if (fileByteSize > 0) { if (fileByteSize > 0) {
ReadMaterials(offset, fileData, fileByteSize); ReadMaterials(offset, fileData, fileByteSize);
} }
delete fileData; delete fileData;
} }
void RawModelCustom::ReadMaterials(unsigned int& offset, char* fileData, unsigned int& fileByteSize) void RawModelCustom::ReadMaterials(std::size_t& offset, char* fileData, const unsigned int& fileByteSize)
{ {
#ifdef BOOST_LITTLE_ENDIAN #ifdef BOOST_LITTLE_ENDIAN
unsigned int* numMaterials = (unsigned int*)(fileData); unsigned int* numMaterials = (unsigned int*)(fileData);
MaterialGroups.reserve(*numMaterials); MaterialGroups.reserve(*numMaterials);
offset += sizeof(unsigned int); offset += sizeof(unsigned int);
for (int i = 0; i < *numMaterials; i++) { for (unsigned int i = 0; i < *numMaterials; i++) {
ReadMaterialSingle(offset, fileData, fileByteSize); ReadMaterialSingle(offset, fileData, fileByteSize);
} }
#else #else
#endif #endif
} }
void RawModelCustom::ReadMaterialSingle(unsigned int &offset, char* fileData, unsigned int& fileByteSize) void RawModelCustom::ReadMaterialSingle(std::size_t& offset, char* fileData, const unsigned int& fileByteSize)
{ {
MaterialGroup newMaterial; MaterialGroup newMaterial;
@@ -210,14 +211,14 @@ void RawModelCustom::ReadAnimationFile(std::string filePath)
return; return;
} }
unsigned int fileByteSize = in.tellg(); unsigned int fileByteSize = static_cast<unsigned int>(in.tellg());
in.seekg(0, std::ios_base::beg); in.seekg(0, std::ios_base::beg);
fileData = new char[fileByteSize]; fileData = new char[fileByteSize];
in.read(fileData, fileByteSize); in.read(fileData, fileByteSize);
in.close(); in.close();
unsigned int offset = 0; std::size_t offset = 0;
if (fileByteSize > 0) { if (fileByteSize > 0) {
m_Skeleton = new Skeleton(); m_Skeleton = new Skeleton();
@@ -235,7 +236,7 @@ void RawModelCustom::ReadAnimationFile(std::string filePath)
delete fileData; delete fileData;
} }
void RawModelCustom::ReadAnimationBindPoses(unsigned int &offset, char* fileData, unsigned int& fileByteSize) void RawModelCustom::ReadAnimationBindPoses(std::size_t& offset, char* fileData, const unsigned int& fileByteSize)
{ {
#ifdef BOOST_LITTLE_ENDIAN #ifdef BOOST_LITTLE_ENDIAN
unsigned int* numBones = (unsigned int*)(fileData + offset); unsigned int* numBones = (unsigned int*)(fileData + offset);
@@ -248,7 +249,7 @@ void RawModelCustom::ReadAnimationBindPoses(unsigned int &offset, char* fileData
#endif #endif
} }
void RawModelCustom::ReadAnimationJoint(unsigned int &offset, char* fileData, unsigned int& fileByteSize) void RawModelCustom::ReadAnimationJoint(std::size_t& offset, char* fileData, const unsigned int& fileByteSize)
{ {
#ifdef BOOST_LITTLE_ENDIAN #ifdef BOOST_LITTLE_ENDIAN
if (offset + sizeof(unsigned int) > fileByteSize) { if (offset + sizeof(unsigned int) > fileByteSize) {
@@ -290,14 +291,14 @@ void RawModelCustom::ReadAnimationJoint(unsigned int &offset, char* fileData, un
#endif #endif
} }
void RawModelCustom::ReadAnimationClips(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int numberOfClips) void RawModelCustom::ReadAnimationClips(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int numberOfClips)
{ {
for (unsigned int i = 0; i < numberOfClips; i++) { for (unsigned int i = 0; i < numberOfClips; i++) {
ReadAnimationClipSingle(offset, fileData, fileByteSize, i); ReadAnimationClipSingle(offset, fileData, fileByteSize, i);
} }
} }
void RawModelCustom::ReadAnimationClipSingle(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int clipIndex) void RawModelCustom::ReadAnimationClipSingle(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int clipIndex)
{ {
#ifdef BOOST_LITTLE_ENDIAN #ifdef BOOST_LITTLE_ENDIAN
Skeleton::Animation newAnimation; Skeleton::Animation newAnimation;
@@ -342,7 +343,7 @@ void RawModelCustom::ReadAnimationClipSingle(unsigned int &offset, char* fileDat
#endif #endif
} }
void RawModelCustom::ReadAnimationKeyFrame(unsigned int &offset, char* fileData, unsigned int& fileByteSize, unsigned int nrOfJoints, Skeleton::Animation& animation) void RawModelCustom::ReadAnimationKeyFrame(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int numberOfJoints, Skeleton::Animation& animation)
{ {
Skeleton::Animation::Keyframe newKeyFrame; Skeleton::Animation::Keyframe newKeyFrame;
@@ -358,12 +359,12 @@ void RawModelCustom::ReadAnimationKeyFrame(unsigned int &offset, char* fileData,
newKeyFrame.Time = *(float*)(fileData + offset); newKeyFrame.Time = *(float*)(fileData + offset);
offset += sizeof(float); offset += sizeof(float);
if (offset + sizeof(Skeleton::Animation::Keyframe::BoneProperty) * nrOfJoints> fileByteSize) { if (offset + sizeof(Skeleton::Animation::Keyframe::BoneProperty) * numberOfJoints> fileByteSize) {
throw Resource::FailedLoadingException("Reading AnimationKeyFrame joints failed"); throw Resource::FailedLoadingException("Reading AnimationKeyFrame joints failed");
} }
Skeleton::Animation::Keyframe::BoneProperty newBone; Skeleton::Animation::Keyframe::BoneProperty newBone;
for (unsigned int i = 0; i < nrOfJoints; i++) { for (unsigned int i = 0; i < numberOfJoints; i++) {
memcpy(&newBone, (fileData + offset), sizeof(Skeleton::Animation::Keyframe::BoneProperty)); memcpy(&newBone, (fileData + offset), sizeof(Skeleton::Animation::Keyframe::BoneProperty));
offset += sizeof(Skeleton::Animation::Keyframe::BoneProperty); offset += sizeof(Skeleton::Animation::Keyframe::BoneProperty);
newKeyFrame.BoneProperties[newBone.ID] = newBone; newKeyFrame.BoneProperties[newBone.ID] = newBone;
+1 -1
View File
@@ -21,7 +21,7 @@ GLuint Shader::CompileShader(GLenum shaderType, std::string fileName)
return 0; return 0;
const GLchar* shaderFiles = shaderFile.c_str(); const GLchar* shaderFiles = shaderFile.c_str();
const GLint length = shaderFile.length(); const GLint length = static_cast<GLint>(shaderFile.length());
glShaderSource(shader, 1, &shaderFiles, &length); glShaderSource(shader, 1, &shaderFiles, &length);
if (GLERROR("glShaderSource")) if (GLERROR("glShaderSource"))
return 0; return 0;
+2 -2
View File
@@ -53,11 +53,11 @@ std::vector<glm::mat4> Skeleton::GetFrameBones(const Animation& animation, doubl
const Animation::Keyframe& currentFrame = animation.Keyframes[currentKeyframeIndex]; const Animation::Keyframe& currentFrame = animation.Keyframes[currentKeyframeIndex];
const Animation::Keyframe& nextFrame = animation.Keyframes[(currentKeyframeIndex + 1) % animation.Keyframes.size()]; const Animation::Keyframe& nextFrame = animation.Keyframes[(currentKeyframeIndex + 1) % animation.Keyframes.size()];
float alpha = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); double alpha = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
//auto animationFrame = Animations[""].Keyframes[frame]; //auto animationFrame = Animations[""].Keyframes[frame];
std::map<int, glm::mat4> frameBones; std::map<int, glm::mat4> frameBones;
AccumulateBoneTransforms(noRootMotion, currentFrame, nextFrame, alpha, frameBones, RootBone, glm::mat4(1)); AccumulateBoneTransforms(noRootMotion, currentFrame, nextFrame, static_cast<float>(alpha), frameBones, RootBone, glm::mat4(1));
std::vector<glm::mat4> finalMatrices; std::vector<glm::mat4> finalMatrices;
for (auto &kv : frameBones) { for (auto &kv : frameBones) {
+5 -1
View File
@@ -116,7 +116,11 @@ void SoundSystem::updateEmitters(double dt)
setSourcePos(it->second->ALsource, nextPos); setSourcePos(it->second->ALsource, nextPos);
setSourceVel(it->second->ALsource, velocity); setSourceVel(it->second->ALsource, velocity);
float gain; float gain;
(bool)(it->second->Type) ? gain = m_SFXVolumeChannel : gain = m_BGMVolumeChannel; if (it->second->Type == SoundType::SFX) {
gain = m_SFXVolumeChannel;
} else if (it->second->Type == SoundType::BGM) {
gain = m_BGMVolumeChannel;
}
auto emitter = m_World->GetComponent(it->first, "SoundEmitter"); auto emitter = m_World->GetComponent(it->first, "SoundEmitter");
setSoundProperties(it->second->ALsource, &emitter); setSoundProperties(it->second->ALsource, &emitter);
+5 -2
View File
@@ -74,6 +74,7 @@ Game::Game(int argc, char* argv[])
// Create Octrees // Create Octrees
m_OctreeCollision = new Octree<EntityAABB>(AABB(glm::vec3(-100), glm::vec3(100)), 4); m_OctreeCollision = new Octree<EntityAABB>(AABB(glm::vec3(-100), glm::vec3(100)), 4);
m_OctreeTrigger = new Octree<EntityAABB>(AABB(glm::vec3(-100), glm::vec3(100)), 4);
m_OctreeFrustrumCulling = new Octree<EntityAABB>(AABB(glm::vec3(-100), glm::vec3(100)), 4); m_OctreeFrustrumCulling = new Octree<EntityAABB>(AABB(glm::vec3(-100), glm::vec3(100)), 4);
// Create system pipeline // Create system pipeline
m_SystemPipeline = new SystemPipeline(m_World, m_EventBroker); m_SystemPipeline = new SystemPipeline(m_World, m_EventBroker);
@@ -92,14 +93,15 @@ Game::Game(int argc, char* argv[])
m_SystemPipeline->AddSystem<CapturePointSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<CapturePointSystem>(updateOrderLevel);
// Populate Octree with collidables // Populate Octree with collidables
++updateOrderLevel; ++updateOrderLevel;
m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeCollision); m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player");
m_SystemPipeline->AddSystem<PlayerHUD>(updateOrderLevel); m_SystemPipeline->AddSystem<PlayerHUD>(updateOrderLevel);
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
// Collision and TriggerSystem should update after player. // Collision and TriggerSystem should update after player.
++updateOrderLevel; ++updateOrderLevel;
m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision); m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision);
m_SystemPipeline->AddSystem<TriggerSystem>(updateOrderLevel, m_OctreeCollision); m_SystemPipeline->AddSystem<TriggerSystem>(updateOrderLevel, m_OctreeTrigger);
++updateOrderLevel; ++updateOrderLevel;
m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame); m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame);
++updateOrderLevel; ++updateOrderLevel;
@@ -123,6 +125,7 @@ Game::~Game()
delete m_SoundSystem; delete m_SoundSystem;
delete m_OctreeFrustrumCulling; delete m_OctreeFrustrumCulling;
delete m_OctreeCollision; delete m_OctreeCollision;
delete m_OctreeTrigger;
delete m_World; delete m_World;
delete m_FrameStack; delete m_FrameStack;
delete m_InputProxy; delete m_InputProxy;
+4 -3
View File
@@ -64,9 +64,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
std::map<std::string, int> nextPossibleCapturePoint; std::map<std::string, int> nextPossibleCapturePoint;
nextPossibleCapturePoint["Red"] = -1; nextPossibleCapturePoint["Red"] = -1;
nextPossibleCapturePoint["Blue"] = -1; nextPossibleCapturePoint["Blue"] = -1;
for (size_t i = 0; i < m_NumberOfCapturePoints; i++) for (int i = 0; i < m_NumberOfCapturePoints; i++)
{ {
if (m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) {
continue; continue;
} }
ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"]; ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"];
@@ -93,7 +93,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
//reset timers and reset the bool that triggers this //reset timers and reset the bool that triggers this
if (m_ResetTimers) { if (m_ResetTimers) {
for (size_t i = 0; i < m_NumberOfCapturePoints; i++) for (int i = 0; i < m_NumberOfCapturePoints; i++)
{ {
ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"]; ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"];
if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] && if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] &&
@@ -119,6 +119,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
if (std::get<1>(triggerTouched) == capturePointEntity) { if (std::get<1>(triggerTouched) == capturePointEntity) {
//some player has touched this - lets figure out: what team, health //some player has touched this - lets figure out: what team, health
EntityWrapper player = std::get<0>(triggerTouched); EntityWrapper player = std::get<0>(triggerTouched);
//check if its really a player that has triggered the touch
if (!player.HasComponent("Player")) { if (!player.HasComponent("Player")) {
//if a non-player has entered the capturePoint, just erase that event and continue //if a non-player has entered the capturePoint, just erase that event and continue
m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i - 1); m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i - 1);
+7 -1
View File
@@ -76,7 +76,13 @@ void PlayerMovementSystem::Update(double dt)
ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity));
} }
if (controller->Jumping() && !controller->Crouching() && velocity.y == 0.f) { if (controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !controller->DoubleJumping())) {
if (velocity.y == 0.f) {
controller->SetDoubleJumping(false);
}
else {
controller->SetDoubleJumping(true);
}
velocity.y += 4.f; velocity.y += 4.f;
} }
+1 -1
View File
@@ -30,7 +30,7 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent /
if (spawnPoints.size() > 1) { if (spawnPoints.size() > 1) {
static std::random_device randomDevice; static std::random_device randomDevice;
static std::mt19937 randomGenerator(randomDevice()); static std::mt19937 randomGenerator(randomDevice());
std::uniform_int_distribution<> distribution(0, std::distance(spawnPoints.begin(), spawnPoints.end()) - 1); std::uniform_int_distribution<> distribution(0, static_cast<int>(std::distance(spawnPoints.begin(), spawnPoints.end())) - 1);
auto randomSpawnPointIt = spawnPoints.begin(); auto randomSpawnPointIt = spawnPoints.begin();
std::advance(randomSpawnPointIt, distribution(randomGenerator)); std::advance(randomSpawnPointIt, distribution(randomGenerator));
spawnPoint = *randomSpawnPointIt; spawnPoint = *randomSpawnPointIt;