mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
CLEANUP(instancemode): Always drop everything the same way
This commit is contained in:
parent
0fea0868ed
commit
fb9b191027
4 changed files with 19 additions and 109 deletions
|
@ -336,10 +336,7 @@ void CSMPrefs::State::declare()
|
||||||
declareShortcut(mValues->mKeyBindings.mSceneSelectTertiary, "Tertiary Select");
|
declareShortcut(mValues->mKeyBindings.mSceneSelectTertiary, "Tertiary Select");
|
||||||
declareModifier(mValues->mKeyBindings.mSceneSpeedModifier, "Speed Modifier");
|
declareModifier(mValues->mKeyBindings.mSceneSpeedModifier, "Speed Modifier");
|
||||||
declareShortcut(mValues->mKeyBindings.mSceneDelete, "Delete Instance");
|
declareShortcut(mValues->mKeyBindings.mSceneDelete, "Delete Instance");
|
||||||
declareShortcut(mValues->mKeyBindings.mSceneInstanceDropTerrain, "Drop to Terrain Level");
|
declareShortcut(mValues->mKeyBindings.mSceneInstanceDrop, "Drop to Collision");
|
||||||
declareShortcut(mValues->mKeyBindings.mSceneInstanceDropCollision, "Drop to Collision");
|
|
||||||
declareShortcut(mValues->mKeyBindings.mSceneInstanceDropTerrainSeparately, "Drop to Terrain Level Separately");
|
|
||||||
declareShortcut(mValues->mKeyBindings.mSceneInstanceDropCollisionSeparately, "Drop to Collision Separately");
|
|
||||||
declareShortcut(mValues->mKeyBindings.mSceneLoadCamCell, "Load Camera Cell");
|
declareShortcut(mValues->mKeyBindings.mSceneLoadCamCell, "Load Camera Cell");
|
||||||
declareShortcut(mValues->mKeyBindings.mSceneLoadCamEastcell, "Load East Cell");
|
declareShortcut(mValues->mKeyBindings.mSceneLoadCamEastcell, "Load East Cell");
|
||||||
declareShortcut(mValues->mKeyBindings.mSceneLoadCamNorthcell, "Load North Cell");
|
declareShortcut(mValues->mKeyBindings.mSceneLoadCamNorthcell, "Load North Cell");
|
||||||
|
|
|
@ -447,14 +447,7 @@ namespace CSMPrefs
|
||||||
Settings::SettingValue<std::string> mSceneSelectTertiary{ mIndex, sName, "scene-select-tertiary", "Shift+LMB" };
|
Settings::SettingValue<std::string> mSceneSelectTertiary{ mIndex, sName, "scene-select-tertiary", "Shift+LMB" };
|
||||||
Settings::SettingValue<std::string> mSceneSpeedModifier{ mIndex, sName, "scene-speed-modifier", "Shift" };
|
Settings::SettingValue<std::string> mSceneSpeedModifier{ mIndex, sName, "scene-speed-modifier", "Shift" };
|
||||||
Settings::SettingValue<std::string> mSceneDelete{ mIndex, sName, "scene-delete", "Delete" };
|
Settings::SettingValue<std::string> mSceneDelete{ mIndex, sName, "scene-delete", "Delete" };
|
||||||
Settings::SettingValue<std::string> mSceneInstanceDropTerrain{ mIndex, sName, "scene-instance-drop-terrain",
|
Settings::SettingValue<std::string> mSceneInstanceDrop{ mIndex, sName, "scene-instance-drop", "F" };
|
||||||
"B" };
|
|
||||||
Settings::SettingValue<std::string> mSceneInstanceDropCollision{ mIndex, sName, "scene-instance-drop-collision",
|
|
||||||
"H" };
|
|
||||||
Settings::SettingValue<std::string> mSceneInstanceDropTerrainSeparately{ mIndex, sName,
|
|
||||||
"scene-instance-drop-terrain-separately", "" };
|
|
||||||
Settings::SettingValue<std::string> mSceneInstanceDropCollisionSeparately{ mIndex, sName,
|
|
||||||
"scene-instance-drop-collision-separately", "" };
|
|
||||||
Settings::SettingValue<std::string> mSceneDuplicate{ mIndex, sName, "scene-duplicate", "Shift+C" };
|
Settings::SettingValue<std::string> mSceneDuplicate{ mIndex, sName, "scene-duplicate", "Shift+C" };
|
||||||
Settings::SettingValue<std::string> mSceneLoadCamCell{ mIndex, sName, "scene-load-cam-cell", "Keypad+5" };
|
Settings::SettingValue<std::string> mSceneLoadCamCell{ mIndex, sName, "scene-load-cam-cell", "Keypad+5" };
|
||||||
Settings::SettingValue<std::string> mSceneLoadCamEastcell{ mIndex, sName, "scene-load-cam-eastcell",
|
Settings::SettingValue<std::string> mSceneLoadCamEastcell{ mIndex, sName, "scene-load-cam-eastcell",
|
||||||
|
|
|
@ -320,26 +320,8 @@ CSVRender::InstanceMode::InstanceMode(
|
||||||
connect(
|
connect(
|
||||||
duplicateShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this, &InstanceMode::cloneSelectedInstances);
|
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
|
connect(new CSMPrefs::Shortcut("scene-instance-drop", worldspaceWidget),
|
||||||
// Qt5.14
|
qOverload<>(&CSMPrefs::Shortcut::activated), this, &InstanceMode::dropToCollision);
|
||||||
CSMPrefs::Shortcut* dropToCollisionShortcut
|
|
||||||
= new CSMPrefs::Shortcut("scene-instance-drop-collision", worldspaceWidget);
|
|
||||||
|
|
||||||
connect(dropToCollisionShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this,
|
|
||||||
&InstanceMode::dropSelectedInstancesToCollision);
|
|
||||||
|
|
||||||
CSMPrefs::Shortcut* dropToTerrainLevelShortcut
|
|
||||||
= new CSMPrefs::Shortcut("scene-instance-drop-terrain", worldspaceWidget);
|
|
||||||
connect(dropToTerrainLevelShortcut, qOverload<>(&CSMPrefs::Shortcut::activated), this,
|
|
||||||
&InstanceMode::dropSelectedInstancesToTerrain);
|
|
||||||
CSMPrefs::Shortcut* dropToCollisionShortcut2
|
|
||||||
= new CSMPrefs::Shortcut("scene-instance-drop-collision-separately", worldspaceWidget);
|
|
||||||
connect(dropToCollisionShortcut2, qOverload<>(&CSMPrefs::Shortcut::activated), this,
|
|
||||||
&InstanceMode::dropSelectedInstancesToCollisionSeparately);
|
|
||||||
CSMPrefs::Shortcut* dropToTerrainLevelShortcut2
|
|
||||||
= new CSMPrefs::Shortcut("scene-instance-drop-terrain-separately", worldspaceWidget);
|
|
||||||
connect(dropToTerrainLevelShortcut2, qOverload<>(&CSMPrefs::Shortcut::activated), this,
|
|
||||||
&InstanceMode::dropSelectedInstancesToTerrainSeparately);
|
|
||||||
|
|
||||||
for (short i = 0; i <= 9; i++)
|
for (short i = 0; i <= 9; i++)
|
||||||
{
|
{
|
||||||
|
@ -1254,7 +1236,7 @@ void CSVRender::InstanceMode::dropInstance(CSVRender::Object* object, float drop
|
||||||
object->setPosition(position.pos);
|
object->setPosition(position.pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
float CSVRender::InstanceMode::calculateDropHeight(DropMode dropMode, CSVRender::Object* object, float objectHeight)
|
float CSVRender::InstanceMode::calculateDropHeight(CSVRender::Object* object, float objectHeight)
|
||||||
{
|
{
|
||||||
osg::Vec3d point = object->getPosition().asVec3();
|
osg::Vec3d point = object->getPosition().asVec3();
|
||||||
|
|
||||||
|
@ -1268,10 +1250,7 @@ float CSVRender::InstanceMode::calculateDropHeight(DropMode dropMode, CSVRender:
|
||||||
intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::NO_LIMIT);
|
intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::NO_LIMIT);
|
||||||
osgUtil::IntersectionVisitor visitor(intersector);
|
osgUtil::IntersectionVisitor visitor(intersector);
|
||||||
|
|
||||||
if (dropMode & Terrain)
|
visitor.setTraversalMask(Mask_Terrain | Mask_Reference);
|
||||||
visitor.setTraversalMask(Mask_Terrain);
|
|
||||||
if (dropMode & Collision)
|
|
||||||
visitor.setTraversalMask(Mask_Terrain | Mask_Reference);
|
|
||||||
|
|
||||||
mParentNode->accept(visitor);
|
mParentNode->accept(visitor);
|
||||||
|
|
||||||
|
@ -1286,27 +1265,7 @@ float CSVRender::InstanceMode::calculateDropHeight(DropMode dropMode, CSVRender:
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::InstanceMode::dropSelectedInstancesToCollision()
|
void CSVRender::InstanceMode::dropToCollision()
|
||||||
{
|
|
||||||
handleDropMethod(Collision, "Drop instances to next collision");
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::InstanceMode::dropSelectedInstancesToTerrain()
|
|
||||||
{
|
|
||||||
handleDropMethod(Terrain, "Drop instances to terrain level");
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::InstanceMode::dropSelectedInstancesToCollisionSeparately()
|
|
||||||
{
|
|
||||||
handleDropMethod(CollisionSep, "Drop instances to next collision level separately");
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::InstanceMode::dropSelectedInstancesToTerrainSeparately()
|
|
||||||
{
|
|
||||||
handleDropMethod(TerrainSep, "Drop instances to terrain level separately");
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::InstanceMode::handleDropMethod(DropMode dropMode, QString commandMsg)
|
|
||||||
{
|
{
|
||||||
std::vector<osg::ref_ptr<TagBase>> selection = getWorldspaceWidget().getSelection(Mask_Reference);
|
std::vector<osg::ref_ptr<TagBase>> selection = getWorldspaceWidget().getSelection(Mask_Reference);
|
||||||
if (selection.empty())
|
if (selection.empty())
|
||||||
|
@ -1315,43 +1274,19 @@ void CSVRender::InstanceMode::handleDropMethod(DropMode dropMode, QString comman
|
||||||
CSMDoc::Document& document = getWorldspaceWidget().getDocument();
|
CSMDoc::Document& document = getWorldspaceWidget().getDocument();
|
||||||
QUndoStack& undoStack = document.getUndoStack();
|
QUndoStack& undoStack = document.getUndoStack();
|
||||||
|
|
||||||
CSMWorld::CommandMacro macro(undoStack, commandMsg);
|
CSMWorld::CommandMacro macro(undoStack, "Drop objects to collision");
|
||||||
|
|
||||||
DropObjectHeightHandler dropObjectDataHandler(&getWorldspaceWidget());
|
DropObjectHeightHandler dropObjectDataHandler(&getWorldspaceWidget());
|
||||||
|
|
||||||
if (dropMode & Separate)
|
int counter = 0;
|
||||||
{
|
for (osg::ref_ptr<TagBase> tag : selection)
|
||||||
int counter = 0;
|
if (CSVRender::ObjectTag* objectTag = dynamic_cast<CSVRender::ObjectTag*>(tag.get()))
|
||||||
for (osg::ref_ptr<TagBase> tag : selection)
|
{
|
||||||
if (CSVRender::ObjectTag* objectTag = dynamic_cast<CSVRender::ObjectTag*>(tag.get()))
|
float objectHeight = dropObjectDataHandler.mObjectHeights[counter++];
|
||||||
{
|
float dropHeight = calculateDropHeight(objectTag->mObject, objectHeight);
|
||||||
float objectHeight = dropObjectDataHandler.mObjectHeights[counter];
|
dropInstance(objectTag->mObject, dropHeight);
|
||||||
float dropHeight = calculateDropHeight(dropMode, objectTag->mObject, objectHeight);
|
objectTag->mObject->apply(macro);
|
||||||
dropInstance(objectTag->mObject, dropHeight);
|
}
|
||||||
objectTag->mObject->apply(macro);
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float smallestDropHeight = std::numeric_limits<float>::max();
|
|
||||||
int counter = 0;
|
|
||||||
for (osg::ref_ptr<TagBase> tag : selection)
|
|
||||||
if (CSVRender::ObjectTag* objectTag = dynamic_cast<CSVRender::ObjectTag*>(tag.get()))
|
|
||||||
{
|
|
||||||
float objectHeight = dropObjectDataHandler.mObjectHeights[counter];
|
|
||||||
float thisDrop = calculateDropHeight(dropMode, objectTag->mObject, objectHeight);
|
|
||||||
if (thisDrop < smallestDropHeight)
|
|
||||||
smallestDropHeight = thisDrop;
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
for (osg::ref_ptr<TagBase> tag : selection)
|
|
||||||
if (CSVRender::ObjectTag* objectTag = dynamic_cast<CSVRender::ObjectTag*>(tag.get()))
|
|
||||||
{
|
|
||||||
dropInstance(objectTag->mObject, smallestDropHeight);
|
|
||||||
objectTag->mObject->apply(macro);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::DropObjectHeightHandler::DropObjectHeightHandler(WorldspaceWidget* worldspacewidget)
|
CSVRender::DropObjectHeightHandler::DropObjectHeightHandler(WorldspaceWidget* worldspacewidget)
|
||||||
|
|
|
@ -41,17 +41,6 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
enum DropMode
|
|
||||||
{
|
|
||||||
Separate = 0b1,
|
|
||||||
|
|
||||||
Collision = 0b10,
|
|
||||||
Terrain = 0b100,
|
|
||||||
|
|
||||||
CollisionSep = Collision | Separate,
|
|
||||||
TerrainSep = Terrain | Separate,
|
|
||||||
};
|
|
||||||
|
|
||||||
CSVWidget::SceneToolMode* mSubMode;
|
CSVWidget::SceneToolMode* mSubMode;
|
||||||
std::string mSubModeId;
|
std::string mSubModeId;
|
||||||
InstanceSelectionMode* mSelectionMode;
|
InstanceSelectionMode* mSelectionMode;
|
||||||
|
@ -77,7 +66,7 @@ namespace CSVRender
|
||||||
osg::Vec3 getMousePlaneCoords(const QPoint& point, const osg::Vec3d& dragStart);
|
osg::Vec3 getMousePlaneCoords(const QPoint& point, const osg::Vec3d& dragStart);
|
||||||
void handleSelectDrag(const QPoint& pos);
|
void handleSelectDrag(const QPoint& pos);
|
||||||
void dropInstance(CSVRender::Object* object, float dropHeight);
|
void dropInstance(CSVRender::Object* object, float dropHeight);
|
||||||
float calculateDropHeight(DropMode dropMode, CSVRender::Object* object, float objectHeight);
|
float calculateDropHeight(CSVRender::Object* object, float objectHeight);
|
||||||
osg::Vec3 calculateSnapPositionRelativeToTarget(osg::Vec3 initalPosition, osg::Vec3 targetPosition,
|
osg::Vec3 calculateSnapPositionRelativeToTarget(osg::Vec3 initalPosition, osg::Vec3 targetPosition,
|
||||||
osg::Vec3 targetRotation, osg::Vec3 translation, double snap) const;
|
osg::Vec3 targetRotation, osg::Vec3 translation, double snap) const;
|
||||||
|
|
||||||
|
@ -139,11 +128,7 @@ namespace CSVRender
|
||||||
void cloneSelectedInstances();
|
void cloneSelectedInstances();
|
||||||
void getSelectionGroup(const int group);
|
void getSelectionGroup(const int group);
|
||||||
void saveSelectionGroup(const int group);
|
void saveSelectionGroup(const int group);
|
||||||
void dropSelectedInstancesToCollision();
|
void dropToCollision();
|
||||||
void dropSelectedInstancesToTerrain();
|
|
||||||
void dropSelectedInstancesToCollisionSeparately();
|
|
||||||
void dropSelectedInstancesToTerrainSeparately();
|
|
||||||
void handleDropMethod(DropMode dropMode, QString commandMsg);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Helper class to handle object mask data in safe way
|
/// \brief Helper class to handle object mask data in safe way
|
||||||
|
|
Loading…
Reference in a new issue