Merge branch 'master' of github.com:highfidelity/hifi into notificationsForFourApps

This commit is contained in:
Zach Fox 2018-09-21 09:43:30 -07:00
commit e75a45af92
11 changed files with 120 additions and 79 deletions

View file

@ -382,9 +382,8 @@ void ParabolaPointer::RenderState::ParabolaRenderItem::updateBounds() {
const gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::getParabolaPipeline() { const gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::getParabolaPipeline() {
if (!_parabolaPipeline || !_transparentParabolaPipeline) { if (!_parabolaPipeline || !_transparentParabolaPipeline) {
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::parabola);
{ {
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::parabola);
auto state = std::make_shared<gpu::State>(); auto state = std::make_shared<gpu::State>();
state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setBlendFunction(false, state->setBlendFunction(false,
@ -396,6 +395,7 @@ const gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::get
} }
{ {
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::parabola_translucent);
auto state = std::make_shared<gpu::State>(); auto state = std::make_shared<gpu::State>();
state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setBlendFunction(true, state->setBlendFunction(true,

View file

@ -1322,6 +1322,8 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
emit DependencyManager::get<scriptable::ModelProviderFactory>()-> emit DependencyManager::get<scriptable::ModelProviderFactory>()->
modelRemovedFromScene(entity->getEntityItemID(), NestableType::Entity, _model); modelRemovedFromScene(entity->getEntityItemID(), NestableType::Entity, _model);
} }
setKey(false);
_didLastVisualGeometryRequestSucceed = false;
return; return;
} }
@ -1347,6 +1349,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
if (_parsedModelURL != model->getURL()) { if (_parsedModelURL != model->getURL()) {
withWriteLock([&] { withWriteLock([&] {
_texturesLoaded = false; _texturesLoaded = false;
_jointMappingCompleted = false;
model->setURL(_parsedModelURL); model->setURL(_parsedModelURL);
}); });
} }
@ -1457,7 +1460,6 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
mapJoints(entity, model->getJointNames()); mapJoints(entity, model->getJointNames());
//else the joint have been mapped before but we have a new animation to load //else the joint have been mapped before but we have a new animation to load
} else if (_animation && (_animation->getURL().toString() != entity->getAnimationURL())) { } else if (_animation && (_animation->getURL().toString() != entity->getAnimationURL())) {
_animation = DependencyManager::get<AnimationCache>()->getAnimation(entity->getAnimationURL());
_jointMappingCompleted = false; _jointMappingCompleted = false;
mapJoints(entity, model->getJointNames()); mapJoints(entity, model->getJointNames());
} }

View file

@ -187,7 +187,7 @@ private:
const void* _collisionMeshKey { nullptr }; const void* _collisionMeshKey { nullptr };
// used on client side // used on client side
bool _jointMappingCompleted{ false }; bool _jointMappingCompleted { false };
QVector<int> _jointMapping; // domain is index into model-joints, range is index into animation-joints QVector<int> _jointMapping; // domain is index into model-joints, range is index into animation-joints
AnimationPointer _animation; AnimationPointer _animation;
QUrl _parsedModelURL; QUrl _parsedModelURL;

View file

@ -187,12 +187,10 @@ ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createPa
particle.basePosition = baseTransform.getTranslation(); particle.basePosition = baseTransform.getTranslation();
// Position, velocity, and acceleration // Position, velocity, and acceleration
glm::vec3 emitDirection;
if (polarStart == 0.0f && polarFinish == 0.0f && emitDimensions.z == 0.0f) { if (polarStart == 0.0f && polarFinish == 0.0f && emitDimensions.z == 0.0f) {
// Emit along z-axis from position // Emit along z-axis from position
emitDirection = Vectors::UNIT_Z;
particle.velocity = (emitSpeed + randFloatInRange(-1.0f, 1.0f) * speedSpread) * (emitOrientation * Vectors::UNIT_Z);
particle.acceleration = emitAcceleration + randFloatInRange(-1.0f, 1.0f) * accelerationSpread;
} else { } else {
// Emit around point or from ellipsoid // Emit around point or from ellipsoid
// - Distribute directions evenly around point // - Distribute directions evenly around point
@ -210,7 +208,6 @@ ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createPa
azimuth = azimuthStart + (TWO_PI + azimuthFinish - azimuthStart) * randFloat(); azimuth = azimuthStart + (TWO_PI + azimuthFinish - azimuthStart) * randFloat();
} }
glm::vec3 emitDirection;
if (emitDimensions == Vectors::ZERO) { if (emitDimensions == Vectors::ZERO) {
// Point // Point
emitDirection = glm::quat(glm::vec3(PI_OVER_TWO - elevation, 0.0f, azimuth)) * Vectors::UNIT_Z; emitDirection = glm::quat(glm::vec3(PI_OVER_TWO - elevation, 0.0f, azimuth)) * Vectors::UNIT_Z;
@ -235,10 +232,10 @@ ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createPa
)); ));
particle.relativePosition += emitOrientation * emitPosition; particle.relativePosition += emitOrientation * emitPosition;
} }
particle.velocity = (emitSpeed + randFloatInRange(-1.0f, 1.0f) * speedSpread) * (emitOrientation * emitDirection);
particle.acceleration = emitAcceleration + randFloatInRange(-1.0f, 1.0f) * accelerationSpread;
} }
particle.velocity = (emitSpeed + randFloatInRange(-1.0f, 1.0f) * speedSpread) * (emitOrientation * emitDirection);
particle.acceleration = emitAcceleration +
glm::vec3(randFloatInRange(-1.0f, 1.0f), randFloatInRange(-1.0f, 1.0f), randFloatInRange(-1.0f, 1.0f)) * accelerationSpread;
return particle; return particle;
} }

View file

@ -66,7 +66,9 @@ EntityItemProperties ModelEntityItem::getProperties(EntityPropertyFlags desiredP
COPY_ENTITY_PROPERTY_TO_PROPERTIES(jointTranslationsSet, getJointTranslationsSet); COPY_ENTITY_PROPERTY_TO_PROPERTIES(jointTranslationsSet, getJointTranslationsSet);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(jointTranslations, getJointTranslations); COPY_ENTITY_PROPERTY_TO_PROPERTIES(jointTranslations, getJointTranslations);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(relayParentJoints, getRelayParentJoints); COPY_ENTITY_PROPERTY_TO_PROPERTIES(relayParentJoints, getRelayParentJoints);
withReadLock([&] {
_animationProperties.getProperties(properties); _animationProperties.getProperties(properties);
});
return properties; return properties;
} }
@ -123,15 +125,18 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
// grab a local copy of _animationProperties to avoid multiple locks // grab a local copy of _animationProperties to avoid multiple locks
int bytesFromAnimation; int bytesFromAnimation;
AnimationPropertyGroup animationProperties;
withReadLock([&] { withReadLock([&] {
AnimationPropertyGroup animationProperties = _animationProperties; animationProperties = _animationProperties;
bytesFromAnimation = animationProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, bytesFromAnimation = animationProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
propertyFlags, overwriteLocalData, animationPropertiesChanged); propertyFlags, overwriteLocalData, animationPropertiesChanged);
});
if (animationPropertiesChanged) { if (animationPropertiesChanged) {
withWriteLock([&] {
applyNewAnimationProperties(animationProperties); applyNewAnimationProperties(animationProperties);
});
somethingChanged = true; somethingChanged = true;
} }
});
bytesRead += bytesFromAnimation; bytesRead += bytesFromAnimation;
dataAt += bytesFromAnimation; dataAt += bytesFromAnimation;
@ -305,8 +310,10 @@ void ModelEntityItem::setAnimationURL(const QString& url) {
void ModelEntityItem::setAnimationSettings(const QString& value) { void ModelEntityItem::setAnimationSettings(const QString& value) {
// NOTE: this method only called for old bitstream format // NOTE: this method only called for old bitstream format
withWriteLock([&] { AnimationPropertyGroup animationProperties;
auto animationProperties = _animationProperties; withReadLock([&] {
animationProperties = _animationProperties;
});
// the animations setting is a JSON string that may contain various animation settings. // the animations setting is a JSON string that may contain various animation settings.
// if it includes fps, currentFrame, or running, those values will be parsed out and // if it includes fps, currentFrame, or running, those values will be parsed out and
@ -356,18 +363,24 @@ void ModelEntityItem::setAnimationSettings(const QString& value) {
bool allowTranslation = settingsMap["allowTranslation"].toBool(); bool allowTranslation = settingsMap["allowTranslation"].toBool();
animationProperties.setAllowTranslation(allowTranslation); animationProperties.setAllowTranslation(allowTranslation);
} }
withWriteLock([&] {
applyNewAnimationProperties(animationProperties); applyNewAnimationProperties(animationProperties);
}); });
} }
void ModelEntityItem::setAnimationIsPlaying(bool value) { void ModelEntityItem::setAnimationIsPlaying(bool value) {
_flags |= Simulation::DIRTY_UPDATEABLE; _flags |= Simulation::DIRTY_UPDATEABLE;
withWriteLock([&] {
_animationProperties.setRunning(value); _animationProperties.setRunning(value);
});
} }
void ModelEntityItem::setAnimationFPS(float value) { void ModelEntityItem::setAnimationFPS(float value) {
_flags |= Simulation::DIRTY_UPDATEABLE; _flags |= Simulation::DIRTY_UPDATEABLE;
withWriteLock([&] {
_animationProperties.setFPS(value); _animationProperties.setFPS(value);
});
} }
// virtual // virtual
@ -557,11 +570,9 @@ void ModelEntityItem::setColor(const xColor& value) {
// Animation related items... // Animation related items...
AnimationPropertyGroup ModelEntityItem::getAnimationProperties() const { AnimationPropertyGroup ModelEntityItem::getAnimationProperties() const {
AnimationPropertyGroup result; return resultWithReadLock<AnimationPropertyGroup>([&] {
withReadLock([&] { return _animationProperties;
result = _animationProperties;
}); });
return result;
} }
bool ModelEntityItem::hasAnimation() const { bool ModelEntityItem::hasAnimation() const {
@ -582,6 +593,18 @@ void ModelEntityItem::setAnimationCurrentFrame(float value) {
}); });
} }
void ModelEntityItem::setAnimationAllowTranslation(bool value) {
withWriteLock([&] {
_animationProperties.setAllowTranslation(value);
});
}
bool ModelEntityItem::getAnimationAllowTranslation() const {
return resultWithReadLock<bool>([&] {
return _animationProperties.getAllowTranslation();
});
}
void ModelEntityItem::setAnimationLoop(bool loop) { void ModelEntityItem::setAnimationLoop(bool loop) {
withWriteLock([&] { withWriteLock([&] {
_animationProperties.setLoop(loop); _animationProperties.setLoop(loop);

View file

@ -88,8 +88,8 @@ public:
void setAnimationIsPlaying(bool value); void setAnimationIsPlaying(bool value);
void setAnimationFPS(float value); void setAnimationFPS(float value);
void setAnimationAllowTranslation(bool value) { _animationProperties.setAllowTranslation(value); }; void setAnimationAllowTranslation(bool value);
bool getAnimationAllowTranslation() const { return _animationProperties.getAllowTranslation(); }; bool getAnimationAllowTranslation() const;
void setAnimationLoop(bool loop); void setAnimationLoop(bool loop);
bool getAnimationLoop() const; bool getAnimationLoop() const;

View file

@ -57,7 +57,7 @@ void GL41Backend::postLinkProgram(ShaderObject& programObject, const Shader& pro
const auto resourceBufferUniforms = ::gl::Uniform::loadByName(glprogram, program.getResourceBuffers().getNames()); const auto resourceBufferUniforms = ::gl::Uniform::loadByName(glprogram, program.getResourceBuffers().getNames());
for (const auto& resourceBuffer : resourceBufferUniforms) { for (const auto& resourceBuffer : resourceBufferUniforms) {
const auto& targetBinding = expectedResourceBuffers.at(resourceBuffer.name); const auto& targetBinding = expectedResourceBuffers.at(resourceBuffer.name);
glProgramUniform1i(glprogram, resourceBuffer.binding, targetBinding); glProgramUniform1i(glprogram, resourceBuffer.binding, targetBinding + GL41Backend::RESOURCE_BUFFER_SLOT0_TEX_UNIT);
} }
} }

View file

@ -15,7 +15,7 @@
<@include Highlight_shared.slh@> <@include Highlight_shared.slh@>
layout(binding=RENDER_UTILS_BUFFER_HIGHLIGHT_PARAMS) uniform highlightParamsBuffer { layout(std140, binding=RENDER_UTILS_BUFFER_HIGHLIGHT_PARAMS) uniform highlightParamsBuffer {
HighlightParameters params; HighlightParameters params;
}; };

View file

@ -45,7 +45,7 @@ struct HighlightParameters {
vec2 outlineWidth; vec2 outlineWidth;
}; };
layout(binding=0) uniform parametersBuffer { layout(std140, binding=0) uniform parametersBuffer {
HighlightParameters _parameters; HighlightParameters _parameters;
}; };

View file

@ -0,0 +1,18 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gondelman on 9/10/2018
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DeferredBufferWrite.slh@>
layout(location=0) in vec4 _color;
void main(void) {
packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), _color.a, _color.rgb, DEFAULT_FRESNEL, DEFAULT_ROUGHNESS);
}

View file

@ -0,0 +1 @@
VERTEX parabola