significantly lowered the cost of the network graph by computing pairwise repulsive forces 8 times less often

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6195 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-03-07 20:16:04 +00:00
parent 23209c8c45
commit 29a762d340

View File

@ -219,7 +219,7 @@ void GraphWidget::itemMoved()
#ifdef DEBUG_ELASTIC
std::cout << "starting timer" << std::endl;
#endif
timerId = startTimer(1000 / 25);
timerId = startTimer(1000 / 25); // hit timer 25 times per second.
}
}
@ -307,9 +307,16 @@ void GraphWidget::timerEvent(QTimerEvent *event)
static const int S = 256 ;
static double *forceMap = new double[2*S*S] ;
memset(forceMap,0,2*S*S*sizeof(double)) ;
// Update force map only once every 8 hits.
//
static uint32_t hit = 0 ;
QRectF R(scene()->sceneRect()) ;
if( (hit++ & 7) == 0)
{
memset(forceMap,0,2*S*S*sizeof(double)) ;
foreach (Node *node, _nodes)
{
QPointF pos = node->mapToScene(QPointF(0,0)) ;
@ -333,6 +340,7 @@ void GraphWidget::timerEvent(QTimerEvent *event)
// compute convolution with 1/omega kernel.
convolveWithGaussian(forceMap,S,20) ;
}
static float speedf=1.0f;