Skip to content

Commit

Permalink
Fixed regrab bugs
Browse files Browse the repository at this point in the history
There were various times during the regrab procedure where the hand would deactivate the interact action set and drop the object. This usually caused the object to end up on the floor because it didn't have a real transform during the regrab.  Now many hand states will also drive the interact action set to be active so you have to actually release or lose the object in order to deactivate it.

Also added more logging.
  • Loading branch information
JoeLudwig committed Jan 3, 2021
1 parent 1480490 commit d8d68a4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion websrc/default_hands/src/default_hands_main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,24 @@ class DefaultHand extends React.Component< DefaultHandProps, DefaultHandState >

componentDidUpdate( prevProps: DefaultHandProps, prevState: DefaultHandState )
{
if( this.state.activeGrab || this.state.activePanel1 || this.state.activeMenu )
if( this.state.activeGrab || this.state.activePanel1 || this.state.activeMenu
|| this.state.state == GrabberState.WaitingForRegrabNewMoveable
|| this.state.state == GrabberState.WaitingForRegrabDropComplete
|| this.state.state == GrabberState.WaitingForRegrab
|| this.state.state == GrabberState.Grabbing )
{
console.log( `${ EHand[ this.props.hand ] } interact activated` );
inputProcessor.activateActionSet( "interact", handToDevice( this.props.hand ) );
}
else
{
console.log( `${ EHand[ this.props.hand ] } interact deactivated` );
inputProcessor.deactivateActionSet( "interact", handToDevice( this.props.hand ) );
}
if( this.state.state != prevState.state )
{
console.log( `${ EHand[ this.props.hand ] } transitioned to ${ GrabberState[ this.state.state ] }` );
}
}

@bind
Expand Down Expand Up @@ -180,6 +190,7 @@ class DefaultHand extends React.Component< DefaultHandProps, DefaultHandState >
@bind
private async onGrabPressed()
{
console.log( `${ EHand[ this.props.hand ] } grab pressed` );
switch( this.grabPressed )
{
case ButtonState.Idle:
Expand Down Expand Up @@ -230,6 +241,7 @@ class DefaultHand extends React.Component< DefaultHandProps, DefaultHandState >
@bind
private async onGrabReleased()
{
console.log( `${ EHand[ this.props.hand ] } grab released` );
switch( this.grabPressed )
{
case ButtonState.Suppressed:
Expand Down Expand Up @@ -413,6 +425,7 @@ class DefaultHand extends React.Component< DefaultHandProps, DefaultHandState >

if( !this.grabPressed )
{
console.log( "Grab was released while regrabbing. Dropping right away")
// the user released the grab while we were acquiring our new moveable. So we need to
// drop it immediately.
await activeInterface.sendEvent( { type: GrabRequestType.DropYourself } as GrabRequest );
Expand All @@ -431,6 +444,8 @@ class DefaultHand extends React.Component< DefaultHandProps, DefaultHandState >
activeInterface.onEvent(
async ( event: GrabRequest ) =>
{
console.log( `GRAB EVENT from ${ endpointAddrToString( activeInterface.peer ) } `
+ `${ event.type } with ${ GrabberState[ this.state.state ] }`, event );
switch( event.type )
{
case GrabRequestType.DropComplete:
Expand All @@ -454,6 +469,7 @@ class DefaultHand extends React.Component< DefaultHandProps, DefaultHandState >
grabberFromGrabbableRange: null,
grabberFromGrabbableRotation: null, } );
let res = await resPromise;
console.log( `RELOCK result ${ InterfaceLockResult[ res ] }` );
if( res != InterfaceLockResult.Success )
{
console.log( `Regrab failed with ${ InterfaceLockResult[ res ] }` );
Expand Down Expand Up @@ -490,6 +506,10 @@ class DefaultHand extends React.Component< DefaultHandProps, DefaultHandState >
event.oldMoveableFromNewMoveable ),
} );
}
else
{
console.log( `REGRAB requested when we were ${ GrabberState[ this.state.state ]}` );
}
}
break;

Expand Down

0 comments on commit d8d68a4

Please sign in to comment.