merge from upstream

This commit is contained in:
Seth Alves 2016-08-18 11:46:02 -07:00
commit 15ce40ecf4
8 changed files with 121 additions and 101 deletions

View file

@ -4253,22 +4253,11 @@ namespace render {
auto backgroundMode = skyStage->getBackgroundMode(); auto backgroundMode = skyStage->getBackgroundMode();
switch (backgroundMode) { switch (backgroundMode) {
case model::SunSkyStage::SKY_BOX: { case model::SunSkyStage::SKY_DEFAULT: {
auto skybox = skyStage->getSkybox(); static const glm::vec3 DEFAULT_SKYBOX_COLOR{ 255.0f / 255.0f, 220.0f / 255.0f, 194.0f / 255.0f };
if (skybox) { static const float DEFAULT_SKYBOX_INTENSITY{ 0.2f };
PerformanceTimer perfTimer("skybox"); static const float DEFAULT_SKYBOX_AMBIENT_INTENSITY{ 2.0f };
skybox->render(batch, args->getViewFrustum()); static const glm::vec3 DEFAULT_SKYBOX_DIRECTION{ 0.0f, 0.0f, -1.0f };
break;
}
}
// Fall through: if no skybox is available, render the SKY_DOME
case model::SunSkyStage::SKY_DOME: {
if (Menu::getInstance()->isOptionChecked(MenuOption::DefaultSkybox)) {
static const glm::vec3 DEFAULT_SKYBOX_COLOR { 255.0f / 255.0f, 220.0f / 255.0f, 194.0f / 255.0f };
static const float DEFAULT_SKYBOX_INTENSITY { 0.2f };
static const float DEFAULT_SKYBOX_AMBIENT_INTENSITY { 2.0f };
static const glm::vec3 DEFAULT_SKYBOX_DIRECTION { 0.0f, 0.0f, -1.0f };
auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage(); auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage();
auto sceneKeyLight = scene->getKeyLight(); auto sceneKeyLight = scene->getKeyLight();
@ -4277,16 +4266,31 @@ namespace render {
sceneKeyLight->setIntensity(DEFAULT_SKYBOX_INTENSITY); sceneKeyLight->setIntensity(DEFAULT_SKYBOX_INTENSITY);
sceneKeyLight->setAmbientIntensity(DEFAULT_SKYBOX_AMBIENT_INTENSITY); sceneKeyLight->setAmbientIntensity(DEFAULT_SKYBOX_AMBIENT_INTENSITY);
sceneKeyLight->setDirection(DEFAULT_SKYBOX_DIRECTION); sceneKeyLight->setDirection(DEFAULT_SKYBOX_DIRECTION);
// fall through: render a skybox, if available
}
case model::SunSkyStage::SKY_BOX: {
auto skybox = skyStage->getSkybox();
if (skybox) {
PerformanceTimer perfTimer("skybox");
skybox->render(batch, args->getViewFrustum());
break;
}
// fall through: render defaults, if available
}
case model::SunSkyStage::SKY_DEFAULT_AMBIENT_TEXTURE: {
if (Menu::getInstance()->isOptionChecked(MenuOption::DefaultSkybox)) {
auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage();
auto sceneKeyLight = scene->getKeyLight();
auto defaultSkyboxAmbientTexture = qApp->getDefaultSkyboxAmbientTexture(); auto defaultSkyboxAmbientTexture = qApp->getDefaultSkyboxAmbientTexture();
sceneKeyLight->setAmbientSphere(defaultSkyboxAmbientTexture->getIrradiance()); // do not set the ambient sphere - it peaks too high, and causes flashing when turning
sceneKeyLight->setAmbientMap(defaultSkyboxAmbientTexture); sceneKeyLight->setAmbientMap(defaultSkyboxAmbientTexture);
}
// fall through: render defaults, if available
}
case model::SunSkyStage::SKY_DEFAULT_TEXTURE:
if (Menu::getInstance()->isOptionChecked(MenuOption::DefaultSkybox)) {
qApp->getDefaultSkybox()->render(batch, args->getViewFrustum()); qApp->getDefaultSkybox()->render(batch, args->getViewFrustum());
} }
}
break;
case model::SunSkyStage::NO_BACKGROUND: case model::SunSkyStage::NO_BACKGROUND:
default: default:
// this line intentionally left blank // this line intentionally left blank
@ -4503,7 +4507,7 @@ void Application::clearDomainOctreeDetails() {
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage(); auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT);
_recentlyClearedDomain = true; _recentlyClearedDomain = true;
} }

View file

@ -23,6 +23,7 @@ Line3DOverlay::Line3DOverlay() :
Line3DOverlay::Line3DOverlay(const Line3DOverlay* line3DOverlay) : Line3DOverlay::Line3DOverlay(const Line3DOverlay* line3DOverlay) :
Base3DOverlay(line3DOverlay), Base3DOverlay(line3DOverlay),
_start(line3DOverlay->_start),
_end(line3DOverlay->_end), _end(line3DOverlay->_end),
_geometryCacheID(DependencyManager::get<GeometryCache>()->allocateID()) _geometryCacheID(DependencyManager::get<GeometryCache>()->allocateID())
{ {
@ -31,6 +32,40 @@ Line3DOverlay::Line3DOverlay(const Line3DOverlay* line3DOverlay) :
Line3DOverlay::~Line3DOverlay() { Line3DOverlay::~Line3DOverlay() {
} }
glm::vec3 Line3DOverlay::getStart() const {
bool success;
glm::vec3 worldStart = localToWorld(_start, _parentID, _parentJointIndex, success);
if (!success) {
qDebug() << "Line3DOverlay::getStart failed";
}
return worldStart;
}
glm::vec3 Line3DOverlay::getEnd() const {
bool success;
glm::vec3 worldEnd = localToWorld(_end, _parentID, _parentJointIndex, success);
if (!success) {
qDebug() << "Line3DOverlay::getEnd failed";
}
return worldEnd;
}
void Line3DOverlay::setStart(const glm::vec3& start) {
bool success;
_start = worldToLocal(start, _parentID, _parentJointIndex, success);
if (!success) {
qDebug() << "Line3DOverlay::setStart failed";
}
}
void Line3DOverlay::setEnd(const glm::vec3& end) {
bool success;
_end = worldToLocal(end, _parentID, _parentJointIndex, success);
if (!success) {
qDebug() << "Line3DOverlay::setEnd failed";
}
}
AABox Line3DOverlay::getBounds() const { AABox Line3DOverlay::getBounds() const {
auto extents = Extents{}; auto extents = Extents{};
extents.addPoint(_start); extents.addPoint(_start);
@ -76,8 +111,8 @@ const render::ShapeKey Line3DOverlay::getShapeKey() {
return builder.build(); return builder.build();
} }
void Line3DOverlay::setProperties(const QVariantMap& properties) { void Line3DOverlay::setProperties(const QVariantMap& originalProperties) {
Base3DOverlay::setProperties(properties); QVariantMap properties = originalProperties;
auto start = properties["start"]; auto start = properties["start"];
// if "start" property was not there, check to see if they included aliases: startPoint // if "start" property was not there, check to see if they included aliases: startPoint
@ -87,6 +122,7 @@ void Line3DOverlay::setProperties(const QVariantMap& properties) {
if (start.isValid()) { if (start.isValid()) {
setStart(vec3FromVariant(start)); setStart(vec3FromVariant(start));
} }
properties.remove("start"); // so that Base3DOverlay doesn't respond to it
auto end = properties["end"]; auto end = properties["end"];
// if "end" property was not there, check to see if they included aliases: endPoint // if "end" property was not there, check to see if they included aliases: endPoint
@ -109,14 +145,16 @@ void Line3DOverlay::setProperties(const QVariantMap& properties) {
if (glowWidth.isValid()) { if (glowWidth.isValid()) {
setGlow(glowWidth.toFloat()); setGlow(glowWidth.toFloat());
} }
Base3DOverlay::setProperties(properties);
} }
QVariant Line3DOverlay::getProperty(const QString& property) { QVariant Line3DOverlay::getProperty(const QString& property) {
if (property == "start" || property == "startPoint" || property == "p1") { if (property == "start" || property == "startPoint" || property == "p1") {
return vec3toVariant(_start); return vec3toVariant(getStart());
} }
if (property == "end" || property == "endPoint" || property == "p2") { if (property == "end" || property == "endPoint" || property == "p2") {
return vec3toVariant(_end); return vec3toVariant(getEnd());
} }
return Base3DOverlay::getProperty(property); return Base3DOverlay::getProperty(property);
@ -125,3 +163,8 @@ QVariant Line3DOverlay::getProperty(const QString& property) {
Line3DOverlay* Line3DOverlay::createClone() const { Line3DOverlay* Line3DOverlay::createClone() const {
return new Line3DOverlay(this); return new Line3DOverlay(this);
} }
void Line3DOverlay::locationChanged(bool tellPhysics) {
// do nothing
}

View file

@ -28,14 +28,15 @@ public:
virtual AABox getBounds() const override; virtual AABox getBounds() const override;
// getters // getters
const glm::vec3& getStart() const { return _start; } glm::vec3 getStart() const;
const glm::vec3& getEnd() const { return _end; } glm::vec3 getEnd() const;
const float& getGlow() const { return _glow; } const float& getGlow() const { return _glow; }
const float& getGlowWidth() const { return _glowWidth; } const float& getGlowWidth() const { return _glowWidth; }
// setters // setters
void setStart(const glm::vec3& start) { _start = start; } void setStart(const glm::vec3& start);
void setEnd(const glm::vec3& end) { _end = end; } void setEnd(const glm::vec3& end);
void setGlow(const float& glow) { _glow = glow; } void setGlow(const float& glow) { _glow = glow; }
void setGlowWidth(const float& glowWidth) { _glowWidth = glowWidth; } void setGlowWidth(const float& glowWidth) { _glowWidth = glowWidth; }
@ -44,6 +45,8 @@ public:
virtual Line3DOverlay* createClone() const override; virtual Line3DOverlay* createClone() const override;
virtual void locationChanged(bool tellPhysics = true) override;
protected: protected:
glm::vec3 _start; glm::vec3 _start;
glm::vec3 _end; glm::vec3 _end;

View file

@ -346,15 +346,13 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
auto sceneStage = scene->getStage(); auto sceneStage = scene->getStage();
auto skyStage = scene->getSkyStage(); auto skyStage = scene->getSkyStage();
auto sceneKeyLight = sceneStage->getKeyLight(); auto sceneKeyLight = sceneStage->getKeyLight();
auto sceneLocation = sceneStage->getLocation();
auto sceneTime = sceneStage->getTime();
// Skybox and procedural skybox data // Skybox and procedural skybox data
auto skybox = std::dynamic_pointer_cast<ProceduralSkybox>(skyStage->getSkybox()); auto skybox = std::dynamic_pointer_cast<ProceduralSkybox>(skyStage->getSkybox());
static QString userData;
// If there is no zone, use the default background
if (!zone) { if (!zone) {
userData = QString(); _zoneUserData = QString();
skybox->clear(); skybox->clear();
_pendingSkyboxTexture = false; _pendingSkyboxTexture = false;
@ -363,50 +361,33 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
_pendingAmbientTexture = false; _pendingAmbientTexture = false;
_ambientTexture.clear(); _ambientTexture.clear();
if (_hasPreviousZone) {
sceneKeyLight->resetAmbientSphere(); sceneKeyLight->resetAmbientSphere();
sceneKeyLight->setAmbientMap(nullptr); sceneKeyLight->setAmbientMap(nullptr);
sceneKeyLight->setColor(_previousKeyLightColor);
sceneKeyLight->setIntensity(_previousKeyLightIntensity);
sceneKeyLight->setAmbientIntensity(_previousKeyLightAmbientIntensity);
sceneKeyLight->setDirection(_previousKeyLightDirection);
sceneStage->setSunModelEnable(_previousStageSunModelEnabled);
sceneStage->setLocation(_previousStageLongitude, _previousStageLatitude,
_previousStageAltitude);
sceneTime->setHour(_previousStageHour);
sceneTime->setDay(_previousStageDay);
_hasPreviousZone = false; skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT);
} return;
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application background through
return; // Early exit
}
if (!_hasPreviousZone) {
_previousKeyLightColor = sceneKeyLight->getColor();
_previousKeyLightIntensity = sceneKeyLight->getIntensity();
_previousKeyLightAmbientIntensity = sceneKeyLight->getAmbientIntensity();
_previousKeyLightDirection = sceneKeyLight->getDirection();
_previousStageSunModelEnabled = sceneStage->isSunModelEnabled();
_previousStageLongitude = sceneLocation->getLongitude();
_previousStageLatitude = sceneLocation->getLatitude();
_previousStageAltitude = sceneLocation->getAltitude();
_previousStageHour = sceneTime->getHour();
_previousStageDay = sceneTime->getDay();
_hasPreviousZone = true;
} }
// Set the keylight
sceneKeyLight->setColor(ColorUtils::toVec3(zone->getKeyLightProperties().getColor())); sceneKeyLight->setColor(ColorUtils::toVec3(zone->getKeyLightProperties().getColor()));
sceneKeyLight->setIntensity(zone->getKeyLightProperties().getIntensity()); sceneKeyLight->setIntensity(zone->getKeyLightProperties().getIntensity());
sceneKeyLight->setAmbientIntensity(zone->getKeyLightProperties().getAmbientIntensity()); sceneKeyLight->setAmbientIntensity(zone->getKeyLightProperties().getAmbientIntensity());
sceneKeyLight->setDirection(zone->getKeyLightProperties().getDirection()); sceneKeyLight->setDirection(zone->getKeyLightProperties().getDirection());
sceneStage->setSunModelEnable(zone->getStageProperties().getSunModelEnabled());
sceneStage->setLocation(zone->getStageProperties().getLongitude(), zone->getStageProperties().getLatitude(), // Set the stage
bool isSunModelEnabled = zone->getStageProperties().getSunModelEnabled();
sceneStage->setSunModelEnable(isSunModelEnabled);
if (isSunModelEnabled) {
sceneStage->setLocation(zone->getStageProperties().getLongitude(),
zone->getStageProperties().getLatitude(),
zone->getStageProperties().getAltitude()); zone->getStageProperties().getAltitude());
auto sceneTime = sceneStage->getTime();
sceneTime->setHour(zone->getStageProperties().calculateHour()); sceneTime->setHour(zone->getStageProperties().calculateHour());
sceneTime->setDay(zone->getStageProperties().calculateDay()); sceneTime->setDay(zone->getStageProperties().calculateDay());
}
// Set the ambient texture
bool isAmbientTextureSet = false; bool isAmbientTextureSet = false;
if (zone->getKeyLightProperties().getAmbientURL().isEmpty()) { if (zone->getKeyLightProperties().getAmbientURL().isEmpty()) {
_pendingAmbientTexture = false; _pendingAmbientTexture = false;
@ -429,12 +410,13 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
} }
} }
// Set the skybox texture
switch (zone->getBackgroundMode()) { switch (zone->getBackgroundMode()) {
case BACKGROUND_MODE_SKYBOX: { case BACKGROUND_MODE_SKYBOX: {
skybox->setColor(zone->getSkyboxProperties().getColorVec3()); skybox->setColor(zone->getSkyboxProperties().getColorVec3());
if (userData != zone->getUserData()) { if (_zoneUserData != zone->getUserData()) {
userData = zone->getUserData(); _zoneUserData = zone->getUserData();
skybox->parse(userData); skybox->parse(_zoneUserData);
} }
if (zone->getSkyboxProperties().getURL().isEmpty()) { if (zone->getSkyboxProperties().getURL().isEmpty()) {
skybox->setCubemap(nullptr); skybox->setCubemap(nullptr);
@ -471,14 +453,18 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
case BACKGROUND_MODE_INHERIT: case BACKGROUND_MODE_INHERIT:
default: default:
// Clear the skybox to release its textures // Clear the skybox to release its textures
userData = QString(); _zoneUserData = QString();
skybox->clear(); skybox->clear();
_skyboxTexture.clear(); _skyboxTexture.clear();
_pendingSkyboxTexture = false; _pendingSkyboxTexture = false;
// Let the application background through // Let the application background through
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); if (isAmbientTextureSet) {
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT_TEXTURE);
} else {
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT_AMBIENT_TEXTURE);
}
break; break;
} }

View file

@ -185,10 +185,11 @@ private:
QMultiMap<QUrl, EntityItemID> _waitingOnPreload; QMultiMap<QUrl, EntityItemID> _waitingOnPreload;
bool _hasPreviousZone { false };
std::shared_ptr<ZoneEntityItem> _bestZone; std::shared_ptr<ZoneEntityItem> _bestZone;
float _bestZoneVolume; float _bestZoneVolume;
QString _zoneUserData;
quint64 _lastZoneCheck { 0 }; quint64 _lastZoneCheck { 0 };
const quint64 ZONE_CHECK_INTERVAL = USECS_PER_MSEC * 100; // ~10hz const quint64 ZONE_CHECK_INTERVAL = USECS_PER_MSEC * 100; // ~10hz
const float ZONE_CHECK_DISTANCE = 0.001f; const float ZONE_CHECK_DISTANCE = 0.001f;

View file

@ -244,21 +244,6 @@ void SunSkyStage::updateGraphicsObject() const {
double originAlt = _earthSunModel.getAltitude(); double originAlt = _earthSunModel.getAltitude();
_sunLight->setPosition(Vec3(0.0f, originAlt, 0.0f)); _sunLight->setPosition(Vec3(0.0f, originAlt, 0.0f));
} }
// Background
switch (getBackgroundMode()) {
case NO_BACKGROUND: {
break;
}
case SKY_DOME: {
break;
}
case SKY_BOX: {
break;
}
case NUM_BACKGROUND_MODES:
Q_UNREACHABLE();
};
} }
void SunSkyStage::setBackgroundMode(BackgroundMode mode) { void SunSkyStage::setBackgroundMode(BackgroundMode mode) {

View file

@ -160,8 +160,10 @@ public:
enum BackgroundMode { enum BackgroundMode {
NO_BACKGROUND = 0, NO_BACKGROUND = 0,
SKY_DOME, SKY_DEFAULT,
SKY_BOX, SKY_BOX,
SKY_DEFAULT_AMBIENT_TEXTURE,
SKY_DEFAULT_TEXTURE,
NUM_BACKGROUND_MODES, NUM_BACKGROUND_MODES,
}; };
@ -173,7 +175,7 @@ public:
const SkyboxPointer& getSkybox() const { valid(); return _skybox; } const SkyboxPointer& getSkybox() const { valid(); return _skybox; }
protected: protected:
BackgroundMode _backgroundMode = SKY_DOME; BackgroundMode _backgroundMode = SKY_DEFAULT;
LightPointer _sunLight; LightPointer _sunLight;
mutable SkyboxPointer _skybox; mutable SkyboxPointer _skybox;

View file

@ -345,10 +345,6 @@ namespace render {
break; break;
} }
} }
// Fall through: if no skybox is available, render the SKY_DOME
case model::SunSkyStage::SKY_DOME:
case model::SunSkyStage::NO_BACKGROUND:
default: default:
// this line intentionally left blank // this line intentionally left blank
break; break;