Add PickTransformNode

This commit is contained in:
sabrina-shanman 2018-08-23 14:06:39 -07:00
parent 3167d3c0c7
commit b0f8d3e427
5 changed files with 59 additions and 0 deletions

View file

@ -17,6 +17,7 @@
#include <QVariant>
#include <shared/ReadWriteLockable.h>
#include <Transform.h>
enum IntersectionType {
NONE = 0,

View file

@ -88,6 +88,14 @@ void PickManager::setIncludeItems(unsigned int uid, const QVector<QUuid>& includ
}
}
Transform PickManager::getResultTransform(unsigned int uid) const {
auto pick = findPick(uid);
if (pick) {
return pick->getResultTransform();
}
return Transform();
}
void PickManager::update() {
uint64_t expiry = usecTimestampNow() + _perFrameTimeBudget;
std::unordered_map<PickQuery::PickType, std::unordered_map<unsigned int, std::shared_ptr<PickQuery>>> cachedPicks;

View file

@ -40,6 +40,8 @@ public:
void setIgnoreItems(unsigned int uid, const QVector<QUuid>& ignore) const;
void setIncludeItems(unsigned int uid, const QVector<QUuid>& include) const;
Transform getResultTransform(unsigned int uid) const;
bool isLeftHand(unsigned int uid);
bool isRightHand(unsigned int uid);
bool isMouse(unsigned int uid);

View file

@ -0,0 +1,26 @@
//
// Created by Sabrina Shanman 8/22/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 "PickTransformNode.h"
#include "DependencyManager.h"
#include "PickManager.h"
PickTransformNode::PickTransformNode(unsigned int uid) :
_uid(uid)
{
}
Transform PickTransformNode::getTransform() {
auto pickManager = DependencyManager::get<PickManager>();
if (!pickManager) {
return Transform();
}
return pickManager->getResultTransform(_uid);
}

View file

@ -0,0 +1,22 @@
//
// Created by Sabrina Shanman 8/22/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
//
#ifndef hifi_PickTransformNode_h
#define hifi_PickTransformNode_h
#include "TransformNode.h"
class PickTransformNode : public TransformNode {
public:
PickTransformNode(unsigned int uid);
Transform getTransform() override;
protected:
unsigned int _uid;
};
#endif // hifi_PickTransformNode_h