remove dependency on Menu from Model

This commit is contained in:
ZappoMan 2014-12-16 13:14:57 -08:00
parent 16c1e597f1
commit efa8a752f2
4 changed files with 18 additions and 8 deletions

View file

@ -191,6 +191,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_isVSyncOn(true),
_aboutToQuit(false)
{
Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us
// read the ApplicationInfo.ini file for Name/Version/Domain information
QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
@ -429,8 +431,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
#endif
this->installEventFilter(this);
Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us
}
void Application::aboutToQuit() {
@ -2939,6 +2939,10 @@ void Application::setupWorldLight() {
glMateriali(GL_FRONT, GL_SHININESS, 96);
}
bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera);
}
QImage Application::renderAvatarBillboard() {
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();

View file

@ -256,6 +256,7 @@ public:
void controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes);
virtual void setupWorldLight();
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera);
QImage renderAvatarBillboard();

View file

@ -31,7 +31,6 @@
#include <SphereShape.h>
#include "AnimationHandle.h"
#include "Menu.h"
#include "Model.h"
@ -64,7 +63,9 @@ Model::Model(QObject* parent) :
_meshGroupsKnown(false) {
// we may have been created in the network thread, but we live in the main thread
moveToThread(_viewState->getMainThread());
if (_viewState) {
moveToThread(_viewState->getMainThread());
}
}
Model::~Model() {
@ -720,6 +721,9 @@ bool Model::render(float alpha, RenderMode mode, RenderArgs* args) {
bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) {
PROFILE_RANGE(__FUNCTION__);
if (!_viewState) {
return false;
}
// Let's introduce a gpu::Batch to capture all the calls to the graphics api
_renderBatch.clear();
@ -2329,9 +2333,9 @@ int Model::renderMeshes(gpu::Batch& batch, RenderMode mode, bool translucent, fl
int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold, RenderArgs* args,
Locations* locations, SkinLocations* skinLocations) {
PROFILE_RANGE(__FUNCTION__);
bool dontCullOutOfViewMeshParts = Menu::getInstance()->isOptionChecked(MenuOption::DontCullOutOfViewMeshParts);
bool cullTooSmallMeshParts = !Menu::getInstance()->isOptionChecked(MenuOption::DontCullTooSmallMeshParts);
bool dontReduceMaterialSwitches = Menu::getInstance()->isOptionChecked(MenuOption::DontReduceMaterialSwitches);
bool dontCullOutOfViewMeshParts = false; // Menu::getInstance()->isOptionChecked(MenuOption::DontCullOutOfViewMeshParts);
bool cullTooSmallMeshParts = true; // !Menu::getInstance()->isOptionChecked(MenuOption::DontCullTooSmallMeshParts);
bool dontReduceMaterialSwitches = false; // Menu::getInstance()->isOptionChecked(MenuOption::DontReduceMaterialSwitches);
TextureCache* textureCache = DependencyManager::get<TextureCache>();
GlowEffect* glowEffect = DependencyManager::get<GlowEffect>();
@ -2373,7 +2377,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod
args->_viewFrustum->boxInFrustum(_calculatedMeshBoxes.at(i)) != ViewFrustum::OUTSIDE;
if (shouldRender && cullTooSmallMeshParts) {
float distance = args->_viewFrustum->distanceToCamera(_calculatedMeshBoxes.at(i).calcCenter());
shouldRender = Menu::getInstance()->shouldRenderMesh(_calculatedMeshBoxes.at(i).getLargestDimension(),
shouldRender = !_viewState ? false : _viewState->shouldRenderMesh(_calculatedMeshBoxes.at(i).getLargestDimension(),
distance);
if (!shouldRender) {
args->_meshesTooSmall++;

View file

@ -37,6 +37,7 @@ public:
virtual QThread* getMainThread() = 0;
virtual const Transform& getViewTransform() const = 0;
virtual void setupWorldLight() = 0;
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera) = 0;
};