Corrected default values - for reading legacy content.

This commit is contained in:
Nissim Hadar 2018-01-11 14:53:58 -08:00
parent d1cd2d9c96
commit 4bd09fd9af
2 changed files with 18 additions and 22 deletions

View file

@ -39,11 +39,9 @@
#include "EntityEditFilters.h" #include "EntityEditFilters.h"
#include "EntityDynamicFactoryInterface.h" #include "EntityDynamicFactoryInterface.h"
static const quint64 DELETED_ENTITIES_EXTRA_USECS_TO_CONSIDER = USECS_PER_MSEC * 50; static const quint64 DELETED_ENTITIES_EXTRA_USECS_TO_CONSIDER = USECS_PER_MSEC * 50;
const float EntityTree::DEFAULT_MAX_TMP_ENTITY_LIFETIME = 60 * 60; // 1 hour const float EntityTree::DEFAULT_MAX_TMP_ENTITY_LIFETIME = 60 * 60; // 1 hour
// combines the ray cast arguments into a single object // combines the ray cast arguments into a single object
class RayArgs { class RayArgs {
public: public:
@ -2281,30 +2279,27 @@ bool EntityTree::readFromMap(QVariantMap& map) {
properties.setOwningAvatarID(myNodeID); properties.setOwningAvatarID(myNodeID);
} }
// TEMPORARY fix for older content not containing these fields in the zones // Fix for older content not containing these fields in the zones
if (properties.getType() == EntityTypes::EntityType::Zone) { int contentVersion = map["Version"].toInt();
if (!entityMap.contains("keyLightMode")) { bool needsConversion = (contentVersion < (int)EntityVersion::ZoneLightInheritModes);
properties.setKeyLightMode(COMPONENT_MODE_ENABLED); if (needsConversion && (properties.getType() == EntityTypes::EntityType::Zone)) {
// The background should be enabled if the mode is skybox
// Note that if the values are default then they are not stored in the JSON file
if (entityMap.contains("backgroundMode") && (entityMap["backgroundMode"].toString() == "skybox")) {
properties.setSkyboxMode(COMPONENT_MODE_ENABLED);
} else {
properties.setSkyboxMode(COMPONENT_MODE_INHERIT);
} }
if (!entityMap.contains("skyboxMode")) { // The legacy version had no keylight/ambient modes - these are always on
if (entityMap.contains("backgroundMode") && (entityMap["backgroundMode"].toString() == "nothing")) { properties.setKeyLightMode(COMPONENT_MODE_ENABLED);
properties.setSkyboxMode(COMPONENT_MODE_INHERIT); properties.setAmbientLightMode(COMPONENT_MODE_ENABLED);
} else {
// Either the background mode field is missing (shouldn't happen) or the background mode is "skybox"
properties.setSkyboxMode(COMPONENT_MODE_ENABLED);
// Copy the skybox URL if the ambient URL is empty, as this is the legacy behaviour // Copy the skybox URL if the ambient URL is empty, as this is the legacy behaviour
if (properties.getAmbientLight().getAmbientURL() == "") { if (properties.getAmbientLight().getAmbientURL() == "") {
properties.getAmbientLight().setAmbientURL(properties.getSkybox().getURL()); properties.getAmbientLight().setAmbientURL(properties.getSkybox().getURL());
} }
} }
}
if (!entityMap.contains("ambientLightMode")) {
properties.setAmbientLightMode(COMPONENT_MODE_ENABLED);
}
}
EntityItemPointer entity = addEntity(entityItemID, properties); EntityItemPointer entity = addEntity(entityItemID, properties);
if (!entity) { if (!entity) {
@ -2312,6 +2307,7 @@ bool EntityTree::readFromMap(QVariantMap& map) {
success = false; success = false;
} }
} }
return success; return success;
} }

View file

@ -202,7 +202,7 @@ enum class EntityVersion : PacketVersion {
HazeEffect, HazeEffect,
StaticCertJsonVersionOne, StaticCertJsonVersionOne,
OwnershipChallengeFix, OwnershipChallengeFix,
ZoneLightInheritModes, ZoneLightInheritModes = 82,
ZoneStageRemoved ZoneStageRemoved
}; };