mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 06:10:52 +02:00
Don't attach to joints in range when I grab
This commit is contained in:
parent
73f7390eaa
commit
c7b636365c
1 changed files with 28 additions and 12 deletions
|
@ -88,6 +88,8 @@ function controller(wichSide) {
|
|||
this.oldModelPosition;
|
||||
this.oldModelRadius;
|
||||
|
||||
this.jointsIntersectingFronStart = [];
|
||||
|
||||
this.laser = Overlays.addOverlay("line3d", {
|
||||
position: { x: 0, y: 0, z: 0 },
|
||||
end: { x: 0, y: 0, z: 0 },
|
||||
|
@ -142,6 +144,14 @@ function controller(wichSide) {
|
|||
this.oldModelPosition = properties.position;
|
||||
this.oldModelRotation = properties.modelRotation;
|
||||
this.oldModelRadius = properties.radius;
|
||||
|
||||
this.jointsIntersectingFronStart = [];
|
||||
for (var i = 0; i < jointList.length; i++) {
|
||||
var distance = Vec3.distance(MyAvatar.getJointPosition(jointList[i]), this.oldModelPosition);
|
||||
if (distance < this.oldModelRadius) {
|
||||
this.jointsIntersectingFronStart.push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,10 +171,14 @@ function controller(wichSide) {
|
|||
}
|
||||
}
|
||||
|
||||
print("closestJoint: " + jojntList[closestJointIndex]);
|
||||
print("closestJoint: " + jointList[closestJointIndex]);
|
||||
print("closestJointDistance (attach max distance): " + closestJointDistance + " (" + this.oldModelRadius + ")");
|
||||
|
||||
if (closestJointDistance < this.oldModelRadius) {
|
||||
|
||||
if (this.jointsIntersectingFronStart.indexOf(closestJointIndex) != -1) {
|
||||
// Do nothing
|
||||
} else {
|
||||
print("Attaching to " + jointList[closestJointIndex]);
|
||||
var jointPosition = MyAvatar.getJointPosition(jointList[closestJointIndex]);
|
||||
var jointRotation = MyAvatar.getJointCombinedRotation(jointList[closestJointIndex]);
|
||||
|
@ -179,9 +193,11 @@ function controller(wichSide) {
|
|||
Models.deleteModel(this.modelID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.grabbing = false;
|
||||
this.modelID.isKnownID = false;
|
||||
this.jointsIntersectingFronStart = [];
|
||||
}
|
||||
|
||||
this.checkTrigger = function () {
|
||||
|
|
Loading…
Reference in a new issue