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
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
221private:
222
223 QVector<BufferPointVectorPair> _depthPoints;
219};224};
220 225
221BufferBuilder::BufferBuilder(const MetavoxelLOD& lod) :226BufferBuilder::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
232const int ALPHA_RENDER_THRESHOLD = 0;
233
226int BufferBuilder::visit(MetavoxelInfo& info) {234int 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
255const int BUFFER_LEAF_THRESHOLD = 1024;
256
257bool BufferBuilder::postVisit(MetavoxelInfo& info) {
258 return false;
259}
260
234void MetavoxelSystemClient::dataChanged(const MetavoxelData& oldData) {261void MetavoxelSystemClient::dataChanged(const MetavoxelData& oldData) {
235 BufferBuilder builder(_remoteDataLOD);262 BufferBuilder builder(_remoteDataLOD);
236 _data.guideToDifferent(oldData, builder);263 _data.guideToDifferent(oldData, builder);