Skip to content

Commit

Permalink
Slower the pan speed, increase wheel speed, make pan and pinch exclus…
Browse files Browse the repository at this point in the history
…ive in DeflectPlugin (#66)
  • Loading branch information
tribal-tec authored Nov 24, 2016
1 parent 793c3d2 commit e9ba518
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
7 changes: 6 additions & 1 deletion brayns/common/camera/AbstractManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace
{
const Vector3f UNIT_Y = { 0.f, 1.f, 0.f };
const Vector3f UNIT_Z = { 0.f, 0.f, 1.f };
const float DEFAULT_MOTION_SPEED = 0.01f;
const float DEFAULT_MOTION_SPEED = 0.001f;
const float DEFAULT_ROTATION_SPEED = 0.005f;

}
Expand All @@ -50,6 +50,11 @@ float AbstractManipulator::getRotationSpeed() const
return _rotationSpeed;
}

float AbstractManipulator::getWheelSpeed() const
{
return getMotionSpeed() * 100.f;
}

float AbstractManipulator::getMotionSpeed() const
{
const auto& position = _camera.getPosition();
Expand Down
1 change: 1 addition & 0 deletions brayns/common/camera/AbstractManipulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class AbstractManipulator
void updateMotionSpeed( float speed );

float getRotationSpeed() const;
float getWheelSpeed() const;

protected:
/*! target camera */
Expand Down
6 changes: 3 additions & 3 deletions brayns/common/camera/FlyingModeManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void FlyingModeManipulator::dragMiddle( const Vector2i& to,
void FlyingModeManipulator::wheel( const Vector2i& /*position*/,
const float delta )
{
translate( forwardDirection * delta * getMotionSpeed(), false );
translate( forwardDirection * delta * getWheelSpeed(), false );
}

void FlyingModeManipulator::_strafeLeft()
Expand All @@ -95,12 +95,12 @@ void FlyingModeManipulator::_strafeRight()

void FlyingModeManipulator::_flyForward()
{
translate( forwardDirection * getMotionSpeed(), true );
translate( forwardDirection * getWheelSpeed(), true );
}

void FlyingModeManipulator::_flyBackwards()
{
translate( forwardDirection * -getMotionSpeed(), true );
translate( forwardDirection * -getWheelSpeed(), true );
}

}
2 changes: 1 addition & 1 deletion brayns/common/camera/InspectCenterManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void InspectCenterManipulator::dragMiddle( const Vector2i& to,
void InspectCenterManipulator::wheel( const Vector2i& /*position*/,
float delta )
{
delta *= getMotionSpeed();
delta *= getWheelSpeed();
if( delta < ( _camera.getTarget() - _camera.getPosition( )).length( ))
translate( forwardDirection * delta, false );
}
Expand Down
14 changes: 9 additions & 5 deletions plugins/extensions/plugins/DeflectPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,32 +158,36 @@ bool DeflectPlugin::_handleDeflectEvents()
{
case deflect::Event::EVT_PRESS:
_previousPos = _getWindowPos( event );
_panOrPinch = false;
_pan = _pinch = false;
break;
case deflect::Event::EVT_MOVE:
case deflect::Event::EVT_RELEASE:
{
const auto pos = _getWindowPos( event );
if( !_panOrPinch )
if( !_pan && !_pinch )
_brayns.getCameraManipulator().dragLeft( pos, _previousPos );
_previousPos = pos;
_panOrPinch = false;
_pan = _pinch = false;
break;
}
case deflect::Event::EVT_PAN:
{
if( _pinch )
break;
const auto pos = _getWindowPos( event );
_brayns.getCameraManipulator().dragMiddle( pos, _previousPos );
_previousPos = pos;
_panOrPinch = true;
_pan = true;
break;
}
case deflect::Event::EVT_PINCH:
{
if( _pan )
break;
const auto pos = _getWindowPos( event );
const auto delta = _getZoomDelta( event );
_brayns.getCameraManipulator().wheel( pos, delta * wheelFactor );
_panOrPinch = true;
_pinch = true;
break;
}
case deflect::Event::EVT_KEY_PRESS:
Expand Down
3 changes: 2 additions & 1 deletion plugins/extensions/plugins/DeflectPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class DeflectPlugin : public ExtensionPlugin
double _getZoomDelta( const deflect::Event& pinchEvent ) const;

Vector2d _previousPos;
bool _panOrPinch = false;
bool _pan = false;
bool _pinch = false;
std::unique_ptr< deflect::Stream > _stream;
::lexis::render::Stream _params;
std::string _previousHost;
Expand Down

0 comments on commit e9ba518

Please sign in to comment.