mirror of
https://github.com/overte-org/overte.git
synced 2025-06-18 21:20:38 +02:00
Head Collision Pick added
This commit is contained in:
parent
abb632afda
commit
01424b8179
1 changed files with 69 additions and 39 deletions
|
@ -174,38 +174,6 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
maxDistance: 8.0
|
maxDistance: 8.0
|
||||||
});
|
});
|
||||||
|
|
||||||
this.teleportCollisionPick;
|
|
||||||
|
|
||||||
this.recreateCollisionPick = function() {
|
|
||||||
if (_this.teleportCollisionPick !== undefined) {
|
|
||||||
Picks.removePick(_this.teleportCollisionPick);
|
|
||||||
}
|
|
||||||
|
|
||||||
var capsuleData = MyAvatar.getCollisionCapsule();
|
|
||||||
var capsuleHeight = Vec3.distance(capsuleData.start, capsuleData.end);
|
|
||||||
var offset = Vec3.distance(Vec3.sum(capsuleData.start, {x: 0, y: 0.5*capsuleHeight, z: 0}), MyAvatar.position);
|
|
||||||
var radius = capsuleData.radius;
|
|
||||||
var height = 2.0 * radius + capsuleHeight;
|
|
||||||
|
|
||||||
_this.teleportCollisionPick = Picks.createPick(PickType.Collision, {
|
|
||||||
enabled: true,
|
|
||||||
parentID: Pointers.getPointerProperties(_this.teleportParabolaHandInvisible).renderStates["invisible"].end,
|
|
||||||
filter: Picks.PICK_ENTITIES + Picks.PICK_AVATARS,
|
|
||||||
shape: {
|
|
||||||
shapeType: "capsule-y",
|
|
||||||
dimensions: {
|
|
||||||
x: radius * 2.0,
|
|
||||||
y: height - (radius * 2.0),
|
|
||||||
z: radius * 2.0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
position: { x: 0, y: offset + (height * 0.5), z: 0 },
|
|
||||||
threshold: _this.capsuleThreshold
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_this.recreateCollisionPick();
|
|
||||||
|
|
||||||
this.teleportParabolaHeadVisible = Pointers.createPointer(PickType.Parabola, {
|
this.teleportParabolaHeadVisible = Pointers.createPointer(PickType.Parabola, {
|
||||||
joint: "Avatar",
|
joint: "Avatar",
|
||||||
filter: Picks.PICK_ENTITIES,
|
filter: Picks.PICK_ENTITIES,
|
||||||
|
@ -233,12 +201,66 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
maxDistance: 8.0
|
maxDistance: 8.0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.teleportHeadCollisionPick;
|
||||||
|
this.teleportHandCollisionPick;
|
||||||
|
|
||||||
|
this.recreateCollisionPicks = function() {
|
||||||
|
|
||||||
|
if (_this.teleportHandCollisionPick !== undefined) {
|
||||||
|
Picks.removePick(_this.teleportHandCollisionPick);
|
||||||
|
}
|
||||||
|
if (_this.teleportHeadCollisionPick !== undefined) {
|
||||||
|
Picks.removePick(_this.teleportHeadCollisionPick);
|
||||||
|
}
|
||||||
|
var capsuleData = MyAvatar.getCollisionCapsule();
|
||||||
|
var capsuleHeight = Vec3.distance(capsuleData.start, capsuleData.end);
|
||||||
|
var offset = Vec3.distance(Vec3.sum(capsuleData.start, {x: 0, y: 0.5*capsuleHeight, z: 0}), MyAvatar.position);
|
||||||
|
var radius = capsuleData.radius;
|
||||||
|
var height = 2.0 * radius + capsuleHeight;
|
||||||
|
var scale = height/2.0;
|
||||||
|
|
||||||
|
_this.teleportHandCollisionPick = Picks.createPick(PickType.Collision, {
|
||||||
|
enabled: true,
|
||||||
|
parentID: Pointers.getPointerProperties(_this.teleportParabolaHandInvisible).renderStates["invisible"].end,
|
||||||
|
filter: Picks.PICK_ENTITIES + Picks.PICK_AVATARS,
|
||||||
|
shape: {
|
||||||
|
shapeType: "capsule-y",
|
||||||
|
dimensions: {
|
||||||
|
x: radius * 2.0,
|
||||||
|
y: height - (radius * 2.0),
|
||||||
|
z: radius * 2.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
position: { x: 0, y: offset + (height * 0.5), z: 0 },
|
||||||
|
threshold: scale * _this.capsuleThreshold
|
||||||
|
});
|
||||||
|
|
||||||
|
_this.teleportHeadCollisionPick = Picks.createPick(PickType.Collision, {
|
||||||
|
enabled: true,
|
||||||
|
parentID: Pointers.getPointerProperties(_this.teleportParabolaHeadInvisible).renderStates["invisible"].end,
|
||||||
|
filter: Picks.PICK_ENTITIES + Picks.PICK_AVATARS,
|
||||||
|
shape: {
|
||||||
|
shapeType: "capsule-y",
|
||||||
|
dimensions: {
|
||||||
|
x: radius * 2.0,
|
||||||
|
y: height - (radius * 2.0),
|
||||||
|
z: radius * 2.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
position: { x: 0, y: offset + (height * 0.5), z: 0 },
|
||||||
|
threshold: scale * _this.capsuleThreshold
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_this.recreateCollisionPicks();
|
||||||
|
|
||||||
this.cleanup = function() {
|
this.cleanup = function() {
|
||||||
Pointers.removePointer(_this.teleportParabolaHandVisible);
|
Pointers.removePointer(_this.teleportParabolaHandVisible);
|
||||||
Pointers.removePointer(_this.teleportParabolaHandInvisible);
|
Pointers.removePointer(_this.teleportParabolaHandInvisible);
|
||||||
Pointers.removePointer(_this.teleportParabolaHeadVisible);
|
Pointers.removePointer(_this.teleportParabolaHeadVisible);
|
||||||
Pointers.removePointer(_this.teleportParabolaHeadInvisible);
|
Pointers.removePointer(_this.teleportParabolaHeadInvisible);
|
||||||
Picks.removePick(_this.teleportCollisionPick);
|
Picks.removePick(_this.teleportHandCollisionPick);
|
||||||
|
Picks.removePick(_this.teleportHeadCollisionPick);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.axisButtonStateX = 0; // Left/right axis button pressed.
|
this.axisButtonStateX = 0; // Left/right axis button pressed.
|
||||||
|
@ -307,13 +329,17 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
if (!pose.valid) {
|
if (!pose.valid) {
|
||||||
Pointers.disablePointer(_this.teleportParabolaHandVisible);
|
Pointers.disablePointer(_this.teleportParabolaHandVisible);
|
||||||
Pointers.disablePointer(_this.teleportParabolaHandInvisible);
|
Pointers.disablePointer(_this.teleportParabolaHandInvisible);
|
||||||
|
Picks.disablePick(_this.teleportHandCollisionPick);
|
||||||
Pointers.enablePointer(_this.teleportParabolaHeadVisible);
|
Pointers.enablePointer(_this.teleportParabolaHeadVisible);
|
||||||
Pointers.enablePointer(_this.teleportParabolaHeadInvisible);
|
Pointers.enablePointer(_this.teleportParabolaHeadInvisible);
|
||||||
|
Picks.enablePick(_this.teleportHeadCollisionPick);
|
||||||
} else {
|
} else {
|
||||||
Pointers.enablePointer(_this.teleportParabolaHandVisible);
|
Pointers.enablePointer(_this.teleportParabolaHandVisible);
|
||||||
Pointers.enablePointer(_this.teleportParabolaHandInvisible);
|
Pointers.enablePointer(_this.teleportParabolaHandInvisible);
|
||||||
|
Picks.enablePick(_this.teleportHandCollisionPick);
|
||||||
Pointers.disablePointer(_this.teleportParabolaHeadVisible);
|
Pointers.disablePointer(_this.teleportParabolaHeadVisible);
|
||||||
Pointers.disablePointer(_this.teleportParabolaHeadInvisible);
|
Pointers.disablePointer(_this.teleportParabolaHeadInvisible);
|
||||||
|
Picks.disablePick(_this.teleportHeadCollisionPick);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We do up to 2 picks to find a teleport location.
|
// We do up to 2 picks to find a teleport location.
|
||||||
|
@ -325,15 +351,17 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
// We might hit an invisible entity that is not a seat, so we need to do a second pass.
|
// We might hit an invisible entity that is not a seat, so we need to do a second pass.
|
||||||
// * In the second pass we pick against visible entities only.
|
// * In the second pass we pick against visible entities only.
|
||||||
//
|
//
|
||||||
var result;
|
var result, collisionResult;
|
||||||
if (mode === 'head') {
|
if (mode === 'head') {
|
||||||
result = Pointers.getPrevPickResult(_this.teleportParabolaHeadInvisible);
|
result = Pointers.getPrevPickResult(_this.teleportParabolaHeadInvisible);
|
||||||
|
collisionResult = Picks.getPrevPickResult(_this.teleportHeadCollisionPick);
|
||||||
} else {
|
} else {
|
||||||
result = Pointers.getPrevPickResult(_this.teleportParabolaHandInvisible);
|
result = Pointers.getPrevPickResult(_this.teleportParabolaHandInvisible);
|
||||||
|
collisionResult = Picks.getPrevPickResult(_this.teleportHandCollisionPick);
|
||||||
}
|
}
|
||||||
var collisionResult = Picks.getPrevPickResult(_this.teleportCollisionPick);
|
|
||||||
|
|
||||||
var teleportLocationType = getTeleportTargetType(result, collisionResult);
|
var teleportLocationType = getTeleportTargetType(result, collisionResult);
|
||||||
|
|
||||||
if (teleportLocationType === TARGET.INVISIBLE) {
|
if (teleportLocationType === TARGET.INVISIBLE) {
|
||||||
if (mode === 'head') {
|
if (mode === 'head') {
|
||||||
result = Pointers.getPrevPickResult(_this.teleportParabolaHeadVisible);
|
result = Pointers.getPrevPickResult(_this.teleportParabolaHeadVisible);
|
||||||
|
@ -386,6 +414,8 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
Pointers.disablePointer(_this.teleportParabolaHandInvisible);
|
Pointers.disablePointer(_this.teleportParabolaHandInvisible);
|
||||||
Pointers.disablePointer(_this.teleportParabolaHeadVisible);
|
Pointers.disablePointer(_this.teleportParabolaHeadVisible);
|
||||||
Pointers.disablePointer(_this.teleportParabolaHeadInvisible);
|
Pointers.disablePointer(_this.teleportParabolaHeadInvisible);
|
||||||
|
Picks.disablePick(_this.teleportParabolaHeadInvisible);
|
||||||
|
Picks.disablePick(_this.teleportParabolaHandInvisible);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setTeleportState = function(mode, visibleState, invisibleState) {
|
this.setTeleportState = function(mode, visibleState, invisibleState) {
|
||||||
|
@ -610,13 +640,13 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
var afterSet = new AfterSet(100, 30, function(value) {
|
var afterSet = new AfterSet(100, 30, function(value) {
|
||||||
leftTeleporter.recreateCollisionPick();
|
leftTeleporter.recreateCollisionPicks();
|
||||||
rightTeleporter.recreateCollisionPick();
|
rightTeleporter.recreateCollisionPicks();
|
||||||
});
|
});
|
||||||
|
|
||||||
MyAvatar.onLoadComplete.connect(function () {
|
MyAvatar.onLoadComplete.connect(function () {
|
||||||
leftTeleporter.recreateCollisionPick();
|
leftTeleporter.recreateCollisionPicks();
|
||||||
rightTeleporter.recreateCollisionPick();
|
rightTeleporter.recreateCollisionPicks();
|
||||||
});
|
});
|
||||||
|
|
||||||
MyAvatar.sensorToWorldScaleChanged.connect(function() {
|
MyAvatar.sensorToWorldScaleChanged.connect(function() {
|
||||||
|
|
Loading…
Reference in a new issue