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/UserInputMapper.h>
#include <EntityTreeElement.h>
using namespace bilateral;
float StylusPick::WEB_STYLUS_LENGTH = 0.2f;
@ -146,13 +148,7 @@ PickResultPointer StylusPick::getEntityIntersection(const StylusTip& pick) {
continue;
}
bool visible = entity->getVisible();
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())) {
if (!EntityTreeElement::checkFilterSettings(entity, getFilter())) {
continue;
}

View file

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

View file

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

View file

@ -25,6 +25,7 @@ using namespace render;
using namespace render::entities;
gpu::PipelinePointer PolyLineEntityRenderer::_pipeline = nullptr;
gpu::PipelinePointer PolyLineEntityRenderer::_glowPipeline = nullptr;
static const QUrl DEFAULT_POLYLINE_TEXTURE = PathUtils::resourcesUrl("images/paintStroke.png");
@ -44,14 +45,26 @@ PolyLineEntityRenderer::PolyLineEntityRenderer(const EntityItemPointer& entity)
void PolyLineEntityRenderer::buildPipeline() {
// FIXME: opaque pipeline
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::entities_renderer::program::paintStroke);
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
state->setCullMode(gpu::State::CullMode::CULL_NONE);
state->setDepthTest(true, true, 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);
_pipeline = gpu::Pipeline::create(program, state);
{
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
state->setCullMode(gpu::State::CullMode::CULL_NONE);
state->setDepthTest(true, true, 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);
_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() {
@ -257,11 +270,11 @@ void PolyLineEntityRenderer::doRender(RenderArgs* args) {
Q_ASSERT(args->_batch);
gpu::Batch& batch = *args->_batch;
if (!_pipeline) {
if (!_pipeline || !_glowPipeline) {
buildPipeline();
}
batch.setPipeline(_pipeline);
batch.setPipeline(_glow ? _glowPipeline : _pipeline);
batch.setModelTransform(_renderTransform);
batch.setResourceTexture(0, _textureLoaded ? _texture->getGPUTexture() : DependencyManager::get<TextureCache>()->getWhiteTexture());
batch.setResourceBuffer(0, _polylineGeometryBuffer);

View file

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

View file

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

View file

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