Skip to content

Commit

Permalink
Replaced boost::chrono usage with gettimeofday().
Browse files Browse the repository at this point in the history
The boost::chrono library was introduced in boost 0.47 and we need to support versions back to 0.43.0.
  • Loading branch information
johnhaddon committed Aug 27, 2013
1 parent 6f09d65 commit ea612e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 1 addition & 3 deletions include/GafferUI/ViewportGadget.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
#ifndef GAFFERUI_VIEWPORTGADGET_H
#define GAFFERUI_VIEWPORTGADGET_H

#include "boost/chrono.hpp"

#include "IECore/Camera.h"
#include "IECore/CameraController.h"

Expand Down Expand Up @@ -195,7 +193,7 @@ class ViewportGadget : public IndividualContainer
boost::signals::connection m_dragTrackingIdleConnection;
DragDropEvent m_dragTrackingEvent;
Imath::V2f m_dragTrackingVelocity;
boost::chrono::high_resolution_clock::time_point m_dragTrackingTime;
double m_dragTrackingTime;

};

Expand Down
17 changes: 13 additions & 4 deletions src/GafferUI/ViewportGadget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
//
//////////////////////////////////////////////////////////////////////////

#include <sys/time.h>

#include "boost/bind.hpp"
#include "boost/bind/placeholders.hpp"

Expand Down Expand Up @@ -497,6 +499,13 @@ bool ViewportGadget::dragMove( GadgetPtr gadget, const DragDropEvent &event )
return false;
}

static double currentTime()
{
timeval t;
gettimeofday( &t, NULL ) ;
return (double)t.tv_sec + (double)t.tv_usec / 1000000.0;
}

void ViewportGadget::trackDrag( const DragDropEvent &event )
{

Expand Down Expand Up @@ -537,7 +546,7 @@ void ViewportGadget::trackDrag( const DragDropEvent &event )

if( !m_dragTrackingIdleConnection.connected() )
{
m_dragTrackingTime = boost::chrono::high_resolution_clock::now();
m_dragTrackingTime = currentTime();
m_dragTrackingIdleConnection = idleSignal().connect( boost::bind( &ViewportGadget::trackDragIdle, this ) );
}
}
Expand All @@ -547,11 +556,11 @@ void ViewportGadget::trackDrag( const DragDropEvent &event )

void ViewportGadget::trackDragIdle()
{
boost::chrono::high_resolution_clock::time_point now = boost::chrono::high_resolution_clock::now();
boost::chrono::duration<float> duration = now - m_dragTrackingTime;
double now = currentTime();
float duration = (float)(now - m_dragTrackingTime);

m_cameraController.motionStart( CameraController::Track, V2f( 0 ) );
m_cameraController.motionEnd( m_dragTrackingVelocity * duration.count() * 20.0f );
m_cameraController.motionEnd( m_dragTrackingVelocity * duration * 20.0f );

m_dragTrackingTime = now;

Expand Down

0 comments on commit ea612e9

Please sign in to comment.