From 22ac61e476ee43f1beabcd736314ad2ddab2051b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 17 Jun 2015 14:40:24 -0700 Subject: [PATCH] work around hiding of virtual functions in PolyVox entity classses --- .../src/RenderablePolyVoxEntityItem.cpp | 10 +++------- .../src/RenderablePolyVoxEntityItem.h | 11 ++++++----- libraries/entities/src/PolyVoxEntityItem.h | 14 +++++++++++--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index 71c3537a0c..4106559b6c 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -141,11 +141,7 @@ void RenderablePolyVoxEntityItem::setVoxelVolumeSize(glm::vec3 voxelVolumeSize) decompressVolumeData(); } -void RenderablePolyVoxEntityItem::setVoxelSurfaceStyle(PolyVoxSurfaceStyle voxelSurfaceStyle) { - if (voxelSurfaceStyle == _voxelSurfaceStyle) { - return; - } - +void RenderablePolyVoxEntityItem::updateVoxelSurfaceStyle(PolyVoxSurfaceStyle voxelSurfaceStyle) { // if we are switching to or from "edged" we need to force a resize of _volData. if (voxelSurfaceStyle == SURFACE_EDGED_CUBIC || _voxelSurfaceStyle == SURFACE_EDGED_CUBIC) { @@ -153,10 +149,10 @@ void RenderablePolyVoxEntityItem::setVoxelSurfaceStyle(PolyVoxSurfaceStyle voxel delete _volData; } _volData = nullptr; - PolyVoxEntityItem::setVoxelSurfaceStyle(voxelSurfaceStyle); + _voxelSurfaceStyle = voxelSurfaceStyle; setVoxelVolumeSize(_voxelVolumeSize); } else { - PolyVoxEntityItem::setVoxelSurfaceStyle(voxelSurfaceStyle); + _voxelSurfaceStyle = voxelSurfaceStyle; } _needsModelReload = true; } diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h index c785ed2c1a..1097ad21be 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h @@ -36,18 +36,15 @@ public: virtual uint8_t getVoxel(int x, int y, int z); virtual void setVoxel(int x, int y, int z, uint8_t toValue); - + void updateOnCount(int x, int y, int z, uint8_t new_value); void render(RenderArgs* args); virtual bool supportsDetailedRayIntersection() const { return true; } virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, - bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, + bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking) const; - using PolyVoxEntityItem::setVoxelSurfaceStyle; - virtual void setVoxelSurfaceStyle(PolyVoxSurfaceStyle voxelSurfaceStyle); - void getModel(); virtual void setVoxelData(QByteArray voxelData); @@ -75,6 +72,9 @@ public: SIMPLE_RENDERABLE(); +protected: + virtual void updateVoxelSurfaceStyle(PolyVoxSurfaceStyle voxelSurfaceStyle); + private: // The PolyVoxEntityItem class has _voxelData which contains dimensions and compressed voxel data. The dimensions // may not match _voxelVolumeSize. @@ -83,6 +83,7 @@ private: void compressVolumeData(); void decompressVolumeData(); + PolyVox::SimpleVolume* _volData = nullptr; model::Geometry _modelGeometry; bool _needsModelReload = true; diff --git a/libraries/entities/src/PolyVoxEntityItem.h b/libraries/entities/src/PolyVoxEntityItem.h index e5d511c087..39d67fb9a3 100644 --- a/libraries/entities/src/PolyVoxEntityItem.h +++ b/libraries/entities/src/PolyVoxEntityItem.h @@ -61,10 +61,14 @@ class PolyVoxEntityItem : public EntityItem { SURFACE_EDGED_CUBIC }; - virtual void setVoxelSurfaceStyle(PolyVoxSurfaceStyle voxelSurfaceStyle) { _voxelSurfaceStyle = voxelSurfaceStyle; } - virtual void setVoxelSurfaceStyle(uint16_t voxelSurfaceStyle) { - setVoxelSurfaceStyle((PolyVoxSurfaceStyle) voxelSurfaceStyle); + void setVoxelSurfaceStyle(PolyVoxSurfaceStyle voxelSurfaceStyle) { + if (voxelSurfaceStyle == _voxelSurfaceStyle) { + return; + } + updateVoxelSurfaceStyle(voxelSurfaceStyle); } + // this other version of setVoxelSurfaceStyle is needed for SET_ENTITY_PROPERTY_FROM_PROPERTIES + void setVoxelSurfaceStyle(uint16_t voxelSurfaceStyle) { setVoxelSurfaceStyle((PolyVoxSurfaceStyle) voxelSurfaceStyle); } virtual PolyVoxSurfaceStyle getVoxelSurfaceStyle() const { return _voxelSurfaceStyle; } static const glm::vec3 DEFAULT_VOXEL_VOLUME_SIZE; @@ -89,6 +93,10 @@ class PolyVoxEntityItem : public EntityItem { static QByteArray makeEmptyVoxelData(quint16 voxelXSize = 16, quint16 voxelYSize = 16, quint16 voxelZSize = 16); protected: + virtual void updateVoxelSurfaceStyle(PolyVoxSurfaceStyle voxelSurfaceStyle) { + _voxelSurfaceStyle = voxelSurfaceStyle; + } + glm::vec3 _voxelVolumeSize; // this is always 3 bytes QByteArray _voxelData; PolyVoxSurfaceStyle _voxelSurfaceStyle;