mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 12:53:03 +02:00
fix issue with skyboxMode getting randomly set
This commit is contained in:
parent
8b3b32c70d
commit
4b9c6728e7
7 changed files with 27 additions and 36 deletions
|
@ -56,16 +56,6 @@ Script.update.connect(function(deltaTime) {
|
|||
print("newIntensity:" + newIntensity);
|
||||
|
||||
Entities.editEntity(zoneEntityA, {
|
||||
skyboxMode: "atmosphere",
|
||||
atmosphere: {
|
||||
center: { x: 1000, y: 0, z: 1000},
|
||||
innerRadius: 1000.0,
|
||||
outerRadius: 1025.0,
|
||||
rayleighScattering: 0.0025,
|
||||
mieScattering: 0.0010,
|
||||
scatteringWavelengths: { x: 0.650, y: 0.570, z: 0.475 },
|
||||
hasStars: false
|
||||
},
|
||||
stageHour: newHour,
|
||||
keyLightIntensity: newIntensity
|
||||
});
|
||||
|
|
|
@ -432,7 +432,12 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
|
|||
EnvironmentData data = _bestZone->getEnvironmentData();
|
||||
glm::vec3 keyLightDirection = scene->getKeyLightDirection();
|
||||
glm::vec3 inverseKeyLightDirection = keyLightDirection * -1.0f;
|
||||
glm::vec3 keyLightLocation = _viewState->getAvatarPosition() + (inverseKeyLightDirection * data.getAtmosphereOuterRadius());
|
||||
|
||||
// NOTE: is this right? It seems like the "sun" should be based on the center of the
|
||||
// atmosphere, not where the camera is.
|
||||
glm::vec3 keyLightLocation = _viewState->getAvatarPosition()
|
||||
+ (inverseKeyLightDirection * data.getAtmosphereOuterRadius());
|
||||
|
||||
data.setSunLocation(keyLightLocation);
|
||||
|
||||
const float KEY_LIGHT_INTENSITY_TO_SUN_BRIGHTNESS_RATIO = 20.0f;
|
||||
|
|
|
@ -47,13 +47,13 @@ void AtmospherePropertyGroup::copyFromScriptValue(const QScriptValue& object, bo
|
|||
|
||||
void AtmospherePropertyGroup::debugDump() const {
|
||||
qDebug() << " AtmospherePropertyGroup: ---------------------------------------------";
|
||||
qDebug() << " Center:" << getCenter();
|
||||
qDebug() << " Inner Radius:" << getInnerRadius();
|
||||
qDebug() << " Outer Radius:" << getOuterRadius();
|
||||
qDebug() << " Mie Scattering:" << getMieScattering();
|
||||
qDebug() << " Rayleigh Scattering:" << getRayleighScattering();
|
||||
qDebug() << " Scattering Wavelengths:" << getScatteringWavelengths();
|
||||
qDebug() << " Has Stars:" << getHasStars();
|
||||
qDebug() << " Center:" << getCenter() << " has changed:" << centerChanged();
|
||||
qDebug() << " Inner Radius:" << getInnerRadius() << " has changed:" << innerRadiusChanged();
|
||||
qDebug() << " Outer Radius:" << getOuterRadius() << " has changed:" << outerRadiusChanged();
|
||||
qDebug() << " Mie Scattering:" << getMieScattering() << " has changed:" << mieScatteringChanged();
|
||||
qDebug() << " Rayleigh Scattering:" << getRayleighScattering() << " has changed:" << rayleighScatteringChanged();
|
||||
qDebug() << " Scattering Wavelengths:" << getScatteringWavelengths() << " has changed:" << scatteringWavelengthsChanged();
|
||||
qDebug() << " Has Stars:" << getHasStars() << " has changed:" << hasStarsChanged();
|
||||
}
|
||||
|
||||
bool AtmospherePropertyGroup::appentToEditPacket(OctreePacketData* packetData,
|
||||
|
|
|
@ -257,11 +257,17 @@ QString EntityItemProperties::getSkyboxModeAsString() const {
|
|||
return QString(skyboxModeNames[SKYBOX_MODE_INHERIT]);
|
||||
}
|
||||
|
||||
void EntityItemProperties::setSkyboxModeFromString(const QString& shapeName) {
|
||||
QString EntityItemProperties::getSkyboxModeString(SkyboxMode mode) {
|
||||
if (mode < sizeof(skyboxModeNames) / sizeof(char *))
|
||||
return QString(skyboxModeNames[mode]);
|
||||
return QString(skyboxModeNames[SKYBOX_MODE_INHERIT]);
|
||||
}
|
||||
|
||||
void EntityItemProperties::setSkyboxModeFromString(const QString& skyboxMode) {
|
||||
if (stringToSkyboxModeLookup.empty()) {
|
||||
buildStringToSkyboxModeLookup();
|
||||
}
|
||||
auto skyboxModeItr = stringToSkyboxModeLookup.find(shapeName.toLower());
|
||||
auto skyboxModeItr = stringToSkyboxModeLookup.find(skyboxMode.toLower());
|
||||
if (skyboxModeItr != stringToSkyboxModeLookup.end()) {
|
||||
_skyboxMode = skyboxModeItr.value();
|
||||
_skyboxModeChanged = true;
|
||||
|
@ -518,11 +524,8 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object) {
|
|||
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(stageAltitude, setStageAltitude);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_INT(stageDay, setStageDay);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(stageHour, setStageHour);
|
||||
|
||||
COPY_PROPERTY_FROM_QSCRITPTVALUE_ENUM(skyboxMode, SkyboxMode);
|
||||
|
||||
_atmosphere.copyFromScriptValue(object, _defaultSettings);
|
||||
|
||||
_lastEdited = usecTimestampNow();
|
||||
}
|
||||
|
||||
|
|
|
@ -141,6 +141,8 @@ public:
|
|||
DEFINE_PROPERTY_GROUP(Atmosphere, atmosphere, AtmospherePropertyGroup);
|
||||
DEFINE_PROPERTY_REF_ENUM(PROP_SKYBOX_MODE, SkyboxMode, skyboxMode, SkyboxMode);
|
||||
|
||||
static QString getSkyboxModeString(SkyboxMode mode);
|
||||
|
||||
|
||||
public:
|
||||
float getMaxDimension() const { return glm::max(_dimensions.x, _dimensions.y, _dimensions.z); }
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
} \
|
||||
}
|
||||
|
||||
|
||||
#define READ_ENTITY_PROPERTY_QUAT(P,M) \
|
||||
if (propertyFlags.getHasProperty(P)) { \
|
||||
glm::quat fromBuffer; \
|
||||
|
@ -458,7 +457,7 @@
|
|||
void set##N##Changed(bool value) { _##n##Changed = value; } \
|
||||
private: \
|
||||
T _##n; \
|
||||
bool _##n##Changed;
|
||||
bool _##n##Changed = false;
|
||||
|
||||
#define DEFINE_PROPERTY_REF(P, N, n, T) \
|
||||
public: \
|
||||
|
@ -468,7 +467,7 @@
|
|||
void set##N##Changed(bool value) { _##n##Changed = value; } \
|
||||
private: \
|
||||
T _##n; \
|
||||
bool _##n##Changed;
|
||||
bool _##n##Changed = false;
|
||||
|
||||
#define DEFINE_PROPERTY_REF_WITH_SETTER(P, N, n, T) \
|
||||
public: \
|
||||
|
|
|
@ -126,7 +126,6 @@ bool ZoneEntityItem::setProperties(const EntityItemProperties& properties) {
|
|||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(stageHour, setStageHour);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, updateShapeType);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(compoundShapeURL, setCompoundShapeURL);
|
||||
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(skyboxMode, setSkyboxMode);
|
||||
|
||||
bool somethingChangedInAtmosphere = _atmospherePropeties.setProperties(properties);
|
||||
|
@ -150,7 +149,6 @@ bool ZoneEntityItem::setProperties(const EntityItemProperties& properties) {
|
|||
int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args,
|
||||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData) {
|
||||
|
||||
int bytesRead = 0;
|
||||
const unsigned char* dataAt = data;
|
||||
|
||||
|
@ -166,13 +164,10 @@ int ZoneEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
|||
READ_ENTITY_PROPERTY(PROP_STAGE_HOUR, float, _stageHour);
|
||||
READ_ENTITY_PROPERTY_SETTER(PROP_SHAPE_TYPE, ShapeType, updateShapeType);
|
||||
READ_ENTITY_PROPERTY_STRING(PROP_COMPOUND_SHAPE_URL, setCompoundShapeURL);
|
||||
|
||||
READ_ENTITY_PROPERTY_SETTER(PROP_SKYBOX_MODE, SkyboxMode, setSkyboxMode);
|
||||
|
||||
bytesRead += _atmospherePropeties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||
propertyFlags, overwriteLocalData);
|
||||
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
|
@ -193,9 +188,7 @@ EntityPropertyFlags ZoneEntityItem::getEntityProperties(EncodeBitstreamParams& p
|
|||
requestedProperties += PROP_STAGE_HOUR;
|
||||
requestedProperties += PROP_SHAPE_TYPE;
|
||||
requestedProperties += PROP_COMPOUND_SHAPE_URL;
|
||||
|
||||
requestedProperties += PROP_SKYBOX_MODE;
|
||||
|
||||
requestedProperties += _atmospherePropeties.getEntityProperties(params);
|
||||
|
||||
return requestedProperties;
|
||||
|
@ -223,8 +216,7 @@ void ZoneEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
|
|||
APPEND_ENTITY_PROPERTY(PROP_STAGE_HOUR, appendValue, getStageHour());
|
||||
APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, appendValue, (uint32_t)getShapeType());
|
||||
APPEND_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, appendValue, getCompoundShapeURL());
|
||||
|
||||
APPEND_ENTITY_PROPERTY(PROP_SKYBOX_MODE, appendValue, (uint32_t)getShapeType()); // could this be a uint16??
|
||||
APPEND_ENTITY_PROPERTY(PROP_SKYBOX_MODE, appendValue, (uint32_t)getSkyboxMode()); // could this be a uint16??
|
||||
|
||||
_atmospherePropeties.appendSubclassData(packetData, params, modelTreeElementExtraEncodeData, requestedProperties,
|
||||
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||
|
@ -247,7 +239,7 @@ void ZoneEntityItem::debugDump() const {
|
|||
qCDebug(entities) << " _stageAltitude:" << _stageAltitude;
|
||||
qCDebug(entities) << " _stageDay:" << _stageDay;
|
||||
qCDebug(entities) << " _stageHour:" << _stageHour;
|
||||
qCDebug(entities) << " _skyboxMode:" << _skyboxMode;
|
||||
qCDebug(entities) << " _skyboxMode:" << EntityItemProperties::getSkyboxModeString(_skyboxMode);
|
||||
|
||||
_atmospherePropeties.debugDump();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue