Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 2 files). Show all
Unified · Split
| @@ -216,21 +216,48 @@ public: · 215 unmodified lines | |||
| 216 | BufferBuilder(const MetavoxelLOD& lod); | 216 | BufferBuilder(const MetavoxelLOD& lod); |
| 217 | 217 | ||
| 218 | virtual int visit(MetavoxelInfo& info); | 218 | virtual int visit(MetavoxelInfo& info); |
| 219 | virtual bool postVisit(MetavoxelInfo& info); | ||
| 220 | |||
| 221 | private: | ||
| 222 | |||
| 223 | QVector<BufferPointVectorPair> _depthPoints; | ||
| 219 | }; | 224 | }; |
| 220 | 225 | ||
| 221 | BufferBuilder::BufferBuilder(const MetavoxelLOD& lod) : | 226 | BufferBuilder::BufferBuilder(const MetavoxelLOD& lod) : |
| 222 | MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getColorAttribute() << | 227 | MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getColorAttribute() << |
| 223 | AttributeRegistry::getInstance()->getNormalAttribute(), QVector<AttributePointer>(), lod) { | 228 | AttributeRegistry::getInstance()->getNormalAttribute(), QVector<AttributePointer>() << |
| 229 | Application::getInstance()->getMetavoxels()->getPointBufferAttribute(), lod) { | ||
| 224 | } | 230 | } |
| 225 | 231 | ||
| 232 | const int ALPHA_RENDER_THRESHOLD = 0; | ||
| 233 | |||
| 226 | int BufferBuilder::visit(MetavoxelInfo& info) { | 234 | int BufferBuilder::visit(MetavoxelInfo& info) { |
| 235 | if (_depth >= _depthPoints.size()) { | ||
| 236 | _depthPoints.resize(_depth + 1); | ||
| 237 | } | ||
| 238 | QRgb color = info.inputValues.at(0).getInlineValue<QRgb>(); | ||
| 239 | quint8 alpha = qAlpha(color); | ||
| 240 | if (alpha <= ALPHA_RENDER_THRESHOLD) { | ||
| 241 | return info.isLeaf ? STOP_RECURSION : DEFAULT_ORDER; | ||
| 242 | } | ||
| 243 | QRgb normal = info.inputValues.at(1).getInlineValue<QRgb>(); | ||
| 244 | BufferPoint point = { glm::vec4(info.minimum + glm::vec3(info.size, info.size, info.size) * 0.5f, info.size), | ||
| 245 | { quint8(qRed(color)), quint8(qGreen(color)), quint8(qBlue(color)) }, | ||
| 246 | { quint8(qRed(normal)), quint8(qGreen(normal)), quint8(qBlue(normal)) } }; | ||
| 227 | if (info.isLeaf) { | 247 | if (info.isLeaf) { |
| 228 | 248 | _depthPoints[_depth].first.append(point); | |
| 229 | return STOP_RECURSION; | 249 | return STOP_RECURSION; |
| 230 | } | 250 | } |
| 251 | _depthPoints[_depth].second.append(point); | ||
| 231 | return DEFAULT_ORDER; | 252 | return DEFAULT_ORDER; |
| 232 | } | 253 | } |
| 233 | 254 | ||
| 255 | const int BUFFER_LEAF_THRESHOLD = 1024; | ||
| 256 | |||
| 257 | bool BufferBuilder::postVisit(MetavoxelInfo& info) { | ||
| 258 | return false; | ||
| 259 | } | ||
| 260 | |||
| 234 | void MetavoxelSystemClient::dataChanged(const MetavoxelData& oldData) { | 261 | void MetavoxelSystemClient::dataChanged(const MetavoxelData& oldData) { |
| 235 | BufferBuilder builder(_remoteDataLOD); | 262 | BufferBuilder builder(_remoteDataLOD); |
| 236 | _data.guideToDifferent(oldData, builder); | 263 | _data.guideToDifferent(oldData, builder); |