fix keyboard intersection, laser alpha

This commit is contained in:
SamGondelman 2019-02-01 12:11:00 -08:00
parent 7d47bfa2e4
commit 50bfe84aa7
7 changed files with 34 additions and 21 deletions

View file

@ -18,6 +18,8 @@
#include <controllers/StandardControls.h> #include <controllers/StandardControls.h>
#include <controllers/UserInputMapper.h> #include <controllers/UserInputMapper.h>
#include <EntityTreeElement.h>
using namespace bilateral; using namespace bilateral;
float StylusPick::WEB_STYLUS_LENGTH = 0.2f; float StylusPick::WEB_STYLUS_LENGTH = 0.2f;
@ -146,13 +148,7 @@ PickResultPointer StylusPick::getEntityIntersection(const StylusTip& pick) {
continue; continue;
} }
bool visible = entity->getVisible(); if (!EntityTreeElement::checkFilterSettings(entity, getFilter())) {
bool collisionless = entity->getCollisionless();
if ((!visible && !getFilter().doesPickInvisible()) || (visible && !getFilter().doesPickVisible()) ||
(!collisionless && !getFilter().doesPickCollidable()) || (collisionless && !getFilter().doesPickNonCollidable()) ||
(entity->isLocalEntity() && !getFilter().doesPickLocalEntities()) ||
(entity->isAvatarEntity() && !getFilter().doesPickAvatarEntities()) ||
(entity->isDomainEntity() && !getFilter().doesPickDomainEntities())) {
continue; continue;
} }

View file

@ -628,8 +628,8 @@ void Keyboard::handleTriggerContinue(const QUuid& id, const PointerEvent& event)
auto stylusPickResult = std::dynamic_pointer_cast<StylusPickResult>(pickResult); auto stylusPickResult = std::dynamic_pointer_cast<StylusPickResult>(pickResult);
float distance = stylusPickResult->distance; float distance = stylusPickResult->distance;
static const float PENATRATION_THRESHOLD = 0.025f; static const float PENETRATION_THRESHOLD = 0.025f;
if (distance < PENATRATION_THRESHOLD) { if (distance < PENETRATION_THRESHOLD) {
static const float Z_OFFSET = 0.002f; static const float Z_OFFSET = 0.002f;
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();

View file

@ -514,7 +514,9 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove
auto iter = overlayProps.find("lineWidth"); auto iter = overlayProps.find("lineWidth");
if (iter != overlayProps.end()) { if (iter != overlayProps.end()) {
QVariantList widths; QVariantList widths;
widths.append(iter.value()); QVariant width = iter.value();
widths.append(width);
widths.append(width);
overlayProps["strokeWidths"] = widths; overlayProps["strokeWidths"] = widths;
} }
} }

View file

@ -25,6 +25,7 @@ using namespace render;
using namespace render::entities; using namespace render::entities;
gpu::PipelinePointer PolyLineEntityRenderer::_pipeline = nullptr; gpu::PipelinePointer PolyLineEntityRenderer::_pipeline = nullptr;
gpu::PipelinePointer PolyLineEntityRenderer::_glowPipeline = nullptr;
static const QUrl DEFAULT_POLYLINE_TEXTURE = PathUtils::resourcesUrl("images/paintStroke.png"); static const QUrl DEFAULT_POLYLINE_TEXTURE = PathUtils::resourcesUrl("images/paintStroke.png");
@ -44,6 +45,7 @@ PolyLineEntityRenderer::PolyLineEntityRenderer(const EntityItemPointer& entity)
void PolyLineEntityRenderer::buildPipeline() { void PolyLineEntityRenderer::buildPipeline() {
// FIXME: opaque pipeline // FIXME: opaque pipeline
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::entities_renderer::program::paintStroke); gpu::ShaderPointer program = gpu::Shader::createProgram(shader::entities_renderer::program::paintStroke);
{
gpu::StatePointer state = gpu::StatePointer(new gpu::State()); gpu::StatePointer state = gpu::StatePointer(new gpu::State());
state->setCullMode(gpu::State::CullMode::CULL_NONE); state->setCullMode(gpu::State::CullMode::CULL_NONE);
state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setDepthTest(true, true, gpu::LESS_EQUAL);
@ -53,6 +55,17 @@ void PolyLineEntityRenderer::buildPipeline() {
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
_pipeline = gpu::Pipeline::create(program, state); _pipeline = gpu::Pipeline::create(program, state);
} }
{
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
state->setCullMode(gpu::State::CullMode::CULL_NONE);
state->setDepthTest(true, false, gpu::LESS_EQUAL);
PrepareStencil::testMask(*state);
state->setBlendFunction(true,
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
_glowPipeline = gpu::Pipeline::create(program, state);
}
}
ItemKey PolyLineEntityRenderer::getKey() { ItemKey PolyLineEntityRenderer::getKey() {
return ItemKey::Builder::transparentShape().withTypeMeta().withTagBits(getTagMask()).withLayer(getHifiRenderLayer()); return ItemKey::Builder::transparentShape().withTypeMeta().withTagBits(getTagMask()).withLayer(getHifiRenderLayer());
@ -257,11 +270,11 @@ void PolyLineEntityRenderer::doRender(RenderArgs* args) {
Q_ASSERT(args->_batch); Q_ASSERT(args->_batch);
gpu::Batch& batch = *args->_batch; gpu::Batch& batch = *args->_batch;
if (!_pipeline) { if (!_pipeline || !_glowPipeline) {
buildPipeline(); buildPipeline();
} }
batch.setPipeline(_pipeline); batch.setPipeline(_glow ? _glowPipeline : _pipeline);
batch.setModelTransform(_renderTransform); batch.setModelTransform(_renderTransform);
batch.setResourceTexture(0, _textureLoaded ? _texture->getGPUTexture() : DependencyManager::get<TextureCache>()->getWhiteTexture()); batch.setResourceTexture(0, _textureLoaded ? _texture->getGPUTexture() : DependencyManager::get<TextureCache>()->getWhiteTexture());
batch.setResourceBuffer(0, _polylineGeometryBuffer); batch.setResourceBuffer(0, _polylineGeometryBuffer);

View file

@ -59,6 +59,7 @@ protected:
gpu::BufferPointer _polylineDataBuffer; gpu::BufferPointer _polylineDataBuffer;
gpu::BufferPointer _polylineGeometryBuffer; gpu::BufferPointer _polylineGeometryBuffer;
static gpu::PipelinePointer _pipeline; static gpu::PipelinePointer _pipeline;
static gpu::PipelinePointer _glowPipeline;
}; };
} } // namespace } } // namespace

View file

@ -139,7 +139,7 @@ bool EntityTreeElement::bestFitBounds(const glm::vec3& minPoint, const glm::vec3
return false; return false;
} }
bool checkFilterSettings(const EntityItemPointer& entity, PickFilter searchFilter) { bool EntityTreeElement::checkFilterSettings(const EntityItemPointer& entity, PickFilter searchFilter) {
bool visible = entity->isVisible(); bool visible = entity->isVisible();
entity::HostType hostType = entity->getEntityHostType(); entity::HostType hostType = entity->getEntityHostType();
if ((!searchFilter.doesPickVisible() && visible) || (!searchFilter.doesPickInvisible() && !visible) || if ((!searchFilter.doesPickVisible() && visible) || (!searchFilter.doesPickInvisible() && !visible) ||

View file

@ -134,6 +134,7 @@ public:
virtual bool isRendered() const override { return getShouldRender(); } virtual bool isRendered() const override { return getShouldRender(); }
virtual bool deleteApproved() const override { return !hasEntities(); } virtual bool deleteApproved() const override { return !hasEntities(); }
static bool checkFilterSettings(const EntityItemPointer& entity, PickFilter searchFilter);
virtual bool canPickIntersect() const override { return hasEntities(); } virtual bool canPickIntersect() const override { return hasEntities(); }
virtual EntityItemID evalRayIntersection(const glm::vec3& origin, const glm::vec3& direction, virtual EntityItemID evalRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
OctreeElementPointer& element, float& distance, BoxFace& face, glm::vec3& surfaceNormal, OctreeElementPointer& element, float& distance, BoxFace& face, glm::vec3& surfaceNormal,