mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 18:39:43 +00:00
Feat(CS): Implement instance cloning
This commit is contained in:
parent
2bb8ceef56
commit
7069a970ae
2 changed files with 29 additions and 0 deletions
|
@ -205,12 +205,19 @@ CSVRender::InstanceMode::InstanceMode(
|
||||||
connect(
|
connect(
|
||||||
deleteShortcut, qOverload<bool>(&CSMPrefs::Shortcut::activated), this, &InstanceMode::deleteSelectedInstances);
|
deleteShortcut, qOverload<bool>(&CSMPrefs::Shortcut::activated), this, &InstanceMode::deleteSelectedInstances);
|
||||||
|
|
||||||
|
CSMPrefs::Shortcut* duplicateShortcut = new CSMPrefs::Shortcut("scene-duplicate", worldspaceWidget);
|
||||||
|
|
||||||
|
connect(
|
||||||
|
duplicateShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this, &InstanceMode::cloneSelectedInstances);
|
||||||
|
|
||||||
// Following classes could be simplified by using QSignalMapper, which is obsolete in Qt5.10, but not in Qt4.8 and
|
// Following classes could be simplified by using QSignalMapper, which is obsolete in Qt5.10, but not in Qt4.8 and
|
||||||
// Qt5.14
|
// Qt5.14
|
||||||
CSMPrefs::Shortcut* dropToCollisionShortcut
|
CSMPrefs::Shortcut* dropToCollisionShortcut
|
||||||
= new CSMPrefs::Shortcut("scene-instance-drop-collision", worldspaceWidget);
|
= new CSMPrefs::Shortcut("scene-instance-drop-collision", worldspaceWidget);
|
||||||
|
|
||||||
connect(dropToCollisionShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this,
|
connect(dropToCollisionShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this,
|
||||||
&InstanceMode::dropSelectedInstancesToCollision);
|
&InstanceMode::dropSelectedInstancesToCollision);
|
||||||
|
|
||||||
CSMPrefs::Shortcut* dropToTerrainLevelShortcut
|
CSMPrefs::Shortcut* dropToTerrainLevelShortcut
|
||||||
= new CSMPrefs::Shortcut("scene-instance-drop-terrain", worldspaceWidget);
|
= new CSMPrefs::Shortcut("scene-instance-drop-terrain", worldspaceWidget);
|
||||||
connect(dropToTerrainLevelShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this,
|
connect(dropToTerrainLevelShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this,
|
||||||
|
@ -1087,6 +1094,27 @@ void CSVRender::InstanceMode::deleteSelectedInstances(bool active)
|
||||||
getWorldspaceWidget().clearSelection(Mask_Reference);
|
getWorldspaceWidget().clearSelection(Mask_Reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::InstanceMode::cloneSelectedInstances()
|
||||||
|
{
|
||||||
|
std::vector<osg::ref_ptr<TagBase>> selection = getWorldspaceWidget().getSelection(Mask_Reference);
|
||||||
|
if (selection.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
CSMDoc::Document& document = getWorldspaceWidget().getDocument();
|
||||||
|
CSMWorld::IdTable& referencesTable
|
||||||
|
= dynamic_cast<CSMWorld::IdTable&>(*document.getData().getTableModel(CSMWorld::UniversalId::Type_References));
|
||||||
|
QUndoStack& undoStack = document.getUndoStack();
|
||||||
|
|
||||||
|
CSMWorld::CommandMacro macro(undoStack, "Clone Instances");
|
||||||
|
for (osg::ref_ptr<TagBase> tag : selection)
|
||||||
|
if (CSVRender::ObjectTag* objectTag = dynamic_cast<CSVRender::ObjectTag*>(tag.get()))
|
||||||
|
{
|
||||||
|
macro.push(new CSMWorld::CloneCommand(referencesTable, objectTag->mObject->getReferenceId(),
|
||||||
|
"ref#" + std::to_string(referencesTable.rowCount()), CSMWorld::UniversalId::Type_Reference));
|
||||||
|
}
|
||||||
|
// getWorldspaceWidget().clearSelection(Mask_Reference);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVRender::InstanceMode::dropInstance(CSVRender::Object* object, float dropHeight)
|
void CSVRender::InstanceMode::dropInstance(CSVRender::Object* object, float dropHeight)
|
||||||
{
|
{
|
||||||
object->setEdited(Object::Override_Position);
|
object->setEdited(Object::Override_Position);
|
||||||
|
|
|
@ -132,6 +132,7 @@ namespace CSVRender
|
||||||
|
|
||||||
void subModeChanged(const std::string& id);
|
void subModeChanged(const std::string& id);
|
||||||
void deleteSelectedInstances(bool active);
|
void deleteSelectedInstances(bool active);
|
||||||
|
void cloneSelectedInstances();
|
||||||
void dropSelectedInstancesToCollision();
|
void dropSelectedInstancesToCollision();
|
||||||
void dropSelectedInstancesToTerrain();
|
void dropSelectedInstancesToTerrain();
|
||||||
void dropSelectedInstancesToCollisionSeparately();
|
void dropSelectedInstancesToCollisionSeparately();
|
||||||
|
|
Loading…
Reference in a new issue