Exemplo n.º 1
0
void ezVisualScriptTypeRegistry::UpdateNodeType(const ezRTTI* pRtti)
{
  if (pRtti->GetAttributeByType<ezHiddenAttribute>() != nullptr)
    return;

  if (pRtti->IsDerivedFrom<ezMessage>() && !pRtti->GetTypeFlags().IsSet(ezTypeFlags::Abstract))
  {
    if (pRtti->GetAttributeByType<ezAutoGenVisScriptMsgSender>())
    {
      CreateMessageNodeType(pRtti);
    }

    if (pRtti->GetAttributeByType<ezAutoGenVisScriptMsgHandler>())
    {
      CreateEventMessageNodeType(pRtti);
    }
  }

  if (!pRtti->IsDerivedFrom<ezVisualScriptNode>() || pRtti->GetTypeFlags().IsAnySet(ezTypeFlags::Abstract))
    return;

  ezHybridArray<ezAbstractProperty*, 32> properties;
  static const ezColor ExecutionPinColor = ezColor::LightSlateGrey;

  ezVisualScriptNodeDescriptor nd;
  nd.m_sTypeName = pRtti->GetTypeName();
  nd.m_Color = ezColor::CadetBlue;

  if (const ezCategoryAttribute* pAttr = pRtti->GetAttributeByType<ezCategoryAttribute>())
  {
    nd.m_sCategory = pAttr->GetCategory();

    if (nd.m_sCategory == "Debug")
      nd.m_Color = ezColorGammaUB(127, 0, 110);
    else if (nd.m_sCategory == "Logic")
      nd.m_Color = ezColorGammaUB(128, 0, 0);
    else if (nd.m_sCategory == "Input")
      nd.m_Color = ezColorGammaUB(38, 105, 0);
    else if (nd.m_sCategory == "Math")
      nd.m_Color = ezColorGammaUB(183, 153, 0);
    else if (nd.m_sCategory == "Objects")
      nd.m_Color = ezColorGammaUB(0, 53, 91);
    else if (nd.m_sCategory == "Components")
      nd.m_Color = ezColorGammaUB(0, 53, 91);
    else if (nd.m_sCategory == "References")
      nd.m_Color = ezColorGammaUB(0, 89, 153);
    else if (nd.m_sCategory == "Variables")
      nd.m_Color = ezColorGammaUB(250, 70, 0);
  }

  if (const ezTitleAttribute* pAttr = pRtti->GetAttributeByType<ezTitleAttribute>())
  {
    nd.m_sTitle = pAttr->GetTitle();
  }

  if (const ezColorAttribute* pAttr = pRtti->GetAttributeByType<ezColorAttribute>())
  {
    nd.m_Color = pAttr->GetColor();
  }

  pRtti->GetAllProperties(properties);

  ezSet<ezInt32> usedInputDataPinIDs;
  ezSet<ezInt32> usedOutputDataPinIDs;
  ezSet<ezInt32> usedInputExecPinIDs;
  ezSet<ezInt32> usedOutputExecPinIDs;

  for (auto prop : properties)
  {
    ezVisualScriptPinDescriptor pd;
    pd.m_sName = prop->GetPropertyName();
    pd.m_sTooltip = ""; /// \todo Use ezTranslateTooltip

    if (const ezVisScriptDataPinInAttribute* pAttr = prop->GetAttributeByType<ezVisScriptDataPinInAttribute>())
    {
      pd.m_PinType = ezVisualScriptPinDescriptor::Data;
      pd.m_Color = PinTypeColor(pAttr->m_DataType);
      pd.m_DataType = pAttr->m_DataType;
      pd.m_uiPinIndex = pAttr->m_uiPinSlot;
      nd.m_InputPins.PushBack(pd);

      if (usedInputDataPinIDs.Contains(pd.m_uiPinIndex))
        ezLog::Error("Visual Script Node '{0}' uses the same input data pin index multiple times: '{1}'", nd.m_sTypeName, pd.m_uiPinIndex);

      usedInputDataPinIDs.Insert(pd.m_uiPinIndex);
    }

    if (const ezVisScriptDataPinOutAttribute* pAttr = prop->GetAttributeByType<ezVisScriptDataPinOutAttribute>())
    {
      pd.m_PinType = ezVisualScriptPinDescriptor::Data;
      pd.m_Color = PinTypeColor(pAttr->m_DataType);
      pd.m_DataType = pAttr->m_DataType;
      pd.m_uiPinIndex = pAttr->m_uiPinSlot;
      nd.m_OutputPins.PushBack(pd);

      if (usedOutputDataPinIDs.Contains(pd.m_uiPinIndex))
        ezLog::Error("Visual Script Node '{0}' uses the same output data pin index multiple times: '{1}'", nd.m_sTypeName, pd.m_uiPinIndex);

      usedOutputDataPinIDs.Insert(pd.m_uiPinIndex);
    }

    if (const ezVisScriptExecPinInAttribute* pAttr = prop->GetAttributeByType<ezVisScriptExecPinInAttribute>())
    {
      pd.m_PinType = ezVisualScriptPinDescriptor::Execution;
      pd.m_Color = ExecutionPinColor;
      pd.m_uiPinIndex = pAttr->m_uiPinSlot;
      nd.m_InputPins.PushBack(pd);

      if (usedInputExecPinIDs.Contains(pd.m_uiPinIndex))
        ezLog::Error("Visual Script Node '{0}' uses the same input exec pin index multiple times: '{1}'", nd.m_sTypeName, pd.m_uiPinIndex);

      usedInputExecPinIDs.Insert(pd.m_uiPinIndex);
    }

    if (const ezVisScriptExecPinOutAttribute* pAttr = prop->GetAttributeByType<ezVisScriptExecPinOutAttribute>())
    {
      pd.m_PinType = ezVisualScriptPinDescriptor::Execution;
      pd.m_Color = ExecutionPinColor;
      pd.m_uiPinIndex = pAttr->m_uiPinSlot;
      nd.m_OutputPins.PushBack(pd);

      if (usedOutputExecPinIDs.Contains(pd.m_uiPinIndex))
        ezLog::Error("Visual Script Node '{0}' uses the same output exec pin index multiple times: '{1}'", nd.m_sTypeName, pd.m_uiPinIndex);

      usedOutputExecPinIDs.Insert(pd.m_uiPinIndex);
    }

    if (prop->GetCategory() == ezPropertyCategory::Constant)
      continue;

    {
      ezReflectedPropertyDescriptor pd;
      pd.m_Flags = prop->GetFlags();
      pd.m_Category = prop->GetCategory();
      pd.m_sName = prop->GetPropertyName();
      pd.m_sType = prop->GetSpecificType()->GetTypeName();

      for (ezPropertyAttribute* const pAttr : prop->GetAttributes())
      {
        pd.m_Attributes.PushBack(ezReflectionSerializer::Clone(pAttr));
      }

      nd.m_Properties.PushBack(pd);
    }
  }

  m_NodeDescriptors.Insert(GenerateTypeFromDesc(nd), nd);
}
Exemplo n.º 2
0
#include <RendererFoundation/Profiling/Profiling.h>

// clang-format off
EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezRenderPipelinePass, 1, ezRTTINoAllocator)
{
  EZ_BEGIN_PROPERTIES
  {
    EZ_MEMBER_PROPERTY("Active", m_bActive)->AddAttributes(new ezDefaultValueAttribute(true)),
    EZ_ACCESSOR_PROPERTY("Name", GetName, SetName),
    EZ_SET_ACCESSOR_PROPERTY("Renderers", GetRenderers, AddRenderer, RemoveRenderer)->AddFlags(ezPropertyFlags::PointerOwner),
  }
  EZ_END_PROPERTIES;
  EZ_BEGIN_ATTRIBUTES
  {
    new ezColorAttribute(ezColorGammaUB(64, 32, 96))
  }
  EZ_END_ATTRIBUTES;
}
EZ_END_DYNAMIC_REFLECTED_TYPE;
// clang-format on

ezRenderPipelinePass::ezRenderPipelinePass(const char* szName, bool bIsStereoAware)
    : m_bActive(true)
    , m_bIsStereoAware(bIsStereoAware)
    , m_pPipeline(nullptr)
{
  m_sName.Assign(szName);
}

ezRenderPipelinePass::~ezRenderPipelinePass()