From caa39719208a3c77915db74edbface023b99a93b Mon Sep 17 00:00:00 2001 From: dfranx Date: Thu, 2 Apr 2020 16:21:30 +0200 Subject: [PATCH] Add shader variables that point to object properties --- CHANGELOG.txt | 2 + src/SHADERed/GUIManager.cpp | 4 +- .../Objects/FunctionVariableManager.cpp | 253 ++++++++++-------- .../Objects/FunctionVariableManager.h | 27 +- src/SHADERed/Objects/Names.cpp | 1 + src/SHADERed/Objects/Names.h | 2 +- src/SHADERed/Objects/ProjectParser.cpp | 13 +- src/SHADERed/Objects/ShaderVariable.h | 3 +- .../Objects/ShaderVariableContainer.cpp | 4 +- src/SHADERed/UI/Tools/VariableValueEdit.cpp | 72 ++++- 10 files changed, 256 insertions(+), 125 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index f72b9327..a872e158 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,9 +1,11 @@ [v1.3.2] + add texture properties ++ add shader variables that point to shader properties + add "Changelog" popup which shows up on startup after an update + add "Show tips on startup" option + add "This will unassign Shortcut.ID" popup when changing shortcuts + fix ScreenQuad position and size on other RTs ++ fix a bug that caused SHADERed to crash when clicking on shader variable function list combobox [v1.3.1] + add confirmation dialog when deleting a shader pass item diff --git a/src/SHADERed/GUIManager.cpp b/src/SHADERed/GUIManager.cpp index 5283fed3..f547a3d9 100644 --- a/src/SHADERed/GUIManager.cpp +++ b/src/SHADERed/GUIManager.cpp @@ -196,6 +196,8 @@ namespace ed { m_checkChangelog(); + FunctionVariableManager::Instance().Initialize(&objects->Pipeline); + m_data->Renderer.Pause(Settings::Instance().Preview.PausedOnStartup); } GUIManager::~GUIManager() @@ -515,7 +517,7 @@ namespace ed { // update audio textures m_data->Objects.Update(delta); - FunctionVariableManager::ClearVariableList(); + FunctionVariableManager::Instance().ClearVariableList(); // update editor & workspace font if (((CodeEditorUI*)Get(ViewID::Code))->NeedsFontUpdate() || ((m_cachedFont != settings.General.Font || m_cachedFontSize != settings.General.FontSize) && strcmp(settings.General.Font, "null") != 0) || m_fontNeedsUpdate) { diff --git a/src/SHADERed/Objects/FunctionVariableManager.cpp b/src/SHADERed/Objects/FunctionVariableManager.cpp index 5ce6a324..e4e57b50 100644 --- a/src/SHADERed/Objects/FunctionVariableManager.cpp +++ b/src/SHADERed/Objects/FunctionVariableManager.cpp @@ -5,115 +5,26 @@ #include namespace ed { - int FunctionVariableManager::CurrentIndex = 0; - std::vector FunctionVariableManager::VariableList = std::vector(); - - size_t FunctionVariableManager::GetArgumentCount(ed::FunctionShaderVariable func) + FunctionVariableManager::FunctionVariableManager() { - switch (func) { - case FunctionShaderVariable::MatrixIdentity: return 0; - case FunctionShaderVariable::MatrixLookAtLH: return 9; - case FunctionShaderVariable::MatrixLookToLH: return 9; - case FunctionShaderVariable::MatrixOrthographicLH: return 4; - case FunctionShaderVariable::MatrixPerspectiveFovLH: return 4; - case FunctionShaderVariable::MatrixPerspectiveLH: return 4; - case FunctionShaderVariable::MatrixRotationAxis: return 4; - case FunctionShaderVariable::MatrixRotationNormal: return 4; - case FunctionShaderVariable::MatrixRotationRollPitchYaw: return 3; - case FunctionShaderVariable::MatrixRotationX: return 1; - case FunctionShaderVariable::MatrixRotationY: return 1; - case FunctionShaderVariable::MatrixRotationZ: return 1; - case FunctionShaderVariable::MatrixScaling: return 3; - case FunctionShaderVariable::MatrixTranslation: return 3; - case FunctionShaderVariable::ScalarCos: return 1; - case FunctionShaderVariable::ScalarSin: return 1; - case FunctionShaderVariable::Pointer: return 1; - case FunctionShaderVariable::CameraSnapshot: return 1; - case FunctionShaderVariable::VectorNormalize: return 4; - } - return 0; + m_currentIndex = 0; } - void FunctionVariableManager::AllocateArgumentSpace(ed::ShaderVariable* var, ed::FunctionShaderVariable func) - { - size_t args = GetArgumentCount(func) * sizeof(float); - if (func == FunctionShaderVariable::PluginFunction) - args = var->PluginFuncData.Owner->GetVariableFunctionArgSpaceSize(var->PluginFuncData.Name, (plugin::VariableType)var->GetType()); - var->Function = func; - - if (func == ed::FunctionShaderVariable::Pointer || func == ed::FunctionShaderVariable::CameraSnapshot) - args = sizeof(char) * VARIABLE_NAME_LENGTH; - - if (var->Arguments != nullptr) { - free(var->Arguments); - var->Arguments = (char*)calloc(args, 1); - // set default values - switch (func) { - case FunctionShaderVariable::MatrixLookAtLH: - *LoadFloat(var->Arguments, 5) = 1; - *LoadFloat(var->Arguments, 7) = 1; - break; - case FunctionShaderVariable::MatrixLookToLH: - *LoadFloat(var->Arguments, 5) = 1; - *LoadFloat(var->Arguments, 7) = 1; - break; - case FunctionShaderVariable::MatrixPerspectiveLH: - case FunctionShaderVariable::MatrixOrthographicLH: - *LoadFloat(var->Arguments, 0) = 800; - *LoadFloat(var->Arguments, 1) = 600; - *LoadFloat(var->Arguments, 2) = 0.1f; - *LoadFloat(var->Arguments, 3) = 100.0f; - break; - case FunctionShaderVariable::MatrixPerspectiveFovLH: - *LoadFloat(var->Arguments, 0) = glm::half_pi(); - *LoadFloat(var->Arguments, 1) = 800 / 600.0f; - *LoadFloat(var->Arguments, 2) = 0.1f; - *LoadFloat(var->Arguments, 3) = 100.0f; - break; - case FunctionShaderVariable::MatrixRotationAxis: - *LoadFloat(var->Arguments, 0) = 1; - break; - case FunctionShaderVariable::MatrixRotationNormal: - *LoadFloat(var->Arguments, 0) = 1; - break; - case FunctionShaderVariable::VectorNormalize: - *LoadFloat(var->Arguments, 0) = 1; - break; - case FunctionShaderVariable::Pointer: - memset(var->Arguments, 0, VARIABLE_NAME_LENGTH * sizeof(char)); - break; - case FunctionShaderVariable::CameraSnapshot: - memset(var->Arguments, 0, VARIABLE_NAME_LENGTH * sizeof(char)); - break; - } - } else - var->Arguments = (char*)calloc(args, 1); - } - bool FunctionVariableManager::HasValidReturnType(ShaderVariable::ValueType ret, ed::FunctionShaderVariable func) + void FunctionVariableManager::Initialize(PipelineManager* pipe) { - if (func >= FunctionShaderVariable::MatrixIdentity && func <= FunctionShaderVariable::MatrixTranslation) - return ret == ShaderVariable::ValueType::Float4x4; - else if (func >= FunctionShaderVariable::ScalarCos && func <= FunctionShaderVariable::ScalarSin) - return ret == ShaderVariable::ValueType::Float1; - else if (func == FunctionShaderVariable::VectorNormalize) - return ret > ShaderVariable::ValueType::Float1 && ret <= ShaderVariable::ValueType::Float4; - else if (func == FunctionShaderVariable::CameraSnapshot) - return ret == ShaderVariable::ValueType::Float4x4; - else if (func == FunctionShaderVariable::Pointer) - return true; - return false; + m_pipeline = pipe; + m_currentIndex = 0; } + void FunctionVariableManager::AddToList(ed::ShaderVariable* var) { - int& curIndex = FunctionVariableManager::CurrentIndex; - std::vector& varList = FunctionVariableManager::VariableList; - for (int i = 0; i < curIndex; i++) - if (varList[i] == var) + for (int i = 0; i < m_currentIndex; i++) + if (VariableList[i] == var) return; // already exists - if (curIndex % 20 == 0) - varList.resize(curIndex + 20); - varList[curIndex] = var; - curIndex++; + if (m_currentIndex % 20 == 0) + VariableList.resize(m_currentIndex + 20); + VariableList[m_currentIndex] = var; + m_currentIndex++; } void FunctionVariableManager::Update(ed::ShaderVariable* var) { @@ -121,19 +32,47 @@ namespace ed { return; if (var->Function == FunctionShaderVariable::Pointer) { - std::vector& varList = FunctionVariableManager::VariableList; - for (int i = 0; i < varList.size(); i++) { - if (varList[i] == nullptr) + for (int i = 0; i < VariableList.size(); i++) { + if (VariableList[i] == nullptr) continue; - if (strcmp(varList[i]->Name, var->Arguments) == 0) { - memcpy(var->Data, varList[i]->Data, ShaderVariable::GetSize(var->GetType())); + if (strcmp(VariableList[i]->Name, var->Arguments) == 0) { + memcpy(var->Data, VariableList[i]->Data, ShaderVariable::GetSize(var->GetType())); break; } } } else if (var->Function == FunctionShaderVariable::CameraSnapshot) { glm::mat4 camVal = CameraSnapshots::Get(var->Arguments); memcpy(var->Data, glm::value_ptr(camVal), sizeof(glm::mat4)); + } else if (var->Function == FunctionShaderVariable::ObjectProperty) { + ed::PipelineItem* item = m_pipeline->Get(var->Arguments); + char* propName = var->Arguments + PIPELINE_ITEM_NAME_LENGTH; + glm::vec4 dataVal(0.0f); + + if (item->Type == PipelineItem::ItemType::Geometry) { + pipe::GeometryItem* geom = (pipe::GeometryItem*)item->Data; + + if (strcmp(propName, "Position") == 0) + dataVal = glm::vec4(geom->Position, 1.0f); + else if (strcmp(propName, "Scale") == 0) + dataVal = glm::vec4(geom->Scale, 0.0f); + else if (strcmp(propName, "Rotation") == 0) + dataVal = glm::vec4(geom->Rotation, 0.0f); + } else if (item->Type == PipelineItem::ItemType::Model) { + pipe::Model* mdl = (pipe::Model*)item->Data; + + if (strcmp(propName, "Position") == 0) + dataVal = glm::vec4(mdl->Position, 1.0f); + else if (strcmp(propName, "Scale") == 0) + dataVal = glm::vec4(mdl->Scale, 0.0f); + else if (strcmp(propName, "Rotation") == 0) + dataVal = glm::vec4(mdl->Rotation, 0.0f); + } + + if (var->GetType() == ShaderVariable::ValueType::Float3) + memcpy(var->Data, glm::value_ptr(dataVal), sizeof(glm::vec3)); + else if (var->GetType() == ShaderVariable::ValueType::Float4) + memcpy(var->Data, glm::value_ptr(dataVal), sizeof(glm::vec4)); } else if (var->Function >= FunctionShaderVariable::MatrixIdentity && var->Function <= FunctionShaderVariable::MatrixTranslation) { glm::mat4 matrix; @@ -264,8 +203,106 @@ namespace ed { } void FunctionVariableManager::ClearVariableList() { - FunctionVariableManager::VariableList.clear(); - FunctionVariableManager::CurrentIndex = 0; + VariableList.clear(); + m_currentIndex = 0; + } + + void FunctionVariableManager::AllocateArgumentSpace(ed::ShaderVariable* var, ed::FunctionShaderVariable func) + { + size_t args = GetArgumentCount(func) * sizeof(float); + if (func == FunctionShaderVariable::PluginFunction) + args = var->PluginFuncData.Owner->GetVariableFunctionArgSpaceSize(var->PluginFuncData.Name, (plugin::VariableType)var->GetType()); + var->Function = func; + + if (func == ed::FunctionShaderVariable::Pointer || func == ed::FunctionShaderVariable::CameraSnapshot || func == ed::FunctionShaderVariable::ObjectProperty) + args = sizeof(char) * VARIABLE_NAME_LENGTH; + + if (var->Arguments != nullptr) { + free(var->Arguments); + var->Arguments = (char*)calloc(args, 1); + + // set default values + switch (func) { + case FunctionShaderVariable::MatrixLookAtLH: + *LoadFloat(var->Arguments, 5) = 1; + *LoadFloat(var->Arguments, 7) = 1; + break; + case FunctionShaderVariable::MatrixLookToLH: + *LoadFloat(var->Arguments, 5) = 1; + *LoadFloat(var->Arguments, 7) = 1; + break; + case FunctionShaderVariable::MatrixPerspectiveLH: + case FunctionShaderVariable::MatrixOrthographicLH: + *LoadFloat(var->Arguments, 0) = 800; + *LoadFloat(var->Arguments, 1) = 600; + *LoadFloat(var->Arguments, 2) = 0.1f; + *LoadFloat(var->Arguments, 3) = 100.0f; + break; + case FunctionShaderVariable::MatrixPerspectiveFovLH: + *LoadFloat(var->Arguments, 0) = glm::half_pi(); + *LoadFloat(var->Arguments, 1) = 800 / 600.0f; + *LoadFloat(var->Arguments, 2) = 0.1f; + *LoadFloat(var->Arguments, 3) = 100.0f; + break; + case FunctionShaderVariable::MatrixRotationAxis: + *LoadFloat(var->Arguments, 0) = 1; + break; + case FunctionShaderVariable::MatrixRotationNormal: + *LoadFloat(var->Arguments, 0) = 1; + break; + case FunctionShaderVariable::VectorNormalize: + *LoadFloat(var->Arguments, 0) = 1; + break; + case FunctionShaderVariable::CameraSnapshot: + case FunctionShaderVariable::ObjectProperty: + case FunctionShaderVariable::Pointer: + memset(var->Arguments, 0, VARIABLE_NAME_LENGTH * sizeof(char)); + break; + } + } else + var->Arguments = (char*)calloc(args, 1); + } + size_t FunctionVariableManager::GetArgumentCount(ed::FunctionShaderVariable func) + { + switch (func) { + case FunctionShaderVariable::MatrixIdentity: return 0; + case FunctionShaderVariable::MatrixLookAtLH: return 9; + case FunctionShaderVariable::MatrixLookToLH: return 9; + case FunctionShaderVariable::MatrixOrthographicLH: return 4; + case FunctionShaderVariable::MatrixPerspectiveFovLH: return 4; + case FunctionShaderVariable::MatrixPerspectiveLH: return 4; + case FunctionShaderVariable::MatrixRotationAxis: return 4; + case FunctionShaderVariable::MatrixRotationNormal: return 4; + case FunctionShaderVariable::MatrixRotationRollPitchYaw: return 3; + case FunctionShaderVariable::MatrixRotationX: return 1; + case FunctionShaderVariable::MatrixRotationY: return 1; + case FunctionShaderVariable::MatrixRotationZ: return 1; + case FunctionShaderVariable::MatrixScaling: return 3; + case FunctionShaderVariable::MatrixTranslation: return 3; + case FunctionShaderVariable::ScalarCos: return 1; + case FunctionShaderVariable::ScalarSin: return 1; + case FunctionShaderVariable::Pointer: return 1; + case FunctionShaderVariable::CameraSnapshot: return 1; + case FunctionShaderVariable::ObjectProperty: return 2; + case FunctionShaderVariable::VectorNormalize: return 4; + } + return 0; + } + bool FunctionVariableManager::HasValidReturnType(ShaderVariable::ValueType ret, ed::FunctionShaderVariable func) + { + if (func >= FunctionShaderVariable::MatrixIdentity && func <= FunctionShaderVariable::MatrixTranslation) + return ret == ShaderVariable::ValueType::Float4x4; + else if (func >= FunctionShaderVariable::ScalarCos && func <= FunctionShaderVariable::ScalarSin) + return ret == ShaderVariable::ValueType::Float1; + else if (func == FunctionShaderVariable::VectorNormalize) + return ret > ShaderVariable::ValueType::Float1 && ret <= ShaderVariable::ValueType::Float4; + else if (func == FunctionShaderVariable::CameraSnapshot) + return ret == ShaderVariable::ValueType::Float4x4; + else if (func == FunctionShaderVariable::Pointer) + return true; + else if (func == FunctionShaderVariable::ObjectProperty) + return ret == ShaderVariable::ValueType::Float4 || ret == ShaderVariable::ValueType::Float3; + return false; } float* FunctionVariableManager::LoadFloat(char* data, int index) { diff --git a/src/SHADERed/Objects/FunctionVariableManager.h b/src/SHADERed/Objects/FunctionVariableManager.h index 87975d29..9cb4e06d 100644 --- a/src/SHADERed/Objects/FunctionVariableManager.h +++ b/src/SHADERed/Objects/FunctionVariableManager.h @@ -1,20 +1,35 @@ #pragma once #include +#include #include namespace ed { class FunctionVariableManager { public: - static size_t GetArgumentCount(ed::FunctionShaderVariable func); + FunctionVariableManager(); + + void Initialize(PipelineManager* pipe); + + void AddToList(ed::ShaderVariable* var); + void Update(ed::ShaderVariable* var); + static void AllocateArgumentSpace(ed::ShaderVariable* var, ed::FunctionShaderVariable func); + static size_t GetArgumentCount(ed::FunctionShaderVariable func); static bool HasValidReturnType(ShaderVariable::ValueType ret, ed::FunctionShaderVariable func); - static void AddToList(ed::ShaderVariable* var); - static void Update(ed::ShaderVariable* var); static float* LoadFloat(char* data, int index); - static void ClearVariableList(); + void ClearVariableList(); + + std::vector VariableList; + + static inline FunctionVariableManager& Instance() + { + static FunctionVariableManager ret; + return ret; + } - static int CurrentIndex; - static std::vector VariableList; + private: + int m_currentIndex; + PipelineManager* m_pipeline; }; } \ No newline at end of file diff --git a/src/SHADERed/Objects/Names.cpp b/src/SHADERed/Objects/Names.cpp index 276828df..88b80743 100644 --- a/src/SHADERed/Objects/Names.cpp +++ b/src/SHADERed/Objects/Names.cpp @@ -88,6 +88,7 @@ const char* FUNCTION_NAMES[] = { "None", "Pointer", "CameraSnapshot", + "ObjectProperty", "MatrixIdentity", "MatrixLookAtLH", "MatrixLookToLH", diff --git a/src/SHADERed/Objects/Names.h b/src/SHADERed/Objects/Names.h index dca2a4c7..260eb3dc 100644 --- a/src/SHADERed/Objects/Names.h +++ b/src/SHADERed/Objects/Names.h @@ -5,7 +5,7 @@ extern const char* TOPOLOGY_ITEM_NAMES[10]; extern const char* SYSTEM_VARIABLE_NAMES[20]; extern const char* VARIABLE_TYPE_NAMES[15]; extern const char* VARIABLE_TYPE_NAMES_GLSL[15]; -extern const char* FUNCTION_NAMES[23]; +extern const char* FUNCTION_NAMES[22]; extern const char* GEOMETRY_NAMES[7]; extern const char* PIPELINE_ITEM_NAMES[7]; extern const char* BLEND_NAMES[20]; diff --git a/src/SHADERed/Objects/ProjectParser.cpp b/src/SHADERed/Objects/ProjectParser.cpp index c02a894c..db8f3a73 100644 --- a/src/SHADERed/Objects/ProjectParser.cpp +++ b/src/SHADERed/Objects/ProjectParser.cpp @@ -974,6 +974,13 @@ namespace ed { strcpy(var->Arguments, value.text().as_string()); else if (var->Function == FunctionShaderVariable::CameraSnapshot) strcpy(var->Arguments, value.text().as_string()); + else if (var->Function == FunctionShaderVariable::ObjectProperty) { + if (colID == 0) + strcpy(var->Arguments, value.text().as_string()); + else + strcpy(var->Arguments + PIPELINE_ITEM_NAME_LENGTH, value.text().as_string()); + colID++; + } else if (var->Function == FunctionShaderVariable::PluginFunction) var->PluginFuncData.Owner->ImportFunctionArguments(var->PluginFuncData.Name, (plugin::VariableType)var->GetType(), var->Arguments, getInnerXML(value).c_str()); else @@ -1016,6 +1023,9 @@ namespace ed { valueRowNode.append_child("value").text().set(var->Arguments); } else if (var->Function == FunctionShaderVariable::CameraSnapshot) { valueRowNode.append_child("value").text().set(var->Arguments); + } else if (var->Function == FunctionShaderVariable::ObjectProperty) { + valueRowNode.append_child("value").text().set(var->Arguments); + valueRowNode.append_child("value").text().set(var->Arguments + PIPELINE_ITEM_NAME_LENGTH); } else if (var->Function == FunctionShaderVariable::PluginFunction) { m_addPlugin(m_plugins->GetPluginName(var->PluginFuncData.Owner)); @@ -1023,9 +1033,8 @@ namespace ed { valueRowNode.append_child("value").append_buffer(valNode, strlen(valNode)); } else { // save arguments - for (int i = 0; i < FunctionVariableManager::GetArgumentCount(var->Function); i++) { + for (int i = 0; i < FunctionVariableManager::GetArgumentCount(var->Function); i++) valueRowNode.append_child("value").text().set(*FunctionVariableManager::LoadFloat(var->Arguments, i)); - } } } } diff --git a/src/SHADERed/Objects/ShaderVariable.h b/src/SHADERed/Objects/ShaderVariable.h index 7949756c..159a0d13 100644 --- a/src/SHADERed/Objects/ShaderVariable.h +++ b/src/SHADERed/Objects/ShaderVariable.h @@ -44,13 +44,13 @@ namespace ed { None, // using user input instead of built-in functions Pointer, CameraSnapshot, + ObjectProperty, MatrixIdentity, MatrixLookAtLH, MatrixLookToLH, MatrixOrthographicLH, MatrixPerspectiveFovLH, MatrixPerspectiveLH, - MatrixReflect, MatrixRotationAxis, MatrixRotationNormal, MatrixRotationRollPitchYaw, @@ -58,7 +58,6 @@ namespace ed { MatrixRotationY, MatrixRotationZ, MatrixScaling, - MatrixShadow, MatrixTranslation, ScalarCos, ScalarSin, diff --git a/src/SHADERed/Objects/ShaderVariableContainer.cpp b/src/SHADERed/Objects/ShaderVariableContainer.cpp index 306e4f0c..c58a578e 100644 --- a/src/SHADERed/Objects/ShaderVariableContainer.cpp +++ b/src/SHADERed/Objects/ShaderVariableContainer.cpp @@ -86,7 +86,7 @@ namespace ed { void ShaderVariableContainer::Bind(void* item) { for (int i = 0; i < m_vars.size(); i++) { - FunctionVariableManager::AddToList(m_vars[i]); + FunctionVariableManager::Instance().AddToList(m_vars[i]); if (m_uLocs.count(m_vars[i]->Name) == 0) continue; @@ -95,7 +95,7 @@ namespace ed { // update values if needed SystemVariableManager::Instance().Update(m_vars[i], item); - FunctionVariableManager::Update(m_vars[i]); + FunctionVariableManager::Instance().Update(m_vars[i]); // update uniform every time we bind this container // TODO: maybe we shouldn't update variables that havent changed diff --git a/src/SHADERed/UI/Tools/VariableValueEdit.cpp b/src/SHADERed/UI/Tools/VariableValueEdit.cpp index 7f8d8d8c..5624e9c9 100644 --- a/src/SHADERed/UI/Tools/VariableValueEdit.cpp +++ b/src/SHADERed/UI/Tools/VariableValueEdit.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -194,7 +195,7 @@ namespace ed { ImGui::Columns(2, 0, false); - ImGui::SetColumnWidth(0, 15 + 105); + ImGui::SetColumnWidth(0, Settings::Instance().CalculateWidth(120)); ImGui::Indent(15); switch (m_var->Function) { @@ -202,7 +203,7 @@ namespace ed { ImGui::Text("Variable:"); ImGui::NextColumn(); - auto& varList = FunctionVariableManager::VariableList; + auto& varList = FunctionVariableManager::Instance().VariableList; if (ImGui::BeginCombo(("##ptrVars" + std::string(m_var->Name)).c_str(), m_var->Arguments)) { for (int n = 0; n < varList.size(); n++) { if (m_var == varList[n] || varList[n] == nullptr) @@ -229,7 +230,7 @@ namespace ed { ImGui::NextColumn(); auto& camList = CameraSnapshots::GetList(); - if (ImGui::BeginCombo(("##ptrCams" + std::string(m_var->Name)).c_str(), m_var->Arguments)) { + if (ImGui::BeginCombo(("##camSnaps" + std::string(m_var->Name)).c_str(), m_var->Arguments)) { for (int n = 0; n < camList.size(); n++) { bool is_selected = strcmp(m_var->Arguments, camList[n].c_str()) == 0; if (ImGui::Selectable(camList[n].c_str(), is_selected)) { @@ -244,6 +245,71 @@ namespace ed { ImGui::NextColumn(); } break; + case FunctionShaderVariable::ObjectProperty: { + auto& pipeList = m_data->Pipeline.GetList(); + ImGui::Text("Item:"); + ImGui::NextColumn(); + if (ImGui::BeginCombo(("##pipeItems" + std::string(m_var->Name)).c_str(), m_var->Arguments)) { + for (int n = 0; n < pipeList.size(); n++) { + if (pipeList[n]->Type == PipelineItem::ItemType::ShaderPass) { + pipe::ShaderPass* pass = (pipe::ShaderPass*)pipeList[n]->Data; + for (int j = 0; j < pass->Items.size(); j++) { + PipelineItem* item = pass->Items[j]; + + if (item->Type != PipelineItem::ItemType::Geometry && item->Type != PipelineItem::ItemType::Model) + continue; + + bool is_selected = strcmp(m_var->Arguments, item->Name) == 0; + if (ImGui::Selectable(item->Name, is_selected)) { + strcpy(m_var->Arguments, item->Name); + ret = true; + } + if (is_selected) + ImGui::SetItemDefaultFocus(); + } + } + } + ImGui::EndCombo(); + } + ImGui::NextColumn(); + + char* propName = m_var->Arguments + PIPELINE_ITEM_NAME_LENGTH; + ImGui::Text("Property:"); + ImGui::NextColumn(); + if (ImGui::BeginCombo(("##itemProps" + std::string(m_var->Name)).c_str(), propName)) { + /* POSITION */ + bool isSelected = strcmp(propName, "Position") == 0; + if (ImGui::Selectable("Position", isSelected)) { + strcpy(propName, "Position"); + ret = true; + } + if (isSelected) + ImGui::SetItemDefaultFocus(); + + /* SCALE */ + isSelected = strcmp(propName, "Scale") == 0; + if (ImGui::Selectable("Scale", isSelected)) { + strcpy(propName, "Scale"); + ret = true; + } + if (isSelected) + ImGui::SetItemDefaultFocus(); + + /* ROTATION */ + isSelected = strcmp(propName, "Rotation") == 0; + if (ImGui::Selectable("Rotation", isSelected)) { + strcpy(propName, "Rotation"); + ret = true; + } + if (isSelected) + ImGui::SetItemDefaultFocus(); + + ImGui::EndCombo(); + } + ImGui::NextColumn(); + + } break; + case FunctionShaderVariable::MatrixLookAtLH: { ImGui::Text("Eye position:"); ImGui::NextColumn();