mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 08:29:32 -05:00
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:
parent
23209c8c45
commit
29a762d340
@ -219,7 +219,7 @@ void GraphWidget::itemMoved()
|
|||||||
#ifdef DEBUG_ELASTIC
|
#ifdef DEBUG_ELASTIC
|
||||||
std::cout << "starting timer" << std::endl;
|
std::cout << "starting timer" << std::endl;
|
||||||
#endif
|
#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 const int S = 256 ;
|
||||||
static double *forceMap = new double[2*S*S] ;
|
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()) ;
|
QRectF R(scene()->sceneRect()) ;
|
||||||
|
|
||||||
|
if( (hit++ & 7) == 0)
|
||||||
|
{
|
||||||
|
memset(forceMap,0,2*S*S*sizeof(double)) ;
|
||||||
|
|
||||||
foreach (Node *node, _nodes)
|
foreach (Node *node, _nodes)
|
||||||
{
|
{
|
||||||
QPointF pos = node->mapToScene(QPointF(0,0)) ;
|
QPointF pos = node->mapToScene(QPointF(0,0)) ;
|
||||||
@ -333,6 +340,7 @@ void GraphWidget::timerEvent(QTimerEvent *event)
|
|||||||
|
|
||||||
// compute convolution with 1/omega kernel.
|
// compute convolution with 1/omega kernel.
|
||||||
convolveWithGaussian(forceMap,S,20) ;
|
convolveWithGaussian(forceMap,S,20) ;
|
||||||
|
}
|
||||||
|
|
||||||
static float speedf=1.0f;
|
static float speedf=1.0f;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user