@@ -800,32 +800,71 @@ void OvEditor::Core::EditorActions::DuplicateActor(OvCore::ECS::Actor & p_toDupl
800800
801801 newActor.SetID (idToUse);
802802 newActor.SetGUID (guidToUse);
803+ auto currentScene = m_context.sceneManager .GetCurrentScene ();
803804
804805 if (p_forcedParent)
806+ {
805807 newActor.SetParent (*p_forcedParent);
806- else
808+ }
809+ else if (newActor.GetParentID () > 0 )
807810 {
808- auto currentScene = m_context.sceneManager .GetCurrentScene ();
809-
810- if (newActor.GetParentID () > 0 )
811- {
812- if (auto found = currentScene->FindActorByID (newActor.GetParentID ()); found)
813- {
814- newActor.SetParent (*found);
815- }
816- }
811+ if (auto found = currentScene->FindActorByID (newActor.GetParentID ()); found)
812+ {
813+ newActor.SetParent (*found);
814+ }
815+ }
817816
818- const auto uniqueName = FindDuplicatedActorUniqueName (p_toDuplicate, newActor, *currentScene);
819- newActor.SetName (uniqueName);
817+ if (p_focus || !p_forcedParent)
818+ {
819+ const auto uniqueName = FindDuplicatedActorUniqueName (p_toDuplicate, newActor, *currentScene);
820+ newActor.SetName (uniqueName);
820821 }
821822
822823 if (p_focus)
824+ {
823825 SelectActor (newActor);
826+ }
824827
825828 for (auto & child : p_toDuplicate.GetChildren ())
826829 DuplicateActor (*child, &newActor, false );
827830}
828831
832+ void OvEditor::Core::EditorActions::CopyActor (OvCore::ECS ::Actor& p_actor)
833+ {
834+ m_context.copyBuffer = Context::ActorCopyBuffer{
835+ .guid = p_actor.GetGUID ()
836+ };
837+ }
838+
839+ void OvEditor::Core::EditorActions::PasteActor (OvCore::ECS ::Actor* p_parent)
840+ {
841+ const auto actorCopyBuffer = std::get_if<Context::ActorCopyBuffer>(&m_context.copyBuffer );
842+ if (!actorCopyBuffer)
843+ {
844+ return ;
845+ }
846+
847+ const auto currentScene = m_context.sceneManager .GetCurrentScene ();
848+ if (!currentScene)
849+ {
850+ return ;
851+ }
852+
853+ if (const auto copiedActor = currentScene->FindActorByGUID (actorCopyBuffer->guid ))
854+ {
855+ auto * destinationParent = p_parent;
856+
857+ // Pasting on the copied actor itself falls back to its current parent,
858+ // preserving the "duplicate-like" behavior by default.
859+ if (destinationParent && destinationParent->GetGUID () == copiedActor->GetGUID ())
860+ {
861+ destinationParent = copiedActor->GetParent ();
862+ }
863+
864+ DuplicateActor (*copiedActor, destinationParent, true );
865+ }
866+ }
867+
829868void OvEditor::Core::EditorActions::SelectActor (OvCore::ECS ::Actor& p_target)
830869{
831870 EDITOR_PANEL (Panels::Inspector, " Inspector" ).FocusActor (p_target);
0 commit comments