Fixed events on V8

This commit is contained in:
ksuprynowicz 2023-03-10 22:15:13 +01:00
parent de75aa1794
commit 819ebc9e49
4 changed files with 29 additions and 24 deletions

View file

@ -23,13 +23,15 @@
#include "TouchEvent.h"
#include "WheelEvent.h"
STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
auto scriptEngine = manager->engine().get();
//STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
// auto scriptEngine = manager->engine().get();
void registerEventTypes(ScriptEngine* scriptEngine){
scriptRegisterMetaType<KeyEvent, KeyEvent::toScriptValue, KeyEvent::fromScriptValue>(scriptEngine, "KeyEvent");
scriptRegisterMetaType<MouseEvent, MouseEvent::toScriptValue, MouseEvent::fromScriptValue>(scriptEngine, "MouseEvent");
scriptRegisterMetaType<PointerEvent, PointerEvent::toScriptValue, PointerEvent::fromScriptValue>(scriptEngine, "PointerEvent");
scriptRegisterMetaType<TouchEvent, TouchEvent::toScriptValue, TouchEvent::fromScriptValue>(scriptEngine, "TouchEvent");
scriptRegisterMetaType<WheelEvent, WheelEvent::toScriptValue, WheelEvent::fromScriptValue>(scriptEngine, "WheelEvent");
scriptRegisterMetaType<SpatialEvent, SpatialEvent::toScriptValue, SpatialEvent::fromScriptValue>(scriptEngine, "SpatialEvent");
}));
}
//}));

View file

@ -104,6 +104,7 @@ static bool scriptableResourceFromScriptValue(const ScriptValue& value, Scriptab
STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
auto scriptEngine = manager->engine().get();
registerEventTypes(scriptEngine);
scriptRegisterMetaType<ExternalResource::Bucket, externalResourceBucketToScriptValue, externalResourceBucketFromScriptValue>(scriptEngine);
scriptRegisterMetaType<ScriptableResourceRawPtr, scriptableResourceToScriptValue, scriptableResourceFromScriptValue>(scriptEngine);

View file

@ -1384,7 +1384,7 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu
}
_callCounter++;
if (_callCounter % 10 == 0) {
if (_callCounter % 1000 == 0) {
qCDebug(scriptengine_v8) << "Script engine: " << _engine->manager()->getFilename() << " Signal proxy " << fullName()
<< " call count: " << _callCounter << " total time: " << _totalCallTime_s;
}

View file

@ -369,6 +369,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
for (h = LEFT_HAND; h <= RIGHT_HAND; h++) {
// XXX find a way to extract searchRay from samuel's stuff
if (controllerLocations[h].valid) {
rayPicks[h].searchRay = {
origin: controllerLocations[h].position,
direction: Quat.getUp(controllerLocations[h].orientation),
@ -392,6 +393,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
return a.distance - b.distance;
});
}
}
// sometimes, during a HMD snap-turn, an equipped or held item wont be near
// the hand when the findEntities is done. Gather up any hand-children here.