mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 02:48:12 +02:00
Merge pull request #14737 from SamGondelman/zone
Case 19291: Fix zone bugs
This commit is contained in:
commit
851b968501
6 changed files with 51 additions and 57 deletions
|
@ -198,24 +198,33 @@ void ZoneEntityRenderer::removeFromScene(const ScenePointer& scene, Transaction&
|
||||||
void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
|
void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
|
||||||
DependencyManager::get<EntityTreeRenderer>()->updateZone(entity->getID());
|
DependencyManager::get<EntityTreeRenderer>()->updateZone(entity->getID());
|
||||||
|
|
||||||
|
auto position = entity->getWorldPosition();
|
||||||
|
auto rotation = entity->getWorldOrientation();
|
||||||
|
auto dimensions = entity->getScaledDimensions();
|
||||||
|
bool rotationChanged = rotation != _lastRotation;
|
||||||
|
bool transformChanged = rotationChanged || position != _lastPosition || dimensions != _lastDimensions;
|
||||||
|
|
||||||
|
auto proceduralUserData = entity->getUserData();
|
||||||
|
bool proceduralUserDataChanged = _proceduralUserData != proceduralUserData;
|
||||||
|
|
||||||
// FIXME one of the bools here could become true between being fetched and being reset,
|
// FIXME one of the bools here could become true between being fetched and being reset,
|
||||||
// resulting in a lost update
|
// resulting in a lost update
|
||||||
bool keyLightChanged = entity->keyLightPropertiesChanged();
|
bool keyLightChanged = entity->keyLightPropertiesChanged() || rotationChanged;
|
||||||
bool ambientLightChanged = entity->ambientLightPropertiesChanged();
|
bool ambientLightChanged = entity->ambientLightPropertiesChanged() || transformChanged;
|
||||||
bool skyboxChanged = entity->skyboxPropertiesChanged();
|
bool skyboxChanged = entity->skyboxPropertiesChanged() || proceduralUserDataChanged;
|
||||||
bool hazeChanged = entity->hazePropertiesChanged();
|
bool hazeChanged = entity->hazePropertiesChanged();
|
||||||
bool bloomChanged = entity->bloomPropertiesChanged();
|
bool bloomChanged = entity->bloomPropertiesChanged();
|
||||||
|
|
||||||
entity->resetRenderingPropertiesChanged();
|
entity->resetRenderingPropertiesChanged();
|
||||||
_lastPosition = entity->getWorldPosition();
|
|
||||||
_lastRotation = entity->getWorldOrientation();
|
|
||||||
_lastDimensions = entity->getScaledDimensions();
|
|
||||||
|
|
||||||
_keyLightProperties = entity->getKeyLightProperties();
|
if (transformChanged) {
|
||||||
_ambientLightProperties = entity->getAmbientLightProperties();
|
_lastPosition = entity->getWorldPosition();
|
||||||
_skyboxProperties = entity->getSkyboxProperties();
|
_lastRotation = entity->getWorldOrientation();
|
||||||
_hazeProperties = entity->getHazeProperties();
|
_lastDimensions = entity->getScaledDimensions();
|
||||||
_bloomProperties = entity->getBloomProperties();
|
}
|
||||||
|
|
||||||
|
if (proceduralUserDataChanged) {
|
||||||
|
_proceduralUserData = entity->getUserData();
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (_lastShapeURL != _typedEntity->getCompoundShapeURL()) {
|
if (_lastShapeURL != _typedEntity->getCompoundShapeURL()) {
|
||||||
|
@ -239,21 +248,29 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
|
||||||
updateKeyZoneItemFromEntity(entity);
|
updateKeyZoneItemFromEntity(entity);
|
||||||
|
|
||||||
if (keyLightChanged) {
|
if (keyLightChanged) {
|
||||||
|
_keyLightProperties = entity->getKeyLightProperties();
|
||||||
updateKeySunFromEntity(entity);
|
updateKeySunFromEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ambientLightChanged) {
|
if (ambientLightChanged) {
|
||||||
|
_ambientLightProperties = entity->getAmbientLightProperties();
|
||||||
updateAmbientLightFromEntity(entity);
|
updateAmbientLightFromEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skyboxChanged || _proceduralUserData != entity->getUserData()) {
|
if (skyboxChanged) {
|
||||||
|
_skyboxProperties = entity->getSkyboxProperties();
|
||||||
updateKeyBackgroundFromEntity(entity);
|
updateKeyBackgroundFromEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hazeChanged) {
|
if (hazeChanged) {
|
||||||
|
_hazeProperties = entity->getHazeProperties();
|
||||||
updateHazeFromEntity(entity);
|
updateHazeFromEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bloomChanged) {
|
||||||
|
_bloomProperties = entity->getBloomProperties();
|
||||||
|
updateBloomFromEntity(entity);
|
||||||
|
}
|
||||||
|
|
||||||
bool visuallyReady = true;
|
bool visuallyReady = true;
|
||||||
uint32_t skyboxMode = entity->getSkyboxMode();
|
uint32_t skyboxMode = entity->getSkyboxMode();
|
||||||
|
@ -264,10 +281,6 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
|
||||||
}
|
}
|
||||||
|
|
||||||
entity->setVisuallyReady(visuallyReady);
|
entity->setVisuallyReady(visuallyReady);
|
||||||
|
|
||||||
if (bloomChanged) {
|
|
||||||
updateBloomFromEntity(entity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
void ZoneEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
||||||
|
@ -344,7 +357,7 @@ void ZoneEntityRenderer::updateKeySunFromEntity(const TypedEntityPointer& entity
|
||||||
// Set the keylight
|
// Set the keylight
|
||||||
sunLight->setColor(ColorUtils::toVec3(_keyLightProperties.getColor()));
|
sunLight->setColor(ColorUtils::toVec3(_keyLightProperties.getColor()));
|
||||||
sunLight->setIntensity(_keyLightProperties.getIntensity());
|
sunLight->setIntensity(_keyLightProperties.getIntensity());
|
||||||
sunLight->setDirection(entity->getTransform().getRotation() * _keyLightProperties.getDirection());
|
sunLight->setDirection(_lastRotation * _keyLightProperties.getDirection());
|
||||||
sunLight->setCastShadows(_keyLightProperties.getCastShadows());
|
sunLight->setCastShadows(_keyLightProperties.getCastShadows());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +369,6 @@ void ZoneEntityRenderer::updateAmbientLightFromEntity(const TypedEntityPointer&
|
||||||
ambientLight->setPosition(_lastPosition);
|
ambientLight->setPosition(_lastPosition);
|
||||||
ambientLight->setOrientation(_lastRotation);
|
ambientLight->setOrientation(_lastRotation);
|
||||||
|
|
||||||
|
|
||||||
// Set the ambient light
|
// Set the ambient light
|
||||||
ambientLight->setAmbientIntensity(_ambientLightProperties.getAmbientIntensity());
|
ambientLight->setAmbientIntensity(_ambientLightProperties.getAmbientIntensity());
|
||||||
|
|
||||||
|
@ -395,8 +407,6 @@ void ZoneEntityRenderer::updateHazeFromEntity(const TypedEntityPointer& entity)
|
||||||
haze->setHazeAttenuateKeyLight(_hazeProperties.getHazeAttenuateKeyLight());
|
haze->setHazeAttenuateKeyLight(_hazeProperties.getHazeAttenuateKeyLight());
|
||||||
haze->setHazeKeyLightRangeFactor(graphics::Haze::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange()));
|
haze->setHazeKeyLightRangeFactor(graphics::Haze::convertHazeRangeToHazeRangeFactor(_hazeProperties.getHazeKeyLightRange()));
|
||||||
haze->setHazeKeyLightAltitudeFactor(graphics::Haze::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude()));
|
haze->setHazeKeyLightAltitudeFactor(graphics::Haze::convertHazeAltitudeToHazeAltitudeFactor(_hazeProperties.getHazeKeyLightAltitude()));
|
||||||
|
|
||||||
haze->setTransform(entity->getTransform().getMatrix());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneEntityRenderer::updateBloomFromEntity(const TypedEntityPointer& entity) {
|
void ZoneEntityRenderer::updateBloomFromEntity(const TypedEntityPointer& entity) {
|
||||||
|
@ -414,13 +424,13 @@ void ZoneEntityRenderer::updateKeyBackgroundFromEntity(const TypedEntityPointer&
|
||||||
|
|
||||||
editBackground();
|
editBackground();
|
||||||
setSkyboxColor(toGlm(_skyboxProperties.getColor()));
|
setSkyboxColor(toGlm(_skyboxProperties.getColor()));
|
||||||
setProceduralUserData(entity->getUserData());
|
setProceduralUserData(_proceduralUserData);
|
||||||
setSkyboxURL(_skyboxProperties.getURL());
|
setSkyboxURL(_skyboxProperties.getURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneEntityRenderer::updateKeyZoneItemFromEntity(const TypedEntityPointer& entity) {
|
void ZoneEntityRenderer::updateKeyZoneItemFromEntity(const TypedEntityPointer& entity) {
|
||||||
// Update rotation values
|
// Update rotation values
|
||||||
editSkybox()->setOrientation(entity->getTransform().getRotation());
|
editSkybox()->setOrientation(_lastRotation);
|
||||||
|
|
||||||
/* TODO: Implement the sun model behavior / Keep this code here for reference, this is how we
|
/* TODO: Implement the sun model behavior / Keep this code here for reference, this is how we
|
||||||
{
|
{
|
||||||
|
@ -540,9 +550,6 @@ void ZoneEntityRenderer::setSkyboxColor(const glm::vec3& color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneEntityRenderer::setProceduralUserData(const QString& userData) {
|
void ZoneEntityRenderer::setProceduralUserData(const QString& userData) {
|
||||||
if (_proceduralUserData != userData) {
|
std::dynamic_pointer_cast<ProceduralSkybox>(editSkybox())->parse(userData);
|
||||||
_proceduralUserData = userData;
|
|
||||||
std::dynamic_pointer_cast<ProceduralSkybox>(editSkybox())->parse(_proceduralUserData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ bool ZoneEntityItem::setSubClassProperties(const EntityItemProperties& propertie
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(bloomMode, setBloomMode);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(bloomMode, setBloomMode);
|
||||||
|
|
||||||
somethingChanged = somethingChanged || _keyLightPropertiesChanged || _ambientLightPropertiesChanged ||
|
somethingChanged = somethingChanged || _keyLightPropertiesChanged || _ambientLightPropertiesChanged ||
|
||||||
_stagePropertiesChanged || _skyboxPropertiesChanged || _hazePropertiesChanged || _bloomPropertiesChanged;
|
_skyboxPropertiesChanged || _hazePropertiesChanged || _bloomPropertiesChanged;
|
||||||
|
|
||||||
return somethingChanged;
|
return somethingChanged;
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,6 @@ void ZoneEntityItem::resetRenderingPropertiesChanged() {
|
||||||
_skyboxPropertiesChanged = false;
|
_skyboxPropertiesChanged = false;
|
||||||
_hazePropertiesChanged = false;
|
_hazePropertiesChanged = false;
|
||||||
_bloomPropertiesChanged = false;
|
_bloomPropertiesChanged = false;
|
||||||
_stagePropertiesChanged = false;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,6 @@ public:
|
||||||
bool hazePropertiesChanged() const { return _hazePropertiesChanged; }
|
bool hazePropertiesChanged() const { return _hazePropertiesChanged; }
|
||||||
bool bloomPropertiesChanged() const { return _bloomPropertiesChanged; }
|
bool bloomPropertiesChanged() const { return _bloomPropertiesChanged; }
|
||||||
|
|
||||||
bool stagePropertiesChanged() const { return _stagePropertiesChanged; }
|
|
||||||
|
|
||||||
void resetRenderingPropertiesChanged();
|
void resetRenderingPropertiesChanged();
|
||||||
|
|
||||||
virtual bool supportsDetailedIntersection() const override { return true; }
|
virtual bool supportsDetailedIntersection() const override { return true; }
|
||||||
|
@ -155,7 +153,6 @@ protected:
|
||||||
bool _skyboxPropertiesChanged { false };
|
bool _skyboxPropertiesChanged { false };
|
||||||
bool _hazePropertiesChanged{ false };
|
bool _hazePropertiesChanged{ false };
|
||||||
bool _bloomPropertiesChanged { false };
|
bool _bloomPropertiesChanged { false };
|
||||||
bool _stagePropertiesChanged { false };
|
|
||||||
|
|
||||||
static bool _drawZoneBoundaries;
|
static bool _drawZoneBoundaries;
|
||||||
static bool _zonesArePickable;
|
static bool _zonesArePickable;
|
||||||
|
|
|
@ -182,12 +182,3 @@ void Haze::setHazeBackgroundBlend(const float hazeBackgroundBlend) {
|
||||||
_hazeParametersBuffer.edit<Parameters>().hazeBackgroundBlend = newBlend;
|
_hazeParametersBuffer.edit<Parameters>().hazeBackgroundBlend = newBlend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Haze::setTransform(const glm::mat4& transform) {
|
|
||||||
auto& params = _hazeParametersBuffer.get<Parameters>();
|
|
||||||
|
|
||||||
if (params.transform != transform) {
|
|
||||||
_hazeParametersBuffer.edit<Parameters>().transform = transform;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,6 @@ namespace graphics {
|
||||||
|
|
||||||
void setHazeBackgroundBlend(const float hazeBackgroundBlend);
|
void setHazeBackgroundBlend(const float hazeBackgroundBlend);
|
||||||
|
|
||||||
void setTransform(const glm::mat4& transform);
|
|
||||||
|
|
||||||
using UniformBufferView = gpu::BufferView;
|
using UniformBufferView = gpu::BufferView;
|
||||||
UniformBufferView getHazeParametersBuffer() const { return _hazeParametersBuffer; }
|
UniformBufferView getHazeParametersBuffer() const { return _hazeParametersBuffer; }
|
||||||
|
|
||||||
|
@ -101,30 +99,32 @@ namespace graphics {
|
||||||
class Parameters {
|
class Parameters {
|
||||||
public:
|
public:
|
||||||
// DO NOT CHANGE ORDER HERE WITHOUT UNDERSTANDING THE std140 LAYOUT
|
// DO NOT CHANGE ORDER HERE WITHOUT UNDERSTANDING THE std140 LAYOUT
|
||||||
glm::vec3 hazeColor{ INITIAL_HAZE_COLOR };
|
glm::vec3 hazeColor { INITIAL_HAZE_COLOR };
|
||||||
float hazeGlareBlend{ convertGlareAngleToPower(INITIAL_HAZE_GLARE_ANGLE) };
|
float hazeGlareBlend { convertGlareAngleToPower(INITIAL_HAZE_GLARE_ANGLE) };
|
||||||
|
|
||||||
glm::vec3 hazeGlareColor{ INITIAL_HAZE_GLARE_COLOR };
|
glm::vec3 hazeGlareColor { INITIAL_HAZE_GLARE_COLOR };
|
||||||
float hazeBaseReference{ INITIAL_HAZE_BASE_REFERENCE };
|
float hazeBaseReference { INITIAL_HAZE_BASE_REFERENCE };
|
||||||
|
|
||||||
glm::vec3 colorModulationFactor;
|
glm::vec3 colorModulationFactor;
|
||||||
int hazeMode{ 0 }; // bit 0 - set to activate haze attenuation of fragment color
|
int hazeMode { 0 }; // bit 0 - set to activate haze attenuation of fragment color
|
||||||
// bit 1 - set to add the effect of altitude to the haze attenuation
|
// bit 1 - set to add the effect of altitude to the haze attenuation
|
||||||
// bit 2 - set to activate directional light attenuation mode
|
// bit 2 - set to activate directional light attenuation mode
|
||||||
// bit 3 - set to blend between blend-in and blend-out colours
|
// bit 3 - set to blend between blend-in and blend-out colours
|
||||||
|
|
||||||
glm::mat4 transform;
|
// Padding required to align the struct
|
||||||
|
#if defined(__clang__)
|
||||||
|
__attribute__((unused))
|
||||||
|
#endif
|
||||||
|
vec3 __padding;
|
||||||
|
|
||||||
// Amount of background (skybox) to display, overriding the haze effect for the background
|
// Amount of background (skybox) to display, overriding the haze effect for the background
|
||||||
float hazeBackgroundBlend{ INITIAL_HAZE_BACKGROUND_BLEND };
|
float hazeBackgroundBlend { INITIAL_HAZE_BACKGROUND_BLEND };
|
||||||
// The haze attenuation exponents used by both fragment and directional light attenuation
|
// The haze attenuation exponents used by both fragment and directional light attenuation
|
||||||
float hazeRangeFactor{ convertHazeRangeToHazeRangeFactor(INITIAL_HAZE_RANGE) };
|
float hazeRangeFactor { convertHazeRangeToHazeRangeFactor(INITIAL_HAZE_RANGE) };
|
||||||
float hazeHeightFactor{ convertHazeAltitudeToHazeAltitudeFactor(INITIAL_HAZE_HEIGHT) };
|
float hazeHeightFactor { convertHazeAltitudeToHazeAltitudeFactor(INITIAL_HAZE_HEIGHT) };
|
||||||
float hazeKeyLightRangeFactor{ convertHazeRangeToHazeRangeFactor(INITIAL_KEY_LIGHT_RANGE) };
|
float hazeKeyLightRangeFactor { convertHazeRangeToHazeRangeFactor(INITIAL_KEY_LIGHT_RANGE) };
|
||||||
|
|
||||||
float hazeKeyLightAltitudeFactor{ convertHazeAltitudeToHazeAltitudeFactor(INITIAL_KEY_LIGHT_ALTITUDE) };
|
float hazeKeyLightAltitudeFactor { convertHazeAltitudeToHazeAltitudeFactor(INITIAL_KEY_LIGHT_ALTITUDE) };
|
||||||
// Padding required to align the structure to sizeof(vec4)
|
|
||||||
vec3 __padding;
|
|
||||||
|
|
||||||
Parameters() {}
|
Parameters() {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct HazeParams {
|
||||||
vec3 colorModulationFactor;
|
vec3 colorModulationFactor;
|
||||||
int hazeMode;
|
int hazeMode;
|
||||||
|
|
||||||
mat4 transform;
|
vec3 spare;
|
||||||
float backgroundBlend;
|
float backgroundBlend;
|
||||||
|
|
||||||
float hazeRangeFactor;
|
float hazeRangeFactor;
|
||||||
|
|
Loading…
Reference in a new issue