mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 13:19:55 +02:00
Make MouseTransformNode actually parent the pick to a mouse rather than a MouseRayPick, and properly include rotation information
This commit is contained in:
parent
397b03d5d5
commit
c6e6da2e3f
2 changed files with 13 additions and 34 deletions
|
@ -8,36 +8,20 @@
|
||||||
|
|
||||||
#include "MouseTransformNode.h"
|
#include "MouseTransformNode.h"
|
||||||
|
|
||||||
#include "DependencyManager.h"
|
#include "Application.h"
|
||||||
#include "PickManager.h"
|
#include "display-plugins/CompositorHelper.h"
|
||||||
#include "MouseRayPick.h"
|
#include "RayPick.h"
|
||||||
|
|
||||||
const PickFilter MOUSE_TRANSFORM_NODE_PICK_FILTER(
|
|
||||||
1 << PickFilter::PICK_ENTITIES |
|
|
||||||
1 << PickFilter::PICK_AVATARS |
|
|
||||||
1 << PickFilter::PICK_INCLUDE_NONCOLLIDABLE
|
|
||||||
);
|
|
||||||
const float MOUSE_TRANSFORM_NODE_MAX_DISTANCE = 1000.0f;
|
|
||||||
|
|
||||||
MouseTransformNode::MouseTransformNode() {
|
|
||||||
_parentMouseRayPick = DependencyManager::get<PickManager>()->addPick(PickQuery::Ray,
|
|
||||||
std::make_shared<MouseRayPick>(MOUSE_TRANSFORM_NODE_PICK_FILTER, MOUSE_TRANSFORM_NODE_MAX_DISTANCE, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseTransformNode::~MouseTransformNode() {
|
|
||||||
if (DependencyManager::isSet<PickManager>()) {
|
|
||||||
auto pickManager = DependencyManager::get<PickManager>();
|
|
||||||
if (pickManager) {
|
|
||||||
pickManager->removePick(_parentMouseRayPick);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform MouseTransformNode::getTransform() {
|
Transform MouseTransformNode::getTransform() {
|
||||||
Transform transform;
|
QVariant position = qApp->getApplicationCompositor().getReticleInterface()->getPosition();
|
||||||
std::shared_ptr<RayPickResult> rayPickResult = DependencyManager::get<PickManager>()->getPrevPickResultTyped<RayPickResult>(_parentMouseRayPick);
|
if (position.isValid()) {
|
||||||
if (rayPickResult) {
|
Transform transform;
|
||||||
transform.setTranslation(rayPickResult->intersection);
|
QVariantMap posMap = position.toMap();
|
||||||
|
PickRay pickRay = qApp->getCamera().computePickRay(posMap["x"].toFloat(), posMap["y"].toFloat());
|
||||||
|
transform.setTranslation(pickRay.origin);
|
||||||
|
transform.setRotation(rotationBetween(Vectors::UP, pickRay.direction));
|
||||||
|
return transform;
|
||||||
}
|
}
|
||||||
return transform;
|
|
||||||
|
return Transform();
|
||||||
}
|
}
|
|
@ -12,12 +12,7 @@
|
||||||
|
|
||||||
class MouseTransformNode : public TransformNode {
|
class MouseTransformNode : public TransformNode {
|
||||||
public:
|
public:
|
||||||
MouseTransformNode();
|
|
||||||
~MouseTransformNode();
|
|
||||||
Transform getTransform() override;
|
Transform getTransform() override;
|
||||||
|
|
||||||
protected:
|
|
||||||
unsigned int _parentMouseRayPick = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_MouseTransformNode_h
|
#endif // hifi_MouseTransformNode_h
|
Loading…
Reference in a new issue