mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 18:26:11 +02:00
Working on optimized point rendering.
This commit is contained in:
parent
1d6f4295c3
commit
cda1a7f32a
2 changed files with 34 additions and 2 deletions
|
@ -216,21 +216,48 @@ public:
|
|||
BufferBuilder(const MetavoxelLOD& lod);
|
||||
|
||||
virtual int visit(MetavoxelInfo& info);
|
||||
virtual bool postVisit(MetavoxelInfo& info);
|
||||
|
||||
private:
|
||||
|
||||
QVector<BufferPointVectorPair> _depthPoints;
|
||||
};
|
||||
|
||||
BufferBuilder::BufferBuilder(const MetavoxelLOD& lod) :
|
||||
MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getColorAttribute() <<
|
||||
AttributeRegistry::getInstance()->getNormalAttribute(), QVector<AttributePointer>(), lod) {
|
||||
AttributeRegistry::getInstance()->getNormalAttribute(), QVector<AttributePointer>() <<
|
||||
Application::getInstance()->getMetavoxels()->getPointBufferAttribute(), lod) {
|
||||
}
|
||||
|
||||
const int ALPHA_RENDER_THRESHOLD = 0;
|
||||
|
||||
int BufferBuilder::visit(MetavoxelInfo& info) {
|
||||
if (_depth >= _depthPoints.size()) {
|
||||
_depthPoints.resize(_depth + 1);
|
||||
}
|
||||
QRgb color = info.inputValues.at(0).getInlineValue<QRgb>();
|
||||
quint8 alpha = qAlpha(color);
|
||||
if (alpha <= ALPHA_RENDER_THRESHOLD) {
|
||||
return info.isLeaf ? STOP_RECURSION : DEFAULT_ORDER;
|
||||
}
|
||||
QRgb normal = info.inputValues.at(1).getInlineValue<QRgb>();
|
||||
BufferPoint point = { glm::vec4(info.minimum + glm::vec3(info.size, info.size, info.size) * 0.5f, info.size),
|
||||
{ quint8(qRed(color)), quint8(qGreen(color)), quint8(qBlue(color)) },
|
||||
{ quint8(qRed(normal)), quint8(qGreen(normal)), quint8(qBlue(normal)) } };
|
||||
if (info.isLeaf) {
|
||||
|
||||
_depthPoints[_depth].first.append(point);
|
||||
return STOP_RECURSION;
|
||||
}
|
||||
_depthPoints[_depth].second.append(point);
|
||||
return DEFAULT_ORDER;
|
||||
}
|
||||
|
||||
const int BUFFER_LEAF_THRESHOLD = 1024;
|
||||
|
||||
bool BufferBuilder::postVisit(MetavoxelInfo& info) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void MetavoxelSystemClient::dataChanged(const MetavoxelData& oldData) {
|
||||
BufferBuilder builder(_remoteDataLOD);
|
||||
_data.guideToDifferent(oldData, builder);
|
||||
|
|
|
@ -32,6 +32,8 @@ public:
|
|||
|
||||
MetavoxelSystem();
|
||||
|
||||
const AttributePointer& getPointBufferAttribute() const { return _pointBufferAttribute; }
|
||||
|
||||
virtual void init();
|
||||
|
||||
virtual MetavoxelLOD getLOD() const;
|
||||
|
@ -107,6 +109,9 @@ public:
|
|||
quint8 normal[3];
|
||||
};
|
||||
|
||||
typedef QVector<BufferPoint> BufferPointVector;
|
||||
typedef QPair<BufferPointVector, BufferPointVector> BufferPointVectorPair;
|
||||
|
||||
/// Contains the information necessary to render a group of points at variable detail levels.
|
||||
class PointBuffer {
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue