make GeometryCache work with DependancyManager

This commit is contained in:
ZappoMan 2014-12-15 10:49:34 -08:00
parent 7d75d2d1bf
commit e0a017e963
15 changed files with 34 additions and 41 deletions

View file

@ -3080,7 +3080,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
// draw a red sphere
float originSphereRadius = 0.05f;
glColor3f(1,0,0);
GeometryCache::getInstance()->renderSphere(originSphereRadius, 15, 15);
DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15);
// Draw voxels
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {

View file

@ -261,7 +261,7 @@ void Environment::renderAtmosphere(Camera& camera, const EnvironmentData& data)
glDepthMask(GL_FALSE);
glDisable(GL_DEPTH_TEST);
GeometryCache::getInstance()->renderSphere(1.0f, 100, 50); //Draw a unit sphere
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, 100, 50); //Draw a unit sphere
glDepthMask(GL_TRUE);
program->release();

View file

@ -471,7 +471,7 @@ void ModelUploader::processCheck() {
QString("ModelUploader::processCheck()"),
QString("Your model is now available in the browser."),
QMessageBox::Ok);
GeometryCache::getInstance()->refresh(_url);
DependencyManager::get<GeometryCache>()->refresh(_url);
foreach (const QByteArray& filename, _textureFilenames) {
DependencyManager::get<TextureCache>()->refresh(_textureBase + filename);
}

View file

@ -71,22 +71,22 @@ void renderWorldBox() {
glPushMatrix();
glTranslatef(MARKER_DISTANCE, 0, 0);
glColor3fv(red);
GeometryCache::getInstance()->renderSphere(MARKER_RADIUS, 10, 10);
DependencyManager::get<GeometryCache>()->renderSphere(MARKER_RADIUS, 10, 10);
glPopMatrix();
glPushMatrix();
glTranslatef(0, MARKER_DISTANCE, 0);
glColor3fv(green);
GeometryCache::getInstance()->renderSphere(MARKER_RADIUS, 10, 10);
DependencyManager::get<GeometryCache>()->renderSphere(MARKER_RADIUS, 10, 10);
glPopMatrix();
glPushMatrix();
glTranslatef(0, 0, MARKER_DISTANCE);
glColor3fv(blue);
GeometryCache::getInstance()->renderSphere(MARKER_RADIUS, 10, 10);
DependencyManager::get<GeometryCache>()->renderSphere(MARKER_RADIUS, 10, 10);
glPopMatrix();
glPushMatrix();
glColor3fv(gray);
glTranslatef(MARKER_DISTANCE, 0, MARKER_DISTANCE);
GeometryCache::getInstance()->renderSphere(MARKER_RADIUS, 10, 10);
DependencyManager::get<GeometryCache>()->renderSphere(MARKER_RADIUS, 10, 10);
glPopMatrix();
}

View file

@ -394,7 +394,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
} else {
glTranslatef(_position.x, getDisplayNamePosition().y + LOOK_AT_INDICATOR_OFFSET, _position.z);
}
GeometryCache::getInstance()->renderSphere(LOOK_AT_INDICATOR_RADIUS, 15, 15);
DependencyManager::get<GeometryCache>()->renderSphere(LOOK_AT_INDICATOR_RADIUS, 15, 15);
glPopMatrix();
}
}
@ -422,7 +422,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool
glPushMatrix();
glTranslatef(_position.x, _position.y, _position.z);
glScalef(height, height, height);
GeometryCache::getInstance()->renderSphere(sphereRadius, 15, 15);
DependencyManager::get<GeometryCache>()->renderSphere(sphereRadius, 15, 15);
glPopMatrix();
}

View file

@ -114,7 +114,7 @@ void Hand::render(bool isMine, Model::RenderMode renderMode) {
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glColor3f(0.0f, 1.0f, 0.0f);
GeometryCache::getInstance()->renderSphere(PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10);
DependencyManager::get<GeometryCache>()->renderSphere(PALM_COLLISION_RADIUS * _owningAvatar->getScale(), 10, 10);
glPopMatrix();
}
}
@ -179,7 +179,7 @@ void Hand::renderHandTargets(bool isMine) {
Avatar::renderJointConnectingCone(root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f);
glPushMatrix();
glTranslatef(root.x, root.y, root.z);
GeometryCache::getInstance()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f);
DependencyManager::get<GeometryCache>()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f);
glPopMatrix();
}
}

View file

@ -394,7 +394,7 @@ void MyAvatar::renderDebugBodyPoints() {
glPushMatrix();
glColor4f(0, 1, 0, .5f);
glTranslatef(position.x, position.y, position.z);
GeometryCache::getInstance()->renderSphere(0.2f, 10.0f, 10.0f);
DependencyManager::get<GeometryCache>()->renderSphere(0.2f, 10.0f, 10.0f);
glPopMatrix();
// Head Sphere
@ -402,7 +402,7 @@ void MyAvatar::renderDebugBodyPoints() {
glPushMatrix();
glColor4f(0, 1, 0, .5f);
glTranslatef(position.x, position.y, position.z);
GeometryCache::getInstance()->renderSphere(0.15f, 10.0f, 10.0f);
DependencyManager::get<GeometryCache>()->renderSphere(0.15f, 10.0f, 10.0f);
glPopMatrix();
}

View file

@ -561,9 +561,9 @@ void SkeletonModel::renderRagdoll() {
glTranslatef(position.x, position.y, position.z);
// draw each point as a yellow hexagon with black border
glColor4f(0.0f, 0.0f, 0.0f, alpha);
GeometryCache::getInstance()->renderSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
DependencyManager::get<GeometryCache>()->renderSphere(radius2, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
glColor4f(1.0f, 1.0f, 0.0f, alpha);
GeometryCache::getInstance()->renderSphere(radius1, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
DependencyManager::get<GeometryCache>()->renderSphere(radius1, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
glPopMatrix();
}
glPopMatrix();
@ -913,7 +913,7 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
endPoint = endPoint - _translation;
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
glColor4f(0.6f, 0.6f, 0.8f, alpha);
GeometryCache::getInstance()->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
DependencyManager::get<GeometryCache>()->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
// draw a yellow sphere at the capsule startpoint
glm::vec3 startPoint;
@ -922,7 +922,7 @@ void SkeletonModel::renderBoundingCollisionShapes(float alpha) {
glm::vec3 axis = endPoint - startPoint;
glTranslatef(-axis.x, -axis.y, -axis.z);
glColor4f(0.8f, 0.8f, 0.6f, alpha);
GeometryCache::getInstance()->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
DependencyManager::get<GeometryCache>()->renderSphere(_boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
// draw a green cylinder between the two points
glm::vec3 origin(0.0f);
@ -955,7 +955,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
glTranslatef(position.x, position.y, position.z);
// draw a grey sphere at shape position
glColor4f(0.75f, 0.75f, 0.75f, alpha);
GeometryCache::getInstance()->renderSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
DependencyManager::get<GeometryCache>()->renderSphere(shape->getBoundingRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
} else if (shape->getType() == CAPSULE_SHAPE) {
CapsuleShape* capsule = static_cast<CapsuleShape*>(shape);
@ -965,7 +965,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
endPoint = endPoint - simulationTranslation;
glTranslatef(endPoint.x, endPoint.y, endPoint.z);
glColor4f(0.6f, 0.6f, 0.8f, alpha);
GeometryCache::getInstance()->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
DependencyManager::get<GeometryCache>()->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
// draw a yellow sphere at the capsule startpoint
glm::vec3 startPoint;
@ -974,7 +974,7 @@ void SkeletonModel::renderJointCollisionShapes(float alpha) {
glm::vec3 axis = endPoint - startPoint;
glTranslatef(-axis.x, -axis.y, -axis.z);
glColor4f(0.8f, 0.8f, 0.6f, alpha);
GeometryCache::getInstance()->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
DependencyManager::get<GeometryCache>()->renderSphere(capsule->getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS);
// draw a green cylinder between the two points
glm::vec3 origin(0.0f);

View file

@ -51,7 +51,7 @@ void DeferredLightingEffect::releaseSimpleProgram() {
void DeferredLightingEffect::renderSolidSphere(float radius, int slices, int stacks) {
bindSimpleProgram();
GeometryCache::getInstance()->renderSphere(radius, slices, stacks);
DependencyManager::get<GeometryCache>()->renderSphere(radius, slices, stacks);
releaseSimpleProgram();
}
@ -75,7 +75,7 @@ void DeferredLightingEffect::renderWireCube(float size) {
void DeferredLightingEffect::renderSolidCone(float base, float height, int slices, int stacks) {
bindSimpleProgram();
GeometryCache::getInstance()->renderCone(base, height, slices, stacks);
DependencyManager::get<GeometryCache>()->renderCone(base, height, slices, stacks);
releaseSimpleProgram();
}
@ -270,7 +270,7 @@ void DeferredLightingEffect::render() {
} else {
glTranslatef(light.position.x, light.position.y, light.position.z);
GeometryCache::getInstance()->renderSphere(expandedRadius, 32, 32);
DependencyManager::get<GeometryCache>()->renderSphere(expandedRadius, 32, 32);
}
glPopMatrix();
@ -323,7 +323,7 @@ void DeferredLightingEffect::render() {
glm::vec3 axis = glm::axis(spotRotation);
glRotatef(glm::degrees(glm::angle(spotRotation)), axis.x, axis.y, axis.z);
glTranslatef(0.0f, 0.0f, -light.radius * (1.0f + SCALE_EXPANSION * 0.5f));
GeometryCache::getInstance()->renderCone(expandedRadius * glm::tan(light.cutoff),
DependencyManager::get<GeometryCache>()->renderCone(expandedRadius * glm::tan(light.cutoff),
expandedRadius, 32, 1);
}

View file

@ -23,11 +23,6 @@
#include "GeometryCache.h"
#include "TextureCache.h"
GeometryCache* GeometryCache::getInstance() {
static GeometryCache instance;
return &instance;
}
GeometryCache::GeometryCache() {
}

View file

@ -18,6 +18,7 @@
#include <QMap>
#include <QOpenGLBuffer>
#include <DependencyManager.h>
#include <ResourceCache.h>
#include <FBXReader.h>
@ -31,16 +32,10 @@ class NetworkMesh;
class NetworkTexture;
/// Stores cached geometry.
class GeometryCache : public ResourceCache {
class GeometryCache : public ResourceCache, public DependencyManager::Dependency {
Q_OBJECT
public:
static GeometryCache* getInstance();
GeometryCache();
virtual ~GeometryCache();
void renderHemisphere(int slices, int stacks);
void renderSphere(float radius, int slices, int stacks);
void renderSquare(int xDivisions, int yDivisions);
@ -59,6 +54,9 @@ protected:
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
private:
GeometryCache();
virtual ~GeometryCache();
friend class DependencyManager;
typedef QPair<int, int> IntPair;
typedef QPair<GLuint, GLuint> VerticesIndices;

View file

@ -997,7 +997,7 @@ void Model::setURL(const QUrl& url, const QUrl& fallback, bool retainCurrent, bo
_url = url;
// if so instructed, keep the current geometry until the new one is loaded
_nextBaseGeometry = _nextGeometry = GeometryCache::getInstance()->getGeometry(url, fallback, delayLoad);
_nextBaseGeometry = _nextGeometry = DependencyManager::get<GeometryCache>()->getGeometry(url, fallback, delayLoad);
_nextLODHysteresis = NetworkGeometry::NO_HYSTERESIS;
if (!retainCurrent || !isActive() || _nextGeometry->isLoaded()) {
applyNextGeometry();

View file

@ -353,7 +353,7 @@ void MetavoxelEditor::render() {
_gridProgram.bind();
GeometryCache::getInstance()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
DependencyManager::get<GeometryCache>()->renderGrid(GRID_DIVISIONS, GRID_DIVISIONS);
_gridProgram.release();

View file

@ -87,7 +87,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
float scale = MINOR_GRID_DIVISIONS * spacing;
glScalef(scale, scale, scale);
GeometryCache::getInstance()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS);
DependencyManager::get<GeometryCache>()->renderGrid(MINOR_GRID_DIVISIONS, MINOR_GRID_DIVISIONS);
}
glPopMatrix();
@ -102,7 +102,7 @@ void Grid3DOverlay::render(RenderArgs* args) {
float scale = MAJOR_GRID_DIVISIONS * spacing;
glScalef(scale, scale, scale);
GeometryCache::getInstance()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS);
DependencyManager::get<GeometryCache>()->renderGrid(MAJOR_GRID_DIVISIONS, MAJOR_GRID_DIVISIONS);
}
glPopMatrix();

View file

@ -63,7 +63,7 @@ void Sphere3DOverlay::render(RenderArgs* args) {
glScalef(dimensions.x, dimensions.y, dimensions.z);
//Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f);
if (_isSolid) {
GeometryCache::getInstance()->renderSphere(1.0f, SLICES, SLICES);
DependencyManager::get<GeometryCache>()->renderSphere(1.0f, SLICES, SLICES);
} else {
glutWireSphere(1.0f, SLICES, SLICES);
}