mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
more Application and Menu dependency removal
This commit is contained in:
parent
5d636e21c6
commit
a465aa20ff
8 changed files with 29 additions and 49 deletions
|
@ -16,8 +16,6 @@
|
||||||
#include <DeferredLightingEffect.h>
|
#include <DeferredLightingEffect.h>
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
#include "Menu.h"
|
|
||||||
#include "RenderableLightEntityItem.h"
|
#include "RenderableLightEntityItem.h"
|
||||||
|
|
||||||
EntityItem* RenderableLightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
EntityItem* RenderableLightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||||
|
@ -55,17 +53,13 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
|
||||||
float exponent = getExponent();
|
float exponent = getExponent();
|
||||||
float cutoff = glm::radians(getCutoff());
|
float cutoff = glm::radians(getCutoff());
|
||||||
|
|
||||||
bool disableLights = Menu::getInstance()->isOptionChecked(MenuOption::DisableLightEntities);
|
if (_isSpotlight) {
|
||||||
|
DependencyManager::get<DeferredLightingEffect>()->addSpotLight(position, largestDiameter / 2.0f,
|
||||||
if (!disableLights) {
|
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation,
|
||||||
if (_isSpotlight) {
|
direction, exponent, cutoff);
|
||||||
DependencyManager::get<DeferredLightingEffect>()->addSpotLight(position, largestDiameter / 2.0f,
|
} else {
|
||||||
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation,
|
DependencyManager::get<DeferredLightingEffect>()->addPointLight(position, largestDiameter / 2.0f,
|
||||||
direction, exponent, cutoff);
|
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation);
|
||||||
} else {
|
|
||||||
DependencyManager::get<DeferredLightingEffect>()->addPointLight(position, largestDiameter / 2.0f,
|
|
||||||
ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
|
@ -88,10 +82,11 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
|
||||||
bool RenderableLightEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
bool RenderableLightEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||||
bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face,
|
bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face,
|
||||||
void** intersectedObject, bool precisionPicking) const {
|
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
|
// TODO: consider if this is really what we want to do. We've made it so that "lights are pickable" is a global state
|
||||||
// EntityTreeRenderer. But we probably do. Technically we could be on the clipboard and someone might be trying to
|
// this is probably reasonable since there's typically only one tree you'd be picking on at a time. Technically we could
|
||||||
// use the ray intersection API there. Anyway... if you ever try to do ray intersection testing off of trees other
|
// be on the clipboard and someone might be trying to use the ray intersection API there. Anyway... if you ever try to
|
||||||
// than the main tree of the main entity renderer, then you'll need to fix this mechanism.
|
// do ray intersection testing off of trees other than the main tree of the main entity renderer, then we'll need to
|
||||||
return Application::getInstance()->getEntities()->getTree()->getLightsArePickable();
|
// fix this mechanism.
|
||||||
|
return _lightsArePickable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,13 @@
|
||||||
|
|
||||||
#include <gpu/GPUConfig.h>
|
#include <gpu/GPUConfig.h>
|
||||||
|
|
||||||
|
#include <QJsonDocument>
|
||||||
|
|
||||||
#include <DeferredLightingEffect.h>
|
#include <DeferredLightingEffect.h>
|
||||||
|
#include <Model.h>
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
|
|
||||||
#include "Menu.h"
|
#include "EntityTreeRenderer.h"
|
||||||
#include "RenderableModelEntityItem.h"
|
#include "RenderableModelEntityItem.h"
|
||||||
|
|
||||||
EntityItem* RenderableModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
EntityItem* RenderableModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||||
|
@ -159,28 +162,11 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
||||||
_needsInitialSimulation = false;
|
_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()) {
|
if (_model->isActive()) {
|
||||||
// TODO: this is the majority of model render time. And rendering of a cube model vs the basic Box render
|
// 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?
|
// is significantly more expensive. Is there a way to call this that doesn't cost us as much?
|
||||||
PerformanceTimer perfTimer("model->render");
|
PerformanceTimer perfTimer("model->render");
|
||||||
bool dontRenderAsScene = Menu::getInstance()->isOptionChecked(MenuOption::DontRenderEntitiesAsScene);
|
_model->renderInScene(alpha, args);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// if we couldn't get a model, then just draw a cube
|
// if we couldn't get a model, then just draw a cube
|
||||||
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);
|
glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <ModelEntityItem.h>
|
#include <ModelEntityItem.h>
|
||||||
|
|
||||||
class Model;
|
class Model;
|
||||||
|
class EntityTreeRenderer;
|
||||||
|
|
||||||
class RenderableModelEntityItem : public ModelEntityItem {
|
class RenderableModelEntityItem : public ModelEntityItem {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "EntityScriptingInterface.h"
|
#include "EntityScriptingInterface.h"
|
||||||
#include "EntityTree.h"
|
#include "EntityTree.h"
|
||||||
|
#include "LightEntityItem.h"
|
||||||
#include "ModelEntityItem.h"
|
#include "ModelEntityItem.h"
|
||||||
|
|
||||||
EntityScriptingInterface::EntityScriptingInterface() :
|
EntityScriptingInterface::EntityScriptingInterface() :
|
||||||
|
@ -226,16 +227,11 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorke
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityScriptingInterface::setLightsArePickable(bool value) {
|
void EntityScriptingInterface::setLightsArePickable(bool value) {
|
||||||
if (_entityTree) {
|
LightEntityItem::setLightsArePickable(value);
|
||||||
_entityTree->setLightsArePickable(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityScriptingInterface::getLightsArePickable() const {
|
bool EntityScriptingInterface::getLightsArePickable() const {
|
||||||
if (_entityTree) {
|
return LightEntityItem::getLightsArePickable();
|
||||||
return _entityTree->getLightsArePickable();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
EntityTree::EntityTree(bool shouldReaverage) :
|
EntityTree::EntityTree(bool shouldReaverage) :
|
||||||
Octree(shouldReaverage),
|
Octree(shouldReaverage),
|
||||||
_fbxService(NULL),
|
_fbxService(NULL),
|
||||||
_lightsArePickable(true),
|
|
||||||
_simulation(NULL)
|
_simulation(NULL)
|
||||||
{
|
{
|
||||||
_rootElement = createNewElement();
|
_rootElement = createNewElement();
|
||||||
|
|
|
@ -150,8 +150,6 @@ public:
|
||||||
|
|
||||||
void emitEntityScriptChanging(const EntityItemID& entityItemID);
|
void emitEntityScriptChanging(const EntityItemID& entityItemID);
|
||||||
|
|
||||||
bool getLightsArePickable() const { return _lightsArePickable; }
|
|
||||||
void setLightsArePickable(bool value) { _lightsArePickable = value; }
|
|
||||||
void setSimulation(EntitySimulation* simulation);
|
void setSimulation(EntitySimulation* simulation);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -180,7 +178,6 @@ private:
|
||||||
|
|
||||||
QHash<EntityItemID, EntityTreeElement*> _entityToElementMap;
|
QHash<EntityItemID, EntityTreeElement*> _entityToElementMap;
|
||||||
|
|
||||||
bool _lightsArePickable;
|
|
||||||
EntitySimulation* _simulation;
|
EntitySimulation* _simulation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "EntityTreeElement.h"
|
#include "EntityTreeElement.h"
|
||||||
#include "LightEntityItem.h"
|
#include "LightEntityItem.h"
|
||||||
|
|
||||||
|
bool LightEntityItem::_lightsArePickable = false;
|
||||||
|
|
||||||
EntityItem* LightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
EntityItem* LightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||||
return new LightEntityItem(entityID, properties);
|
return new LightEntityItem(entityID, properties);
|
||||||
|
|
|
@ -99,6 +99,9 @@ public:
|
||||||
void setCutoff(float value) { _cutoff = value; }
|
void setCutoff(float value) { _cutoff = value; }
|
||||||
|
|
||||||
virtual const Shape& getCollisionShapeInMeters() const { return _emptyShape; }
|
virtual const Shape& getCollisionShapeInMeters() const { return _emptyShape; }
|
||||||
|
|
||||||
|
static bool getLightsArePickable() { return _lightsArePickable; }
|
||||||
|
static void setLightsArePickable(bool value) { _lightsArePickable = value; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void recalculateCollisionShape() { /* nothing to do */ }
|
virtual void recalculateCollisionShape() { /* nothing to do */ }
|
||||||
|
@ -116,6 +119,8 @@ protected:
|
||||||
|
|
||||||
// used for collision detection
|
// used for collision detection
|
||||||
SphereShape _emptyShape;
|
SphereShape _emptyShape;
|
||||||
|
|
||||||
|
static bool _lightsArePickable;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_LightEntityItem_h
|
#endif // hifi_LightEntityItem_h
|
||||||
|
|
Loading…
Reference in a new issue