Fixed grabbing in VR

This commit is contained in:
ksuprynowicz 2023-04-22 19:53:52 +02:00
parent 6f92cf0330
commit 85262dfe28
6 changed files with 22 additions and 10 deletions

View file

@ -39,8 +39,9 @@ Rectangle {
}
Component.onCompleted: {
AudioScriptingInterface.noiseGateOpened.connect(function() { micBar.gated = false; });
AudioScriptingInterface.noiseGateClosed.connect(function() { micBar.gated = true; });
//TODO: this was causing type errors
//AudioScriptingInterface.noiseGateOpened.connect(function() { micBar.gated = false; });
//AudioScriptingInterface.noiseGateClosed.connect(function() { micBar.gated = true; });
HMD.displayModeChanged.connect(function() {
muted = AudioScriptingInterface.muted;
pushToTalk = AudioScriptingInterface.pushToTalk;

View file

@ -102,7 +102,9 @@ Script.include("/~/system/libraries/controllers.js");
for (var i = 0; i < nearbyEntityProperties.length; i++) {
var props = nearbyEntityProperties[i];
var grabPosition = controllerData.controllerLocations[this.hand].position; // Is offset from hand position.
var dist = distanceBetweenPointAndEntityBoundingBox(grabPosition, props);
// TODO: this function gives incorrect result now and needs to be fixed later
//var dist = distanceBetweenPointAndEntityBoundingBox(grabPosition, props);
var dist = 0;
var distance = Vec3.distance(grabPosition, props.position);
if ((dist > nearGrabDistance) ||
(distance > nearGrabRadius)) { // Only smallish entities can be near grabbed.

View file

@ -73,23 +73,24 @@ Script.include("/~/system/libraries/controllers.js");
width: 0.025,
drawInFront: true
};
//V8TODO: check render states
var teleportEnd = {
type: "model",
type: "Model",
url: TARGET_MODEL_URL,
dimensions: TARGET_MODEL_DIMENSIONS,
ignorePickIntersection: true
};
var seatEnd = {
type: "model",
type: "Model",
url: SEAT_MODEL_URL,
dimensions: TARGET_MODEL_DIMENSIONS,
ignorePickIntersection: true
};
var collisionEnd = {
type: "shape",
type: "Shape",
shape: "box",
dimensions: { x: 1.0, y: 0.001, z: 1.0 },
alpha: 0.0,
@ -409,6 +410,7 @@ Script.include("/~/system/libraries/controllers.js");
});
//V8TODO: this won't work anymore
_this.playAreaOverlay = Overlays.addOverlay("model", {
url: _this.PLAY_AREA_OVERLAY_MODEL,
drawInFront: false,
@ -434,6 +436,7 @@ Script.include("/~/system/libraries/controllers.js");
for (var i = 0; i < _this.playAreaSensorPositions.length; i++) {
if (i > _this.playAreaSensorPositionOverlays.length - 1) {
//V8TODO: replace with local entity
var overlay = Overlays.addOverlay("model", {
url: _this.PLAY_AREA_SENSOR_OVERLAY_MODEL,
dimensions: _this.PLAY_AREA_SENSOR_OVERLAY_DIMENSIONS,

View file

@ -11,13 +11,15 @@
/* global Script, Menu */
Script.include("controllerDispatcher.js");
var CONTOLLER_SCRIPTS = [
"squeezeHands.js",
"controllerDisplayManager.js",
"grab.js",
//"toggleAdvancedMovementForHandControllers.js",
"handTouch.js",
"controllerDispatcher.js",
//"controllerDispatcher.js",
"controllerModules/nearParentGrabOverlay.js",
"controllerModules/stylusInput.js",
"controllerModules/equipEntity.js",
@ -44,6 +46,7 @@ var DEBUG_MENU_ITEM = "Debug defaultScripts.js";
function runDefaultsTogether() {
for (var j in CONTOLLER_SCRIPTS) {
if (CONTOLLER_SCRIPTS.hasOwnProperty(j)) {
print("including " + CONTOLLER_SCRIPTS[j]);
Script.include(CONTOLLER_SCRIPTS[j]);
}
}
@ -52,6 +55,7 @@ function runDefaultsTogether() {
function runDefaultsSeparately() {
for (var i in CONTOLLER_SCRIPTS) {
if (CONTOLLER_SCRIPTS.hasOwnProperty(i)) {
print("loading " + CONTOLLER_SCRIPTS[j]);
Script.load(CONTOLLER_SCRIPTS[i]);
}
}

View file

@ -101,7 +101,6 @@ SelectionManager = (function() {
return;
}
print("handleEntitySelectionToolUpdates JSON.parse(message): " + messageParsed.method);
if (messageParsed.method === "selectEntity") {
if (!that.editEnabled) {
return;
@ -1302,7 +1301,7 @@ SelectionDisplay = (function() {
var debugPickPlaneEnabled = false;
var debugPickPlane = Entities.addEntity({
type: "shape",
type: "Shape",
shape: "Quad",
alpha: 0.25,
color: COLOR_DEBUG_PICK_PLANE,

View file

@ -565,6 +565,9 @@ var distanceBetweenPointAndEntityBoundingBox = function(point, entityProps) {
var maxOffset = Vec3.multiplyVbyV(Vec3.subtract(ONE_VEC, entityProps.registrationPoint), entityProps.dimensions);
var localMin = Vec3.subtract(entityXform.pos, minOffset);
var localMax = Vec3.sum(entityXform.pos, maxOffset);
// TODO: was originally this, but this causes an error on V8 branch and probably never worked on QtScript either
//var localMin = Vec3.subtract(entityXform.trans, minOffset);
//var localMax = Vec3.sum(entityXform.trans, maxOffset);
var v = {x: localPoint.x, y: localPoint.y, z: localPoint.z};
v.x = Math.max(v.x, localMin.x);