From 2a2cf3898bb4d0e8cda1d0f1e2fe0843ebe730fb Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Sun, 26 Mar 2023 21:09:46 +0200 Subject: [PATCH] Work on porting laser pointers to local entities, removal of LaserPointer JS API --- interface/src/Application.cpp | 3 - interface/src/LoginStateManager.cpp | 161 ++++++++-------- interface/src/raypick/LaserPointer.cpp | 42 +++-- interface/src/raypick/LaserPointer.h | 4 +- .../LaserPointerScriptingInterface.cpp | 37 ---- .../raypick/LaserPointerScriptingInterface.h | 172 ------------------ interface/src/raypick/ParabolaPointer.cpp | 55 +++--- interface/src/raypick/ParabolaPointer.h | 4 +- .../src/raypick/PointerScriptingInterface.cpp | 101 ++++++++-- .../src/raypick/PointerScriptingInterface.h | 43 ++++- interface/src/raypick/StylusPointer.cpp | 27 ++- .../src/v8/ScriptObjectV8Proxy.cpp | 6 +- scripts/system/libraries/pointersUtils.js | 41 +++-- 13 files changed, 311 insertions(+), 385 deletions(-) delete mode 100644 interface/src/raypick/LaserPointerScriptingInterface.cpp delete mode 100644 interface/src/raypick/LaserPointerScriptingInterface.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 67a8cdca78..88691c933a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -242,7 +242,6 @@ #include #include #include -#include #include #include #include @@ -806,7 +805,6 @@ bool setupEssentials(int& argc, char** argv, const QCommandLineParser& parser, b // Set dependencies DependencyManager::set(); DependencyManager::set(); - DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); @@ -7529,7 +7527,6 @@ void Application::registerScriptEngineWithApplicationServices(const ScriptManage scriptEngine->registerGlobalObject("LocationBookmarks", DependencyManager::get().data()); scriptEngine->registerGlobalObject("RayPick", DependencyManager::get().data()); - scriptEngine->registerGlobalObject("LaserPointers", DependencyManager::get().data()); scriptEngine->registerGlobalObject("Picks", DependencyManager::get().data()); scriptEngine->registerGlobalObject("Pointers", DependencyManager::get().data()); diff --git a/interface/src/LoginStateManager.cpp b/interface/src/LoginStateManager.cpp index af3c35ec4c..4207549d98 100644 --- a/interface/src/LoginStateManager.cpp +++ b/interface/src/LoginStateManager.cpp @@ -25,13 +25,15 @@ #include "scripting/ControllerScriptingInterface.h" static const float SEARCH_SPHERE_SIZE = 0.0132f; -static const QVariantMap SEARCH_SPHERE = {{"x", SEARCH_SPHERE_SIZE}, +/*static const QVariantMap SEARCH_SPHERE = {{"x", SEARCH_SPHERE_SIZE}, {"y", SEARCH_SPHERE_SIZE}, - {"z", SEARCH_SPHERE_SIZE}}; + {"z", SEARCH_SPHERE_SIZE}};*/ + +static const glm::vec3 SEARCH_SPHERE(SEARCH_SPHERE_SIZE, SEARCH_SPHERE_SIZE, SEARCH_SPHERE_SIZE); static const int DEFAULT_SEARCH_SPHERE_DISTANCE = 1000; // how far from camera to search intersection? -static const QVariantMap COLORS_GRAB_SEARCHING_HALF_SQUEEZE = {{"red", 10}, +/*static const QVariantMap COLORS_GRAB_SEARCHING_HALF_SQUEEZE = {{"red", 10}, {"green", 10}, {"blue", 255}}; @@ -41,8 +43,13 @@ static const QVariantMap COLORS_GRAB_SEARCHING_FULL_SQUEEZE = {{"red", 250}, static const QVariantMap COLORS_GRAB_DISTANCE_HOLD = {{"red", 238}, {"green", 75}, - {"blue", 214}}; + {"blue", 214}};*/ +static const glm::u8vec3 COLORS_GRAB_SEARCHING_HALF_SQUEEZE(10, 10, 255); + +static const glm::u8vec3 COLORS_GRAB_SEARCHING_FULL_SQUEEZE(250, 10, 10); + +static const glm::u8vec3 COLORS_GRAB_DISTANCE_HOLD(238, 75, 215); void LoginStateManager::tearDown() { @@ -60,90 +67,88 @@ void LoginStateManager::tearDown() { } void LoginStateManager::setUp() { - QVariantMap fullPathRenderState { - {"type", "line3d"}, - {"color", COLORS_GRAB_SEARCHING_FULL_SQUEEZE}, - {"visible", true}, - {"alpha", 1.0f}, - {"solid", true}, - {"glow", 1.0f}, - {"ignoreRayIntersection", true}, // always ignore this - {"drawInFront", true}, // Even when burried inside of something, show it. - {"drawHUDLayer", false} - }; - QVariantMap fullEndRenderState { - {"type", "sphere"}, - {"dimensions", SEARCH_SPHERE}, - {"solid", true}, - {"color", COLORS_GRAB_SEARCHING_FULL_SQUEEZE}, - {"alpha", 0.9f}, - {"ignoreRayIntersection", true}, - {"drawInFront", true}, // Even when burried inside of something, show it. - {"drawHUDLayer", false}, - {"visible", true} - }; - QVariantMap halfPathRenderState { - {"type", "line3d"}, - {"color", COLORS_GRAB_SEARCHING_HALF_SQUEEZE}, - {"visible", true}, - {"alpha", 1.0f}, - {"solid", true}, - {"glow", 1.0f}, - {"ignoreRayIntersection", true}, // always ignore this - {"drawInFront", true}, // Even when burried inside of something, show it. - {"drawHUDLayer", false} - }; - QVariantMap halfEndRenderState { - {"type", "sphere"}, - {"dimensions", SEARCH_SPHERE}, - {"solid", true}, - {"color", COLORS_GRAB_SEARCHING_HALF_SQUEEZE}, - {"alpha", 0.9f}, - {"ignoreRayIntersection", true}, - {"drawInFront", true}, // Even when burried inside of something, show it. - {"drawHUDLayer", false}, - {"visible", true} - }; - QVariantMap holdPathRenderState { - {"type", "line3d"}, - {"color", COLORS_GRAB_DISTANCE_HOLD}, - {"visible", true}, - {"alpha", 1.0f}, - {"solid", true}, - {"glow", 1.0f}, - {"ignoreRayIntersection", true}, // always ignore this - {"drawInFront", true}, // Even when burried inside of something, show it. - {"drawHUDLayer", false}, - }; + QList entityProperties; + + //V8TODO: are points and normals needed here + EntityItemProperties fullPathRenderState; + fullPathRenderState.setType(EntityTypes::PolyLine); + fullPathRenderState.setColor(COLORS_GRAB_SEARCHING_FULL_SQUEEZE); + fullPathRenderState.setGlow(true); + fullPathRenderState.setIgnorePickIntersection(true); // always ignore this + fullPathRenderState.setRenderLayer(RenderLayer::FRONT); // Even when buried inside of something, show it. + fullPathRenderState.setFaceCamera(true); + int fullPathRenderStateIndex = entityProperties.length(); + entityProperties.append(fullPathRenderState); + + EntityItemProperties fullEndRenderState; + fullEndRenderState.setType(EntityTypes::Sphere); + fullEndRenderState.setDimensions(SEARCH_SPHERE); + fullEndRenderState.setColor(COLORS_GRAB_SEARCHING_FULL_SQUEEZE); + fullEndRenderState.setAlpha(0.9f); + fullEndRenderState.setIgnorePickIntersection(true); // always ignore this + fullEndRenderState.setRenderLayer(RenderLayer::FRONT); // Even when buried inside of something, show it. + int fullEndRenderStateIndex = entityProperties.length(); + entityProperties.append(fullEndRenderState); + + EntityItemProperties halfPathRenderState; + halfPathRenderState.setType(EntityTypes::PolyLine); + halfPathRenderState.setColor(COLORS_GRAB_SEARCHING_HALF_SQUEEZE); + halfPathRenderState.setGlow(true); + halfPathRenderState.setIgnorePickIntersection(true); // always ignore this + halfPathRenderState.setRenderLayer(RenderLayer::FRONT); // Even when buried inside of something, show it. + halfPathRenderState.setFaceCamera(true); + int halfPathRenderStateIndex = entityProperties.length(); + entityProperties.append(halfPathRenderState); + + EntityItemProperties halfEndRenderState; + halfEndRenderState.setType(EntityTypes::Sphere); + halfEndRenderState.setDimensions(SEARCH_SPHERE); + halfEndRenderState.setColor(COLORS_GRAB_SEARCHING_HALF_SQUEEZE); + halfEndRenderState.setAlpha(0.9f); + halfEndRenderState.setIgnorePickIntersection(true); // always ignore this + halfEndRenderState.setRenderLayer(RenderLayer::FRONT); // Even when buried inside of something, show it. + int halfEndRenderStateIndex = entityProperties.length(); + entityProperties.append(halfEndRenderState); + + EntityItemProperties holdPathRenderState; + holdPathRenderState.setType(EntityTypes::PolyLine); + holdPathRenderState.setColor(COLORS_GRAB_DISTANCE_HOLD); + holdPathRenderState.setGlow(true); + holdPathRenderState.setIgnorePickIntersection(true); // always ignore this + holdPathRenderState.setRenderLayer(RenderLayer::FRONT); // Even when buried inside of something, show it. + holdPathRenderState.setFaceCamera(true); + int holdPathRenderStateIndex = entityProperties.length(); + entityProperties.append(holdPathRenderState); + QVariantMap halfRenderStateIdentifier { {"name", "half"}, - {"path", halfPathRenderState}, - {"end", halfEndRenderState} + {"pathPropertyIndex", halfPathRenderStateIndex}, + {"endPropertyIndex", halfEndRenderStateIndex} }; QVariantMap fullRenderStateIdentifier { {"name", "full"}, - {"path", fullPathRenderState}, - {"end", fullEndRenderState} + {"pathPropertyIndex", fullPathRenderStateIndex}, + {"endPropertyIndex", fullEndRenderStateIndex} }; QVariantMap holdRenderStateIdentifier { {"name", "hold"}, - {"path", holdPathRenderState}, + {"pathPropertyIndex", holdPathRenderStateIndex}, }; QVariantMap halfDefaultRenderStateIdentifier { {"name", "half"}, {"distance", DEFAULT_SEARCH_SPHERE_DISTANCE}, - {"path", halfPathRenderState} + {"pathPropertyIndex", halfPathRenderStateIndex} }; QVariantMap fullDefaultRenderStateIdentifier { {"name", "full"}, {"distance", DEFAULT_SEARCH_SPHERE_DISTANCE}, - {"path", fullPathRenderState} + {"pathPropertyIndex", fullPathRenderStateIndex} }; QVariantMap holdDefaultRenderStateIdentifier { {"name", "hold"}, {"distance", DEFAULT_SEARCH_SPHERE_DISTANCE}, - {"path", holdPathRenderState} + {"pathPropertyIndex", holdPathRenderStateIndex} }; _renderStates = QList({halfRenderStateIdentifier, fullRenderStateIdentifier, holdRenderStateIdentifier}); @@ -168,7 +173,7 @@ void LoginStateManager::setUp() { leftPointerTriggerProperties = QList({ltClick1, ltClick2}); const unsigned int leftHand = 0; - QVariantMap leftPointerProperties { + QVariantMap leftPointerPropertiesMap { { "joint", "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND" }, { "filter", PickScriptingInterface::getPickLocalEntities() }, { "triggers", leftPointerTriggerProperties }, @@ -178,9 +183,12 @@ void LoginStateManager::setUp() { { "distanceScaleEnd", true }, { "hand", leftHand } }; - leftPointerProperties["renderStates"] = _renderStates; - leftPointerProperties["defaultRenderStates"] = _defaultRenderStates; - _leftLoginPointerID = pointers->createPointer(PickQuery::PickType::Ray, leftPointerProperties); + leftPointerPropertiesMap["renderStates"] = _renderStates; + leftPointerPropertiesMap["defaultRenderStates"] = _defaultRenderStates; + RayPointerProperties leftPointerProperties; + leftPointerProperties.properties = leftPointerPropertiesMap; + leftPointerProperties.entityProperties = entityProperties; + _leftLoginPointerID = pointers->createRayPointer(leftPointerProperties); pointers->setRenderState(_leftLoginPointerID, ""); pointers->enablePointer(_leftLoginPointerID); const unsigned int rightHand = 1; @@ -195,7 +203,7 @@ void LoginStateManager::setUp() { { "button", "Primary" } }; rightPointerTriggerProperties = QList({rtClick1, rtClick2}); - QVariantMap rightPointerProperties{ + QVariantMap rightPointerPropertiesMap{ { "joint", "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" }, { "filter", PickScriptingInterface::getPickLocalEntities() }, { "triggers", rightPointerTriggerProperties }, @@ -205,9 +213,12 @@ void LoginStateManager::setUp() { { "distanceScaleEnd", true }, { "hand", rightHand } }; - rightPointerProperties["renderStates"] = _renderStates; - rightPointerProperties["defaultRenderStates"] = _defaultRenderStates; - _rightLoginPointerID = pointers->createPointer(PickQuery::PickType::Ray, rightPointerProperties); + rightPointerPropertiesMap["renderStates"] = _renderStates; + rightPointerPropertiesMap["defaultRenderStates"] = _defaultRenderStates; + RayPointerProperties rightPointerProperties; + rightPointerProperties.properties = rightPointerPropertiesMap; + rightPointerProperties.entityProperties = entityProperties; + _rightLoginPointerID = pointers->createRayPointer(rightPointerProperties); pointers->setRenderState(_rightLoginPointerID, ""); pointers->enablePointer(_rightLoginPointerID); } diff --git a/interface/src/raypick/LaserPointer.cpp b/interface/src/raypick/LaserPointer.cpp index b97c9b89cb..f623684da2 100644 --- a/interface/src/raypick/LaserPointer.cpp +++ b/interface/src/raypick/LaserPointer.cpp @@ -4,6 +4,7 @@ // // Created by Sam Gondelman 7/11/2017 // Copyright 2017 High Fidelity, Inc. +// Copyright 2023 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -32,6 +33,7 @@ PickQuery::PickType LaserPointer::getType() const { } void LaserPointer::editRenderStatePath(const std::string& state, const QVariant& pathProps) { + //V8TODO pathProps are not a thing anymore auto renderState = std::static_pointer_cast(_renderStates[state]); if (renderState) { updateRenderState(renderState->getPathID(), pathProps); @@ -51,6 +53,7 @@ PickResultPointer LaserPointer::getPickResultCopy(const PickResultPointer& pickR } QVariantMap LaserPointer::toVariantMap() const { + //V8TODO: this cannot be done anymore without script engine QVariantMap qVariantMap = Parent::toVariantMap(); QVariantMap qRenderStates; @@ -175,6 +178,10 @@ void LaserPointer::RenderState::update(const glm::vec3& origin, const glm::vec3& properties.setLinePoints(points); properties.setVisible(true); properties.setIgnorePickIntersection(doesPathIgnorePicks()); + QVector normals; + normals.append(glm::vec3(0.0f, 0.0f, 1.0f)); + normals.append(glm::vec3(0.0f, 0.0f, 1.0f)); + properties.setNormals(normals); QVector widths; float width = getLineWidth() * parentScale; widths.append(width); @@ -184,33 +191,34 @@ void LaserPointer::RenderState::update(const glm::vec3& origin, const glm::vec3& } } -std::shared_ptr LaserPointer::buildRenderState(const QVariantMap& propMap) { +std::shared_ptr LaserPointer::buildRenderState(const QVariantMap& propMap, const QList &entityProperties) { // FIXME: we have to keep using the Overlays interface here, because existing scripts use overlay properties to define pointers QUuid startID; - if (propMap["start"].isValid()) { - QVariantMap startMap = propMap["start"].toMap(); - if (startMap["type"].isValid()) { - startMap.remove("visible"); - startID = qApp->getOverlays().addOverlay(startMap["type"].toString(), startMap); + if (propMap["startPropertyIndex"].isValid()) { + int startPropertyIndex = propMap["startPropertyIndex"].toInt(); + if (startPropertyIndex >= 0 && startPropertyIndex < entityProperties.length()) { + //startMap.remove("visible"); + startID = DependencyManager::get()->addEntityInternal(entityProperties[startPropertyIndex], entity::HostType::LOCAL); } } QUuid pathID; - if (propMap["path"].isValid()) { - QVariantMap pathMap = propMap["path"].toMap(); - // laser paths must be line3ds - if (pathMap["type"].isValid() && pathMap["type"].toString() == "line3d") { - pathMap.remove("visible"); - pathID = qApp->getOverlays().addOverlay(pathMap["type"].toString(), pathMap); + if (propMap["pathPropertyIndex"].isValid()) { + // laser paths must be PolyLine + int pathPropertyIndex = propMap["pathPropertyIndex"].toInt(); + if (pathPropertyIndex >= 0 && pathPropertyIndex < entityProperties.length()) { + //startMap.remove("visible"); + //pathMap["type"].toString() == "PolyLine" + pathID = DependencyManager::get()->addEntityInternal(entityProperties[pathPropertyIndex], entity::HostType::LOCAL); } } QUuid endID; - if (propMap["end"].isValid()) { - QVariantMap endMap = propMap["end"].toMap(); - if (endMap["type"].isValid()) { - endMap.remove("visible"); - endID = qApp->getOverlays().addOverlay(endMap["type"].toString(), endMap); + if (propMap["endPropertyIndex"].isValid()) { + int endPropertyIndex = propMap["endPropertyIndex"].toInt(); + if (endPropertyIndex >= 0 && endPropertyIndex < entityProperties.length()) { + //startMap.remove("visible"); + endID = DependencyManager::get()->addEntityInternal(entityProperties[endPropertyIndex], entity::HostType::LOCAL); } } diff --git a/interface/src/raypick/LaserPointer.h b/interface/src/raypick/LaserPointer.h index 330449a52d..74f0fd88d3 100644 --- a/interface/src/raypick/LaserPointer.h +++ b/interface/src/raypick/LaserPointer.h @@ -13,6 +13,8 @@ #include "PathPointer.h" +#include + class LaserPointer : public PathPointer { using Parent = PathPointer; public: @@ -46,7 +48,7 @@ public: QVariantMap toVariantMap() const override; - static std::shared_ptr buildRenderState(const QVariantMap& propMap); + static std::shared_ptr buildRenderState(const QVariantMap& propMap, const QList &entityProperties); protected: PickResultPointer getPickResultCopy(const PickResultPointer& pickResult) const override; diff --git a/interface/src/raypick/LaserPointerScriptingInterface.cpp b/interface/src/raypick/LaserPointerScriptingInterface.cpp deleted file mode 100644 index 167b601782..0000000000 --- a/interface/src/raypick/LaserPointerScriptingInterface.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// -// LaserPointerScriptingInterface.cpp -// interface/src/raypick -// -// Created by Sam Gondelman 7/11/2017 -// Copyright 2017 High Fidelity, Inc. -// Copyright 2023 Overte e.V. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// SPDX-License-Identifier: Apache-2.0 -// - -#include "LaserPointerScriptingInterface.h" - -#include "PointerScriptingInterface.h" -#include - -void LaserPointerScriptingInterface::setIgnoreItems(unsigned int uid, const ScriptValue& ignoreItems) const { - DependencyManager::get()->setIgnoreItems(uid, qVectorQUuidFromScriptValue(ignoreItems)); -} - -void LaserPointerScriptingInterface::setIncludeItems(unsigned int uid, const ScriptValue& includeItems) const { - DependencyManager::get()->setIncludeItems(uid, qVectorQUuidFromScriptValue(includeItems)); -} - -unsigned int LaserPointerScriptingInterface::createLaserPointer(const QVariant& properties) const { - return DependencyManager::get()->createPointer(PickQuery::PickType::Ray, properties); -} - -void LaserPointerScriptingInterface::editRenderState(unsigned int uid, const QString& renderState, const QVariant& properties) const { - DependencyManager::get()->editRenderState(uid, renderState, properties); -} - -QVariantMap LaserPointerScriptingInterface::getPrevRayPickResult(unsigned int uid) const { - return DependencyManager::get()->getPrevPickResult(uid); -} diff --git a/interface/src/raypick/LaserPointerScriptingInterface.h b/interface/src/raypick/LaserPointerScriptingInterface.h deleted file mode 100644 index 23939124a7..0000000000 --- a/interface/src/raypick/LaserPointerScriptingInterface.h +++ /dev/null @@ -1,172 +0,0 @@ -// -// LaserPointerScriptingInterface.h -// interface/src/raypick -// -// Created by Sam Gondelman 7/11/2017 -// Copyright 2017 High Fidelity, Inc. -// Copyright 2023 Overte e.V. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// SPDX-License-Identifier: Apache-2.0 -// -#ifndef hifi_LaserPointerScriptingInterface_h -#define hifi_LaserPointerScriptingInterface_h - -#include - -#include "DependencyManager.h" -#include - -class ScriptValue; - -class LaserPointerScriptingInterface : public QObject, public Dependency { - Q_OBJECT - SINGLETON_DEPENDENCY - -/*@jsdoc - * The LaserPointers API is a subset of the {@link Pointers} API. It lets you create, manage, and visually - * represent objects for repeatedly calculating ray intersections with avatars, entities, and overlays. Ray pointers can also - * be configured to generate events on entities and overlays intersected. - * - * @namespace LaserPointers - * - * @deprecated This API is deprecated and will be removed. Use {@link Pointers} instead. - * - * @hifi-interface - * @hifi-client-entity - * @hifi-avatar - * - * @borrows Pointers.enablePointer as enableLaserPointer - * @borrows Pointers.disablePointer as disableLaserPointer - * @borrows Pointers.removePointer as removeLaserPointer - * @borrows Pointers.setPrecisionPicking as setPrecisionPicking - */ -public: - - /*@jsdoc - * Creates a new ray pointer. The pointer can have a wide range of behaviors depending on the properties specified. For - * example, it may be a static ray pointer, a mouse ray pointer, or joint ray pointer. - *

Warning: Pointers created using this method currently always intersect at least visible and - * collidable things but this may not always be the case.

- * @function LaserPointers.createLaserPointer - * @param {Pointers.RayPointerProperties} properties - The properties of the pointer, including the properties of the - * underlying pick that the pointer uses to do its picking. - * @returns {number} The ID of the pointer if successfully created, otherwise 0. - */ - Q_INVOKABLE unsigned int createLaserPointer(const QVariant& properties) const; - - // jsdoc @borrows from Pointers - Q_INVOKABLE void enableLaserPointer(unsigned int uid) const { DependencyManager::get()->enablePointer(uid); } - - // jsdoc @borrows from Pointers - Q_INVOKABLE void disableLaserPointer(unsigned int uid) const { DependencyManager::get()->disablePointer(uid); } - - // jsdoc @borrows from Pointers - Q_INVOKABLE void removeLaserPointer(unsigned int uid) const { DependencyManager::get()->removePointer(uid); } - - /*@jsdoc - * Edits a render state of a pointer, to change its visual appearance for the state when the pointer is intersecting - * something. - *

Note: You can only edit the properties of the existing parts of the pointer; you cannot change the - * type of any part.

- *

Note: You cannot use this method to change the appearance of a default render state.

- * @function LaserPointers.editRenderState - * @param {number} id - The ID of the pointer. - * @param {string} renderState - The name of the render state to edit. - * @param {Pointers.RayPointerRenderState} properties - The new properties for the render state. Only the overlay - * properties to change need be specified. - */ - Q_INVOKABLE void editRenderState(unsigned int uid, const QString& renderState, const QVariant& properties) const; - - /*@jsdoc - * Sets the render state of a pointer, to change its visual appearance and possibly disable or enable it. - * @function LaserPointers.setRenderState - * @param {string} renderState -

The name of the render state to set the pointer to. This may be:

- *
    - *
  • The name of one of the render states set in the pointer's properties.
  • - *
  • "", to hide the pointer and disable emitting of events.
  • - *
- * @param {number} id - The ID of the pointer. - */ - Q_INVOKABLE void setRenderState(unsigned int uid, const QString& renderState) const { DependencyManager::get()->setRenderState(uid, renderState.toStdString()); } - - /*@jsdoc - * Gets the most recent intersection of a pointer. A pointer continues to be updated ready to return a result, as long as - * it is enabled, regardless of the render state. - * @function LaserPointers.getPrevRayPickResult - * @param {number} id - The ID of the pointer. - * @returns {RayPickResult} The most recent intersection of the pointer. - */ - Q_INVOKABLE QVariantMap getPrevRayPickResult(unsigned int uid) const; - - // jsdoc @borrows from Pointers - Q_INVOKABLE void setPrecisionPicking(unsigned int uid, bool precisionPicking) const { DependencyManager::get()->setPrecisionPicking(uid, precisionPicking); } - - /*@jsdoc - * Sets the length of a pointer. - * @function LaserPointers.setLaserLength - * @param {number} id - The ID of the pointer. - * @param {number} laserLength - The desired length of the pointer. - */ - Q_INVOKABLE void setLaserLength(unsigned int uid, float laserLength) const { DependencyManager::get()->setLength(uid, laserLength); } - - /*@jsdoc - * Sets a list of entity and avatar IDs that a pointer should ignore during intersection. - * @function LaserPointers.setIgnoreItems - * @param {number} id - The ID of the pointer. - * @param {Uuid[]} ignoreItems - A list of IDs to ignore. - */ - Q_INVOKABLE void setIgnoreItems(unsigned int uid, const ScriptValue& ignoreEntities) const; - - /*@jsdoc - * Sets a list of entity and avatar IDs that a pointer should include during intersection, instead of intersecting with - * everything. - * @function LaserPointers.setIncludeItems - * @param {number} id - The ID of the pointer. - * @param {Uuid[]} includeItems - A list of IDs to include. - */ - Q_INVOKABLE void setIncludeItems(unsigned int uid, const ScriptValue& includeEntities) const; - - - /*@jsdoc - * Locks a pointer onto a specific entity or avatar. - * @function LaserPointers.setLockEndUUID - * @param {number} id - The ID of the pointer. - * @param {Uuid} targetID - The ID of the entity or avatar to lock the pointer on to. - * @param {boolean} isAvatar - true if the target is an avatar, false if it is an entity. - * @param {Mat4} [offset] - The offset of the target point from the center of the target item. If not specified, the - * pointer locks on to the center of the target item. - */ - Q_INVOKABLE void setLockEndUUID(unsigned int uid, const QUuid& objectID, bool isAvatar, const glm::mat4& offsetMat = glm::mat4()) const { DependencyManager::get()->setLockEndUUID(uid, objectID, isAvatar, offsetMat); } - - - /*@jsdoc - * Checks if a pointer is associated with the left hand: a pointer with joint property set to - * "_CONTROLLER_LEFTHAND" or "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND". - * @function LaserPointers.isLeftHand - * @param {number} id - The ID of the pointer. - * @returns {boolean} true if the pointer is associated with the left hand, false if it isn't. - */ - Q_INVOKABLE bool isLeftHand(unsigned int uid) { return DependencyManager::get()->isLeftHand(uid); } - - /*@jsdoc - * Checks if a pointer is associated with the right hand: a pointer with joint property set to - * "_CONTROLLER_RIGHTHAND" or "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND". - * @function LaserPointers.isRightHand - * @param {number} id - The ID of the pointer. - * @returns {boolean} true if the pointer is associated with the right hand, false if it isn't. - */ - Q_INVOKABLE bool isRightHand(unsigned int uid) { return DependencyManager::get()->isRightHand(uid); } - - /*@jsdoc - * Checks if a pointer is associated with the system mouse: a pointer with joint property set to - * "Mouse". - * @function LaserPointers.isMouse - * @param {number} id - The ID of the pointer. - * @returns {boolean} true if the pointer is associated with the system mouse, false if it isn't. - */ - Q_INVOKABLE bool isMouse(unsigned int uid) { return DependencyManager::get()->isMouse(uid); } -}; - -#endif // hifi_LaserPointerScriptingInterface_h diff --git a/interface/src/raypick/ParabolaPointer.cpp b/interface/src/raypick/ParabolaPointer.cpp index 2c32be5d79..2d74385eb7 100644 --- a/interface/src/raypick/ParabolaPointer.cpp +++ b/interface/src/raypick/ParabolaPointer.cpp @@ -1,6 +1,7 @@ // // Created by Sam Gondelman 7/17/2018 // Copyright 2018 High Fidelity, Inc. +// Copyright 2023 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -232,14 +233,13 @@ void ParabolaPointer::RenderState::update(const glm::vec3& origin, const glm::ve } } -std::shared_ptr ParabolaPointer::buildRenderState(const QVariantMap& propMap) { - // FIXME: we have to keep using the Overlays interface here, because existing scripts use overlay properties to define pointers +std::shared_ptr ParabolaPointer::buildRenderState(const QVariantMap& propMap, const QList &entityProperties) { QUuid startID; - if (propMap["start"].isValid()) { - QVariantMap startMap = propMap["start"].toMap(); - if (startMap["type"].isValid()) { - startMap.remove("visible"); - startID = qApp->getOverlays().addOverlay(startMap["type"].toString(), startMap); + if (propMap["startPropertyIndex"].isValid()) { + int startPropertyIndex = propMap["startPropertyIndex"].toInt(); + if (startPropertyIndex >= 0 && startPropertyIndex < entityProperties.length()) { + //startMap.remove("visible"); + startID = DependencyManager::get()->addEntityInternal(entityProperties[startPropertyIndex], entity::HostType::LOCAL); } } @@ -249,36 +249,25 @@ std::shared_ptr ParabolaPointer::buildRenderState(const QVa bool isVisibleInSecondaryCamera = RenderState::ParabolaRenderItem::DEFAULT_PARABOLA_ISVISIBLEINSECONDARYCAMERA; bool drawInFront = RenderState::ParabolaRenderItem::DEFAULT_PARABOLA_DRAWINFRONT; bool enabled = false; - if (propMap["path"].isValid()) { - enabled = true; - QVariantMap pathMap = propMap["path"].toMap(); - if (pathMap["color"].isValid()) { - color = toGlm(u8vec3FromVariant(pathMap["color"])); - } - - if (pathMap["alpha"].isValid()) { - alpha = pathMap["alpha"].toFloat(); - } - - if (pathMap["width"].isValid()) { - width = pathMap["width"].toFloat(); - } - - if (pathMap["isVisibleInSecondaryCamera"].isValid()) { - isVisibleInSecondaryCamera = pathMap["isVisibleInSecondaryCamera"].toBool(); - } - - if (pathMap["drawInFront"].isValid()) { - drawInFront = pathMap["drawInFront"].toBool(); + if (propMap["pathPropertyIndex"].isValid()) { + int pathPropertyIndex = propMap["pathPropertyIndex"].toInt(); + if (pathPropertyIndex >= 0 && pathPropertyIndex < entityProperties.length()) { + const EntityItemProperties &pathProperties(entityProperties[pathPropertyIndex]); + enabled = true; + color = pathProperties.getColor(); + alpha = pathProperties.getAlpha(); + //V8TODO I'm not sure how to do this one + //width = pathProperties.getWidth; + drawInFront = (pathProperties.getRenderLayer() == RenderLayer::FRONT); } } QUuid endID; - if (propMap["end"].isValid()) { - QVariantMap endMap = propMap["end"].toMap(); - if (endMap["type"].isValid()) { - endMap.remove("visible"); - endID = qApp->getOverlays().addOverlay(endMap["type"].toString(), endMap); + if (propMap["endPropertyIndex"].isValid()) { + int endPropertyIndex = propMap["endPropertyIndex"].toInt(); + if (endPropertyIndex >= 0 && endPropertyIndex < entityProperties.length()) { + //endMap.remove("visible"); + endID = DependencyManager::get()->addEntityInternal(entityProperties[endPropertyIndex], entity::HostType::LOCAL); } } diff --git a/interface/src/raypick/ParabolaPointer.h b/interface/src/raypick/ParabolaPointer.h index 1701e4dcfa..59168be5ed 100644 --- a/interface/src/raypick/ParabolaPointer.h +++ b/interface/src/raypick/ParabolaPointer.h @@ -10,6 +10,8 @@ #include "PathPointer.h" +#include + #include class ParabolaPointer : public PathPointer { @@ -105,7 +107,7 @@ public: QVariantMap toVariantMap() const override; - static std::shared_ptr buildRenderState(const QVariantMap& propMap); + static std::shared_ptr buildRenderState(const QVariantMap& propMap, const QList &entityProperties); protected: virtual PickResultPointer getPickResultCopy(const PickResultPointer& pickResult) const override; diff --git a/interface/src/raypick/PointerScriptingInterface.cpp b/interface/src/raypick/PointerScriptingInterface.cpp index 211ce2f9df..192bf494f0 100644 --- a/interface/src/raypick/PointerScriptingInterface.cpp +++ b/interface/src/raypick/PointerScriptingInterface.cpp @@ -22,6 +22,13 @@ #include "StylusPointer.h" #include "ParabolaPointer.h" #include "StylusPick.h" +#include + +STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){ + qDebug() << "STATIC_SCRIPT_TYPES_INITIALIZER PointerScriptingInterface"; + auto scriptEngine = manager->engine().get(); + scriptRegisterMetaType(scriptEngine); +})); static const glm::quat X_ROT_NEG_90{ 0.70710678f, -0.70710678f, 0.0f, 0.0f }; static const glm::vec3 DEFAULT_POSITION_OFFSET{0.0f, 0.0f, -StylusPick::WEB_STYLUS_LENGTH / 2.0f}; @@ -35,26 +42,26 @@ void PointerScriptingInterface::setIncludeItems(unsigned int uid, const ScriptVa DependencyManager::get()->setIncludeItems(uid, qVectorQUuidFromScriptValue(includeItems)); } -unsigned int PointerScriptingInterface::createPointer(const PickQuery::PickType& type, const QVariant& properties) { +unsigned int PointerScriptingInterface::createPointerInternal(const PickQuery::PickType& type, const PointerProperties& properties) { // Interaction with managers should always happen on the main thread if (QThread::currentThread() != qApp->thread()) { unsigned int result; - BLOCKING_INVOKE_METHOD(this, "createPointer", Q_RETURN_ARG(unsigned int, result), Q_ARG(PickQuery::PickType, type), Q_ARG(QVariant, properties)); + BLOCKING_INVOKE_METHOD(this, "createPointerInternal", Q_RETURN_ARG(unsigned int, result), Q_ARG(PickQuery::PickType, type), Q_ARG(PointerProperties, properties)); return result; } - QVariantMap propertyMap = properties.toMap(); + QVariantMap propertyMap = properties.properties; std::shared_ptr pointer; switch (type) { case PickQuery::PickType::Ray: - pointer = buildLaserPointer(propertyMap); + pointer = buildLaserPointer(properties); break; case PickQuery::PickType::Stylus: - pointer = buildStylus(propertyMap); + pointer = buildStylus(properties); break; case PickQuery::PickType::Parabola: - pointer = buildParabolaPointer(propertyMap); + pointer = buildParabolaPointer(properties); break; default: break; @@ -71,6 +78,10 @@ unsigned int PointerScriptingInterface::createPointer(const PickQuery::PickType& return DependencyManager::get()->addPointer(pointer); } +unsigned int PointerScriptingInterface::createRayPointer(RayPointerProperties properties) { + return createPointerInternal(PickQuery::PickType::Ray, properties); +} + bool PointerScriptingInterface::isPointerEnabled(unsigned int uid) const { return DependencyManager::get()->isPointerEnabled(uid); } @@ -109,8 +120,8 @@ QVariantMap PointerScriptingInterface::getPointerScriptParameters(unsigned int u * offset. * @property {Quat} [rotationOffset] - The rotation offset of the model from the hand, to override the default rotation offset. */ -std::shared_ptr PointerScriptingInterface::buildStylus(const QVariant& properties) { - QVariantMap propertyMap = properties.toMap(); +std::shared_ptr PointerScriptingInterface::buildStylus(const PointerProperties& properties) { + QVariantMap propertyMap = properties.properties; bool hover = false; if (propertyMap["hover"].isValid()) { @@ -142,7 +153,7 @@ std::shared_ptr PointerScriptingInterface::buildStylus(const QVariant& } } - return std::make_shared(properties, StylusPointer::buildStylus(propertyMap), hover, enabled, modelPositionOffset, modelRotationOffset, modelDimensions); + return std::make_shared(properties.properties, StylusPointer::buildStylus(propertyMap), hover, enabled, modelPositionOffset, modelRotationOffset, modelDimensions); } /*@jsdoc @@ -221,8 +232,8 @@ std::shared_ptr PointerScriptingInterface::buildStylus(const QVariant& * {@link Pointers.getPointerProperties}. * @see {@link Picks.RayPickProperties} for additional properties from the underlying ray pick. */ -std::shared_ptr PointerScriptingInterface::buildLaserPointer(const QVariant& properties) { - QVariantMap propertyMap = properties.toMap(); +std::shared_ptr PointerScriptingInterface::buildLaserPointer(const PointerProperties& properties) { + QVariantMap propertyMap = properties.properties; #if defined (Q_OS_ANDROID) QString jointName { "" }; @@ -284,7 +295,7 @@ std::shared_ptr PointerScriptingInterface::buildLaserPointer(const QVar QVariantMap renderStateMap = renderStateVariant.toMap(); if (renderStateMap["name"].isValid()) { std::string name = renderStateMap["name"].toString().toStdString(); - renderStates[name] = LaserPointer::buildRenderState(renderStateMap); + renderStates[name] = LaserPointer::buildRenderState(renderStateMap, properties.entityProperties); } } } @@ -299,7 +310,8 @@ std::shared_ptr PointerScriptingInterface::buildLaserPointer(const QVar if (renderStateMap["name"].isValid() && renderStateMap["distance"].isValid()) { std::string name = renderStateMap["name"].toString().toStdString(); float distance = renderStateMap["distance"].toFloat(); - defaultRenderStates[name] = std::pair>(distance, LaserPointer::buildRenderState(renderStateMap)); + defaultRenderStates[name] = std::pair>(distance, + LaserPointer::buildRenderState(renderStateMap, properties.entityProperties)); } } } @@ -328,7 +340,7 @@ std::shared_ptr PointerScriptingInterface::buildLaserPointer(const QVar } } - return std::make_shared(properties, renderStates, defaultRenderStates, hover, triggers, + return std::make_shared(properties.properties, renderStates, defaultRenderStates, hover, triggers, faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd, distanceScaleEnd, scaleWithParent, enabled); } @@ -416,8 +428,8 @@ std::shared_ptr PointerScriptingInterface::buildLaserPointer(const QVar * {@link Pointers.getPointerProperties}. * @see {@link Picks.ParabolaPickProperties} for additional properties from the underlying parabola pick. */ -std::shared_ptr PointerScriptingInterface::buildParabolaPointer(const QVariant& properties) { - QVariantMap propertyMap = properties.toMap(); +std::shared_ptr PointerScriptingInterface::buildParabolaPointer(const PointerProperties& properties) { + QVariantMap propertyMap = properties.properties; bool faceAvatar = false; if (propertyMap["faceAvatar"].isValid()) { @@ -468,7 +480,7 @@ std::shared_ptr PointerScriptingInterface::buildParabolaPointer(const Q QVariantMap renderStateMap = renderStateVariant.toMap(); if (renderStateMap["name"].isValid()) { std::string name = renderStateMap["name"].toString().toStdString(); - renderStates[name] = ParabolaPointer::buildRenderState(renderStateMap); + renderStates[name] = ParabolaPointer::buildRenderState(renderStateMap, properties.entityProperties); } } } @@ -483,7 +495,8 @@ std::shared_ptr PointerScriptingInterface::buildParabolaPointer(const Q if (renderStateMap["name"].isValid() && renderStateMap["distance"].isValid()) { std::string name = renderStateMap["name"].toString().toStdString(); float distance = renderStateMap["distance"].toFloat(); - defaultRenderStates[name] = std::pair>(distance, ParabolaPointer::buildRenderState(renderStateMap)); + defaultRenderStates[name] = std::pair>(distance, + ParabolaPointer::buildRenderState(renderStateMap, properties.entityProperties)); } } } @@ -512,12 +525,13 @@ std::shared_ptr PointerScriptingInterface::buildParabolaPointer(const Q } } - return std::make_shared(properties, renderStates, defaultRenderStates, hover, triggers, + return std::make_shared(properties.properties, renderStates, defaultRenderStates, hover, triggers, faceAvatar, followNormal, followNormalStrength, centerEndY, lockEnd, distanceScaleEnd, scaleWithParent, enabled); } void PointerScriptingInterface::editRenderState(unsigned int uid, const QString& renderState, const QVariant& properties) const { + //V8TODO: this won't work for now QVariantMap propMap = properties.toMap(); QVariant startProps; @@ -546,3 +560,52 @@ QVariantMap PointerScriptingInterface::getPrevPickResult(unsigned int uid) const } return result; } + +ScriptValue rayPointerPropertiesToScriptValue(ScriptEngine* engine, const RayPointerProperties& in) { + return engine->newVariant(QVariant(in.properties)); +} + +bool rayPointerPropertiesFromScriptValue(const ScriptValue& value, RayPointerProperties& out) { + // This copies properties from script value, but also converts entity properties of entities used in render states + // from JS objects into EntityItemProperties + out.properties = value.engine()->fromScriptValue(value); + if (out.properties["renderStates"].canConvert()) { + QVariantList renderStates = out.properties["renderStates"].value(); + for( int i = 0; i < renderStates.length(); i++) { + if (renderStates[i].canConvert()) { + QVariantMap stateMap = renderStates[i].value(); + if (stateMap["name"].canConvert()) { + stateMap["name"].value(); + } + if (stateMap["start"].isValid()) { + ScriptValue start = value.property("renderStates").property(i).property("start"); + EntityItemProperties startProperties; + startProperties.copyFromScriptValue(start, false); + stateMap.insert("startPropertyIndex", QVariant(out.entityProperties.length())); + out.entityProperties.append(startProperties); + } + + if (stateMap["path"].isValid()) { + ScriptValue path = value.property("renderStates").property(i).property("path"); + EntityItemProperties pathProperties; + pathProperties.copyFromScriptValue(path, false); + stateMap.insert("pathPropertyIndex", QVariant(out.entityProperties.length())); + out.entityProperties.append(pathProperties); + } + + if (stateMap["end"].isValid()) { + ScriptValue end = value.property("renderStates").property(i).property("end"); + EntityItemProperties endProperties; + endProperties.copyFromScriptValue(end, false); + stateMap.insert("endPropertyIndex", QVariant(out.entityProperties.length())); + out.entityProperties.append(endProperties); + } + // V8TODO: Check if path is a polyline and if values are valid + renderStates[i].setValue(stateMap); + } + } + out.properties["renderStates"].setValue(renderStates); + } + qDebug() << "rayPointerPropertiesFromScriptValue" << out.properties; + return true; +} diff --git a/interface/src/raypick/PointerScriptingInterface.h b/interface/src/raypick/PointerScriptingInterface.h index c7d4cc038c..3313ce0bc2 100644 --- a/interface/src/raypick/PointerScriptingInterface.h +++ b/interface/src/raypick/PointerScriptingInterface.h @@ -14,14 +14,15 @@ #include "DependencyManager.h" #include "RegisteredMetaTypes.h" +#include #include #include class ScriptValue; /*@jsdoc - * The Pointers API lets you create, manage, and visually represent objects for repeatedly calculating - * intersections with avatars, entities, and overlays. Pointers can also be configured to generate events on entities and + * The Pointers API lets you create, manage, and visually represent objects for repeatedly calculating + * intersections with avatars, entities, and overlays. Pointers can also be configured to generate events on entities and * overlays intersected. * * @namespace Pointers @@ -31,12 +32,34 @@ class ScriptValue; * @hifi-avatar */ +class PointerProperties { +public: + QVariantMap properties; + QList entityProperties; +}; + +class RayPointerProperties : public PointerProperties { +}; + +class ParabolaPointerProperties : public PointerProperties { +}; + +class StylusPointerProperties : public PointerProperties { +}; + +Q_DECLARE_METATYPE(RayPointerProperties); +Q_DECLARE_METATYPE(PointerProperties); + class PointerScriptingInterface : public QObject, public Dependency { Q_OBJECT SINGLETON_DEPENDENCY public: + + // The purpose of registering different classes is to let the script engine know what data structure it has to + // expect in JS object that will be converted to PointerProperties + /*@jsdoc * Specifies that a {@link Controller} action or function should trigger events on the entity or overlay currently * intersected by a {@link Pointers.RayPointerProperties|Ray} or {@link Pointers.ParabolaPointerProperties|Parabola} @@ -133,7 +156,9 @@ public: * }); */ // TODO: expand Pointers to be able to be fully configurable with PickFilters - Q_INVOKABLE unsigned int createPointer(const PickQuery::PickType& type, const QVariant& properties); + + // V8TODO: add documentation + Q_INVOKABLE unsigned int createRayPointer(RayPointerProperties properties); /*@jsdoc * Enables and shows a pointer. Enabled pointers update their pick results and generate events. @@ -479,9 +504,15 @@ public: Q_INVOKABLE QVariantMap getPointerProperties(unsigned int uid) const; protected: - static std::shared_ptr buildLaserPointer(const QVariant& properties); - static std::shared_ptr buildStylus(const QVariant& properties); - static std::shared_ptr buildParabolaPointer(const QVariant& properties); + static std::shared_ptr buildLaserPointer(const PointerProperties& properties); + static std::shared_ptr buildStylus(const PointerProperties& properties); + static std::shared_ptr buildParabolaPointer(const PointerProperties& properties); +private: + Q_INVOKABLE unsigned int createPointerInternal(const PickQuery::PickType& type, const PointerProperties& properties); }; +ScriptValue rayPointerPropertiesToScriptValue(ScriptEngine* engine, const RayPointerProperties& in); + +bool rayPointerPropertiesFromScriptValue(const ScriptValue& value, RayPointerProperties& out); + #endif // hifi_PointerScriptingInterface_h diff --git a/interface/src/raypick/StylusPointer.cpp b/interface/src/raypick/StylusPointer.cpp index 48b61e9a2a..0e19b0fe6b 100644 --- a/interface/src/raypick/StylusPointer.cpp +++ b/interface/src/raypick/StylusPointer.cpp @@ -49,7 +49,7 @@ PickQuery::PickType StylusPointer::getType() const { QUuid StylusPointer::buildStylus(const QVariantMap& properties) { // FIXME: we have to keep using the Overlays interface here, because existing scripts use overlay properties to define pointers - QVariantMap propertiesMap; + /*QVariantMap propertiesMap; QString modelUrl = DEFAULT_STYLUS_MODEL_URL; @@ -69,7 +69,30 @@ QUuid StylusPointer::buildStylus(const QVariantMap& properties) { propertiesMap["ignorePickIntersection"] = true; propertiesMap["drawInFront"] = false; - return qApp->getOverlays().addOverlay("model", propertiesMap); + return qApp->getOverlays().addOverlay("model", propertiesMap);*/ + + EntityItemProperties entityProperties; + QString modelURL = DEFAULT_STYLUS_MODEL_URL; + + if (properties["model"].isValid()) { + QVariantMap modelData = properties["model"].toMap(); + + if (modelData["url"].isValid()) { + modelURL = modelData["url"].toString(); + } + } + // TODO: make these configurable per pointer + entityProperties.setType(EntityTypes::Model); + entityProperties.setName("stylus"); + entityProperties.setModelURL(modelURL); + // V8TODO: I can't find equivalent for entities + //propertiesMap["loadPriority"] = 10.0f; + entityProperties.setPrimitiveMode(PrimitiveMode::SOLID); + entityProperties.setVisible(true); + entityProperties.setIgnorePickIntersection(true); + // V8TODO: I can't find equivalent for entities but shouldn't be necessary + //propertiesMap["drawInFront"] = false; + return DependencyManager::get()->addEntityInternal(entityProperties, entity::HostType::LOCAL); } void StylusPointer::updateVisuals(const PickResultPointer& pickResult) { diff --git a/libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp b/libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp index 3af798842f..f4efb2494a 100644 --- a/libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp +++ b/libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp @@ -1051,7 +1051,11 @@ void ScriptMethodV8Proxy::call(const v8::FunctionCallbackInfo& argume for (int arg = 0; arg < numArgs; ++arg) { int methodArgTypeId = meta.parameterType(arg); - Q_ASSERT(methodArgTypeId != QMetaType::UnknownType); + if (methodArgTypeId == QMetaType::UnknownType) { + QString methodName = fullName(); + qCDebug(scriptengine_v8) << "One of the arguments is QMetaType::UnknownType for method " << methodName; + Q_ASSERT(false); + } v8::Local argVal = arguments[arg]; if (methodArgTypeId == scriptValueTypeId) { qScriptArgLists[i].append(ScriptValue(new ScriptValueV8Wrapper(_engine, V8ScriptValue(_engine, argVal)))); diff --git a/scripts/system/libraries/pointersUtils.js b/scripts/system/libraries/pointersUtils.js index bb93ae2735..dbbd9fc863 100644 --- a/scripts/system/libraries/pointersUtils.js +++ b/scripts/system/libraries/pointersUtils.js @@ -23,58 +23,62 @@ var Pointer = function(hudLayer, pickType, pointerData) { this.SEARCH_SPHERE_SIZE = 0.0132; this.dim = {x: this.SEARCH_SPHERE_SIZE, y: this.SEARCH_SPHERE_SIZE, z: this.SEARCH_SPHERE_SIZE}; this.halfPath = { - type: "line3d", + type: "PolyLine", color: COLORS_GRAB_SEARCHING_HALF_SQUEEZE, visible: true, alpha: 1, solid: true, - glow: 1.0, - ignoreRayIntersection: true, // always ignore this - drawInFront: !hudLayer, // Even when burried inside of something, show it. + glow: true, + billboardMode: "yaw", + ignorePickIntersection: true, // always ignore this + //V8TODO + drawInFront: !hudLayer, // Even when buried inside of something, show it. drawHUDLayer: hudLayer, }; this.halfEnd = { - type: "sphere", + type: "Sphere", dimensions: this.dim, solid: true, color: COLORS_GRAB_SEARCHING_HALF_SQUEEZE, alpha: 0.9, - ignoreRayIntersection: true, - drawInFront: !hudLayer, // Even when burried inside of something, show it. + ignorePickIntersection: true, + drawInFront: !hudLayer, // Even when buried inside of something, show it. drawHUDLayer: hudLayer, visible: true }; this.fullPath = { - type: "line3d", + type: "PolyLine", color: COLORS_GRAB_SEARCHING_FULL_SQUEEZE, visible: true, alpha: 1, solid: true, - glow: 1.0, - ignoreRayIntersection: true, // always ignore this - drawInFront: !hudLayer, // Even when burried inside of something, show it. + glow: true, + billboardMode: "yaw", + ignorePickIntersection: true, // always ignore this + drawInFront: !hudLayer, // Even when buried inside of something, show it. drawHUDLayer: hudLayer, }; this.fullEnd = { - type: "sphere", + type: "Sphere", dimensions: this.dim, solid: true, color: COLORS_GRAB_SEARCHING_FULL_SQUEEZE, alpha: 0.9, - ignoreRayIntersection: true, - drawInFront: !hudLayer, // Even when burried inside of something, show it. + ignorePickIntersection: true, + drawInFront: !hudLayer, // Even when buried inside of something, show it. drawHUDLayer: hudLayer, visible: true }; this.holdPath = { - type: "line3d", + type: "PolyLine", color: COLORS_GRAB_DISTANCE_HOLD, visible: true, alpha: 1, solid: true, - glow: 1.0, - ignoreRayIntersection: true, // always ignore this - drawInFront: !hudLayer, // Even when burried inside of something, show it. + glow: true, + billboardMode: "yaw", + ignorePickIntersection: true, // always ignore this + drawInFront: !hudLayer, // Even when buried inside of something, show it. drawHUDLayer: hudLayer, }; @@ -99,6 +103,7 @@ var Pointer = function(hudLayer, pickType, pointerData) { delete pointerData.hand; function createPointer(pickType, pointerData) { + //V8TODO var pointerID = Pointers.createPointer(pickType, pointerData); Pointers.setRenderState(pointerID, ""); Pointers.enablePointer(pointerID);