Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 103 files). Show all
Unified · Split
| @@ -21,17 +21,18 @@ · 20 unmodified lines | ||
| 21 | 21 | |
| 22 | 22 | #include <glm/gtx/transform.hpp> |
| 23 | 23 | |
| 24 | +#include <DeferredLightingEffect.h> | |
| 24 | 25 | #include <GeometryUtil.h> |
| 26 | +#include <Model.h> | |
| 25 | 27 | #include <SharedUtil.h> |
| 26 | 28 | |
| 27 | 29 | #include <MetavoxelMessages.h> |
| 28 | 30 | #include <MetavoxelUtil.h> |
| 31 | +#include <PathUtils.h> | |
| 29 | 32 | #include <ScriptCache.h> |
| 30 | 33 | |
| 31 | 34 | #include "Application.h" |
| 32 | 35 | #include "MetavoxelSystem.h" |
| 33 | −#include "renderer/Model.h" | |
| 34 | −#include "renderer/RenderUtil.h" | |
| 35 | 36 | |
| 36 | 37 | REGISTER_META_OBJECT(DefaultMetavoxelRendererImplementation) |
| 37 | 38 | REGISTER_META_OBJECT(SphereRenderer) |
| @@ -63,9 +64,9 @@ void MetavoxelSystem::init() { · 25 unmodified lines | ||
| 63 | 64 | _voxelBufferAttribute->setLODThresholdMultiplier( |
| 64 | 65 | AttributeRegistry::getInstance()->getVoxelColorAttribute()->getLODThresholdMultiplier()); |
| 65 | 66 | |
| 66 | − _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + | |
| 67 | + _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + | |
| 67 | 68 | "shaders/metavoxel_heightfield_base.vert"); |
| 68 | − _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + | |
| 69 | + _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + | |
| 69 | 70 | "shaders/metavoxel_heightfield_base.frag"); |
| 70 | 71 | _baseHeightfieldProgram.link(); |
| 71 | 72 | |
| @@ -78,9 +79,9 @@ void MetavoxelSystem::init() { · 6 unmodified lines | ||
| 78 | 79 | |
| 79 | 80 | loadSplatProgram("heightfield", _splatHeightfieldProgram, _splatHeightfieldLocations); |
| 80 | 81 | |
| 81 | − _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + | |
| 82 | + _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + | |
| 82 | 83 | "shaders/metavoxel_heightfield_cursor.vert"); |
| 83 | − _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + | |
| 84 | + _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + | |
| 84 | 85 | "shaders/metavoxel_cursor.frag"); |
| 85 | 86 | _heightfieldCursorProgram.link(); |
| 86 | 87 | |
| @@ -88,17 +89,17 @@ void MetavoxelSystem::init() { · 1 unmodified line | ||
| 88 | 89 | _heightfieldCursorProgram.setUniformValue("heightMap", 0); |
| 89 | 90 | _heightfieldCursorProgram.release(); |
| 90 | 91 | |
| 91 | − _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + | |
| 92 | + _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + | |
| 92 | 93 | "shaders/metavoxel_voxel_base.vert"); |
| 93 | − _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + | |
| 94 | + _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + | |
| 94 | 95 | "shaders/metavoxel_voxel_base.frag"); |
| 95 | 96 | _baseVoxelProgram.link(); |
| 96 | 97 | |
| 97 | 98 | loadSplatProgram("voxel", _splatVoxelProgram, _splatVoxelLocations); |
| 98 | 99 | |
| 99 | − _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + | |
| 100 | + _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + | |
| 100 | 101 | "shaders/metavoxel_voxel_cursor.vert"); |
| 101 | − _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + | |
| 102 | + _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + | |
| 102 | 103 | "shaders/metavoxel_cursor.frag"); |
| 103 | 104 | _voxelCursorProgram.link(); |
| 104 | 105 | } |
| @@ -205,7 +206,7 @@ void MetavoxelSystem::render() { · 100 unmodified lines | ||
| 205 | 206 | glEnableClientState(GL_VERTEX_ARRAY); |
| 206 | 207 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
| 207 | 208 | |
| 208 | − Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true); | |
| 209 | + DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true); | |
| 209 | 210 | |
| 210 | 211 | glDisable(GL_BLEND); |
| 211 | 212 | glEnable(GL_CULL_FACE); |
| @@ -251,7 +252,7 @@ void MetavoxelSystem::render() { · 39 unmodified lines | ||
| 251 | 252 | glPopMatrix(); |
| 252 | 253 | } |
| 253 | 254 | |
| 254 | − Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false); | |
| 255 | + DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false); | |
| 255 | 256 | |
| 256 | 257 | _baseHeightfieldProgram.release(); |
| 257 | 258 | |
| @@ -348,7 +349,7 @@ void MetavoxelSystem::render() { · 90 unmodified lines | ||
| 348 | 349 | } |
| 349 | 350 | |
| 350 | 351 | if (!_voxelBaseBatches.isEmpty()) { |
| 351 | − Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true); | |
| 352 | + DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true); | |
| 352 | 353 | |
| 353 | 354 | glEnableClientState(GL_VERTEX_ARRAY); |
| 354 | 355 | glDisable(GL_BLEND); |
| @@ -383,7 +384,7 @@ void MetavoxelSystem::render() { · 28 unmodified lines | ||
| 383 | 384 | glDisable(GL_ALPHA_TEST); |
| 384 | 385 | glEnable(GL_BLEND); |
| 385 | 386 | |
| 386 | − Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false); | |
| 387 | + DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false); | |
| 387 | 388 | |
| 388 | 389 | if (!_voxelSplatBatches.isEmpty()) { |
| 389 | 390 | glDepthFunc(GL_LEQUAL); |
| @@ -463,14 +464,14 @@ void MetavoxelSystem::render() { · 73 unmodified lines | ||
| 463 | 464 | } |
| 464 | 465 | |
| 465 | 466 | if (!_hermiteBatches.isEmpty() && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHermiteData)) { |
| 466 | − Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, true); | |
| 467 | + DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, true); | |
| 467 | 468 | |
| 468 | 469 | glEnableClientState(GL_VERTEX_ARRAY); |
| 469 | 470 | |
| 470 | 471 | glColor4f(1.0f, 1.0f, 1.0f, 1.0f); |
| 471 | 472 | glNormal3f(0.0f, 1.0f, 0.0f); |
| 472 | 473 | |
| 473 | − Application::getInstance()->getDeferredLightingEffect()->bindSimpleProgram(); | |
| 474 | + DependencyManager::get<DeferredLightingEffect>()->bindSimpleProgram(); | |
| 474 | 475 | |
| 475 | 476 | foreach (const HermiteBatch& batch, _hermiteBatches) { |
| 476 | 477 | batch.vertexBuffer->bind(); |
| @@ -482,11 +483,11 @@ void MetavoxelSystem::render() { · 5 unmodified lines | ||
| 482 | 483 | batch.vertexBuffer->release(); |
| 483 | 484 | } |
| 484 | 485 | |
| 485 | − Application::getInstance()->getDeferredLightingEffect()->releaseSimpleProgram(); | |
| 486 | + DependencyManager::get<DeferredLightingEffect>()->releaseSimpleProgram(); | |
| 486 | 487 | |
| 487 | 488 | glDisableClientState(GL_VERTEX_ARRAY); |
| 488 | 489 | |
| 489 | − Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true, false); | |
| 490 | + DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true, false); | |
| 490 | 491 | } |
| 491 | 492 | _hermiteBatches.clear(); |
| 492 | 493 | |
| @@ -797,7 +798,7 @@ void MetavoxelSystem::applyMaterialEdit(const MetavoxelEditMessage& message, boo · 304 unmodified lines | ||
| 797 | 798 | Q_ARG(bool, reliable)); |
| 798 | 799 | return; |
| 799 | 800 | } |
| 800 | − QSharedPointer<NetworkTexture> texture = Application::getInstance()->getTextureCache()->getTexture( | |
| 801 | + QSharedPointer<NetworkTexture> texture = DependencyManager::get<TextureCache>()->getTexture( | |
| 801 | 802 | material->getDiffuse(), SPLAT_TEXTURE); |
| 802 | 803 | if (texture->isLoaded()) { |
| 803 | 804 | MetavoxelEditMessage newMessage = message; |
| @@ -836,9 +837,9 @@ void MetavoxelSystem::guideToAugmented(MetavoxelVisitor& visitor, bool render) { · 32 unmodified lines | ||
| 836 | 837 | } |
| 837 | 838 | |
| 838 | 839 | void MetavoxelSystem::loadSplatProgram(const char* type, ProgramObject& program, SplatLocations& locations) { |
| 839 | − program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + | |
| 840 | + program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + | |
| 840 | 841 | "shaders/metavoxel_" + type + "_splat.vert"); |
| 841 | − program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + | |
| 842 | + program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + | |
| 842 | 843 | "shaders/metavoxel_" + type + "_splat.frag"); |
| 843 | 844 | program.link(); |
| 844 | 845 | |
| @@ -1177,10 +1178,11 @@ void VoxelBuffer::render(bool cursor) { · 332 unmodified lines | ||
| 1177 | 1178 | |
| 1178 | 1179 | if (!_materials.isEmpty()) { |
| 1179 | 1180 | _networkTextures.resize(_materials.size()); |
| 1181 | + TextureCache* textureCache = DependencyManager::get<TextureCache>(); | |
| 1180 | 1182 | for (int i = 0; i < _materials.size(); i++) { |
| 1181 | 1183 | const SharedObjectPointer material = _materials.at(i); |
| 1182 | 1184 | if (material) { |
| 1183 | − _networkTextures[i] = Application::getInstance()->getTextureCache()->getTexture( | |
| 1185 | + _networkTextures[i] = textureCache->getTexture( | |
| 1184 | 1186 | static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE); |
| 1185 | 1187 | } |
| 1186 | 1188 | } |
| @@ -1980,7 +1982,7 @@ void SphereRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor · 793 unmodified lines | ||
| 1980 | 1982 | glm::vec3 axis = glm::axis(rotation); |
| 1981 | 1983 | glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); |
| 1982 | 1984 | |
| 1983 | − Application::getInstance()->getDeferredLightingEffect()->renderSolidSphere(sphere->getScale(), 32, 32); | |
| 1985 | + DependencyManager::get<DeferredLightingEffect>()->renderSolidSphere(sphere->getScale(), 32, 32); | |
| 1984 | 1986 | |
| 1985 | 1987 | glPopMatrix(); |
| 1986 | 1988 | } |
| @@ -2001,7 +2003,7 @@ void CuboidRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor · 14 unmodified lines | ||
| 2001 | 2003 | glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); |
| 2002 | 2004 | glScalef(1.0f, cuboid->getAspectY(), cuboid->getAspectZ()); |
| 2003 | 2005 | |
| 2004 | − Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(cuboid->getScale() * 2.0f); | |
| 2006 | + DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(cuboid->getScale() * 2.0f); | |
| 2005 | 2007 | |
| 2006 | 2008 | glPopMatrix(); |
| 2007 | 2009 | } |
| @@ -2231,10 +2233,11 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g · 223 unmodified lines | ||
| 2231 | 2233 | |
| 2232 | 2234 | const QVector<SharedObjectPointer>& materials = node->getMaterial()->getMaterials(); |
| 2233 | 2235 | _networkTextures.resize(materials.size()); |
| 2236 | + TextureCache* textureCache = DependencyManager::get<TextureCache>(); | |
| 2234 | 2237 | for (int i = 0; i < materials.size(); i++) { |
| 2235 | 2238 | const SharedObjectPointer& material = materials.at(i); |
| 2236 | 2239 | if (material) { |
| 2237 | − _networkTextures[i] = Application::getInstance()->getTextureCache()->getTexture( | |
| 2240 | + _networkTextures[i] = textureCache->getTexture( | |
| 2238 | 2241 | static_cast<MaterialObject*>(material.data())->getDiffuse(), SPLAT_TEXTURE); |
| 2239 | 2242 | } |
| 2240 | 2243 | } |