mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 07:25:43 +02:00
Removed redundant members, clarified class names, used better hash factors.
This commit is contained in:
parent
87cc565c1a
commit
296718e2aa
2 changed files with 16 additions and 25 deletions
|
@ -215,7 +215,7 @@ void MetavoxelSystem::render() {
|
||||||
|
|
||||||
_baseHeightfieldProgram.bind();
|
_baseHeightfieldProgram.bind();
|
||||||
|
|
||||||
foreach (const HeightfieldBaseBatch& batch, _heightfieldBaseBatches) {
|
foreach (const HeightfieldBaseLayerBatch& batch, _heightfieldBaseBatches) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(batch.translation.x, batch.translation.y, batch.translation.z);
|
glTranslatef(batch.translation.x, batch.translation.y, batch.translation.z);
|
||||||
glm::vec3 axis = glm::axis(batch.rotation);
|
glm::vec3 axis = glm::axis(batch.rotation);
|
||||||
|
@ -362,7 +362,7 @@ void MetavoxelSystem::render() {
|
||||||
|
|
||||||
_baseVoxelProgram.bind();
|
_baseVoxelProgram.bind();
|
||||||
|
|
||||||
foreach (const VoxelBaseBatch& batch, _voxelBaseBatches) {
|
foreach (const VoxelBatch& batch, _voxelBaseBatches) {
|
||||||
batch.vertexBuffer->bind();
|
batch.vertexBuffer->bind();
|
||||||
batch.indexBuffer->bind();
|
batch.indexBuffer->bind();
|
||||||
|
|
||||||
|
@ -1155,7 +1155,7 @@ void VoxelBuffer::render(bool cursor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelBaseBatch baseBatch;
|
VoxelBatch baseBatch;
|
||||||
baseBatch.vertexBuffer = &_vertexBuffer;
|
baseBatch.vertexBuffer = &_vertexBuffer;
|
||||||
baseBatch.indexBuffer = &_indexBuffer;
|
baseBatch.indexBuffer = &_indexBuffer;
|
||||||
baseBatch.vertexCount = _vertexCount;
|
baseBatch.vertexCount = _vertexCount;
|
||||||
|
@ -2209,7 +2209,7 @@ void HeightfieldRenderer::render(bool cursor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeightfieldBaseBatch baseBatch;
|
HeightfieldBaseLayerBatch baseBatch;
|
||||||
baseBatch.vertexBuffer = &bufferPair.first;
|
baseBatch.vertexBuffer = &bufferPair.first;
|
||||||
baseBatch.indexBuffer = &bufferPair.second;
|
baseBatch.indexBuffer = &bufferPair.second;
|
||||||
baseBatch.translation = heightfield->getTranslation();
|
baseBatch.translation = heightfield->getTranslation();
|
||||||
|
|
|
@ -23,10 +23,10 @@
|
||||||
|
|
||||||
#include "renderer/ProgramObject.h"
|
#include "renderer/ProgramObject.h"
|
||||||
|
|
||||||
class HeightfieldBaseBatch;
|
class HeightfieldBaseLayerBatch;
|
||||||
class HeightfieldSplatBatch;
|
class HeightfieldSplatBatch;
|
||||||
class Model;
|
class Model;
|
||||||
class VoxelBaseBatch;
|
class VoxelBatch;
|
||||||
class VoxelSplatBatch;
|
class VoxelSplatBatch;
|
||||||
|
|
||||||
/// Renders a metavoxel tree.
|
/// Renders a metavoxel tree.
|
||||||
|
@ -82,10 +82,10 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void setVoxelMaterial(const SharedObjectPointer& spanner, const SharedObjectPointer& material);
|
Q_INVOKABLE void setVoxelMaterial(const SharedObjectPointer& spanner, const SharedObjectPointer& material);
|
||||||
|
|
||||||
void addHeightfieldBaseBatch(const HeightfieldBaseBatch& batch) { _heightfieldBaseBatches.append(batch); }
|
void addHeightfieldBaseBatch(const HeightfieldBaseLayerBatch& batch) { _heightfieldBaseBatches.append(batch); }
|
||||||
void addHeightfieldSplatBatch(const HeightfieldSplatBatch& batch) { _heightfieldSplatBatches.append(batch); }
|
void addHeightfieldSplatBatch(const HeightfieldSplatBatch& batch) { _heightfieldSplatBatches.append(batch); }
|
||||||
|
|
||||||
void addVoxelBaseBatch(const VoxelBaseBatch& batch) { _voxelBaseBatches.append(batch); }
|
void addVoxelBaseBatch(const VoxelBatch& batch) { _voxelBaseBatches.append(batch); }
|
||||||
void addVoxelSplatBatch(const VoxelSplatBatch& batch) { _voxelSplatBatches.append(batch); }
|
void addVoxelSplatBatch(const VoxelSplatBatch& batch) { _voxelSplatBatches.append(batch); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -116,9 +116,9 @@ private:
|
||||||
NetworkSimulation _networkSimulation;
|
NetworkSimulation _networkSimulation;
|
||||||
QReadWriteLock _networkSimulationLock;
|
QReadWriteLock _networkSimulationLock;
|
||||||
|
|
||||||
QVector<HeightfieldBaseBatch> _heightfieldBaseBatches;
|
QVector<HeightfieldBaseLayerBatch> _heightfieldBaseBatches;
|
||||||
QVector<HeightfieldSplatBatch> _heightfieldSplatBatches;
|
QVector<HeightfieldSplatBatch> _heightfieldSplatBatches;
|
||||||
QVector<VoxelBaseBatch> _voxelBaseBatches;
|
QVector<VoxelBatch> _voxelBaseBatches;
|
||||||
QVector<VoxelSplatBatch> _voxelSplatBatches;
|
QVector<VoxelSplatBatch> _voxelSplatBatches;
|
||||||
|
|
||||||
ProgramObject _baseHeightfieldProgram;
|
ProgramObject _baseHeightfieldProgram;
|
||||||
|
@ -174,19 +174,10 @@ public:
|
||||||
glm::vec4 heightScale;
|
glm::vec4 heightScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A batch containing a heightfield base.
|
/// A batch containing a heightfield base layer.
|
||||||
class HeightfieldBaseBatch : public HeightfieldBatch {
|
class HeightfieldBaseLayerBatch : public HeightfieldBatch {
|
||||||
public:
|
public:
|
||||||
QOpenGLBuffer* vertexBuffer;
|
|
||||||
QOpenGLBuffer* indexBuffer;
|
|
||||||
glm::vec3 translation;
|
|
||||||
glm::quat rotation;
|
|
||||||
glm::vec3 scale;
|
|
||||||
int vertexCount;
|
|
||||||
int indexCount;
|
|
||||||
GLuint heightTextureID;
|
|
||||||
GLuint colorTextureID;
|
GLuint colorTextureID;
|
||||||
glm::vec4 heightScale;
|
|
||||||
glm::vec2 colorScale;
|
glm::vec2 colorScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -203,7 +194,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Base class for voxel batches.
|
/// Base class for voxel batches.
|
||||||
class VoxelBaseBatch {
|
class VoxelBatch {
|
||||||
public:
|
public:
|
||||||
QOpenGLBuffer* vertexBuffer;
|
QOpenGLBuffer* vertexBuffer;
|
||||||
QOpenGLBuffer* indexBuffer;
|
QOpenGLBuffer* indexBuffer;
|
||||||
|
@ -212,7 +203,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A batch containing a voxel splat.
|
/// A batch containing a voxel splat.
|
||||||
class VoxelSplatBatch : public VoxelBaseBatch {
|
class VoxelSplatBatch : public VoxelBatch {
|
||||||
public:
|
public:
|
||||||
int splatTextureIDs[4];
|
int splatTextureIDs[4];
|
||||||
glm::vec4 splatTextureScalesS;
|
glm::vec4 splatTextureScalesS;
|
||||||
|
@ -319,8 +310,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
inline uint qHash(const VoxelCoord& coord, uint seed) {
|
inline uint qHash(const VoxelCoord& coord, uint seed) {
|
||||||
// 31 is just an arbitrary prime number
|
// multiply by prime numbers greater than the possible size
|
||||||
return qHash(qRed(coord.encoded) + 31 * (qGreen(coord.encoded) + 31 * qBlue(coord.encoded)), seed);
|
return qHash(qRed(coord.encoded) + 257 * (qGreen(coord.encoded) + 263 * qBlue(coord.encoded)), seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Contains the information necessary to render a voxel block.
|
/// Contains the information necessary to render a voxel block.
|
||||||
|
|
Loading…
Reference in a new issue