Showing the changes to interface/src/raypick/PickScriptingInterface.cpp (1 of 34 files). Show all
Unified · Split
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | // |
| 2 | 2 | // Created by Sam Gondelman 10/20/2017 |
| 3 | 3 | // Copyright 2017 High Fidelity, Inc. |
| 4 | +// Copyright 2022 Overte e.V. | |
| 4 | 5 | // |
| 5 | 6 | // Distributed under the Apache License, Version 2.0. |
| 6 | 7 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| @@ -32,6 +33,12 @@ · 25 unmodified lines | ||
| 32 | 33 | #include <ScriptEngineCast.h> |
| 33 | 34 | #include <ScriptValueUtils.h> |
| 34 | 35 | |
| 36 | +STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){ | |
| 37 | + auto scriptEngine = manager->engine().get(); | |
| 38 | + | |
| 39 | + PickScriptingInterface::registerMetaTypes(scriptEngine); | |
| 40 | +}); | |
| 41 | + | |
| 35 | 42 | static const float WEB_TOUCH_Y_OFFSET = 0.105f; // how far forward (or back with a negative number) to slide stylus in hand |
| 36 | 43 | static const glm::vec3 TIP_OFFSET = glm::vec3(0.0f, StylusPick::WEB_STYLUS_LENGTH - WEB_TOUCH_Y_OFFSET, 0.0f); |
| 37 | 44 | |
| @@ -457,14 +464,16 @@ bool pickTypesFromScriptValue(const ScriptValue& object, PickQuery::PickType& pi · 419 unmodified lines | ||
| 457 | 464 | } |
| 458 | 465 | |
| 459 | 466 | void PickScriptingInterface::registerMetaTypes(ScriptEngine* engine) { |
| 467 | + scriptRegisterMetaType(engine, pickTypesToScriptValue, pickTypesFromScriptValue); | |
| 468 | +} | |
| 469 | + | |
| 470 | +void PickScriptingInterface::registerProperties(ScriptEngine* engine) { | |
| 460 | 471 | ScriptValue pickTypes = engine->newObject(); |
| 461 | 472 | auto metaEnum = QMetaEnum::fromType<PickQuery::PickType>(); |
| 462 | 473 | for (int i = 0; i < PickQuery::PickType::NUM_PICK_TYPES; ++i) { |
| 463 | 474 | pickTypes.setProperty(metaEnum.key(i), metaEnum.value(i)); |
| 464 | 475 | } |
| 465 | 476 | engine->globalObject().setProperty("PickType", pickTypes); |
| 466 | − | |
| 467 | − scriptRegisterMetaType(engine, pickTypesToScriptValue, pickTypesFromScriptValue); | |
| 468 | 477 | } |
| 469 | 478 | |
| 470 | 479 | unsigned int PickScriptingInterface::getPerFrameTimeBudget() const { |