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,28 +369,30 @@ 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
rayPicks[h].searchRay = {
origin: controllerLocations[h].position,
direction: Quat.getUp(controllerLocations[h].orientation),
length: 1000
};
if (controllerLocations[h].valid) {
rayPicks[h].searchRay = {
origin: controllerLocations[h].position,
direction: Quat.getUp(controllerLocations[h].orientation),
length: 1000
};
if (rayPicks[h].type === Picks.INTERSECTED_ENTITY) {
// XXX check to make sure this one isn't already in nearbyEntityProperties?
if (rayPicks[h].distance < NEAR_GRAB_PICK_RADIUS * sensorScaleFactor) {
var nearEntityID = rayPicks[h].objectID;
var nearbyProps = Entities.getEntityProperties(nearEntityID, DISPATCHER_PROPERTIES);
nearbyProps.id = nearEntityID;
nearbyProps.distance = rayPicks[h].distance;
nearbyEntityPropertiesByID[nearEntityID] = nearbyProps;
nearbyEntityProperties[h].push(nearbyProps);
if (rayPicks[h].type === Picks.INTERSECTED_ENTITY) {
// XXX check to make sure this one isn't already in nearbyEntityProperties?
if (rayPicks[h].distance < NEAR_GRAB_PICK_RADIUS * sensorScaleFactor) {
var nearEntityID = rayPicks[h].objectID;
var nearbyProps = Entities.getEntityProperties(nearEntityID, DISPATCHER_PROPERTIES);
nearbyProps.id = nearEntityID;
nearbyProps.distance = rayPicks[h].distance;
nearbyEntityPropertiesByID[nearEntityID] = nearbyProps;
nearbyEntityProperties[h].push(nearbyProps);
}
}
}
// sort by distance from each hand
nearbyEntityProperties[h].sort(function (a, b) {
return a.distance - b.distance;
});
// sort by distance from each hand
nearbyEntityProperties[h].sort(function (a, b) {
return a.distance - b.distance;
});
}
}
// sometimes, during a HMD snap-turn, an equipped or held item wont be near