From a022b7fa172f1f64236b72d4f1c84b6cefe9b82c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 2 Dec 2014 13:12:45 -0800 Subject: [PATCH] Fix for successive heightfield placements. --- interface/src/ui/MetavoxelEditor.cpp | 2 +- libraries/metavoxels/src/Spanner.cpp | 6 ++++++ libraries/metavoxels/src/Spanner.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 6d1e181907..a88b981d66 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -789,7 +789,7 @@ void ImportHeightfieldTool::apply() { if (!(_height->getHeight() && attribute)) { return; } - MetavoxelEditMessage message = { QVariant::fromValue(InsertSpannerEdit(attribute, _spanner)) }; + MetavoxelEditMessage message = { QVariant::fromValue(InsertSpannerEdit(attribute, _spanner->clone())) }; Application::getInstance()->getMetavoxels()->applyEdit(message, true); } diff --git a/libraries/metavoxels/src/Spanner.cpp b/libraries/metavoxels/src/Spanner.cpp index 301959b16f..cb8cdc6260 100644 --- a/libraries/metavoxels/src/Spanner.cpp +++ b/libraries/metavoxels/src/Spanner.cpp @@ -2063,6 +2063,12 @@ MetavoxelLOD Heightfield::transformLOD(const MetavoxelLOD& lod) const { qMax(0.5f, glm::abs(position.y * _aspectY - 0.5f)) * THRESHOLD_MULTIPLIER); } +SharedObject* Heightfield::clone(bool withID, SharedObject* target) const { + Heightfield* newHeightfield = static_cast(Spanner::clone(withID, target)); + newHeightfield->setRoot(_root); + return newHeightfield; +} + bool Heightfield::isHeightfield() const { return true; } diff --git a/libraries/metavoxels/src/Spanner.h b/libraries/metavoxels/src/Spanner.h index 2173bd67e9..6c38dbcb9a 100644 --- a/libraries/metavoxels/src/Spanner.h +++ b/libraries/metavoxels/src/Spanner.h @@ -579,6 +579,8 @@ public: MetavoxelLOD transformLOD(const MetavoxelLOD& lod) const; + virtual SharedObject* clone(bool withID = false, SharedObject* target = NULL) const; + virtual bool isHeightfield() const; virtual float getHeight(const glm::vec3& location) const;