|
|
|
@ -791,31 +791,8 @@ void CSVRender::InstanceMode::handleDropMethod(DropMode dropMode, QString comman
|
|
|
|
|
|
|
|
|
|
CSMWorld::CommandMacro macro (undoStack, commandMsg);
|
|
|
|
|
|
|
|
|
|
std::vector<osg::Node::NodeMask> oldMasks;
|
|
|
|
|
std::vector<float> objectHeights;
|
|
|
|
|
for(osg::ref_ptr<TagBase> tag: selection)
|
|
|
|
|
{
|
|
|
|
|
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (tag.get()))
|
|
|
|
|
{
|
|
|
|
|
osg::ref_ptr<osg::Group> objectNodeWithGUI = objectTag->mObject->getRootNode();
|
|
|
|
|
osg::ref_ptr<osg::Group> objectNodeWithoutGUI = objectTag->mObject->getBaseNode();
|
|
|
|
|
|
|
|
|
|
osg::ComputeBoundsVisitor computeBounds;
|
|
|
|
|
computeBounds.setTraversalMask(SceneUtil::Mask_EditorReference);
|
|
|
|
|
objectNodeWithoutGUI->accept(computeBounds);
|
|
|
|
|
osg::BoundingBox bounds = computeBounds.getBoundingBox();
|
|
|
|
|
float boundingBoxOffset = 0.0f;
|
|
|
|
|
if (bounds.valid()) boundingBoxOffset = bounds.zMin();
|
|
|
|
|
|
|
|
|
|
objectHeights.emplace_back(boundingBoxOffset);
|
|
|
|
|
oldMasks.emplace_back(objectNodeWithGUI->getNodeMask());
|
|
|
|
|
|
|
|
|
|
objectNodeWithGUI->setNodeMask(SceneUtil::Mask_Disabled);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
DropObjectDataHandler dropObjectDataHandler(&getWorldspaceWidget());
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
switch (dropMode)
|
|
|
|
|
{
|
|
|
|
|
case Terrain:
|
|
|
|
@ -826,7 +803,7 @@ void CSVRender::InstanceMode::handleDropMethod(DropMode dropMode, QString comman
|
|
|
|
|
for(osg::ref_ptr<TagBase> tag: selection)
|
|
|
|
|
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (tag.get()))
|
|
|
|
|
{
|
|
|
|
|
float thisDrop = getDropHeight(dropMode, objectTag->mObject, objectHeights[counter]);
|
|
|
|
|
float thisDrop = getDropHeight(dropMode, objectTag->mObject, dropObjectDataHandler.mObjectHeights[counter]);
|
|
|
|
|
if (thisDrop < smallestDropHeight) smallestDropHeight = thisDrop;
|
|
|
|
|
counter++;
|
|
|
|
|
}
|
|
|
|
@ -849,28 +826,54 @@ void CSVRender::InstanceMode::handleDropMethod(DropMode dropMode, QString comman
|
|
|
|
|
for(osg::ref_ptr<TagBase> tag: selection)
|
|
|
|
|
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (tag.get()))
|
|
|
|
|
{
|
|
|
|
|
dropInstance(dropMode, objectTag->mObject, objectHeights[counter]);
|
|
|
|
|
dropInstance(dropMode, objectTag->mObject, dropObjectDataHandler.mObjectHeights[counter]);
|
|
|
|
|
objectTag->mObject->apply (macro);
|
|
|
|
|
counter++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const std::exception& e)
|
|
|
|
|
|
|
|
|
|
CSVRender::DropObjectDataHandler::DropObjectDataHandler(WorldspaceWidget* worldspacewidget)
|
|
|
|
|
: mWorldspaceWidget(worldspacewidget)
|
|
|
|
|
{
|
|
|
|
|
std::vector<osg::ref_ptr<TagBase> > selection = mWorldspaceWidget->getSelection (SceneUtil::Mask_EditorReference);
|
|
|
|
|
for(osg::ref_ptr<TagBase> tag: selection)
|
|
|
|
|
{
|
|
|
|
|
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (tag.get()))
|
|
|
|
|
{
|
|
|
|
|
Log(Debug::Error) << "Error in dropping instance: " << e.what();
|
|
|
|
|
osg::ref_ptr<osg::Group> objectNodeWithGUI = objectTag->mObject->getRootNode();
|
|
|
|
|
osg::ref_ptr<osg::Group> objectNodeWithoutGUI = objectTag->mObject->getBaseNode();
|
|
|
|
|
|
|
|
|
|
osg::ComputeBoundsVisitor computeBounds;
|
|
|
|
|
computeBounds.setTraversalMask(SceneUtil::Mask_EditorReference);
|
|
|
|
|
objectNodeWithoutGUI->accept(computeBounds);
|
|
|
|
|
osg::BoundingBox bounds = computeBounds.getBoundingBox();
|
|
|
|
|
float boundingBoxOffset = 0.0f;
|
|
|
|
|
if (bounds.valid()) boundingBoxOffset = bounds.zMin();
|
|
|
|
|
|
|
|
|
|
mObjectHeights.emplace_back(boundingBoxOffset);
|
|
|
|
|
mOldMasks.emplace_back(objectNodeWithGUI->getNodeMask());
|
|
|
|
|
|
|
|
|
|
objectNodeWithGUI->setNodeMask(SceneUtil::Mask_Disabled);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSVRender::DropObjectDataHandler::~DropObjectDataHandler()
|
|
|
|
|
{
|
|
|
|
|
std::vector<osg::ref_ptr<TagBase> > selection = mWorldspaceWidget->getSelection (SceneUtil::Mask_EditorReference);
|
|
|
|
|
int counter = 0;
|
|
|
|
|
for(osg::ref_ptr<TagBase> tag: selection)
|
|
|
|
|
{
|
|
|
|
|
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (tag.get()))
|
|
|
|
|
{
|
|
|
|
|
osg::ref_ptr<osg::Group> objectNodeWithGUI = objectTag->mObject->getRootNode();
|
|
|
|
|
objectNodeWithGUI->setNodeMask(oldMasks[counter]);
|
|
|
|
|
objectNodeWithGUI->setNodeMask(mOldMasks[counter]);
|
|
|
|
|
counter++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|