History

Merge branch 'master' of https://github.com/highfidelity/hifi into cuckoo

Stephen Birarda committed 11 years ago

Commit 737741c2 parents a3cc578 61ec1bd103 files · +893 −542Browse files

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

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t