Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b1a59e0ed2 | |||
| b3038ef713 |
@@ -29,7 +29,6 @@ struct EntityWrapper
|
|||||||
EntityWrapper Parent();
|
EntityWrapper Parent();
|
||||||
EntityWrapper FirstChildByName(const std::string& name);
|
EntityWrapper FirstChildByName(const std::string& name);
|
||||||
EntityWrapper FirstParentWithComponent(const std::string& componentType);
|
EntityWrapper FirstParentWithComponent(const std::string& componentType);
|
||||||
EntityWrapper Clone(EntityWrapper parent = EntityWrapper::Invalid);
|
|
||||||
bool IsChildOf(EntityWrapper potentialParent);
|
bool IsChildOf(EntityWrapper potentialParent);
|
||||||
bool Valid() const;
|
bool Valid() const;
|
||||||
|
|
||||||
@@ -40,7 +39,6 @@ struct EntityWrapper
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent);
|
EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent);
|
||||||
EntityWrapper cloneRecursive(EntityWrapper entity, EntityWrapper parent);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
// Change the parent of an entity
|
// Change the parent of an entity
|
||||||
void SetParent(EntityID entity, EntityID parent);
|
void SetParent(EntityID entity, EntityID parent);
|
||||||
// Get children of an entity
|
// Get children of an entity
|
||||||
const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> GetDirectChildren(EntityID entity);
|
const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> GetChildren(EntityID entity);
|
||||||
// Get all component pools
|
// Get all component pools
|
||||||
const std::unordered_map<std::string, ComponentPool*>& GetComponentPools() const { return m_ComponentPools; }
|
const std::unordered_map<std::string, ComponentPool*>& GetComponentPools() const { return m_ComponentPools; }
|
||||||
// Get the entity children map
|
// Get the entity children map
|
||||||
|
|||||||
@@ -73,12 +73,6 @@ public:
|
|||||||
// Called when the user means to rename an entity.
|
// Called when the user means to rename an entity.
|
||||||
typedef std::function<void(EntityWrapper, const std::string&)> OnEntityChangeName_t;
|
typedef std::function<void(EntityWrapper, const std::string&)> OnEntityChangeName_t;
|
||||||
void SetEntityChangeNameCallback(OnEntityChangeName_t f) { m_OnEntityChangeName = f; }
|
void SetEntityChangeNameCallback(OnEntityChangeName_t f) { m_OnEntityChangeName = f; }
|
||||||
// Called when the user pastes an entity previously "copied"
|
|
||||||
// @param EntityWrapper The entity to copy
|
|
||||||
// @param EntityWrapper The entity to parent the new copy to
|
|
||||||
// @return The new copy of the entity
|
|
||||||
typedef std::function<EntityWrapper(EntityWrapper, EntityWrapper)> OnEntityPaste_t;
|
|
||||||
void SetEntityPasteCallback(OnEntityPaste_t f) { m_OnEntityPaste = f; }
|
|
||||||
// Called when the user means to attach a new component to an entity.
|
// Called when the user means to attach a new component to an entity.
|
||||||
typedef std::function<void(EntityWrapper, const std::string&)> OnComponentAttach_t;
|
typedef std::function<void(EntityWrapper, const std::string&)> OnComponentAttach_t;
|
||||||
void SetComponentAttachCallback(OnComponentAttach_t f) { m_OnComponentAttach = f; }
|
void SetComponentAttachCallback(OnComponentAttach_t f) { m_OnComponentAttach = f; }
|
||||||
@@ -117,7 +111,6 @@ private:
|
|||||||
std::string m_DroppedFile = "";
|
std::string m_DroppedFile = "";
|
||||||
bool m_Paused = false;
|
bool m_Paused = false;
|
||||||
bool m_MouseLocked = false;
|
bool m_MouseLocked = false;
|
||||||
EntityWrapper m_CopyTarget = EntityWrapper::Invalid;
|
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
OnEntitySelectedCallback_t m_OnEntitySelected = nullptr;
|
OnEntitySelectedCallback_t m_OnEntitySelected = nullptr;
|
||||||
@@ -131,7 +124,6 @@ private:
|
|||||||
OnComponentDelete_t m_OnComponentDelete = nullptr;
|
OnComponentDelete_t m_OnComponentDelete = nullptr;
|
||||||
OnWidgetMode_t m_OnWidgetMode = nullptr;
|
OnWidgetMode_t m_OnWidgetMode = nullptr;
|
||||||
OnWidgetSpace_t m_OnWidgetSpace = nullptr;
|
OnWidgetSpace_t m_OnWidgetSpace = nullptr;
|
||||||
OnEntityPaste_t m_OnEntityPaste = nullptr;
|
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
EventRelay<EditorGUI, Events::KeyDown> m_EKeyDown;
|
EventRelay<EditorGUI, Events::KeyDown> m_EKeyDown;
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ private:
|
|||||||
void OnEntityDelete(EntityWrapper entity);
|
void OnEntityDelete(EntityWrapper entity);
|
||||||
void OnEntityChangeParent(EntityWrapper entity, EntityWrapper parent);
|
void OnEntityChangeParent(EntityWrapper entity, EntityWrapper parent);
|
||||||
void OnEntityChangeName(EntityWrapper entity, const std::string& name);
|
void OnEntityChangeName(EntityWrapper entity, const std::string& name);
|
||||||
EntityWrapper OnEntityPaste(EntityWrapper entityToCopy, EntityWrapper parent);
|
|
||||||
void OnComponentAttach(EntityWrapper entity, const std::string& componentType);
|
void OnComponentAttach(EntityWrapper entity, const std::string& componentType);
|
||||||
void OnComponentDelete(EntityWrapper entity, const std::string& componentType);
|
void OnComponentDelete(EntityWrapper entity, const std::string& componentType);
|
||||||
void OnWidgetSpace(EditorGUI::WidgetSpace widgetSpace);
|
void OnWidgetSpace(EditorGUI::WidgetSpace widgetSpace);
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Core/ConfigFile.h"
|
#include "Core/ConfigFile.h"
|
||||||
#include "Core/EPlayerDeath.h"
|
|
||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
#include "Core/EPlayerDamage.h"
|
#include "Core/EPlayerDamage.h"
|
||||||
#include "../Game/Events/EDoubleJump.h"
|
#include "../Game/Events/EDoubleJump.h"
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public:
|
|||||||
std::string GetFileName() const;
|
std::string GetFileName() const;
|
||||||
GLuint GetHandle() const;
|
GLuint GetHandle() const;
|
||||||
bool IsCompiled() const;
|
bool IsCompiled() const;
|
||||||
|
static std::string ReadFile(std::string fileName);
|
||||||
|
private:
|
||||||
protected:
|
protected:
|
||||||
GLenum m_ShaderType;
|
GLenum m_ShaderType;
|
||||||
std::string m_FileName;
|
std::string m_FileName;
|
||||||
|
|||||||
@@ -116,12 +116,7 @@ LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensi
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap)
|
#include "Shaders/Util/CommonUniforms.glsl"
|
||||||
{
|
|
||||||
mat3 TBN = mat3(tangent, bitangent, normal);
|
|
||||||
vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0);
|
|
||||||
return vec4(TBN * normalize(NormalMap), 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
@@ -180,6 +175,7 @@ void main()
|
|||||||
color_result += FillColor;
|
color_result += FillColor;
|
||||||
}
|
}
|
||||||
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
||||||
|
//sceneColor = CommonUniforms.testColour;
|
||||||
//sceneColor = vec4(reflectionColor.xyz, 1);
|
//sceneColor = vec4(reflectionColor.xyz, 1);
|
||||||
color_result += glowTexel*GlowIntensity;
|
color_result += glowTexel*GlowIntensity;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap)
|
||||||
|
{
|
||||||
|
mat3 TBN = mat3(tangent, bitangent, normal);
|
||||||
|
vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0);
|
||||||
|
return vec4(TBN * normalize(NormalMap), 0.0);
|
||||||
|
}
|
||||||
@@ -51,17 +51,6 @@ EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& compone
|
|||||||
return EntityWrapper::Invalid;
|
return EntityWrapper::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityWrapper EntityWrapper::Clone(EntityWrapper parent /*= Invalid*/)
|
|
||||||
{
|
|
||||||
if (!Valid()) {
|
|
||||||
return EntityWrapper::Invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
EntityWrapper clone = cloneRecursive(*this, EntityWrapper::Invalid);
|
|
||||||
this->World->SetParent(clone.ID, parent.ID);
|
|
||||||
return clone;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EntityWrapper::IsChildOf(EntityWrapper potentialParent)
|
bool EntityWrapper::IsChildOf(EntityWrapper potentialParent)
|
||||||
{
|
{
|
||||||
EntityWrapper entity = *this;
|
EntityWrapper entity = *this;
|
||||||
@@ -122,7 +111,7 @@ EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name,
|
|||||||
return EntityWrapper::Invalid;
|
return EntityWrapper::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto itPair = this->World->GetDirectChildren(parent);
|
auto itPair = this->World->GetChildren(parent);
|
||||||
if (itPair.first == itPair.second) {
|
if (itPair.first == itPair.second) {
|
||||||
return EntityWrapper::Invalid;
|
return EntityWrapper::Invalid;
|
||||||
}
|
}
|
||||||
@@ -142,27 +131,3 @@ EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name,
|
|||||||
return EntityWrapper::Invalid;
|
return EntityWrapper::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityWrapper EntityWrapper::cloneRecursive(EntityWrapper entity, EntityWrapper parent)
|
|
||||||
{
|
|
||||||
EntityWrapper clone = EntityWrapper(entity.World, entity.World->CreateEntity(parent.ID));
|
|
||||||
entity.World->SetName(clone.ID, entity.Name());
|
|
||||||
|
|
||||||
// Clone components
|
|
||||||
for (auto& kv : entity.World->GetComponentPools()) {
|
|
||||||
if (kv.second->KnowsEntity(entity.ID)) {
|
|
||||||
ComponentWrapper c1 = kv.second->GetByEntity(entity.ID);
|
|
||||||
ComponentWrapper c2 = entity.World->AttachComponent(clone.ID, kv.first);
|
|
||||||
c1.Copy(c2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clone children
|
|
||||||
auto children = entity.World->GetDirectChildren(entity.ID);
|
|
||||||
for (auto it = children.first; it != children.second; ++it) {
|
|
||||||
EntityWrapper child(entity.World, it->second);
|
|
||||||
cloneRecursive(child, clone);
|
|
||||||
}
|
|
||||||
|
|
||||||
return clone;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ void World::SetParent(EntityID entity, EntityID parent)
|
|||||||
m_EntityChildren.insert(std::make_pair(parent, entity));
|
m_EntityChildren.insert(std::make_pair(parent, entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> World::GetDirectChildren(EntityID entity)
|
const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> World::GetChildren(EntityID entity)
|
||||||
{
|
{
|
||||||
return m_EntityChildren.equal_range(entity);
|
return m_EntityChildren.equal_range(entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -580,11 +580,6 @@ void EditorGUI::createWidgetToolButton(WidgetMode mode)
|
|||||||
|
|
||||||
bool EditorGUI::OnKeyDown(const Events::KeyDown& e)
|
bool EditorGUI::OnKeyDown(const Events::KeyDown& e)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
if (io.WantCaptureKeyboard) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.ModCtrl && e.KeyCode == GLFW_KEY_S) {
|
if (e.ModCtrl && e.KeyCode == GLFW_KEY_S) {
|
||||||
if (m_CurrentSelection.Valid()) {
|
if (m_CurrentSelection.Valid()) {
|
||||||
EntityWrapper baseParent = m_CurrentSelection;
|
EntityWrapper baseParent = m_CurrentSelection;
|
||||||
@@ -603,19 +598,6 @@ bool EditorGUI::OnKeyDown(const Events::KeyDown& e)
|
|||||||
entityImport(m_World);
|
entityImport(m_World);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.ModCtrl && e.KeyCode == GLFW_KEY_C) {
|
|
||||||
m_CopyTarget = m_CurrentSelection;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.ModCtrl && e.KeyCode == GLFW_KEY_V) {
|
|
||||||
if (m_OnEntityPaste != nullptr) {
|
|
||||||
EntityWrapper copy = m_OnEntityPaste(m_CopyTarget, m_CurrentSelection);
|
|
||||||
if (copy != EntityWrapper::Invalid) {
|
|
||||||
SelectEntity(copy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.KeyCode == GLFW_KEY_DELETE) {
|
if (e.KeyCode == GLFW_KEY_DELETE) {
|
||||||
if (m_CurrentSelection.Valid()) {
|
if (m_CurrentSelection.Valid()) {
|
||||||
entityDelete(m_CurrentSelection);
|
entityDelete(m_CurrentSelection);
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
|
|||||||
m_EditorGUI->SetEntityDeleteCallback(std::bind(&EditorSystem::OnEntityDelete, this, std::placeholders::_1));
|
m_EditorGUI->SetEntityDeleteCallback(std::bind(&EditorSystem::OnEntityDelete, this, std::placeholders::_1));
|
||||||
m_EditorGUI->SetEntityChangeParentCallback(std::bind(&EditorSystem::OnEntityChangeParent, this, std::placeholders::_1, std::placeholders::_2));
|
m_EditorGUI->SetEntityChangeParentCallback(std::bind(&EditorSystem::OnEntityChangeParent, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
m_EditorGUI->SetEntityChangeNameCallback(std::bind(&EditorSystem::OnEntityChangeName, this, std::placeholders::_1, std::placeholders::_2));
|
m_EditorGUI->SetEntityChangeNameCallback(std::bind(&EditorSystem::OnEntityChangeName, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
m_EditorGUI->SetEntityPasteCallback(std::bind(&EditorSystem::OnEntityPaste, this, std::placeholders::_1, std::placeholders::_2));
|
|
||||||
m_EditorGUI->SetComponentAttachCallback(std::bind(&EditorSystem::OnComponentAttach, this, std::placeholders::_1, std::placeholders::_2));
|
m_EditorGUI->SetComponentAttachCallback(std::bind(&EditorSystem::OnComponentAttach, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2));
|
m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
m_EditorGUI->SetWidgetModeCallback(std::bind(&EditorSystem::setWidgetMode, this, std::placeholders::_1));
|
m_EditorGUI->SetWidgetModeCallback(std::bind(&EditorSystem::setWidgetMode, this, std::placeholders::_1));
|
||||||
@@ -161,11 +160,6 @@ void EditorSystem::OnEntityChangeName(EntityWrapper entity, const std::string& n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityWrapper EditorSystem::OnEntityPaste(EntityWrapper entityToCopy, EntityWrapper parent)
|
|
||||||
{
|
|
||||||
return entityToCopy.Clone(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorSystem::OnComponentAttach(EntityWrapper entity, const std::string& componentType)
|
void EditorSystem::OnComponentAttach(EntityWrapper entity, const std::string& componentType)
|
||||||
{
|
{
|
||||||
if (entity.Valid()) {
|
if (entity.Valid()) {
|
||||||
|
|||||||
@@ -261,14 +261,8 @@ void Client::parseEntityDeletion(Packet & packet)
|
|||||||
if (m_ServerIDToClientID.find(entityToDelete) != m_ServerIDToClientID.end()) {
|
if (m_ServerIDToClientID.find(entityToDelete) != m_ServerIDToClientID.end()) {
|
||||||
EntityID localEntity = m_ServerIDToClientID.at(entityToDelete);
|
EntityID localEntity = m_ServerIDToClientID.at(entityToDelete);
|
||||||
if (m_World->ValidEntity(localEntity)) {
|
if (m_World->ValidEntity(localEntity)) {
|
||||||
if (m_World->HasComponent(localEntity,"Player")) {
|
m_World->DeleteEntity(localEntity);
|
||||||
Events::PlayerDeath e;
|
deleteFromServerClientMaps(entityToDelete, localEntity);
|
||||||
e.Player = EntityWrapper(m_World, localEntity);
|
|
||||||
m_EventBroker->Publish(e);
|
|
||||||
} else {
|
|
||||||
m_World->DeleteEntity(localEntity);
|
|
||||||
deleteFromServerClientMaps(entityToDelete, localEntity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ void Server::addInputCommandsToPacket(Packet& packet)
|
|||||||
|
|
||||||
void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
|
void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
|
||||||
{
|
{
|
||||||
auto itPair = m_World->GetDirectChildren(entityID);
|
auto itPair = m_World->GetChildren(entityID);
|
||||||
std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools();
|
std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools();
|
||||||
// Loop through every child
|
// Loop through every child
|
||||||
for (auto it = itPair.first; it != itPair.second; it++) {
|
for (auto it = itPair.first; it != itPair.second; it++) {
|
||||||
@@ -234,7 +234,7 @@ void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
|
|||||||
|
|
||||||
void Server::addChildrenToPacket(Packet & packet, EntityID entityID)
|
void Server::addChildrenToPacket(Packet & packet, EntityID entityID)
|
||||||
{
|
{
|
||||||
auto itPair = m_World->GetDirectChildren(entityID);
|
auto itPair = m_World->GetChildren(entityID);
|
||||||
std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools();
|
std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools();
|
||||||
// Loop through every child
|
// Loop through every child
|
||||||
for (auto it = itPair.first; it != itPair.second; it++) {
|
for (auto it = itPair.first; it != itPair.second; it++) {
|
||||||
@@ -601,7 +601,7 @@ void Server::parsePlayerTransform(Packet& packet)
|
|||||||
|
|
||||||
bool Server::shouldSendToClient(EntityWrapper childEntity)
|
bool Server::shouldSendToClient(EntityWrapper childEntity)
|
||||||
{
|
{
|
||||||
auto children = m_World->GetDirectChildren(childEntity.ID);
|
auto children = m_World->GetChildren(childEntity.ID);
|
||||||
for (auto it = children.first; it != children.second; it++) {
|
for (auto it = children.first; it != children.second; it++) {
|
||||||
EntityWrapper child(m_World, it->second);
|
EntityWrapper child(m_World, it->second);
|
||||||
if(child.HasComponent("CapturePoint")) {
|
if(child.HasComponent("CapturePoint")) {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ void CubeMapPass::LoadTextures(std::string input)
|
|||||||
m_CubeMapTextures.push_back(img);
|
m_CubeMapTextures.push_back(img);
|
||||||
}
|
}
|
||||||
GenerateCubeMapTexture();
|
GenerateCubeMapTexture();
|
||||||
m_PreviusCubeMapTexture = input;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,22 +4,32 @@ GLuint Shader::CompileShader(GLenum shaderType, std::string fileName)
|
|||||||
{
|
{
|
||||||
LOG_INFO("Compiling shader \"%s\"", fileName.c_str());
|
LOG_INFO("Compiling shader \"%s\"", fileName.c_str());
|
||||||
|
|
||||||
std::string shaderFile;
|
std::string shaderFile = ReadFile(fileName);
|
||||||
std::ifstream in(fileName, std::ios::in);
|
|
||||||
if (!in) {
|
|
||||||
LOG_ERROR("Error: Failed to open shader file \"%s\"", fileName.c_str());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
in.seekg(0, std::ios::end);
|
|
||||||
shaderFile.resize((int)in.tellg());
|
|
||||||
in.seekg(0, std::ios::beg);
|
|
||||||
in.read(&shaderFile[0], shaderFile.size());
|
|
||||||
in.close();
|
|
||||||
|
|
||||||
GLuint shader = glCreateShader(shaderType);
|
GLuint shader = glCreateShader(shaderType);
|
||||||
if (GLERROR("glCreateShader"))
|
if (GLERROR("glCreateShader"))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
std::size_t startPos = 0;
|
||||||
|
std::size_t SEofNewFile[2];
|
||||||
|
std::string key = "#include";
|
||||||
|
while((startPos = shaderFile.find(key, startPos)) != std::string::npos)
|
||||||
|
{
|
||||||
|
SEofNewFile[0] = shaderFile.find('"', startPos+key.length())+1;
|
||||||
|
SEofNewFile[1] = shaderFile.find('"', SEofNewFile[0]);
|
||||||
|
if (SEofNewFile[0] == std::string::npos || SEofNewFile[1] == std::string::npos)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
std::string replacementFileName = shaderFile.substr(SEofNewFile[0], SEofNewFile[1] - SEofNewFile[0]);
|
||||||
|
std::string replacementString = ReadFile(replacementFileName);
|
||||||
|
size_t firstof = replacementString.find_first_of((char)0);
|
||||||
|
replacementString.erase(firstof, replacementString.size() - firstof);
|
||||||
|
if (replacementString.length() <= 0)
|
||||||
|
return 0;
|
||||||
|
shaderFile.replace(startPos, SEofNewFile[1]+2 - startPos, replacementString + "\n");
|
||||||
|
startPos += replacementString.length(); //This might not be wanted.
|
||||||
|
}
|
||||||
|
|
||||||
const GLchar* shaderFiles = shaderFile.c_str();
|
const GLchar* shaderFiles = shaderFile.c_str();
|
||||||
const GLint length = static_cast<GLint>(shaderFile.length());
|
const GLint length = static_cast<GLint>(shaderFile.length());
|
||||||
glShaderSource(shader, 1, &shaderFiles, &length);
|
glShaderSource(shader, 1, &shaderFiles, &length);
|
||||||
@@ -46,6 +56,24 @@ GLuint Shader::CompileShader(GLenum shaderType, std::string fileName)
|
|||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Shader::ReadFile(std::string fileName)
|
||||||
|
{
|
||||||
|
std::string shaderFile;
|
||||||
|
std::ifstream in(fileName, std::ios::in);
|
||||||
|
if (!in) {
|
||||||
|
LOG_ERROR("Error: Failed to open shader file \"%s\"", fileName.c_str());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
in.seekg(0, std::ios::end);
|
||||||
|
shaderFile.resize((int)in.tellg());
|
||||||
|
in.seekg(0, std::ios::beg);
|
||||||
|
in.read(&shaderFile[0], shaderFile.size());
|
||||||
|
in.close();
|
||||||
|
return shaderFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Shader::Shader(GLenum shaderType, std::string fileName) : m_ShaderType(shaderType), m_FileName(fileName)
|
Shader::Shader(GLenum shaderType, std::string fileName) : m_ShaderType(shaderType), m_FileName(fileName)
|
||||||
{
|
{
|
||||||
m_ShaderHandle = 0;
|
m_ShaderHandle = 0;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent /
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find any SpawnPoints existing as children of spawner
|
// Find any SpawnPoints existing as children of spawner
|
||||||
auto children = spawner.World->GetDirectChildren(spawner.ID);
|
auto children = spawner.World->GetChildren(spawner.ID);
|
||||||
std::vector<EntityWrapper> spawnPoints;
|
std::vector<EntityWrapper> spawnPoints;
|
||||||
for (auto kv = children.first; kv != children.second; ++kv) {
|
for (auto kv = children.first; kv != children.second; ++kv) {
|
||||||
const EntityID& child = kv->second;
|
const EntityID& child = kv->second;
|
||||||
|
|||||||
Reference in New Issue
Block a user