Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 3 files). Show all
Unified · Split
| @@ -31,10 +31,6 @@ REGISTER_META_OBJECT(StaticModelRenderer) · 30 unmodified lines | |||
| 31 | 31 | ||
| 32 | static int bufferPointVectorMetaTypeId = qRegisterMetaType<BufferPointVector>(); | 32 | static int bufferPointVectorMetaTypeId = qRegisterMetaType<BufferPointVector>(); |
| 33 | 33 | ||
| 34 | MetavoxelSystem::MetavoxelSystem() : | ||
| 35 | _cursorTexture(QOpenGLTexture::Target2D) { | ||
| 36 | } | ||
| 37 | |||
| 38 | void MetavoxelSystem::init() { | 34 | void MetavoxelSystem::init() { |
| 39 | MetavoxelClientManager::init(); | 35 | MetavoxelClientManager::init(); |
| 40 | DefaultMetavoxelRendererImplementation::init(); | 36 | DefaultMetavoxelRendererImplementation::init(); |
| @@ -155,33 +151,6 @@ int HeightfieldCursorRenderVisitor::visit(MetavoxelInfo& info) { · 114 unmodified lines | |||
| 155 | } | 151 | } |
| 156 | 152 | ||
| 157 | void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float radius) { | 153 | void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float radius) { |
| 158 | // create the cursor texture lazily | ||
| 159 | if (!_cursorTexture.isCreated()) { | ||
| 160 | const int CURSOR_TEXTURE_SIZE = 512; | ||
| 161 | QImage cursorImage(CURSOR_TEXTURE_SIZE, CURSOR_TEXTURE_SIZE, QImage::Format_ARGB32_Premultiplied); | ||
| 162 | cursorImage.fill(0x0); | ||
| 163 | { | ||
| 164 | QPainter painter(&cursorImage); | ||
| 165 | const int ELLIPSE_EDGE = 10; | ||
| 166 | const int OUTER_WIDTH = 10; | ||
| 167 | QPen outerPen; | ||
| 168 | outerPen.setWidth(OUTER_WIDTH); | ||
| 169 | painter.setPen(outerPen); | ||
| 170 | const int HALF_TEXTURE_SIZE = CURSOR_TEXTURE_SIZE / 2; | ||
| 171 | painter.drawEllipse(QPoint(HALF_TEXTURE_SIZE, HALF_TEXTURE_SIZE), HALF_TEXTURE_SIZE - ELLIPSE_EDGE, | ||
| 172 | HALF_TEXTURE_SIZE - ELLIPSE_EDGE); | ||
| 173 | QPen innerPen(Qt::white); | ||
| 174 | const int INNER_WIDTH = 6; | ||
| 175 | innerPen.setWidth(INNER_WIDTH); | ||
| 176 | painter.setPen(innerPen); | ||
| 177 | painter.drawEllipse(QPoint(HALF_TEXTURE_SIZE, HALF_TEXTURE_SIZE), HALF_TEXTURE_SIZE - ELLIPSE_EDGE, | ||
| 178 | HALF_TEXTURE_SIZE - ELLIPSE_EDGE); | ||
| 179 | } | ||
| 180 | _cursorTexture.setData(cursorImage, QOpenGLTexture::DontGenerateMipMaps); | ||
| 181 | _cursorTexture.setWrapMode(QOpenGLTexture::ClampToEdge); | ||
| 182 | _cursorTexture.setMinificationFilter(QOpenGLTexture::Linear); | ||
| 183 | } | ||
| 184 | |||
| 185 | glDepthFunc(GL_LEQUAL); | 154 | glDepthFunc(GL_LEQUAL); |
| 186 | glEnable(GL_CULL_FACE); | 155 | glEnable(GL_CULL_FACE); |
| 187 | glEnable(GL_POLYGON_OFFSET_FILL); | 156 | glEnable(GL_POLYGON_OFFSET_FILL); |
| @@ -196,21 +165,16 @@ void MetavoxelSystem::renderHeightfieldCursor(const glm::vec3& position, float r · 8 unmodified lines | |||
| 196 | 165 | ||
| 197 | glActiveTexture(GL_TEXTURE4); | 166 | glActiveTexture(GL_TEXTURE4); |
| 198 | float scale = 1.0f / radius; | 167 | float scale = 1.0f / radius; |
| 199 | glm::vec4 sCoefficients(scale, 0.0f, 0.0f, 0.5f - scale * position.x); | 168 | glm::vec4 sCoefficients(scale, 0.0f, 0.0f, -scale * position.x); |
| 200 | glm::vec4 tCoefficients(0.0f, 0.0f, scale, 0.5f - scale * position.z); | 169 | glm::vec4 tCoefficients(0.0f, 0.0f, scale, -scale * position.z); |
| 201 | glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&sCoefficients); | 170 | glTexGenfv(GL_S, GL_EYE_PLANE, (const GLfloat*)&sCoefficients); |
| 202 | glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&tCoefficients); | 171 | glTexGenfv(GL_T, GL_EYE_PLANE, (const GLfloat*)&tCoefficients); |
| 203 | |||
| 204 | _cursorTexture.bind(1); | ||
| 205 | glActiveTexture(GL_TEXTURE0); | 172 | glActiveTexture(GL_TEXTURE0); |
| 206 | 173 | ||
| 207 | glm::vec3 extents(radius, radius, radius); | 174 | glm::vec3 extents(radius, radius, radius); |
| 208 | HeightfieldCursorRenderVisitor visitor(getLOD(), Box(position - extents, position + extents)); | 175 | HeightfieldCursorRenderVisitor visitor(getLOD(), Box(position - extents, position + extents)); |
| 209 | guideToAugmented(visitor); | 176 | guideToAugmented(visitor); |
| 210 | 177 | ||
| 211 | _cursorTexture.release(1); | ||
| 212 | glActiveTexture(GL_TEXTURE0); | ||
| 213 | |||
| 214 | DefaultMetavoxelRendererImplementation::getHeightfieldCursorProgram().release(); | 178 | DefaultMetavoxelRendererImplementation::getHeightfieldCursorProgram().release(); |
| 215 | 179 | ||
| 216 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 180 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |