History

Working on optimized point rendering.

Andrzej Kapolka committed 12 years ago

Commit cda1a7f1 parent 1d6f4292 files · +34 −2Browse files

Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 2 files). Show all

Unified · Split

interface/src/MetavoxelSystem.cpp+29−2
@@ -216,21 +216,48 @@ public: · 215 unmodified lines
216216 BufferBuilder(const MetavoxelLOD& lod);
217217
218218 virtual int visit(MetavoxelInfo& info);
219+ virtual bool postVisit(MetavoxelInfo& info);
220+
221+private:
222+
223+ QVector<BufferPointVectorPair> _depthPoints;
219224 };
220225
221226 BufferBuilder::BufferBuilder(const MetavoxelLOD& lod) :
222227 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) {
224230 }
225231
232+const int ALPHA_RENDER_THRESHOLD = 0;
233+
226234 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)) } };
227247 if (info.isLeaf) {
228−
248+ _depthPoints[_depth].first.append(point);
229249 return STOP_RECURSION;
230250 }
251+ _depthPoints[_depth].second.append(point);
231252 return DEFAULT_ORDER;
232253 }
233254
255+const int BUFFER_LEAF_THRESHOLD = 1024;
256+
257+bool BufferBuilder::postVisit(MetavoxelInfo& info) {
258+ return false;
259+}
260+
234261 void MetavoxelSystemClient::dataChanged(const MetavoxelData& oldData) {
235262 BufferBuilder builder(_remoteDataLOD);
236263 _data.guideToDifferent(oldData, builder);