History

Render voxel cursor on heightfields, too.

Andrzej Kapolka committed 12 years ago

Commit fba383f1 parent 394bf2b5 files · +25 −41Browse files

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

Unified · Split

interface/src/MetavoxelSystem.cpp+18−5
@@ -533,8 +533,10 @@ void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float r · 532 unmodified lines
533533 float scale = 1.0f / radius;
534534 glm::vec4 sCoefficients(scale, 0.0f, 0.0f, -scale * position.x);
535535 glm::vec4 tCoefficients(0.0f, 0.0f, scale, -scale * position.z);
536+ glm::vec4 rCoefficients(0.0f, 0.0f, 0.0f, 0.0f);
536537 glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&sCoefficients);
537538 glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&tCoefficients);
539+ glTexGenfv(GL_R, GL_EYE_PLANE, (const GLfloat*)&rCoefficients);
538540 glActiveTexture(GL_TEXTURE0);
539541
540542 glm::vec3 extents(radius, radius, radius);
@@ -575,12 +577,23 @@ void MetavoxelSystem::renderVoxelCursor(const glm::vec3& position, float radius) · 34 unmodified lines
575577 glActiveTexture(GL_TEXTURE0);
576578
577579 glm::vec3 extents(radius, radius, radius);
578− CursorRenderVisitor visitor(Application::getInstance()->getMetavoxels()->getVoxelBufferAttribute(),
579− Box(position - extents, position + extents));
580− guideToAugmented(visitor);
580+ Box bounds(position - extents, position + extents);
581+ CursorRenderVisitor voxelVisitor(Application::getInstance()->getMetavoxels()->getVoxelBufferAttribute(), bounds);
582+ guideToAugmented(voxelVisitor);
581583
582584 DefaultMetavoxelRendererImplementation::getVoxelCursorProgram().release();
583585
586+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
587+
588+ DefaultMetavoxelRendererImplementation::getHeightfieldCursorProgram().bind();
589+
590+ CursorRenderVisitor heightfieldVisitor(Application::getInstance()->getMetavoxels()->getHeightfieldBufferAttribute(),
591+ bounds);
592+ guideToAugmented(heightfieldVisitor);
593+
594+ DefaultMetavoxelRendererImplementation::getHeightfieldCursorProgram().release();
595+
596+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
584597 glDisableClientState(GL_VERTEX_ARRAY);
585598
586599 glDisable(GL_POLYGON_OFFSET_FILL);
@@ -1450,7 +1463,7 @@ void DefaultMetavoxelRendererImplementation::init() { · 863 unmodified lines
14501463 _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
14511464 "shaders/metavoxel_heightfield_cursor.vert");
14521465 _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
1453− "shaders/metavoxel_heightfield_cursor.frag");
1466+ "shaders/metavoxel_cursor.frag");
14541467 _heightfieldCursorProgram.link();
14551468
14561469 _heightfieldCursorProgram.bind();
@@ -1468,7 +1481,7 @@ void DefaultMetavoxelRendererImplementation::init() { · 11 unmodified lines
14681481 _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
14691482 "shaders/metavoxel_voxel_cursor.vert");
14701483 _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() +
1471− "shaders/metavoxel_voxel_cursor.frag");
1484+ "shaders/metavoxel_cursor.frag");
14721485 _voxelCursorProgram.link();
14731486 }
14741487 }