Merge pull request #12147 from NissimHadar/noBackgroundModeFix

Dealing with legacy domains.
This commit is contained in:
NissimHadar 2018-01-12 12:42:11 -08:00 committed by GitHub
commit e580a19677
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 27 deletions

View file

@ -185,11 +185,9 @@ public:
DEFINE_PROPERTY_REF(PROP_VOXEL_SURFACE_STYLE, VoxelSurfaceStyle, voxelSurfaceStyle, uint16_t, PolyVoxEntityItem::DEFAULT_VOXEL_SURFACE_STYLE); DEFINE_PROPERTY_REF(PROP_VOXEL_SURFACE_STYLE, VoxelSurfaceStyle, voxelSurfaceStyle, uint16_t, PolyVoxEntityItem::DEFAULT_VOXEL_SURFACE_STYLE);
DEFINE_PROPERTY_REF(PROP_NAME, Name, name, QString, ENTITY_ITEM_DEFAULT_NAME); DEFINE_PROPERTY_REF(PROP_NAME, Name, name, QString, ENTITY_ITEM_DEFAULT_NAME);
DEFINE_PROPERTY_REF_ENUM(PROP_KEY_LIGHT_MODE, KeyLightMode, keyLightMode, uint32_t, (uint32_t)COMPONENT_MODE_ENABLED); DEFINE_PROPERTY_REF_ENUM(PROP_KEY_LIGHT_MODE, KeyLightMode, keyLightMode, uint32_t, (uint32_t)COMPONENT_MODE_INHERIT);
DEFINE_PROPERTY_REF_ENUM(PROP_SKYBOX_MODE, SkyboxMode, skyboxMode, uint32_t, (uint32_t)COMPONENT_MODE_ENABLED); DEFINE_PROPERTY_REF_ENUM(PROP_SKYBOX_MODE, SkyboxMode, skyboxMode, uint32_t, (uint32_t)COMPONENT_MODE_INHERIT);
DEFINE_PROPERTY_REF_ENUM(PROP_AMBIENT_LIGHT_MODE, AmbientLightMode, ambientLightMode, uint32_t, (uint32_t)COMPONENT_MODE_ENABLED); DEFINE_PROPERTY_REF_ENUM(PROP_AMBIENT_LIGHT_MODE, AmbientLightMode, ambientLightMode, uint32_t, (uint32_t)COMPONENT_MODE_INHERIT);
// This is the default mode for zone creation
DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, uint32_t, (uint32_t)COMPONENT_MODE_INHERIT); DEFINE_PROPERTY_REF_ENUM(PROP_HAZE_MODE, HazeMode, hazeMode, uint32_t, (uint32_t)COMPONENT_MODE_INHERIT);
DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup); DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup);

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:
@ -2237,10 +2235,14 @@ bool EntityTree::writeToMap(QVariantMap& entityDescription, OctreeElementPointer
} }
bool EntityTree::readFromMap(QVariantMap& map) { bool EntityTree::readFromMap(QVariantMap& map) {
// These are needed to deal with older content (before adding inheritance modes)
int contentVersion = map["Version"].toInt();
bool needsConversion = (contentVersion < (int)EntityVersion::ZoneLightInheritModes);
// map will have a top-level list keyed as "Entities". This will be extracted // map will have a top-level list keyed as "Entities". This will be extracted
// and iterated over. Each member of this list is converted to a QVariantMap, then // and iterated over. Each member of this list is converted to a QVariantMap, then
// to a QScriptValue, and then to EntityItemProperties. These properties are used // to a QScriptValue, and then to EntityItemProperties. These properties are used
// to add the new entity to the EnitytTree. // to add the new entity to the EntityTree.
QVariantList entitiesQList = map["Entities"].toList(); QVariantList entitiesQList = map["Entities"].toList();
QScriptEngine scriptEngine; QScriptEngine scriptEngine;
@ -2281,29 +2283,30 @@ 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) { if (needsConversion && (properties.getType() == EntityTypes::EntityType::Zone)) {
if (!entityMap.contains("keyLightMode")) { // The ambient URL has been moved from "keyLight" to "ambientLight"
properties.setKeyLightMode(COMPONENT_MODE_ENABLED); if (entityMap.contains("keyLight")) {
QVariantMap keyLightObject = entityMap["keyLight"].toMap();
properties.getAmbientLight().setAmbientURL(keyLightObject["ambientURL"].toString());
} }
if (!entityMap.contains("skyboxMode")) { // The background should be enabled if the mode is skybox
if (entityMap.contains("backgroundMode") && (entityMap["backgroundMode"].toString() == "nothing")) { // Note that if the values are default then they are not stored in the JSON file
properties.setSkyboxMode(COMPONENT_MODE_INHERIT); if (entityMap.contains("backgroundMode") && (entityMap["backgroundMode"].toString() == "skybox")) {
} else { properties.setSkyboxMode(COMPONENT_MODE_ENABLED);
// 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
if (properties.getAmbientLight().getAmbientURL() == "") {
// Copy the skybox URL if the ambient URL is empty, as this is the legacy behaviour properties.getAmbientLight().setAmbientURL(properties.getSkybox().getURL());
if (properties.getAmbientLight().getAmbientURL() == "") {
properties.getAmbientLight().setAmbientURL(properties.getSkybox().getURL());
}
} }
} else {
properties.setSkyboxMode(COMPONENT_MODE_INHERIT);
} }
if (!entityMap.contains("ambientLightMode")) { // The legacy version had no keylight/ambient modes - these are always on
properties.setAmbientLightMode(COMPONENT_MODE_ENABLED); properties.setKeyLightMode(COMPONENT_MODE_ENABLED);
} properties.setAmbientLightMode(COMPONENT_MODE_ENABLED);
} }
EntityItemPointer entity = addEntity(entityItemID, properties); EntityItemPointer entity = addEntity(entityItemID, properties);
@ -2312,6 +2315,7 @@ bool EntityTree::readFromMap(QVariantMap& map) {
success = false; success = false;
} }
} }
return success; return success;
} }

View file

@ -196,13 +196,15 @@ void sendWrongProtocolVersionsSignature(bool sendWrongVersion); /// for debuggin
uint qHash(const PacketType& key, uint seed); uint qHash(const PacketType& key, uint seed);
QDebug operator<<(QDebug debug, const PacketType& type); QDebug operator<<(QDebug debug, const PacketType& type);
// Due to the different legacy behaviour, we need special processing for domains that were created before
// the zone inheritance modes were added. These have version numbers up to 80
enum class EntityVersion : PacketVersion { enum class EntityVersion : PacketVersion {
StrokeColorProperty = 0, StrokeColorProperty = 0,
HasDynamicOwnershipTests, HasDynamicOwnershipTests,
HazeEffect, HazeEffect,
StaticCertJsonVersionOne, StaticCertJsonVersionOne,
OwnershipChallengeFix, OwnershipChallengeFix,
ZoneLightInheritModes, ZoneLightInheritModes = 82,
ZoneStageRemoved ZoneStageRemoved
}; };