more Application and Menu dependency removal

This commit is contained in:
ZappoMan 2014-12-17 11:41:42 -08:00
parent 5d636e21c6
commit a465aa20ff
8 changed files with 29 additions and 49 deletions

View file

@ -16,8 +16,6 @@
#include <DeferredLightingEffect.h>
#include <PerfStat.h>
#include "Application.h"
#include "Menu.h"
#include "RenderableLightEntityItem.h"
EntityItem* RenderableLightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
@ -55,17 +53,13 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
float exponent = getExponent();
float cutoff = glm::radians(getCutoff());
bool disableLights = Menu::getInstance()->isOptionChecked(MenuOption::DisableLightEntities);
if (!disableLights) {
if (_isSpotlight) {
DependencyManager::get<DeferredLightingEffect>()->addSpotLight(position, largestDiameter / 2.0f,
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation,
direction, exponent, cutoff);
} else {
DependencyManager::get<DeferredLightingEffect>()->addPointLight(position, largestDiameter / 2.0f,
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation);
}
if (_isSpotlight) {
DependencyManager::get<DeferredLightingEffect>()->addSpotLight(position, largestDiameter / 2.0f,
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation,
direction, exponent, cutoff);
} else {
DependencyManager::get<DeferredLightingEffect>()->addPointLight(position, largestDiameter / 2.0f,
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation);
}
#ifdef WANT_DEBUG
@ -88,10 +82,11 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
bool RenderableLightEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face,
void** intersectedObject, bool precisionPicking) const {
// TODO: this isn't really correct because we don't know if we actually live in the main tree of the applications's
// EntityTreeRenderer. But we probably do. Technically we could be on the clipboard and someone might be trying to
// use the ray intersection API there. Anyway... if you ever try to do ray intersection testing off of trees other
// than the main tree of the main entity renderer, then you'll need to fix this mechanism.
return Application::getInstance()->getEntities()->getTree()->getLightsArePickable();
// TODO: consider if this is really what we want to do. We've made it so that "lights are pickable" is a global state
// this is probably reasonable since there's typically only one tree you'd be picking on at a time. Technically we could
// be on the clipboard and someone might be trying to use the ray intersection API there. Anyway... if you ever try to
// do ray intersection testing off of trees other than the main tree of the main entity renderer, then we'll need to
// fix this mechanism.
return _lightsArePickable;
}

View file

@ -13,10 +13,13 @@
#include <gpu/GPUConfig.h>
#include <QJsonDocument>
#include <DeferredLightingEffect.h>
#include <Model.h>
#include <PerfStat.h>
#include "Menu.h"
#include "EntityTreeRenderer.h"
#include "RenderableModelEntityItem.h"
EntityItem* RenderableModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
@ -159,28 +162,11 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
_needsInitialSimulation = false;
}
// TODO: should we allow entityItems to have alpha on their models?
Model::RenderMode modelRenderMode = args->_renderMode == RenderArgs::SHADOW_RENDER_MODE
? Model::SHADOW_RENDER_MODE : Model::DEFAULT_RENDER_MODE;
if (_model->isActive()) {
// TODO: this is the majority of model render time. And rendering of a cube model vs the basic Box render
// is significantly more expensive. Is there a way to call this that doesn't cost us as much?
PerformanceTimer perfTimer("model->render");
bool dontRenderAsScene = Menu::getInstance()->isOptionChecked(MenuOption::DontRenderEntitiesAsScene);
bool displayModelTriangles = Menu::getInstance()->isOptionChecked(MenuOption::DisplayModelTriangles);
bool rendered = false;
if (displayModelTriangles) {
rendered = _model->renderTriangleProxies();
}
if (!rendered) {
if (dontRenderAsScene) {
_model->render(alpha, modelRenderMode, args);
} else {
_model->renderInScene(alpha, args);
}
}
_model->renderInScene(alpha, args);
} else {
// if we couldn't get a model, then just draw a cube
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);

View file

@ -18,6 +18,7 @@
#include <ModelEntityItem.h>
class Model;
class EntityTreeRenderer;
class RenderableModelEntityItem : public ModelEntityItem {
public:

View file

@ -11,6 +11,7 @@
#include "EntityScriptingInterface.h"
#include "EntityTree.h"
#include "LightEntityItem.h"
#include "ModelEntityItem.h"
EntityScriptingInterface::EntityScriptingInterface() :
@ -226,16 +227,11 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorke
}
void EntityScriptingInterface::setLightsArePickable(bool value) {
if (_entityTree) {
_entityTree->setLightsArePickable(value);
}
LightEntityItem::setLightsArePickable(value);
}
bool EntityScriptingInterface::getLightsArePickable() const {
if (_entityTree) {
return _entityTree->getLightsArePickable();
}
return false;
return LightEntityItem::getLightsArePickable();
}

View file

@ -22,7 +22,6 @@
EntityTree::EntityTree(bool shouldReaverage) :
Octree(shouldReaverage),
_fbxService(NULL),
_lightsArePickable(true),
_simulation(NULL)
{
_rootElement = createNewElement();

View file

@ -150,8 +150,6 @@ public:
void emitEntityScriptChanging(const EntityItemID& entityItemID);
bool getLightsArePickable() const { return _lightsArePickable; }
void setLightsArePickable(bool value) { _lightsArePickable = value; }
void setSimulation(EntitySimulation* simulation);
signals:
@ -180,7 +178,6 @@ private:
QHash<EntityItemID, EntityTreeElement*> _entityToElementMap;
bool _lightsArePickable;
EntitySimulation* _simulation;
};

View file

@ -18,6 +18,7 @@
#include "EntityTreeElement.h"
#include "LightEntityItem.h"
bool LightEntityItem::_lightsArePickable = false;
EntityItem* LightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return new LightEntityItem(entityID, properties);

View file

@ -99,6 +99,9 @@ public:
void setCutoff(float value) { _cutoff = value; }
virtual const Shape& getCollisionShapeInMeters() const { return _emptyShape; }
static bool getLightsArePickable() { return _lightsArePickable; }
static void setLightsArePickable(bool value) { _lightsArePickable = value; }
protected:
virtual void recalculateCollisionShape() { /* nothing to do */ }
@ -116,6 +119,8 @@ protected:
// used for collision detection
SphereShape _emptyShape;
static bool _lightsArePickable;
};
#endif // hifi_LightEntityItem_h