mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 01:36:56 +02:00
IPD Fixes for controllerDispatcher and controllerModules
This commit is contained in:
parent
9a9f4a0d24
commit
7c725756f1
5 changed files with 16 additions and 10 deletions
|
@ -150,6 +150,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
if (PROFILE) {
|
if (PROFILE) {
|
||||||
Script.beginProfileRange("dispatch.pre");
|
Script.beginProfileRange("dispatch.pre");
|
||||||
}
|
}
|
||||||
|
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||||
var deltaTime = _this.updateTimings();
|
var deltaTime = _this.updateTimings();
|
||||||
_this.setIgnoreTablet();
|
_this.setIgnoreTablet();
|
||||||
|
|
||||||
|
@ -196,7 +197,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
var h;
|
var h;
|
||||||
for (h = LEFT_HAND; h <= RIGHT_HAND; h++) {
|
for (h = LEFT_HAND; h <= RIGHT_HAND; h++) {
|
||||||
if (controllerLocations[h].valid) {
|
if (controllerLocations[h].valid) {
|
||||||
var nearbyOverlays = Overlays.findOverlays(controllerLocations[h].position, NEAR_MAX_RADIUS);
|
var nearbyOverlays = Overlays.findOverlays(controllerLocations[h].position, NEAR_MAX_RADIUS * sensorScaleFactor);
|
||||||
nearbyOverlays.sort(function (a, b) {
|
nearbyOverlays.sort(function (a, b) {
|
||||||
var aPosition = Overlays.getProperty(a, "position");
|
var aPosition = Overlays.getProperty(a, "position");
|
||||||
var aDistance = Vec3.distance(aPosition, controllerLocations[h].position);
|
var aDistance = Vec3.distance(aPosition, controllerLocations[h].position);
|
||||||
|
@ -216,7 +217,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
for (h = LEFT_HAND; h <= RIGHT_HAND; h++) {
|
for (h = LEFT_HAND; h <= RIGHT_HAND; h++) {
|
||||||
if (controllerLocations[h].valid) {
|
if (controllerLocations[h].valid) {
|
||||||
var controllerPosition = controllerLocations[h].position;
|
var controllerPosition = controllerLocations[h].position;
|
||||||
var nearbyEntityIDs = Entities.findEntities(controllerPosition, NEAR_MAX_RADIUS);
|
var nearbyEntityIDs = Entities.findEntities(controllerPosition, NEAR_MAX_RADIUS * sensorScaleFactor);
|
||||||
for (var j = 0; j < nearbyEntityIDs.length; j++) {
|
for (var j = 0; j < nearbyEntityIDs.length; j++) {
|
||||||
var entityID = nearbyEntityIDs[j];
|
var entityID = nearbyEntityIDs[j];
|
||||||
var props = Entities.getEntityProperties(entityID, DISPATCHER_PROPERTIES);
|
var props = Entities.getEntityProperties(entityID, DISPATCHER_PROPERTIES);
|
||||||
|
@ -249,7 +250,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
|
|
||||||
if (rayPicks[h].type === RayPick.INTERSECTED_ENTITY) {
|
if (rayPicks[h].type === RayPick.INTERSECTED_ENTITY) {
|
||||||
// XXX check to make sure this one isn't already in nearbyEntityProperties?
|
// XXX check to make sure this one isn't already in nearbyEntityProperties?
|
||||||
if (rayPicks[h].distance < NEAR_GRAB_PICK_RADIUS) {
|
if (rayPicks[h].distance < NEAR_GRAB_PICK_RADIUS * sensorScaleFactor) {
|
||||||
var nearEntityID = rayPicks[h].objectID;
|
var nearEntityID = rayPicks[h].objectID;
|
||||||
var nearbyProps = Entities.getEntityProperties(nearEntityID, DISPATCHER_PROPERTIES);
|
var nearbyProps = Entities.getEntityProperties(nearEntityID, DISPATCHER_PROPERTIES);
|
||||||
nearbyProps.id = nearEntityID;
|
nearbyProps.id = nearEntityID;
|
||||||
|
|
|
@ -147,10 +147,11 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
|
||||||
this.getTargetProps = function (controllerData) {
|
this.getTargetProps = function (controllerData) {
|
||||||
// nearbyEntityProperties is already sorted by distance from controller
|
// nearbyEntityProperties is already sorted by distance from controller
|
||||||
var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
|
var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
|
||||||
|
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||||
for (var i = 0; i < nearbyEntityProperties.length; i++) {
|
for (var i = 0; i < nearbyEntityProperties.length; i++) {
|
||||||
var props = nearbyEntityProperties[i];
|
var props = nearbyEntityProperties[i];
|
||||||
var handPosition = controllerData.controllerLocations[this.hand].position;
|
var handPosition = controllerData.controllerLocations[this.hand].position;
|
||||||
if (props.distance > NEAR_GRAB_RADIUS) {
|
if (props.distance > NEAR_GRAB_RADIUS * sensorScaleFactor) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (entityIsGrabbable(props) || entityIsCloneable(props)) {
|
if (entityIsGrabbable(props) || entityIsCloneable(props)) {
|
||||||
|
|
|
@ -147,11 +147,12 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
|
||||||
this.getTargetProps = function (controllerData) {
|
this.getTargetProps = function (controllerData) {
|
||||||
// nearbyEntityProperties is already sorted by length from controller
|
// nearbyEntityProperties is already sorted by length from controller
|
||||||
var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
|
var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
|
||||||
|
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||||
for (var i = 0; i < nearbyEntityProperties.length; i++) {
|
for (var i = 0; i < nearbyEntityProperties.length; i++) {
|
||||||
var props = nearbyEntityProperties[i];
|
var props = nearbyEntityProperties[i];
|
||||||
var handPosition = controllerData.controllerLocations[this.hand].position;
|
var handPosition = controllerData.controllerLocations[this.hand].position;
|
||||||
var distance = Vec3.distance(props.position, handPosition);
|
var distance = Vec3.distance(props.position, handPosition);
|
||||||
if (distance > NEAR_GRAB_RADIUS) {
|
if (distance > NEAR_GRAB_RADIUS * sensorScaleFactor) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (entityIsGrabbable(props)) {
|
if (entityIsGrabbable(props)) {
|
||||||
|
|
|
@ -8,12 +8,13 @@
|
||||||
|
|
||||||
/* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID,
|
/* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID,
|
||||||
getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule,
|
getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule,
|
||||||
Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,
|
Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, NEAR_GRAB_RADIUS
|
||||||
makeDispatcherModuleParameters, Overlays, makeRunningValues
|
makeDispatcherModuleParameters, Overlays, makeRunningValues, resizeTablet,
|
||||||
|
getTabletWidthFromSettings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
var GRAB_RADIUS = 0.35;
|
Script.include("/~/system/libraries/utils.js");
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
@ -156,11 +157,12 @@ var GRAB_RADIUS = 0.35;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getTargetID = function(overlays, controllerData) {
|
this.getTargetID = function(overlays, controllerData) {
|
||||||
|
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||||
for (var i = 0; i < overlays.length; i++) {
|
for (var i = 0; i < overlays.length; i++) {
|
||||||
var overlayPosition = Overlays.getProperty(overlays[i], "position");
|
var overlayPosition = Overlays.getProperty(overlays[i], "position");
|
||||||
var handPosition = controllerData.controllerLocations[this.hand].position;
|
var handPosition = controllerData.controllerLocations[this.hand].position;
|
||||||
var distance = Vec3.distance(overlayPosition, handPosition);
|
var distance = Vec3.distance(overlayPosition, handPosition);
|
||||||
if (distance <= GRAB_RADIUS) {
|
if (distance <= NEAR_GRAB_RADIUS * sensorScaleFactor) {
|
||||||
return overlays[i];
|
return overlays[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,12 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
this.getTargetProps = function (controllerData) {
|
this.getTargetProps = function (controllerData) {
|
||||||
// nearbyEntityProperties is already sorted by length from controller
|
// nearbyEntityProperties is already sorted by length from controller
|
||||||
var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
|
var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
|
||||||
|
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||||
for (var i = 0; i < nearbyEntityProperties.length; i++) {
|
for (var i = 0; i < nearbyEntityProperties.length; i++) {
|
||||||
var props = nearbyEntityProperties[i];
|
var props = nearbyEntityProperties[i];
|
||||||
var handPosition = controllerData.controllerLocations[this.hand].position;
|
var handPosition = controllerData.controllerLocations[this.hand].position;
|
||||||
var distance = Vec3.distance(props.position, handPosition);
|
var distance = Vec3.distance(props.position, handPosition);
|
||||||
if (distance > NEAR_GRAB_RADIUS) {
|
if (distance > NEAR_GRAB_RADIUS * sensorScaleFactor) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (entityWantsNearTrigger(props)) {
|
if (entityWantsNearTrigger(props)) {
|
||||||
|
|
Loading…
Reference in a new issue