History

Type registeration fixes for scripting engine

ksuprynowicz committed 4 years ago

Commit 0a3ec921 parent 50a6a6334 files · +266 −67Browse files

Showing the changes to interface/src/raypick/PickScriptingInterface.cpp (1 of 34 files). Show all

Unified · Split

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