示例#1
0
void ezQtPropertyAnimAssetDocumentWindow::onRebindSelectedItems()
{
  auto pDoc = GetPropertyAnimDocument();
  auto pHistory = pDoc->GetCommandHistory();

  ezHybridArray<ezUuid, 16> rebindTracks;

  for (ezInt32 iTrack : m_MapSelectionToTrack)
  {
    const ezVariant trackGuid = pDoc->GetPropertyObject()->GetTypeAccessor().GetValue("Tracks", iTrack);

    if (trackGuid.IsValid())
      rebindTracks.PushBack(trackGuid.Get<ezUuid>());
  }

  if (m_iMapGradientToTrack >= 0)
  {
    const ezVariant trackGuid = pDoc->GetPropertyObject()->GetTypeAccessor().GetValue("Tracks", m_iMapGradientToTrack);

    if (trackGuid.IsValid())
      rebindTracks.PushBack(trackGuid.Get<ezUuid>());
  }

  bool ok = false;
  QString result = QInputDialog::getText(this, "Change Animation Binding", "New Binding Path:", QLineEdit::Normal, "", &ok);

  if (!ok)
    return;

  m_pSelectionModel->clear();

  ezStringBuilder path = result.toUtf8().data();
  ;
  path.MakeCleanPath();
  const ezVariant varRes = path.GetData();

  pHistory->StartTransaction("Rebind Tracks");

  for (const ezUuid guid : rebindTracks)
  {
    ezSetObjectPropertyCommand cmdSet;
    cmdSet.m_Object = guid;

    cmdSet.m_sProperty = "ObjectPath";
    cmdSet.m_NewValue = varRes;
    pDoc->GetCommandHistory()->AddCommand(cmdSet);
  }

  pHistory->FinishTransaction();
}
示例#2
0
void ezQtPropertyAnimAssetDocumentWindow::onDeleteSelectedItems()
{
  auto pDoc = GetPropertyAnimDocument();
  auto pHistory = pDoc->GetCommandHistory();

  pHistory->StartTransaction("Delete Tracks");

  m_pGradientToDisplay = nullptr;
  m_CurvesToDisplay.Clear();

  // delete the tracks with the highest index first, otherwise the lower indices become invalid
  // do this before modifying anything, as m_MapSelectionToTrack will change once the remove commands are executed
  ezHybridArray<ezInt32, 16> sortedTrackIDs;
  {
    for (ezInt32 iTrack : m_MapSelectionToTrack)
    {
      sortedTrackIDs.PushBack(iTrack);
    }

    if (m_iMapGradientToTrack >= 0)
    {
      sortedTrackIDs.PushBack(m_iMapGradientToTrack);
    }

    sortedTrackIDs.Sort();
  }

  for (ezUInt32 i = sortedTrackIDs.GetCount(); i > 0; --i)
  {
    const ezInt32 iTrack = sortedTrackIDs[i - 1];

    const ezVariant trackGuid = pDoc->GetPropertyObject()->GetTypeAccessor().GetValue("Tracks", iTrack);

    if (trackGuid.IsValid())
    {
      ezRemoveObjectCommand cmd;
      cmd.m_Object = trackGuid.Get<ezUuid>();

      pHistory->AddCommand(cmd);
    }
  }

  m_MapSelectionToTrack.Clear();
  m_iMapGradientToTrack = -1;

  pHistory->FinishTransaction();
}
示例#3
0
void ezQtPropertyAnimAssetDocumentWindow::onEventTrackCpDeleted(ezUInt32 cpIdx)
{
  ezPropertyAnimAssetDocument* pDoc = GetPropertyAnimDocument();

  ezObjectCommandAccessor accessor(pDoc->GetCommandHistory());

  const ezAbstractProperty* pTrackProp = ezGetStaticRTTI<ezPropertyAnimationTrackGroup>()->FindPropertyByName("EventTrack");
  const ezUuid trackGuid = accessor.Get<ezUuid>(pDoc->GetPropertyObject(), pTrackProp);
  const ezDocumentObject* pTrackObj = accessor.GetObject(trackGuid);

  const ezVariant cpGuid = pTrackObj->GetTypeAccessor().GetValue("ControlPoints", cpIdx);

  if (!cpGuid.IsValid())
    return;

  ezRemoveObjectCommand cmdSet;
  cmdSet.m_Object = cpGuid.Get<ezUuid>();
  pDoc->GetCommandHistory()->AddCommand(cmdSet);
}
示例#4
0
void ezQtPropertyAnimAssetDocumentWindow::onCurveCpDeleted(ezUInt32 uiCurveIdx, ezUInt32 cpIdx)
{
  if (uiCurveIdx >= m_MapSelectionToTrack.GetCount())
    return;

  ezPropertyAnimAssetDocument* pDoc = GetPropertyAnimDocument();

  auto pProp = pDoc->GetPropertyObject();

  const ezInt32 iTrackIdx = m_MapSelectionToTrack[uiCurveIdx];
  const ezVariant trackGuid = pDoc->GetPropertyObject()->GetTypeAccessor().GetValue("Tracks", iTrackIdx);
  const ezDocumentObject* trackObject = pDoc->GetObjectManager()->GetObject(trackGuid.Get<ezUuid>());
  const ezVariant curveGuid = trackObject->GetTypeAccessor().GetValue("FloatCurve");

  const ezDocumentObject* pCurvesArray = pDoc->GetObjectManager()->GetObject(curveGuid.Get<ezUuid>());
  const ezVariant cpGuid = pCurvesArray->GetTypeAccessor().GetValue("ControlPoints", cpIdx);

  if (!cpGuid.IsValid())
    return;

  ezRemoveObjectCommand cmdSet;
  cmdSet.m_Object = cpGuid.Get<ezUuid>();
  pDoc->GetCommandHistory()->AddCommand(cmdSet);
}
示例#5
0
void ezMaterialResource::SetParameter(const char* szName, const ezVariant& value)
{
  ezTempHashedString sName(szName);

  ezUInt32 uiIndex = ezInvalidIndex;
  for (ezUInt32 i = 0; i < m_Desc.m_Parameters.GetCount(); ++i)
  {
    if (m_Desc.m_Parameters[i].m_Name == sName)
    {
      uiIndex = i;
      break;
    }
  }

  if (value.IsValid())
  {
    if (uiIndex != ezInvalidIndex)
    {
      if (m_Desc.m_Parameters[uiIndex].m_Value == value)
      {
        return;
      }

      m_Desc.m_Parameters[uiIndex].m_Value = value;
    }
    else
    {
      auto& param = m_Desc.m_Parameters.ExpandAndGetRef();
      param.m_Name.Assign(szName);
      param.m_Value = value;
    }
  }
  else
  {
    if (uiIndex == ezInvalidIndex)
    {
      return;
    }

    m_Desc.m_Parameters.RemoveAtAndSwap(uiIndex);
  }

  m_iLastModified.Increment();
  m_iLastConstantsModified.Increment();

  m_ModifiedEvent.Broadcast(this);
}
示例#6
0
void ezVariant::CopyFrom(const ezVariant& other)
{
  m_Type = other.m_Type;
  m_bIsShared = other.m_bIsShared;
  
  if (m_bIsShared)
  {
    m_Data.shared = other.m_Data.shared;
    m_Data.shared->m_uiRef.Increment();
  }
  else if (other.IsValid())
  {
    CopyFunc copyFunc;
    copyFunc.m_pThis = this;
    copyFunc.m_pOther = &other;

    DispatchTo(copyFunc, GetType());
  }
}
示例#7
0
void ezJSONWriter::WriteVariant(const ezVariant& value)
{
  switch (value.GetType())
  {
  case ezVariant::Type::Invalid:
    //EZ_REPORT_FAILURE("Variant of Type 'Invalid' cannot be written as JSON.");
    WriteNULL();
    return;
  case ezVariant::Type::Bool:
    WriteBool(value.Get<bool>());
    return;
  case ezVariant::Type::Int8:
    WriteInt32(value.Get<ezInt8>());
    return;
  case ezVariant::Type::UInt8:
    WriteUInt32(value.Get<ezUInt8>());
    return;
  case ezVariant::Type::Int16:
    WriteInt32(value.Get<ezInt16>());
    return;
  case ezVariant::Type::UInt16:
    WriteUInt32(value.Get<ezUInt16>());
    return;
  case ezVariant::Type::Int32:
    WriteInt32(value.Get<ezInt32>());
    return;
  case ezVariant::Type::UInt32:
    WriteUInt32(value.Get<ezUInt32>());
    return;
  case ezVariant::Type::Int64:
    WriteInt64(value.Get<ezInt64>());
    return;
  case ezVariant::Type::UInt64:
    WriteUInt64(value.Get<ezUInt64>());
    return;
  case ezVariant::Type::Float:
    WriteFloat(value.Get<float>());
    return;
  case ezVariant::Type::Double:
    WriteDouble(value.Get<double>());
    return;
  case ezVariant::Type::Color:
    WriteColor(value.Get<ezColor>());
    return;
  case ezVariant::Type::Vector2:
    WriteVec2(value.Get<ezVec2>());
    return;
  case ezVariant::Type::Vector3:
    WriteVec3(value.Get<ezVec3>());
    return;
  case ezVariant::Type::Vector4:
    WriteVec4(value.Get<ezVec4>());
    return;
  case ezVariant::Type::Quaternion:
    WriteQuat(value.Get<ezQuat>());
    return;
  case ezVariant::Type::Matrix3:
    WriteMat3(value.Get<ezMat3>());
    return;
  case ezVariant::Type::Matrix4:
    WriteMat4(value.Get<ezMat4>());
    return;
  case ezVariant::Type::String:
    WriteString(value.Get<ezString>().GetData());
    return;
  case ezVariant::Type::Time:
    WriteTime(value.Get<ezTime>());
    return;
  case ezVariant::Type::Uuid:
    WriteUuid(value.Get<ezUuid>());
    return;

  default:
    break;
  }

  EZ_REPORT_FAILURE("The Variant Type %i is not supported by ezJSONWriter::WriteVariant.", value.GetType());
}