Fix for toggling Hermite display.

This commit is contained in:
Andrzej Kapolka 2014-12-29 15:16:40 -08:00
parent c78d38b925
commit 10fdb01436
2 changed files with 8 additions and 3 deletions

View file

@ -579,7 +579,8 @@ bool MetavoxelSystem::findFirstRayVoxelIntersection(const glm::vec3& origin, con
}
void MetavoxelSystem::paintHeightfieldColor(const glm::vec3& position, float radius, const QColor& color) {
MetavoxelEditMessage edit = { QVariant::fromValue(PaintHeightfieldMaterialEdit(position, radius, SharedObjectPointer(), color)) };
MetavoxelEditMessage edit = { QVariant::fromValue(PaintHeightfieldMaterialEdit(position, radius,
SharedObjectPointer(), color)) };
applyEdit(edit, true);
}
@ -1106,6 +1107,7 @@ VoxelBuffer::VoxelBuffer(const QVector<VoxelPoint>& vertices, const QVector<int>
_vertices(vertices),
_indices(indices),
_hermite(hermite),
_hermiteEnabled(Menu::getInstance()->isOptionChecked(MenuOption::DisplayHermiteData)),
_quadIndices(quadIndices),
_size(size),
_vertexCount(vertices.size()),
@ -2292,7 +2294,8 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g
// restore the default alignment; it's what Qt uses for image storage
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
}
if (!_voxels && node->getStack()) {
bool displayHermite = Menu::getInstance()->isOptionChecked(MenuOption::DisplayHermiteData);
if ((!_voxels || (displayHermite && !static_cast<VoxelBuffer*>(_voxels.data())->isHermiteEnabled())) && node->getStack()) {
QVector<VoxelPoint> vertices;
QVector<int> indices;
QVector<glm::vec3> hermiteSegments;
@ -2306,7 +2309,6 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g
glm::vec3 pos;
glm::vec3 step(1.0f / innerStackWidth, scale.x / (innerStackWidth * scale.y),
1.0f / innerStackHeight);
bool displayHermite = Menu::getInstance()->isOptionChecked(MenuOption::DisplayHermiteData);
for (int z = 0; z < stackHeight; z++, pos.z += step.z) {
pos.x = 0.0f;

View file

@ -331,6 +331,8 @@ public:
const QMultiHash<VoxelCoord, int>& quadIndices, int size, const QVector<SharedObjectPointer>& materials =
QVector<SharedObjectPointer>());
bool isHermiteEnabled() const { return _hermiteEnabled; }
/// Finds the first intersection between the described ray and the voxel data.
/// \param entry the entry point of the ray in relative coordinates, from (0, 0, 0) to (1, 1, 1)
bool findFirstRayIntersection(const glm::vec3& entry, const glm::vec3& origin,
@ -344,6 +346,7 @@ private:
QVector<VoxelPoint> _vertices;
QVector<int> _indices;
QVector<glm::vec3> _hermite;
bool _hermiteEnabled;
QMultiHash<VoxelCoord, int> _quadIndices;
int _size;
int _vertexCount;