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(); }
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(); }
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); }
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); }
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()); } }
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); }