mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 22:22:54 +02:00
Merge pull request #9672 from ctrlaltdavid/21121
Fix far grabbing making entity jump upon grab
This commit is contained in:
commit
01bdac49d0
1 changed files with 13 additions and 5 deletions
|
@ -1989,7 +1989,9 @@ function MyController(hand) {
|
||||||
|
|
||||||
this.shouldScale = false;
|
this.shouldScale = false;
|
||||||
|
|
||||||
var worldControllerPosition = getControllerWorldLocation(this.handToController(), true).position;
|
var controllerLocation = getControllerWorldLocation(this.handToController(), true);
|
||||||
|
var worldControllerPosition = controllerLocation.position;
|
||||||
|
var worldControllerRotation = controllerLocation.orientation;
|
||||||
|
|
||||||
// transform the position into room space
|
// transform the position into room space
|
||||||
var worldToSensorMat = Mat4.inverse(MyAvatar.getSensorToWorldMatrix());
|
var worldToSensorMat = Mat4.inverse(MyAvatar.getSensorToWorldMatrix());
|
||||||
|
@ -2007,7 +2009,12 @@ function MyController(hand) {
|
||||||
this.grabRadius = Vec3.distance(this.currentObjectPosition, worldControllerPosition);
|
this.grabRadius = Vec3.distance(this.currentObjectPosition, worldControllerPosition);
|
||||||
this.grabRadialVelocity = 0.0;
|
this.grabRadialVelocity = 0.0;
|
||||||
|
|
||||||
// compute a constant based on the initial conditions which we use below to exagerate hand motion
|
// offset between controller vector at the grab radius and the entity position
|
||||||
|
var targetPosition = Vec3.multiply(this.grabRadius, Quat.getUp(worldControllerRotation));
|
||||||
|
targetPosition = Vec3.sum(targetPosition, worldControllerPosition);
|
||||||
|
this.offsetPosition = Vec3.subtract(this.currentObjectPosition, targetPosition);
|
||||||
|
|
||||||
|
// compute a constant based on the initial conditions which we use below to exaggerate hand motion
|
||||||
// onto the held object
|
// onto the held object
|
||||||
this.radiusScalar = Math.log(this.grabRadius + 1.0);
|
this.radiusScalar = Math.log(this.grabRadius + 1.0);
|
||||||
if (this.radiusScalar < 1.0) {
|
if (this.radiusScalar < 1.0) {
|
||||||
|
@ -2124,6 +2131,7 @@ function MyController(hand) {
|
||||||
|
|
||||||
var newTargetPosition = Vec3.multiply(this.grabRadius, Quat.getUp(worldControllerRotation));
|
var newTargetPosition = Vec3.multiply(this.grabRadius, Quat.getUp(worldControllerRotation));
|
||||||
newTargetPosition = Vec3.sum(newTargetPosition, worldControllerPosition);
|
newTargetPosition = Vec3.sum(newTargetPosition, worldControllerPosition);
|
||||||
|
newTargetPosition = Vec3.sum(newTargetPosition, this.offsetPosition);
|
||||||
|
|
||||||
var objectToAvatar = Vec3.subtract(this.currentObjectPosition, MyAvatar.position);
|
var objectToAvatar = Vec3.subtract(this.currentObjectPosition, MyAvatar.position);
|
||||||
var handControllerData = getEntityCustomData('handControllerKey', this.grabbedEntity, defaultMoveWithHeadData);
|
var handControllerData = getEntityCustomData('handControllerKey', this.grabbedEntity, defaultMoveWithHeadData);
|
||||||
|
|
Loading…
Reference in a new issue