From 001af5f982771a892b31750d8863533b155b28c5 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 30 Sep 2014 12:17:35 -0700 Subject: [PATCH] Simplify the message situation by removing color-only edits. --- interface/src/ui/MetavoxelEditor.cpp | 10 ++-- .../metavoxels/src/MetavoxelMessages.cpp | 44 --------------- libraries/metavoxels/src/MetavoxelMessages.h | 53 ------------------- libraries/networking/src/PacketHeaders.cpp | 2 +- 4 files changed, 6 insertions(+), 103 deletions(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index bb62bee9a1..f2288a1f97 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1284,7 +1284,7 @@ HeightfieldColorBrushTool::HeightfieldColorBrushTool(MetavoxelEditor* editor) : } QVariant HeightfieldColorBrushTool::createEdit(bool alternate) { - return QVariant::fromValue(PaintHeightfieldColorEdit(_position, _radius->value(), + return QVariant::fromValue(PaintHeightfieldMaterialEdit(_position, _radius->value(), SharedObjectPointer(), alternate ? QColor() : _color->getColor())); } @@ -1334,8 +1334,8 @@ void VoxelColorBoxTool::applyValue(const glm::vec3& minimum, const glm::vec3& ma // ensure that color is either 100% transparent or 100% opaque QColor color = _color->getColor(); color.setAlphaF(color.alphaF() > 0.5f ? 1.0f : 0.0f); - MetavoxelEditMessage message = { QVariant::fromValue(VoxelColorBoxEdit(Box(minimum, maximum), - _editor->getGridSpacing(), color)) }; + MetavoxelEditMessage message = { QVariant::fromValue(VoxelMaterialBoxEdit(Box(minimum, maximum), + _editor->getGridSpacing(), SharedObjectPointer(), color)) }; Application::getInstance()->getMetavoxels()->applyEdit(message, true); } @@ -1454,8 +1454,8 @@ void VoxelColorSphereTool::applyValue(const glm::vec3& position, float radius) { // ensure that color is either 100% transparent or 100% opaque QColor color = _color->getColor(); color.setAlphaF(color.alphaF() > 0.5f ? 1.0f : 0.0f); - MetavoxelEditMessage message = { QVariant::fromValue(VoxelColorSphereEdit(position, radius, - _editor->getGridSpacing(), color)) }; + MetavoxelEditMessage message = { QVariant::fromValue(VoxelMaterialSphereEdit(position, radius, + _editor->getGridSpacing(), SharedObjectPointer(), color)) }; Application::getInstance()->getMetavoxels()->applyEdit(message, true); } diff --git a/libraries/metavoxels/src/MetavoxelMessages.cpp b/libraries/metavoxels/src/MetavoxelMessages.cpp index 791604f63f..04ed5c5d02 100644 --- a/libraries/metavoxels/src/MetavoxelMessages.cpp +++ b/libraries/metavoxels/src/MetavoxelMessages.cpp @@ -408,12 +408,6 @@ void PaintHeightfieldHeightEdit::apply(MetavoxelData& data, const WeakSharedObje data.guide(visitor); } -PaintHeightfieldColorEdit::PaintHeightfieldColorEdit(const glm::vec3& position, float radius, const QColor& color) : - position(position), - radius(radius), - color(color) { -} - class PaintHeightfieldMaterialEditVisitor : public MetavoxelVisitor { public: @@ -599,11 +593,6 @@ int PaintHeightfieldMaterialEditVisitor::visit(MetavoxelInfo& info) { return STOP_RECURSION; } -void PaintHeightfieldColorEdit::apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const { - PaintHeightfieldMaterialEditVisitor visitor(position, radius, SharedObjectPointer(), color); - data.guide(visitor); -} - PaintHeightfieldMaterialEdit::PaintHeightfieldMaterialEdit(const glm::vec3& position, float radius, const SharedObjectPointer& material, const QColor& averageColor) : position(position), @@ -617,12 +606,6 @@ void PaintHeightfieldMaterialEdit::apply(MetavoxelData& data, const WeakSharedOb data.guide(visitor); } -VoxelColorBoxEdit::VoxelColorBoxEdit(const Box& region, float granularity, const QColor& color) : - region(region), - granularity(granularity), - color(color) { -} - const int VOXEL_BLOCK_SIZE = 16; const int VOXEL_BLOCK_SAMPLES = VOXEL_BLOCK_SIZE + 1; const int VOXEL_BLOCK_AREA = VOXEL_BLOCK_SAMPLES * VOXEL_BLOCK_SAMPLES; @@ -849,15 +832,6 @@ int VoxelMaterialBoxEditVisitor::visit(MetavoxelInfo& info) { return STOP_RECURSION; } -void VoxelColorBoxEdit::apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const { - // expand to fit the entire edit - while (!data.getBounds().contains(region)) { - data.expand(); - } - VoxelMaterialBoxEditVisitor visitor(region, granularity, SharedObjectPointer(), color); - data.guide(visitor); -} - VoxelMaterialBoxEdit::VoxelMaterialBoxEdit(const Box& region, float granularity, const SharedObjectPointer& material, const QColor& averageColor) : region(region), @@ -875,13 +849,6 @@ void VoxelMaterialBoxEdit::apply(MetavoxelData& data, const WeakSharedObjectHash data.guide(visitor); } -VoxelColorSphereEdit::VoxelColorSphereEdit(const glm::vec3& center, float radius, float granularity, const QColor& color) : - center(center), - radius(radius), - granularity(granularity), - color(color) { -} - class VoxelMaterialSphereEditVisitor : public MetavoxelVisitor { public: @@ -1148,17 +1115,6 @@ int VoxelMaterialSphereEditVisitor::visit(MetavoxelInfo& info) { return STOP_RECURSION; } - -void VoxelColorSphereEdit::apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const { - // expand to fit the entire edit - glm::vec3 extents(radius, radius, radius); - Box bounds(center - extents, center + extents); - while (!data.getBounds().contains(bounds)) { - data.expand(); - } - VoxelMaterialSphereEditVisitor visitor(center, radius, bounds, granularity, SharedObjectPointer(), color); - data.guide(visitor); -} VoxelMaterialSphereEdit::VoxelMaterialSphereEdit(const glm::vec3& center, float radius, float granularity, const SharedObjectPointer& material, const QColor& averageColor) : diff --git a/libraries/metavoxels/src/MetavoxelMessages.h b/libraries/metavoxels/src/MetavoxelMessages.h index 2eb5684d77..fec8e69aaa 100644 --- a/libraries/metavoxels/src/MetavoxelMessages.h +++ b/libraries/metavoxels/src/MetavoxelMessages.h @@ -224,23 +224,6 @@ public: DECLARE_STREAMABLE_METATYPE(PaintHeightfieldHeightEdit) -/// An edit that sets a region of a heightfield color. -class PaintHeightfieldColorEdit : public MetavoxelEdit { - STREAMABLE - -public: - - STREAM glm::vec3 position; - STREAM float radius; - STREAM QColor color; - - PaintHeightfieldColorEdit(const glm::vec3& position = glm::vec3(), float radius = 0.0f, const QColor& color = QColor()); - - virtual void apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const; -}; - -DECLARE_STREAMABLE_METATYPE(PaintHeightfieldColorEdit) - /// An edit that sets a region of a heightfield material. class PaintHeightfieldMaterialEdit : public MetavoxelEdit { STREAMABLE @@ -260,23 +243,6 @@ public: DECLARE_STREAMABLE_METATYPE(PaintHeightfieldMaterialEdit) -/// An edit that sets the color of voxels within a box to a value. -class VoxelColorBoxEdit : public MetavoxelEdit { - STREAMABLE - -public: - - STREAM Box region; - STREAM float granularity; - STREAM QColor color; - - VoxelColorBoxEdit(const Box& region = Box(), float granularity = 0.0f, const QColor& color = QColor()); - - virtual void apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const; -}; - -DECLARE_STREAMABLE_METATYPE(VoxelColorBoxEdit) - /// An edit that sets the materials of voxels within a box to a value. class VoxelMaterialBoxEdit : public MetavoxelEdit { STREAMABLE @@ -296,25 +262,6 @@ public: DECLARE_STREAMABLE_METATYPE(VoxelMaterialBoxEdit) -/// An edit that sets the color of voxels within a sphere to a value. -class VoxelColorSphereEdit : public MetavoxelEdit { - STREAMABLE - -public: - - STREAM glm::vec3 center; - STREAM float radius; - STREAM float granularity; - STREAM QColor color; - - VoxelColorSphereEdit(const glm::vec3& center = glm::vec3(), float radius = 0.0f, - float granularity = 0.0f, const QColor& color = QColor()); - - virtual void apply(MetavoxelData& data, const WeakSharedObjectHash& objects) const; -}; - -DECLARE_STREAMABLE_METATYPE(VoxelColorSphereEdit) - /// An edit that sets the materials of voxels within a sphere to a value. class VoxelMaterialSphereEdit : public MetavoxelEdit { STREAMABLE diff --git a/libraries/networking/src/PacketHeaders.cpp b/libraries/networking/src/PacketHeaders.cpp index f04e398b98..14bcd7c3ce 100644 --- a/libraries/networking/src/PacketHeaders.cpp +++ b/libraries/networking/src/PacketHeaders.cpp @@ -85,7 +85,7 @@ PacketVersion versionForPacketType(PacketType type) { case PacketTypeAudioStreamStats: return 1; case PacketTypeMetavoxelData: - return 3; + return 4; case PacketTypeVoxelData: return VERSION_VOXELS_HAS_FILE_BREAKS; default: