mirror of
https://github.com/lubosz/overte.git
synced 2025-04-27 02:15:38 +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
interface/src/raypick
|
@ -8,36 +8,20 @@
|
|||
|
||||
#include "MouseTransformNode.h"
|
||||
|
||||
#include "DependencyManager.h"
|
||||
#include "PickManager.h"
|
||||
#include "MouseRayPick.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
#include "Application.h"
|
||||
#include "display-plugins/CompositorHelper.h"
|
||||
#include "RayPick.h"
|
||||
|
||||
Transform MouseTransformNode::getTransform() {
|
||||
Transform transform;
|
||||
std::shared_ptr<RayPickResult> rayPickResult = DependencyManager::get<PickManager>()->getPrevPickResultTyped<RayPickResult>(_parentMouseRayPick);
|
||||
if (rayPickResult) {
|
||||
transform.setTranslation(rayPickResult->intersection);
|
||||
QVariant position = qApp->getApplicationCompositor().getReticleInterface()->getPosition();
|
||||
if (position.isValid()) {
|
||||
Transform transform;
|
||||
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 {
|
||||
public:
|
||||
MouseTransformNode();
|
||||
~MouseTransformNode();
|
||||
Transform getTransform() override;
|
||||
|
||||
protected:
|
||||
unsigned int _parentMouseRayPick = 0;
|
||||
};
|
||||
|
||||
#endif // hifi_MouseTransformNode_h
|
Loading…
Reference in a new issue