From 17cb3414d832c7128e44e5715e15933d196db952 Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Thu, 19 Mar 2020 11:18:54 +0200 Subject: [PATCH] clean-up, improve formatting --- apps/opencs/view/render/instancemode.cpp | 36 +++++++++++++----------- apps/opencs/view/render/instancemode.hpp | 4 +-- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index ef7449f569..7c0020f1e1 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -700,7 +700,7 @@ void CSVRender::InstanceMode::deleteSelectedInstances(bool active) void CSVRender::InstanceMode::dropInstance(DropMode dropMode, CSVRender::Object* object, float objectHeight) { - const osg::Vec3d& point = object->getPosition().asVec3(); + osg::Vec3d point = object->getPosition().asVec3(); osg::Vec3d start = point; start.z() += objectHeight; @@ -712,8 +712,10 @@ void CSVRender::InstanceMode::dropInstance(DropMode dropMode, CSVRender::Object* intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::NO_LIMIT); osgUtil::IntersectionVisitor visitor(intersector); - if (dropMode == Terrain_sep) visitor.setTraversalMask(SceneUtil::Mask_Terrain); - if (dropMode == Collision_sep) visitor.setTraversalMask(SceneUtil::Mask_Terrain | SceneUtil::Mask_EditorReference); + if (dropMode == TerrainSep) + visitor.setTraversalMask(SceneUtil::Mask_Terrain); + if (dropMode == CollisionSep) + visitor.setTraversalMask(SceneUtil::Mask_Terrain | SceneUtil::Mask_EditorReference); mParentNode->accept(visitor); @@ -732,7 +734,7 @@ void CSVRender::InstanceMode::dropInstance(DropMode dropMode, CSVRender::Object* float CSVRender::InstanceMode::getDropHeight(DropMode dropMode, CSVRender::Object* object, float objectHeight) { - const osg::Vec3d& point = object->getPosition().asVec3(); + osg::Vec3d point = object->getPosition().asVec3(); osg::Vec3d start = point; start.z() += objectHeight; @@ -744,8 +746,10 @@ float CSVRender::InstanceMode::getDropHeight(DropMode dropMode, CSVRender::Objec intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::NO_LIMIT); osgUtil::IntersectionVisitor visitor(intersector); - if (dropMode == Terrain) visitor.setTraversalMask(SceneUtil::Mask_Terrain); - if (dropMode == Collision) visitor.setTraversalMask(SceneUtil::Mask_Terrain | SceneUtil::Mask_EditorReference); + if (dropMode == Terrain) + visitor.setTraversalMask(SceneUtil::Mask_Terrain); + if (dropMode == Collision) + visitor.setTraversalMask(SceneUtil::Mask_Terrain | SceneUtil::Mask_EditorReference); mParentNode->accept(visitor); @@ -772,18 +776,19 @@ void CSVRender::InstanceMode::dropSelectedInstancesToTerrain() void CSVRender::InstanceMode::dropSelectedInstancesToCollisionSeparately() { - handleDropMethod(Terrain_sep, "Drop instances to next collision level separately"); + handleDropMethod(TerrainSep, "Drop instances to next collision level separately"); } void CSVRender::InstanceMode::dropSelectedInstancesToTerrainSeparately() { - handleDropMethod(Collision_sep, "Drop instances to terrain level separately"); + handleDropMethod(CollisionSep, "Drop instances to terrain level separately"); } void CSVRender::InstanceMode::handleDropMethod(DropMode dropMode, QString commandMsg) { std::vector > selection = getWorldspaceWidget().getSelection (SceneUtil::Mask_EditorReference); - if (selection.empty()) return; + if (selection.empty()) + return; CSMDoc::Document& document = getWorldspaceWidget().getDocument(); QUndoStack& undoStack = document.getUndoStack(); @@ -803,7 +808,8 @@ void CSVRender::InstanceMode::handleDropMethod(DropMode dropMode, QString comman if (CSVRender::ObjectTag *objectTag = dynamic_cast (tag.get())) { float thisDrop = getDropHeight(dropMode, objectTag->mObject, dropObjectDataHandler.mObjectHeights[counter]); - if (thisDrop < smallestDropHeight) smallestDropHeight = thisDrop; + if (thisDrop < smallestDropHeight) + smallestDropHeight = thisDrop; counter++; } for(osg::ref_ptr tag: selection) @@ -818,8 +824,8 @@ void CSVRender::InstanceMode::handleDropMethod(DropMode dropMode, QString comman } break; - case Terrain_sep: - case Collision_sep: + case TerrainSep: + case CollisionSep: { int counter = 0; for(osg::ref_ptr tag: selection) @@ -831,9 +837,6 @@ void CSVRender::InstanceMode::handleDropMethod(DropMode dropMode, QString comman } } break; - - default: - break; } } @@ -853,7 +856,8 @@ CSVRender::DropObjectDataHandler::DropObjectDataHandler(WorldspaceWidget* worlds objectNodeWithoutGUI->accept(computeBounds); osg::BoundingBox bounds = computeBounds.getBoundingBox(); float boundingBoxOffset = 0.0f; - if (bounds.valid()) boundingBoxOffset = bounds.zMin(); + if (bounds.valid()) + boundingBoxOffset = bounds.zMin(); mObjectHeights.emplace_back(boundingBoxOffset); mOldMasks.emplace_back(objectNodeWithGUI->getNodeMask()); diff --git a/apps/opencs/view/render/instancemode.hpp b/apps/opencs/view/render/instancemode.hpp index b1d5de7fe3..84b9e9ee20 100644 --- a/apps/opencs/view/render/instancemode.hpp +++ b/apps/opencs/view/render/instancemode.hpp @@ -37,8 +37,8 @@ namespace CSVRender { Collision, Terrain, - Collision_sep, - Terrain_sep + CollisionSep, + Terrainsep }; CSVWidget::SceneToolMode *mSubMode;