Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 1 file). Show all
Unified · Split
| @@ -40,13 +40,13 @@ REGISTER_META_OBJECT(StaticModelRenderer) · 39 unmodified lines | ||
| 40 | 40 | REGISTER_META_OBJECT(HeightfieldRenderer) |
| 41 | 41 | |
| 42 | 42 | MetavoxelSystem::NetworkSimulation::NetworkSimulation(float dropRate, float repeatRate, |
| 43 | − int minimumDelay, int maximumDelay, int bandwidthLimit) : | |
| 44 | −dropRate(dropRate), | |
| 45 | −repeatRate(repeatRate), | |
| 46 | −minimumDelay(minimumDelay), | |
| 47 | −maximumDelay(maximumDelay), | |
| 48 | −bandwidthLimit(bandwidthLimit) { | |
| 49 | −} | |
| 43 | + int minimumDelay, int maximumDelay, int bandwidthLimit) : | |
| 44 | + dropRate(dropRate), | |
| 45 | + repeatRate(repeatRate), | |
| 46 | + minimumDelay(minimumDelay), | |
| 47 | + maximumDelay(maximumDelay), | |
| 48 | + bandwidthLimit(bandwidthLimit) { | |
| 49 | +} | |
| 50 | 50 | |
| 51 | 51 | MetavoxelSystem::~MetavoxelSystem() { |
| 52 | 52 | // kill the updater before we delete our network simulation objects |
| @@ -59,14 +59,14 @@ void MetavoxelSystem::init() { · 6 unmodified lines | ||
| 59 | 59 | MetavoxelClientManager::init(); |
| 60 | 60 | |
| 61 | 61 | _voxelBufferAttribute = AttributeRegistry::getInstance()->registerAttribute( |
| 62 | − new BufferDataAttribute("voxelBuffer")); | |
| 62 | + new BufferDataAttribute("voxelBuffer")); | |
| 63 | 63 | _voxelBufferAttribute->setLODThresholdMultiplier( |
| 64 | − AttributeRegistry::getInstance()->getVoxelColorAttribute()->getLODThresholdMultiplier()); | |
| 65 | − | |
| 64 | + AttributeRegistry::getInstance()->getVoxelColorAttribute()->getLODThresholdMultiplier()); | |
| 65 | + | |
| 66 | 66 | _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + |
| 67 | − "shaders/metavoxel_heightfield_base.vert"); | |
| 67 | + "shaders/metavoxel_heightfield_base.vert"); | |
| 68 | 68 | _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + |
| 69 | − "shaders/metavoxel_heightfield_base.frag"); | |
| 69 | + "shaders/metavoxel_heightfield_base.frag"); | |
| 70 | 70 | _baseHeightfieldProgram.link(); |
| 71 | 71 | |
| 72 | 72 | _baseHeightfieldProgram.bind(); |
| @@ -79,9 +79,9 @@ void MetavoxelSystem::init() { · 6 unmodified lines | ||
| 79 | 79 | loadSplatProgram("heightfield", _splatHeightfieldProgram, _splatHeightfieldLocations); |
| 80 | 80 | |
| 81 | 81 | _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + |
| 82 | − "shaders/metavoxel_heightfield_cursor.vert"); | |
| 82 | + "shaders/metavoxel_heightfield_cursor.vert"); | |
| 83 | 83 | _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + |
| 84 | − "shaders/metavoxel_cursor.frag"); | |
| 84 | + "shaders/metavoxel_cursor.frag"); | |
| 85 | 85 | _heightfieldCursorProgram.link(); |
| 86 | 86 | |
| 87 | 87 | _heightfieldCursorProgram.bind(); |
| @@ -89,17 +89,17 @@ void MetavoxelSystem::init() { · 1 unmodified line | ||
| 89 | 89 | _heightfieldCursorProgram.release(); |
| 90 | 90 | |
| 91 | 91 | _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + |
| 92 | − "shaders/metavoxel_voxel_base.vert"); | |
| 92 | + "shaders/metavoxel_voxel_base.vert"); | |
| 93 | 93 | _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + |
| 94 | − "shaders/metavoxel_voxel_base.frag"); | |
| 94 | + "shaders/metavoxel_voxel_base.frag"); | |
| 95 | 95 | _baseVoxelProgram.link(); |
| 96 | 96 | |
| 97 | 97 | loadSplatProgram("voxel", _splatVoxelProgram, _splatVoxelLocations); |
| 98 | 98 | |
| 99 | 99 | _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + |
| 100 | − "shaders/metavoxel_voxel_cursor.vert"); | |
| 100 | + "shaders/metavoxel_voxel_cursor.vert"); | |
| 101 | 101 | _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + |
| 102 | − "shaders/metavoxel_cursor.frag"); | |
| 102 | + "shaders/metavoxel_cursor.frag"); | |
| 103 | 103 | _voxelCursorProgram.link(); |
| 104 | 104 | } |
| 105 | 105 | |
| @@ -124,16 +124,16 @@ public: · 18 unmodified lines | ||
| 124 | 124 | SimulateVisitor(float deltaTime, const MetavoxelLOD& lod); |
| 125 | 125 | |
| 126 | 126 | virtual int visit(MetavoxelInfo& info); |
| 127 | − | |
| 127 | + | |
| 128 | 128 | private: |
| 129 | 129 | |
| 130 | 130 | float _deltaTime; |
| 131 | 131 | }; |
| 132 | 132 | |
| 133 | 133 | SimulateVisitor::SimulateVisitor(float deltaTime, const MetavoxelLOD& lod) : |
| 134 | −MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getRendererAttribute(), | |
| 135 | − QVector<AttributePointer>(), lod), | |
| 136 | −_deltaTime(deltaTime) { | |
| 134 | + MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getRendererAttribute(), | |
| 135 | + QVector<AttributePointer>(), lod), | |
| 136 | + _deltaTime(deltaTime) { | |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | int SimulateVisitor::visit(MetavoxelInfo& info) { |
| @@ -141,7 +141,7 @@ int SimulateVisitor::visit(MetavoxelInfo& info) { · 1 unmodified line | ||
| 141 | 141 | return DEFAULT_ORDER; |
| 142 | 142 | } |
| 143 | 143 | static_cast<MetavoxelRenderer*>(info.inputValues.at(0).getInlineValue< |
| 144 | − SharedObjectPointer>().data())->getImplementation()->simulate(*_data, _deltaTime, info, _lod); | |
| 144 | + SharedObjectPointer>().data())->getImplementation()->simulate(*_data, _deltaTime, info, _lod); | |
| 145 | 145 | return STOP_RECURSION; |
| 146 | 146 | } |
| 147 | 147 | |
| @@ -152,7 +152,7 @@ void MetavoxelSystem::simulate(float deltaTime) { · 4 unmodified lines | ||
| 152 | 152 | const float DEFAULT_LOD_THRESHOLD = 0.01f; |
| 153 | 153 | _lod = MetavoxelLOD(Application::getInstance()->getCamera()->getPosition(), DEFAULT_LOD_THRESHOLD); |
| 154 | 154 | } |
| 155 | − | |
| 155 | + | |
| 156 | 156 | SimulateVisitor simulateVisitor(deltaTime, getLOD()); |
| 157 | 157 | guideToAugmented(simulateVisitor); |
| 158 | 158 | } |
| @@ -166,8 +166,8 @@ public: · 7 unmodified lines | ||
| 166 | 166 | }; |
| 167 | 167 | |
| 168 | 168 | RenderVisitor::RenderVisitor(const MetavoxelLOD& lod) : |
| 169 | −MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getRendererAttribute(), | |
| 170 | − QVector<AttributePointer>(), lod) { | |
| 169 | + MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getRendererAttribute(), | |
| 170 | + QVector<AttributePointer>(), lod) { | |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | int RenderVisitor::visit(MetavoxelInfo& info) { |
| @@ -175,7 +175,7 @@ int RenderVisitor::visit(MetavoxelInfo& info) { · 1 unmodified line | ||
| 175 | 175 | return DEFAULT_ORDER; |
| 176 | 176 | } |
| 177 | 177 | static_cast<MetavoxelRenderer*>(info.inputValues.at(0).getInlineValue< |
| 178 | − SharedObjectPointer>().data())->getImplementation()->render(*_data, info, _lod); | |
| 178 | + SharedObjectPointer>().data())->getImplementation()->render(*_data, info, _lod); | |
| 179 | 179 | return STOP_RECURSION; |
| 180 | 180 | } |
| 181 | 181 | |
| @@ -195,18 +195,18 @@ void MetavoxelSystem::render() { · 13 unmodified lines | ||
| 195 | 195 | // update the frustum |
| 196 | 196 | ViewFrustum* viewFrustum = Application::getInstance()->getDisplayViewFrustum(); |
| 197 | 197 | _frustum.set(viewFrustum->getFarTopLeft(), viewFrustum->getFarTopRight(), viewFrustum->getFarBottomLeft(), |
| 198 | − viewFrustum->getFarBottomRight(), viewFrustum->getNearTopLeft(), viewFrustum->getNearTopRight(), | |
| 199 | − viewFrustum->getNearBottomLeft(), viewFrustum->getNearBottomRight()); | |
| 200 | − | |
| 198 | + viewFrustum->getFarBottomRight(), viewFrustum->getNearTopLeft(), viewFrustum->getNearTopRight(), | |
| 199 | + viewFrustum->getNearBottomLeft(), viewFrustum->getNearBottomRight()); | |
| 200 | + | |
| 201 | 201 | RenderVisitor renderVisitor(getLOD()); |
| 202 | 202 | guideToAugmented(renderVisitor, true); |
| 203 | 203 | |
| 204 | 204 | if (!_heightfieldBaseBatches.isEmpty()) { |
| 205 | 205 | glEnableClientState(GL_VERTEX_ARRAY); |
| 206 | 206 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
| 207 | − | |
| 207 | + | |
| 208 | 208 | Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true); |
| 209 | − | |
| 209 | + | |
| 210 | 210 | glDisable(GL_BLEND); |
| 211 | 211 | glEnable(GL_CULL_FACE); |
| 212 | 212 | glEnable(GL_ALPHA_TEST); |
| @@ -225,7 +225,7 @@ void MetavoxelSystem::render() { · 12 unmodified lines | ||
| 225 | 225 | |
| 226 | 226 | batch.vertexBuffer->bind(); |
| 227 | 227 | batch.indexBuffer->bind(); |
| 228 | − | |
| 228 | + | |
| 229 | 229 | HeightfieldPoint* point = 0; |
| 230 | 230 | glVertexPointer(3, GL_FLOAT, sizeof(HeightfieldPoint), &point->vertex); |
| 231 | 231 | glTexCoordPointer(2, GL_FLOAT, sizeof(HeightfieldPoint), &point->textureCoord); |
| @@ -234,7 +234,7 @@ void MetavoxelSystem::render() { · 2 unmodified lines | ||
| 234 | 234 | |
| 235 | 235 | _baseHeightfieldProgram.setUniform(_baseHeightScaleLocation, batch.heightScale); |
| 236 | 236 | _baseHeightfieldProgram.setUniform(_baseColorScaleLocation, batch.colorScale); |
| 237 | − | |
| 237 | + | |
| 238 | 238 | glActiveTexture(GL_TEXTURE1); |
| 239 | 239 | glBindTexture(GL_TEXTURE_2D, batch.colorTextureID); |
| 240 | 240 | |
| @@ -244,10 +244,10 @@ void MetavoxelSystem::render() { · 3 unmodified lines | ||
| 244 | 244 | |
| 245 | 245 | glActiveTexture(GL_TEXTURE0); |
| 246 | 246 | glBindTexture(GL_TEXTURE_2D, 0); |
| 247 | − | |
| 247 | + | |
| 248 | 248 | batch.vertexBuffer->release(); |
| 249 | 249 | batch.indexBuffer->release(); |
| 250 | − | |
| 250 | + | |
| 251 | 251 | glPopMatrix(); |
| 252 | 252 | } |
| 253 | 253 | |
| @@ -275,7 +275,7 @@ void MetavoxelSystem::render() { · 21 unmodified lines | ||
| 275 | 275 | |
| 276 | 276 | batch.vertexBuffer->bind(); |
| 277 | 277 | batch.indexBuffer->bind(); |
| 278 | − | |
| 278 | + | |
| 279 | 279 | HeightfieldPoint* point = 0; |
| 280 | 280 | glVertexPointer(3, GL_FLOAT, sizeof(HeightfieldPoint), &point->vertex); |
| 281 | 281 | glTexCoordPointer(2, GL_FLOAT, sizeof(HeightfieldPoint), &point->textureCoord); |
| @@ -283,7 +283,7 @@ void MetavoxelSystem::render() { · 1 unmodified line | ||
| 283 | 283 | glBindTexture(GL_TEXTURE_2D, batch.heightTextureID); |
| 284 | 284 | |
| 285 | 285 | _splatHeightfieldProgram.setUniformValue(_splatHeightfieldLocations.heightScale, |
| 286 | − batch.heightScale.x, batch.heightScale.y); | |
| 286 | + batch.heightScale.x, batch.heightScale.y); | |
| 287 | 287 | _splatHeightfieldProgram.setUniform(_splatHeightfieldLocations.textureScale, batch.textureScale); |
| 288 | 288 | _splatHeightfieldProgram.setUniform(_splatHeightfieldLocations.splatTextureOffset, batch.splatTextureOffset); |
| 289 | 289 | |
| @@ -291,18 +291,18 @@ void MetavoxelSystem::render() { · 1 unmodified line | ||
| 291 | 291 | _splatHeightfieldProgram.setUniform(_splatHeightfieldLocations.splatTextureScalesS, batch.splatTextureScalesS); |
| 292 | 292 | _splatHeightfieldProgram.setUniform(_splatHeightfieldLocations.splatTextureScalesT, batch.splatTextureScalesT); |
| 293 | 293 | _splatHeightfieldProgram.setUniformValue( |
| 294 | − _splatHeightfieldLocations.textureValueMinima, | |
| 295 | − (batch.materialIndex + 1) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 296 | − (batch.materialIndex + 2) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 297 | − (batch.materialIndex + 3) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 298 | − (batch.materialIndex + 4) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP); | |
| 294 | + _splatHeightfieldLocations.textureValueMinima, | |
| 295 | + (batch.materialIndex + 1) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 296 | + (batch.materialIndex + 2) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 297 | + (batch.materialIndex + 3) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 298 | + (batch.materialIndex + 4) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP); | |
| 299 | 299 | _splatHeightfieldProgram.setUniformValue( |
| 300 | − _splatHeightfieldLocations.textureValueMaxima, | |
| 301 | − (batch.materialIndex + 1) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 302 | − (batch.materialIndex + 2) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 303 | − (batch.materialIndex + 3) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 304 | − (batch.materialIndex + 4) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP); | |
| 305 | − | |
| 300 | + _splatHeightfieldLocations.textureValueMaxima, | |
| 301 | + (batch.materialIndex + 1) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 302 | + (batch.materialIndex + 2) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 303 | + (batch.materialIndex + 3) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 304 | + (batch.materialIndex + 4) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP); | |
| 305 | + | |
| 306 | 306 | glActiveTexture(GL_TEXTURE1); |
| 307 | 307 | glBindTexture(GL_TEXTURE_2D, batch.materialTextureID); |
| 308 | 308 | |
| @@ -312,22 +312,22 @@ void MetavoxelSystem::render() { · 3 unmodified lines | ||
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | glDrawRangeElements(GL_TRIANGLES, 0, batch.vertexCount - 1, batch.indexCount, GL_UNSIGNED_INT, 0); |
| 315 | − | |
| 315 | + | |
| 316 | 316 | for (int i = 0; i < SPLAT_COUNT; i++) { |
| 317 | 317 | glActiveTexture(GL_TEXTURE0 + SPLAT_TEXTURE_UNITS[i]); |
| 318 | 318 | glBindTexture(GL_TEXTURE_2D, 0); |
| 319 | 319 | } |
| 320 | − | |
| 320 | + | |
| 321 | 321 | glActiveTexture(GL_TEXTURE1); |
| 322 | 322 | glBindTexture(GL_TEXTURE_2D, 0); |
| 323 | − | |
| 323 | + | |
| 324 | 324 | glActiveTexture(GL_TEXTURE0); |
| 325 | 325 | glBindTexture(GL_TEXTURE_2D, 0); |
| 326 | − | |
| 326 | + | |
| 327 | 327 | batch.vertexBuffer->release(); |
| 328 | 328 | batch.indexBuffer->release(); |
| 329 | 329 | |
| 330 | − glPopMatrix(); | |
| 330 | + glPopMatrix(); | |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | _splatHeightfieldProgram.release(); |
| @@ -341,15 +341,15 @@ void MetavoxelSystem::render() { · 7 unmodified lines | ||
| 341 | 341 | |
| 342 | 342 | glDisable(GL_CULL_FACE); |
| 343 | 343 | |
| 344 | − glDisableClientState(GL_TEXTURE_COORD_ARRAY); | |
| 345 | − glDisableClientState(GL_VERTEX_ARRAY); | |
| 344 | + glDisableClientState(GL_TEXTURE_COORD_ARRAY); | |
| 345 | + glDisableClientState(GL_VERTEX_ARRAY); | |
| 346 | 346 | |
| 347 | 347 | _heightfieldBaseBatches.clear(); |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | if (!_voxelBaseBatches.isEmpty()) { |
| 351 | 351 | Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true); |
| 352 | − | |
| 352 | + | |
| 353 | 353 | glEnableClientState(GL_VERTEX_ARRAY); |
| 354 | 354 | glDisable(GL_BLEND); |
| 355 | 355 | glEnable(GL_CULL_FACE); |
| @@ -360,7 +360,7 @@ void MetavoxelSystem::render() { · 4 unmodified lines | ||
| 360 | 360 | |
| 361 | 361 | glEnableClientState(GL_COLOR_ARRAY); |
| 362 | 362 | glEnableClientState(GL_NORMAL_ARRAY); |
| 363 | − | |
| 363 | + | |
| 364 | 364 | _baseVoxelProgram.bind(); |
| 365 | 365 | |
| 366 | 366 | foreach (const VoxelBatch& batch, _voxelBaseBatches) { |
| @@ -379,10 +379,10 @@ void MetavoxelSystem::render() { · 12 unmodified lines | ||
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | _baseVoxelProgram.release(); |
| 382 | − | |
| 382 | + | |
| 383 | 383 | glDisable(GL_ALPHA_TEST); |
| 384 | 384 | glEnable(GL_BLEND); |
| 385 | − | |
| 385 | + | |
| 386 | 386 | Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false); |
| 387 | 387 | |
| 388 | 388 | if (!_voxelSplatBatches.isEmpty()) { |
| @@ -406,25 +406,25 @@ void MetavoxelSystem::render() { · 17 unmodified lines | ||
| 406 | 406 | glNormalPointer(GL_BYTE, sizeof(VoxelPoint), &point->normal); |
| 407 | 407 | |
| 408 | 408 | _splatVoxelProgram.setAttributeBuffer(_splatVoxelLocations.materials, |
| 409 | − GL_UNSIGNED_BYTE, (qint64)&point->materials, SPLAT_COUNT, sizeof(VoxelPoint)); | |
| 409 | + GL_UNSIGNED_BYTE, (qint64)&point->materials, SPLAT_COUNT, sizeof(VoxelPoint)); | |
| 410 | 410 | _splatVoxelProgram.setAttributeBuffer(_splatVoxelLocations.materialWeights, |
| 411 | − GL_UNSIGNED_BYTE, (qint64)&point->materialWeights, SPLAT_COUNT, sizeof(VoxelPoint)); | |
| 411 | + GL_UNSIGNED_BYTE, (qint64)&point->materialWeights, SPLAT_COUNT, sizeof(VoxelPoint)); | |
| 412 | 412 | |
| 413 | 413 | const float QUARTER_STEP = 0.25f * EIGHT_BIT_MAXIMUM_RECIPROCAL; |
| 414 | 414 | _splatVoxelProgram.setUniform(_splatVoxelLocations.splatTextureScalesS, batch.splatTextureScalesS); |
| 415 | 415 | _splatVoxelProgram.setUniform(_splatVoxelLocations.splatTextureScalesT, batch.splatTextureScalesT); |
| 416 | 416 | _splatVoxelProgram.setUniformValue( |
| 417 | − _splatVoxelLocations.textureValueMinima, | |
| 418 | − (batch.materialIndex + 1) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 419 | − (batch.materialIndex + 2) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 420 | − (batch.materialIndex + 3) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 421 | − (batch.materialIndex + 4) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP); | |
| 417 | + _splatVoxelLocations.textureValueMinima, | |
| 418 | + (batch.materialIndex + 1) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 419 | + (batch.materialIndex + 2) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 420 | + (batch.materialIndex + 3) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP, | |
| 421 | + (batch.materialIndex + 4) * EIGHT_BIT_MAXIMUM_RECIPROCAL - QUARTER_STEP); | |
| 422 | 422 | _splatVoxelProgram.setUniformValue( |
| 423 | − _splatVoxelLocations.textureValueMaxima, | |
| 424 | − (batch.materialIndex + 1) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 425 | − (batch.materialIndex + 2) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 426 | − (batch.materialIndex + 3) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 427 | − (batch.materialIndex + 4) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP); | |
| 423 | + _splatVoxelLocations.textureValueMaxima, | |
| 424 | + (batch.materialIndex + 1) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 425 | + (batch.materialIndex + 2) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 426 | + (batch.materialIndex + 3) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP, | |
| 427 | + (batch.materialIndex + 4) * EIGHT_BIT_MAXIMUM_RECIPROCAL + QUARTER_STEP); | |
| 428 | 428 | |
| 429 | 429 | for (int i = 0; i < SPLAT_COUNT; i++) { |
| 430 | 430 | glActiveTexture(GL_TEXTURE0 + SPLAT_TEXTURE_UNITS[i]); |
| @@ -437,9 +437,9 @@ void MetavoxelSystem::render() { · 6 unmodified lines | ||
| 437 | 437 | glActiveTexture(GL_TEXTURE0 + SPLAT_TEXTURE_UNITS[i]); |
| 438 | 438 | glBindTexture(GL_TEXTURE_2D, 0); |
| 439 | 439 | } |
| 440 | − | |
| 440 | + | |
| 441 | 441 | glActiveTexture(GL_TEXTURE0); |
| 442 | − | |
| 442 | + | |
| 443 | 443 | batch.vertexBuffer->release(); |
| 444 | 444 | batch.indexBuffer->release(); |
| 445 | 445 | } |
| @@ -517,10 +517,10 @@ public: · 71 unmodified lines | ||
| 517 | 517 | }; |
| 518 | 518 | |
| 519 | 519 | RayVoxelIntersectionVisitor::RayVoxelIntersectionVisitor(const glm::vec3& origin, |
| 520 | − const glm::vec3& direction, const MetavoxelLOD& lod) : | |
| 521 | −RayIntersectionVisitor(origin, direction, QVector<AttributePointer>() << | |
| 522 | − Application::getInstance()->getMetavoxels()->getVoxelBufferAttribute(), QVector<AttributePointer>(), lod), | |
| 523 | −intersectionDistance(FLT_MAX) { | |
| 520 | + const glm::vec3& direction, const MetavoxelLOD& lod) : | |
| 521 | + RayIntersectionVisitor(origin, direction, QVector<AttributePointer>() << | |
| 522 | + Application::getInstance()->getMetavoxels()->getVoxelBufferAttribute(), QVector<AttributePointer>(), lod), | |
| 523 | + intersectionDistance(FLT_MAX) { | |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | int RayVoxelIntersectionVisitor::visit(MetavoxelInfo& info, float distance) { |
| @@ -528,7 +528,7 @@ int RayVoxelIntersectionVisitor::visit(MetavoxelInfo& info, float distance) { · 1 unmodified line | ||
| 528 | 528 | return _order; |
| 529 | 529 | } |
| 530 | 530 | const VoxelBuffer* buffer = static_cast<VoxelBuffer*>( |
| 531 | − info.inputValues.at(0).getInlineValue<BufferDataPointer>().data()); | |
| 531 | + info.inputValues.at(0).getInlineValue<BufferDataPointer>().data()); | |
| 532 | 532 | if (!buffer) { |
| 533 | 533 | return STOP_RECURSION; |
| 534 | 534 | } |
| @@ -630,7 +630,7 @@ public: · 95 unmodified lines | ||
| 630 | 630 | virtual bool visit(Spanner* spanner); |
| 631 | 631 | |
| 632 | 632 | virtual int visit(MetavoxelInfo& info); |
| 633 | − | |
| 633 | + | |
| 634 | 634 | private: |
| 635 | 635 | |
| 636 | 636 | Box _bounds; |
| @@ -693,17 +693,17 @@ class BufferCursorRenderVisitor : public MetavoxelVisitor { · 56 unmodified lines | ||
| 693 | 693 | public: |
| 694 | 694 | |
| 695 | 695 | BufferCursorRenderVisitor(const AttributePointer& attribute, const Box& bounds); |
| 696 | − | |
| 696 | + | |
| 697 | 697 | virtual int visit(MetavoxelInfo& info); |
| 698 | − | |
| 698 | + | |
| 699 | 699 | private: |
| 700 | 700 | |
| 701 | 701 | Box _bounds; |
| 702 | 702 | }; |
| 703 | 703 | |
| 704 | 704 | BufferCursorRenderVisitor::BufferCursorRenderVisitor(const AttributePointer& attribute, const Box& bounds) : |
| 705 | −MetavoxelVisitor(QVector<AttributePointer>() << attribute), | |
| 706 | −_bounds(bounds) { | |
| 705 | + MetavoxelVisitor(QVector<AttributePointer>() << attribute), | |
| 706 | + _bounds(bounds) { | |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | int BufferCursorRenderVisitor::visit(MetavoxelInfo& info) { |
| @@ -766,11 +766,11 @@ void MetavoxelSystem::renderVoxelCursor(const glm::vec3& position, float radius) · 56 unmodified lines | ||
| 766 | 766 | |
| 767 | 767 | class MaterialEditApplier : public SignalHandler { |
| 768 | 768 | public: |
| 769 | − | |
| 769 | + | |
| 770 | 770 | MaterialEditApplier(const MetavoxelEditMessage& message, const QSharedPointer<NetworkTexture> texture); |
| 771 | 771 | |
| 772 | 772 | virtual void handle(); |
| 773 | − | |
| 773 | + | |
| 774 | 774 | protected: |
| 775 | 775 | |
| 776 | 776 | MetavoxelEditMessage _message; |
| @@ -778,8 +778,8 @@ protected: · 1 unmodified line | ||
| 778 | 778 | }; |
| 779 | 779 | |
| 780 | 780 | MaterialEditApplier::MaterialEditApplier(const MetavoxelEditMessage& message, const QSharedPointer<NetworkTexture> texture) : |
| 781 | −_message(message), | |
| 782 | −_texture(texture) { | |
| 781 | + _message(message), | |
| 782 | + _texture(texture) { | |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | void MaterialEditApplier::handle() { |
| @@ -794,16 +794,16 @@ void MetavoxelSystem::applyMaterialEdit(const MetavoxelEditMessage& message, boo · 8 unmodified lines | ||
| 794 | 794 | if (material && material->getDiffuse().isValid()) { |
| 795 | 795 | if (QThread::currentThread() != thread()) { |
| 796 | 796 | QMetaObject::invokeMethod(this, "applyMaterialEdit", Q_ARG(const MetavoxelEditMessage&, message), |
| 797 | − Q_ARG(bool, reliable)); | |
| 797 | + Q_ARG(bool, reliable)); | |
| 798 | 798 | return; |
| 799 | 799 | } |
| 800 | 800 | QSharedPointer<NetworkTexture> texture = Application::getInstance()->getTextureCache()->getTexture( |
| 801 | − material->getDiffuse(), SPLAT_TEXTURE); | |
| 801 | + material->getDiffuse(), SPLAT_TEXTURE); | |
| 802 | 802 | if (texture->isLoaded()) { |
| 803 | 803 | MetavoxelEditMessage newMessage = message; |
| 804 | 804 | static_cast<MaterialEdit*>(newMessage.edit.data())->averageColor = texture->getAverageColor(); |
| 805 | − applyEdit(newMessage, true); | |
| 806 | − | |
| 805 | + applyEdit(newMessage, true); | |
| 806 | + | |
| 807 | 807 | } else { |
| 808 | 808 | MaterialEditApplier* applier = new MaterialEditApplier(message, texture); |
| 809 | 809 | connect(texture.data(), &Resource::loaded, applier, &SignalHandler::handle); |
| @@ -818,7 +818,7 @@ MetavoxelClient* MetavoxelSystem::createClient(const SharedNodePointer& node) { · 8 unmodified lines | ||
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | void MetavoxelSystem::guideToAugmented(MetavoxelVisitor& visitor, bool render) { |
| 821 | − NodeList::getInstance()->eachNode([&visitor, &render](const SharedNodePointer& node) { | |
| 821 | + NodeList::getInstance()->eachNode([&visitor, &render](const SharedNodePointer& node){ | |
| 822 | 822 | if (node->getType() == NodeType::MetavoxelServer) { |
| 823 | 823 | QMutexLocker locker(&node->getMutex()); |
| 824 | 824 | MetavoxelSystemClient* client = static_cast<MetavoxelSystemClient*>(node->getLinkedData()); |
| @@ -837,9 +837,9 @@ void MetavoxelSystem::guideToAugmented(MetavoxelVisitor& visitor, bool render) { · 12 unmodified lines | ||
| 837 | 837 | |
| 838 | 838 | void MetavoxelSystem::loadSplatProgram(const char* type, ProgramObject& program, SplatLocations& locations) { |
| 839 | 839 | program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + |
| 840 | − "shaders/metavoxel_" + type + "_splat.vert"); | |
| 840 | + "shaders/metavoxel_" + type + "_splat.vert"); | |
| 841 | 841 | program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + |
| 842 | − "shaders/metavoxel_" + type + "_splat.frag"); | |
| 842 | + "shaders/metavoxel_" + type + "_splat.frag"); | |
| 843 | 843 | program.link(); |
| 844 | 844 | |
| 845 | 845 | program.bind(); |
| @@ -859,8 +859,8 @@ void MetavoxelSystem::loadSplatProgram(const char* type, ProgramObject& program, · 13 unmodified lines | ||
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | Throttle::Throttle() : |
| 862 | −_limit(INT_MAX), | |
| 863 | −_total(0) { | |
| 862 | + _limit(INT_MAX), | |
| 863 | + _total(0) { | |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | bool Throttle::shouldThrottle(int bytes) { |
| @@ -881,7 +881,7 @@ bool Throttle::shouldThrottle(int bytes) { · 14 unmodified lines | ||
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | MetavoxelSystemClient::MetavoxelSystemClient(const SharedNodePointer& node, MetavoxelUpdater* updater) : |
| 884 | −MetavoxelClient(node, updater) { | |
| 884 | + MetavoxelClient(node, updater) { | |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | void MetavoxelSystemClient::setAugmentedData(const MetavoxelData& data) { |
| @@ -898,11 +898,11 @@ class ReceiveDelayer : public QObject { · 10 unmodified lines | ||
| 898 | 898 | public: |
| 899 | 899 | |
| 900 | 900 | ReceiveDelayer(const SharedNodePointer& node, const QByteArray& packet); |
| 901 | − | |
| 901 | + | |
| 902 | 902 | protected: |
| 903 | − | |
| 903 | + | |
| 904 | 904 | virtual void timerEvent(QTimerEvent* event); |
| 905 | − | |
| 905 | + | |
| 906 | 906 | private: |
| 907 | 907 | |
| 908 | 908 | SharedNodePointer _node; |
| @@ -910,8 +910,8 @@ private: · 1 unmodified line | ||
| 910 | 910 | }; |
| 911 | 911 | |
| 912 | 912 | ReceiveDelayer::ReceiveDelayer(const SharedNodePointer& node, const QByteArray& packet) : |
| 913 | −_node(node), | |
| 914 | −_packet(packet) { | |
| 913 | + _node(node), | |
| 914 | + _packet(packet) { | |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | void ReceiveDelayer::timerEvent(QTimerEvent* event) { |
| @@ -956,16 +956,16 @@ public: · 38 unmodified lines | ||
| 956 | 956 | AugmentVisitor(const MetavoxelLOD& lod, const MetavoxelData& previousData); |
| 957 | 957 | |
| 958 | 958 | virtual int visit(MetavoxelInfo& info); |
| 959 | − | |
| 959 | + | |
| 960 | 960 | private: |
| 961 | 961 | |
| 962 | 962 | const MetavoxelData& _previousData; |
| 963 | 963 | }; |
| 964 | 964 | |
| 965 | 965 | AugmentVisitor::AugmentVisitor(const MetavoxelLOD& lod, const MetavoxelData& previousData) : |
| 966 | −MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getRendererAttribute(), | |
| 967 | − QVector<AttributePointer>(), lod), | |
| 968 | −_previousData(previousData) { | |
| 966 | + MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getRendererAttribute(), | |
| 967 | + QVector<AttributePointer>(), lod), | |
| 968 | + _previousData(previousData) { | |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | int AugmentVisitor::visit(MetavoxelInfo& info) { |
| @@ -973,7 +973,7 @@ int AugmentVisitor::visit(MetavoxelInfo& info) { · 1 unmodified line | ||
| 973 | 973 | return DEFAULT_ORDER; |
| 974 | 974 | } |
| 975 | 975 | static_cast<MetavoxelRenderer*>(info.inputValues.at(0).getInlineValue< |
| 976 | − SharedObjectPointer>().data())->getImplementation()->augment(*_data, _previousData, info, _lod); | |
| 976 | + SharedObjectPointer>().data())->getImplementation()->augment(*_data, _previousData, info, _lod); | |
| 977 | 977 | return STOP_RECURSION; |
| 978 | 978 | } |
| 979 | 979 | |
| @@ -981,10 +981,10 @@ class Augmenter : public QRunnable { · 1 unmodified line | ||
| 981 | 981 | public: |
| 982 | 982 | |
| 983 | 983 | Augmenter(const SharedNodePointer& node, const MetavoxelData& data, |
| 984 | − const MetavoxelData& previousData, const MetavoxelLOD& lod); | |
| 984 | + const MetavoxelData& previousData, const MetavoxelLOD& lod); | |
| 985 | 985 | |
| 986 | 986 | virtual void run(); |
| 987 | − | |
| 987 | + | |
| 988 | 988 | private: |
| 989 | 989 | |
| 990 | 990 | QWeakPointer<Node> _node; |
| @@ -994,11 +994,11 @@ private: · 3 unmodified lines | ||
| 994 | 994 | }; |
| 995 | 995 | |
| 996 | 996 | Augmenter::Augmenter(const SharedNodePointer& node, const MetavoxelData& data, |
| 997 | − const MetavoxelData& previousData, const MetavoxelLOD& lod) : | |
| 998 | −_node(node), | |
| 999 | −_data(data), | |
| 1000 | −_previousData(previousData), | |
| 1001 | −_lod(lod) { | |
| 997 | + const MetavoxelData& previousData, const MetavoxelLOD& lod) : | |
| 998 | + _node(node), | |
| 999 | + _data(data), | |
| 1000 | + _previousData(previousData), | |
| 1001 | + _lod(lod) { | |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | void Augmenter::run() { |
| @@ -1016,7 +1016,7 @@ void MetavoxelSystemClient::refreshVoxelData() { · 11 unmodified lines | ||
| 1016 | 1016 | // make it look as if all the colors have changed |
| 1017 | 1017 | MetavoxelData oldData = getAugmentedData(); |
| 1018 | 1018 | oldData.touch(AttributeRegistry::getInstance()->getVoxelColorAttribute()); |
| 1019 | − | |
| 1019 | + | |
| 1020 | 1020 | QThreadPool::globalInstance()->start(new Augmenter(_node, _data, oldData, _remoteDataLOD)); |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| @@ -1029,9 +1029,9 @@ class SendDelayer : public QObject { · 6 unmodified lines | ||
| 1029 | 1029 | public: |
| 1030 | 1030 | |
| 1031 | 1031 | SendDelayer(const SharedNodePointer& node, const QByteArray& data); |
| 1032 | − | |
| 1032 | + | |
| 1033 | 1033 | virtual void timerEvent(QTimerEvent* event); |
| 1034 | − | |
| 1034 | + | |
| 1035 | 1035 | private: |
| 1036 | 1036 | |
| 1037 | 1037 | SharedNodePointer _node; |
| @@ -1039,8 +1039,8 @@ private: · 1 unmodified line | ||
| 1039 | 1039 | }; |
| 1040 | 1040 | |
| 1041 | 1041 | SendDelayer::SendDelayer(const SharedNodePointer& node, const QByteArray& data) : |
| 1042 | −_node(node), | |
| 1043 | −_data(data.constData(), data.size()) { | |
| 1042 | + _node(node), | |
| 1043 | + _data(data.constData(), data.size()) { | |
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | void SendDelayer::timerEvent(QTimerEvent* event) { |
| @@ -1083,21 +1083,21 @@ void VoxelPoint::setNormal(const glm::vec3& normal) { · 36 unmodified lines | ||
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | 1085 | VoxelBuffer::VoxelBuffer(const QVector<VoxelPoint>& vertices, const QVector<int>& indices, const QVector<glm::vec3>& hermite, |
| 1086 | − const QMultiHash<VoxelCoord, int>& quadIndices, int size, const QVector<SharedObjectPointer>& materials) : | |
| 1087 | −_vertices(vertices), | |
| 1088 | −_indices(indices), | |
| 1089 | −_hermite(hermite), | |
| 1090 | −_quadIndices(quadIndices), | |
| 1091 | −_size(size), | |
| 1092 | −_vertexCount(vertices.size()), | |
| 1093 | −_indexCount(indices.size()), | |
| 1094 | −_hermiteCount(hermite.size()), | |
| 1095 | −_indexBuffer(QOpenGLBuffer::IndexBuffer), | |
| 1096 | −_materials(materials) { | |
| 1086 | + const QMultiHash<VoxelCoord, int>& quadIndices, int size, const QVector<SharedObjectPointer>& materials) : | |
| 1087 | + _vertices(vertices), | |
| 1088 | + _indices(indices), | |
| 1089 | + _hermite(hermite), | |
| 1090 | + _quadIndices(quadIndices), | |
| 1091 | + _size(size), | |
| 1092 | + _vertexCount(vertices.size()), | |
| 1093 | + _indexCount(indices.size()), | |
| 1094 | + _hermiteCount(hermite.size()), | |
| 1095 | + _indexBuffer(QOpenGLBuffer::IndexBuffer), | |
| 1096 | + _materials(materials) { | |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | 1099 | bool VoxelBuffer::findFirstRayIntersection(const glm::vec3& entry, const glm::vec3& origin, |
| 1100 | − const glm::vec3& direction, float& distance) const { | |
| 1100 | + const glm::vec3& direction, float& distance) const { | |
| 1101 | 1101 | float highest = _size - 1.0f; |
| 1102 | 1102 | glm::vec3 position = entry * highest; |
| 1103 | 1103 | glm::vec3 floors = glm::floor(position); |
| @@ -1105,14 +1105,14 @@ bool VoxelBuffer::findFirstRayIntersection(const glm::vec3& entry, const glm::ve · 1 unmodified line | ||
| 1105 | 1105 | int x = qMin((int)floors.x, max), y = qMin((int)floors.y, max), z = qMin((int)floors.z, max); |
| 1106 | 1106 | forever { |
| 1107 | 1107 | for (QMultiHash<VoxelCoord, int>::const_iterator it = _quadIndices.constFind(qRgb(x + 1, y + 1, z + 1)); |
| 1108 | − it != _quadIndices.constEnd(); it++) { | |
| 1108 | + it != _quadIndices.constEnd(); it++) { | |
| 1109 | 1109 | const int* indices = _indices.constData() + *it; |
| 1110 | 1110 | if (findRayTriangleIntersection(origin, direction, _vertices.at(indices[0]).vertex, |
| 1111 | − _vertices.at(indices[1]).vertex, _vertices.at(indices[2]).vertex, distance) || | |
| 1111 | + _vertices.at(indices[1]).vertex, _vertices.at(indices[2]).vertex, distance) || | |
| 1112 | 1112 | findRayTriangleIntersection(origin, direction, _vertices.at(indices[0]).vertex, |
| 1113 | − _vertices.at(indices[2]).vertex, _vertices.at(indices[3]).vertex, distance)) { | |
| 1114 | − return true; | |
| 1115 | − } | |
| 1113 | + _vertices.at(indices[2]).vertex, _vertices.at(indices[3]).vertex, distance)) { | |
| 1114 | + return true; | |
| 1115 | + } | |
| 1116 | 1116 | } |
| 1117 | 1117 | float xDistance = FLT_MAX, yDistance = FLT_MAX, zDistance = FLT_MAX; |
| 1118 | 1118 | if (direction.x > 0.0f) { |
| @@ -1181,7 +1181,7 @@ void VoxelBuffer::render(bool cursor) { · 62 unmodified lines | ||
| 1181 | 1181 | const SharedObjectPointer material = _materials.at(i); |
| 1182 | 1182 | if (material) { |
| 1183 | 1183 | _networkTextures[i] = Application::getInstance()->getTextureCache()->getTexture( |
| 1184 | − static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE); | |
| 1184 | + static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE); | |
| 1185 | 1185 | } |
| 1186 | 1186 | } |
| 1187 | 1187 | } |
| @@ -1216,7 +1216,7 @@ void VoxelBuffer::render(bool cursor) { · 28 unmodified lines | ||
| 1216 | 1216 | splatBatch.indexBuffer = &_indexBuffer; |
| 1217 | 1217 | splatBatch.vertexCount = _vertexCount; |
| 1218 | 1218 | splatBatch.indexCount = _indexCount; |
| 1219 | − | |
| 1219 | + | |
| 1220 | 1220 | for (int i = 0; i < _materials.size(); i += SPLAT_COUNT) { |
| 1221 | 1221 | for (int j = 0; j < SPLAT_COUNT; j++) { |
| 1222 | 1222 | int index = i + j; |
| @@ -1227,7 +1227,7 @@ void VoxelBuffer::render(bool cursor) { · 4 unmodified lines | ||
| 1227 | 1227 | splatBatch.splatTextureScalesS[j] = 1.0f / material->getScaleS(); |
| 1228 | 1228 | splatBatch.splatTextureScalesT[j] = 1.0f / material->getScaleT(); |
| 1229 | 1229 | splatBatch.splatTextureIDs[j] = texture->getID(); |
| 1230 | − | |
| 1230 | + | |
| 1231 | 1231 | } else { |
| 1232 | 1232 | splatBatch.splatTextureIDs[j] = 0; |
| 1233 | 1233 | } |
| @@ -1256,7 +1256,7 @@ void VoxelBuffer::render(bool cursor) { · 22 unmodified lines | ||
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | BufferDataAttribute::BufferDataAttribute(const QString& name) : |
| 1259 | −InlineAttribute<BufferDataPointer>(name) { | |
| 1259 | + InlineAttribute<BufferDataPointer>(name) { | |
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | bool BufferDataAttribute::merge(void*& parent, void* children[], bool postRead) const { |
| @@ -1278,17 +1278,17 @@ DefaultMetavoxelRendererImplementation::DefaultMetavoxelRendererImplementation() · 15 unmodified lines | ||
| 1278 | 1278 | |
| 1279 | 1279 | class VoxelAugmentVisitor : public MetavoxelVisitor { |
| 1280 | 1280 | public: |
| 1281 | − | |
| 1281 | + | |
| 1282 | 1282 | VoxelAugmentVisitor(const MetavoxelLOD& lod); |
| 1283 | 1283 | |
| 1284 | 1284 | virtual int visit(MetavoxelInfo& info); |
| 1285 | 1285 | }; |
| 1286 | 1286 | |
| 1287 | 1287 | VoxelAugmentVisitor::VoxelAugmentVisitor(const MetavoxelLOD& lod) : |
| 1288 | −MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getVoxelColorAttribute() << | |
| 1289 | − AttributeRegistry::getInstance()->getVoxelMaterialAttribute() << | |
| 1290 | − AttributeRegistry::getInstance()->getVoxelHermiteAttribute(), QVector<AttributePointer>() << | |
| 1291 | − Application::getInstance()->getMetavoxels()->getVoxelBufferAttribute(), lod) { | |
| 1288 | + MetavoxelVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getVoxelColorAttribute() << | |
| 1289 | + AttributeRegistry::getInstance()->getVoxelMaterialAttribute() << | |
| 1290 | + AttributeRegistry::getInstance()->getVoxelHermiteAttribute(), QVector<AttributePointer>() << | |
| 1291 | + Application::getInstance()->getMetavoxels()->getVoxelBufferAttribute(), lod) { | |
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | 1294 | class EdgeCrossing { |
| @@ -1446,9 +1446,9 @@ int VoxelAugmentVisitor::visit(MetavoxelInfo& info) { · 151 unmodified lines | ||
| 1446 | 1446 | // its properties (color, material, normal) if one is present; as before, boundary edges are excluded |
| 1447 | 1447 | int clampedX = qMax(x - 1, 0), clampedY = qMax(y - 1, 0), clampedZ = qMax(z - 1, 0); |
| 1448 | 1448 | const QRgb* hermiteBase = hermiteData + clampedZ * hermiteArea + clampedY * hermiteStride + |
| 1449 | − clampedX * VoxelHermiteData::EDGE_COUNT; | |
| 1449 | + clampedX * VoxelHermiteData::EDGE_COUNT; | |
| 1450 | 1450 | const char* materialBase = materialData ? |
| 1451 | − (materialData + clampedZ * area + clampedY * size + clampedX) : NULL; | |
| 1451 | + (materialData + clampedZ * area + clampedY * size + clampedX) : NULL; | |
| 1452 | 1452 | int crossingCount = 0; |
| 1453 | 1453 | if (middleX) { |
| 1454 | 1454 | if (alpha0 != alpha1) { |
| @@ -1650,7 +1650,7 @@ int VoxelAugmentVisitor::visit(MetavoxelInfo& info) { · 195 unmodified lines | ||
| 1650 | 1650 | |
| 1651 | 1651 | if (displayHermite) { |
| 1652 | 1652 | glm::vec3 start = info.minimum + (glm::vec3(clampedX, clampedY, clampedZ) + |
| 1653 | − crossing.point) * scale; | |
| 1653 | + crossing.point) * scale; | |
| 1654 | 1654 | hermiteSegments.append(start); |
| 1655 | 1655 | hermiteSegments.append(start + crossing.normal * scale); |
| 1656 | 1656 | } |
| @@ -1710,18 +1710,18 @@ int VoxelAugmentVisitor::visit(MetavoxelInfo& info) { · 53 unmodified lines | ||
| 1710 | 1710 | for (int i = 0; i < MAX_ITERATIONS; i++) { |
| 1711 | 1711 | glm::vec3 offDiagonals = glm::abs(glm::vec3(d[1][0], d[2][0], d[2][1])); |
| 1712 | 1712 | int largestIndex = (offDiagonals[0] > offDiagonals[1]) ? (offDiagonals[0] > offDiagonals[2] ? 0 : 2) : |
| 1713 | − (offDiagonals[1] > offDiagonals[2] ? 1 : 2); | |
| 1713 | + (offDiagonals[1] > offDiagonals[2] ? 1 : 2); | |
| 1714 | 1714 | const float DESIRED_PRECISION = 0.00001f; |
| 1715 | 1715 | if (offDiagonals[largestIndex] < DESIRED_PRECISION) { |
| 1716 | 1716 | break; |
| 1717 | 1717 | } |
| 1718 | 1718 | int largestJ = (largestIndex == 2) ? 1 : 0; |
| 1719 | − int largestI = (largestIndex == 0) ? 1 : 2; | |
| 1719 | + int largestI = (largestIndex == 0) ? 1 : 2; | |
| 1720 | 1720 | float sjj = d[largestJ][largestJ]; |
| 1721 | 1721 | float sii = d[largestI][largestI]; |
| 1722 | 1722 | float angle = glm::atan(2.0f * d[largestJ][largestI], sjj - sii) / 2.0f; |
| 1723 | 1723 | glm::quat rotation = glm::angleAxis(angle, largestIndex == 0 ? glm::vec3(0.0f, 0.0f, -1.0f) : |
| 1724 | − (largestIndex == 1 ? glm::vec3(0.0f, 1.0f, 0.0f) : glm::vec3(-1.0f, 0.0f, 0.0f))); | |
| 1724 | + (largestIndex == 1 ? glm::vec3(0.0f, 1.0f, 0.0f) : glm::vec3(-1.0f, 0.0f, 0.0f))); | |
| 1725 | 1725 | combinedRotation = glm::normalize(rotation * combinedRotation); |
| 1726 | 1726 | glm::mat3 matrix = glm::mat3_cast(combinedRotation); |
| 1727 | 1727 | d = matrix * ata * glm::transpose(matrix); |
| @@ -1735,7 +1735,7 @@ int VoxelAugmentVisitor::visit(MetavoxelInfo& info) { · 7 unmodified lines | ||
| 1735 | 1735 | |
| 1736 | 1736 | // compute the pseudo-inverse, ataplus, and use to find the minimizing solution |
| 1737 | 1737 | glm::mat3 u = glm::mat3_cast(combinedRotation); |
| 1738 | − glm::mat3 ataplus = glm::transpose(u) * d * u; | |
| 1738 | + glm::mat3 ataplus = glm::transpose(u) * d * u; | |
| 1739 | 1739 | glm::vec3 solution = (ataplus * atrans * b) + center; |
| 1740 | 1740 | |
| 1741 | 1741 | // make sure it doesn't fall beyond the cell boundaries |
| @@ -1774,7 +1774,7 @@ int VoxelAugmentVisitor::visit(MetavoxelInfo& info) { · 32 unmodified lines | ||
| 1774 | 1774 | |
| 1775 | 1775 | const glm::vec3& first = vertices.at(index.indices[0]).vertex; |
| 1776 | 1776 | glm::vec3 normal = glm::cross(vertices.at(index1.indices[0]).vertex - first, |
| 1777 | − vertices.at(index3.indices[0]).vertex - first); | |
| 1777 | + vertices.at(index3.indices[0]).vertex - first); | |
| 1778 | 1778 | |
| 1779 | 1779 | if (alpha0 == 0) { // quad faces negative x |
| 1780 | 1780 | indices.append(index3.getClosestIndex(normal = -normal, vertices)); |
| @@ -1800,7 +1800,7 @@ int VoxelAugmentVisitor::visit(MetavoxelInfo& info) { · 19 unmodified lines | ||
| 1800 | 1800 | |
| 1801 | 1801 | const glm::vec3& first = vertices.at(index.indices[0]).vertex; |
| 1802 | 1802 | glm::vec3 normal = glm::cross(vertices.at(index3.indices[0]).vertex - first, |
| 1803 | − vertices.at(index1.indices[0]).vertex - first); | |
| 1803 | + vertices.at(index1.indices[0]).vertex - first); | |
| 1804 | 1804 | |
| 1805 | 1805 | if (alpha0 == 0) { // quad faces negative y |
| 1806 | 1806 | indices.append(index1.getClosestIndex(normal = -normal, vertices)); |
| @@ -1826,7 +1826,7 @@ int VoxelAugmentVisitor::visit(MetavoxelInfo& info) { · 19 unmodified lines | ||
| 1826 | 1826 | |
| 1827 | 1827 | const glm::vec3& first = vertices.at(index.indices[0]).vertex; |
| 1828 | 1828 | glm::vec3 normal = glm::cross(vertices.at(index1.indices[0]).vertex - first, |
| 1829 | − vertices.at(index3.indices[0]).vertex - first); | |
| 1829 | + vertices.at(index3.indices[0]).vertex - first); | |
| 1830 | 1830 | |
| 1831 | 1831 | if (alpha0 == 0) { // quad faces negative z |
| 1832 | 1832 | indices.append(index3.getClosestIndex(normal = -normal, vertices)); |
| @@ -1861,7 +1861,7 @@ int VoxelAugmentVisitor::visit(MetavoxelInfo& info) { · 28 unmodified lines | ||
| 1861 | 1861 | } |
| 1862 | 1862 | } |
| 1863 | 1863 | buffer = new VoxelBuffer(vertices, indices, hermiteSegments, quadIndices, size, |
| 1864 | − material ? material->getMaterials() : QVector<SharedObjectPointer>()); | |
| 1864 | + material ? material->getMaterials() : QVector<SharedObjectPointer>()); | |
| 1865 | 1865 | } |
| 1866 | 1866 | BufferDataPointer pointer(buffer); |
| 1867 | 1867 | info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline(pointer)); |
| @@ -1869,14 +1869,14 @@ int VoxelAugmentVisitor::visit(MetavoxelInfo& info) { · 1 unmodified line | ||
| 1869 | 1869 | } |
| 1870 | 1870 | |
| 1871 | 1871 | void DefaultMetavoxelRendererImplementation::augment(MetavoxelData& data, const MetavoxelData& previous, |
| 1872 | − MetavoxelInfo& info, const MetavoxelLOD& lod) { | |
| 1872 | + MetavoxelInfo& info, const MetavoxelLOD& lod) { | |
| 1873 | 1873 | // copy the previous buffers |
| 1874 | 1874 | MetavoxelData expandedPrevious = previous; |
| 1875 | 1875 | while (expandedPrevious.getSize() < data.getSize()) { |
| 1876 | 1876 | expandedPrevious.expand(); |
| 1877 | 1877 | } |
| 1878 | 1878 | const AttributePointer& voxelBufferAttribute = |
| 1879 | − Application::getInstance()->getMetavoxels()->getVoxelBufferAttribute(); | |
| 1879 | + Application::getInstance()->getMetavoxels()->getVoxelBufferAttribute(); | |
| 1880 | 1880 | MetavoxelNode* root = expandedPrevious.getRoot(voxelBufferAttribute); |
| 1881 | 1881 | if (root) { |
| 1882 | 1882 | data.setRoot(voxelBufferAttribute, root); |
| @@ -1892,16 +1892,16 @@ public: · 9 unmodified lines | ||
| 1892 | 1892 | SpannerSimulateVisitor(float deltaTime, const MetavoxelLOD& lod); |
| 1893 | 1893 | |
| 1894 | 1894 | virtual bool visit(Spanner* spanner); |
| 1895 | − | |
| 1895 | + | |
| 1896 | 1896 | private: |
| 1897 | 1897 | |
| 1898 | 1898 | float _deltaTime; |
| 1899 | 1899 | }; |
| 1900 | 1900 | |
| 1901 | 1901 | SpannerSimulateVisitor::SpannerSimulateVisitor(float deltaTime, const MetavoxelLOD& lod) : |
| 1902 | −SpannerVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getSpannersAttribute(), | |
| 1903 | − QVector<AttributePointer>(), QVector<AttributePointer>(), lod), | |
| 1904 | −_deltaTime(deltaTime) { | |
| 1902 | + SpannerVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getSpannersAttribute(), | |
| 1903 | + QVector<AttributePointer>(), QVector<AttributePointer>(), lod), | |
| 1904 | + _deltaTime(deltaTime) { | |
| 1905 | 1905 | } |
| 1906 | 1906 | |
| 1907 | 1907 | bool SpannerSimulateVisitor::visit(Spanner* spanner) { |
| @@ -1910,7 +1910,7 @@ bool SpannerSimulateVisitor::visit(Spanner* spanner) { · 2 unmodified lines | ||
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | 1912 | void DefaultMetavoxelRendererImplementation::simulate(MetavoxelData& data, float deltaTime, |
| 1913 | − MetavoxelInfo& info, const MetavoxelLOD& lod) { | |
| 1913 | + MetavoxelInfo& info, const MetavoxelLOD& lod) { | |
| 1914 | 1914 | SpannerSimulateVisitor spannerSimulateVisitor(deltaTime, lod); |
| 1915 | 1915 | data.guide(spannerSimulateVisitor); |
| 1916 | 1916 | } |
| @@ -1921,7 +1921,7 @@ public: · 4 unmodified lines | ||
| 1921 | 1921 | BufferRenderVisitor(const AttributePointer& attribute); |
| 1922 | 1922 | |
| 1923 | 1923 | virtual int visit(MetavoxelInfo& info); |
| 1924 | − | |
| 1924 | + | |
| 1925 | 1925 | private: |
| 1926 | 1926 | |
| 1927 | 1927 | int _order; |
| @@ -1929,15 +1929,15 @@ private: · 1 unmodified line | ||
| 1929 | 1929 | }; |
| 1930 | 1930 | |
| 1931 | 1931 | BufferRenderVisitor::BufferRenderVisitor(const AttributePointer& attribute) : |
| 1932 | −MetavoxelVisitor(QVector<AttributePointer>() << attribute), | |
| 1933 | −_order(encodeOrder(Application::getInstance()->getDisplayViewFrustum()->getDirection())), | |
| 1934 | −_containmentDepth(INT_MAX) { | |
| 1932 | + MetavoxelVisitor(QVector<AttributePointer>() << attribute), | |
| 1933 | + _order(encodeOrder(Application::getInstance()->getDisplayViewFrustum()->getDirection())), | |
| 1934 | + _containmentDepth(INT_MAX) { | |
| 1935 | 1935 | } |
| 1936 | 1936 | |
| 1937 | 1937 | int BufferRenderVisitor::visit(MetavoxelInfo& info) { |
| 1938 | 1938 | if (_containmentDepth >= _depth) { |
| 1939 | 1939 | Frustum::IntersectionType intersection = Application::getInstance()->getMetavoxels()->getFrustum().getIntersectionType( |
| 1940 | − info.getBounds()); | |
| 1940 | + info.getBounds()); | |
| 1941 | 1941 | if (intersection == Frustum::NO_INTERSECTION) { |
| 1942 | 1942 | return STOP_RECURSION; |
| 1943 | 1943 | } |
| @@ -2007,12 +2007,12 @@ void CuboidRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor · 63 unmodified lines | ||
| 2007 | 2007 | } |
| 2008 | 2008 | |
| 2009 | 2009 | StaticModelRenderer::StaticModelRenderer() : |
| 2010 | −_model(new Model(this)) { | |
| 2010 | + _model(new Model(this)) { | |
| 2011 | 2011 | } |
| 2012 | 2012 | |
| 2013 | 2013 | void StaticModelRenderer::init(Spanner* spanner) { |
| 2014 | 2014 | SpannerRenderer::init(spanner); |
| 2015 | − | |
| 2015 | + | |
| 2016 | 2016 | _model->init(); |
| 2017 | 2017 | |
| 2018 | 2018 | StaticModel* staticModel = static_cast<StaticModel*>(spanner); |
| @@ -2035,7 +2035,7 @@ void StaticModelRenderer::simulate(float deltaTime) { · 16 unmodified lines | ||
| 2035 | 2035 | bounds = Box(extents.minimum, extents.maximum); |
| 2036 | 2036 | } |
| 2037 | 2037 | static_cast<StaticModel*>(_spanner)->setBounds(glm::translate(_model->getTranslation()) * |
| 2038 | − glm::mat4_cast(_model->getRotation()) * glm::scale(_model->getScale()) * bounds); | |
| 2038 | + glm::mat4_cast(_model->getRotation()) * glm::scale(_model->getScale()) * bounds); | |
| 2039 | 2039 | _model->simulate(deltaTime); |
| 2040 | 2040 | } |
| 2041 | 2041 | |
| @@ -2251,7 +2251,7 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g · 209 unmodified lines | ||
| 2251 | 2251 | if (cursor) { |
| 2252 | 2252 | bufferPair.first.bind(); |
| 2253 | 2253 | bufferPair.second.bind(); |
| 2254 | − | |
| 2254 | + | |
| 2255 | 2255 | glPushMatrix(); |
| 2256 | 2256 | glTranslatef(translation.x, translation.y, translation.z); |
| 2257 | 2257 | glm::vec3 axis = glm::axis(rotation); |
| @@ -2286,7 +2286,7 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g · 28 unmodified lines | ||
| 2286 | 2286 | baseBatch.heightScale = glm::vec4(1.0f / width, 1.0f / height, (innerWidth - 1) / -2.0f, (innerHeight - 1) / -2.0f); |
| 2287 | 2287 | baseBatch.colorTextureID = _colorTextureID; |
| 2288 | 2288 | baseBatch.colorScale = glm::vec2((float)width / innerWidth, (float)height / innerHeight); |
| 2289 | − Application::getInstance()->getMetavoxels()->addHeightfieldBaseBatch(baseBatch); | |
| 2289 | + Application::getInstance()->getMetavoxels()->addHeightfieldBaseBatch(baseBatch); | |
| 2290 | 2290 | |
| 2291 | 2291 | if (!_networkTextures.isEmpty()) { |
| 2292 | 2292 | HeightfieldSplatBatch splatBatch; |
| @@ -2331,3 +2331,4 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g · 38 unmodified lines | ||
| 2331 | 2331 | } |
| 2332 | 2332 | |
| 2333 | 2333 | QHash<HeightfieldNodeRenderer::IntPair, HeightfieldNodeRenderer::BufferPair> HeightfieldNodeRenderer::_bufferPairs; |
| 2334 | + | |