[Kstars-devel] branches/kstars/summer/kdeedu/kstars/kstars/skycomponents

Akarsh Simha akarshsimha at gmail.com
Sat Jun 21 07:51:26 CEST 2008


SVN commit 822685 by asimha:

Improving the efficiency of caching of stars. Thanks for pointing out
the flaw, James.

CCMAIL: kstars-devel at kde.org



 M  +24 -17    starcomponent.cpp  


--- branches/kstars/summer/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #822684:822685
@@ -184,6 +184,8 @@
     printf("Done.\n");
 }
 
+
+
 void StarComponent::draw( QPainter& psky )
 {
     if ( ! selected() ) return;
@@ -258,6 +260,28 @@
     if( veryFrugalMem )
         m_StarBlockFactory.freeAll();
 
+    while( region.hasNext() ) {
+        Trixel currentRegion = region.next();
+        for( int i = 1; i < m_starBlockList[ currentRegion ]->getBlockCount(); ++i ) {
+            StarBlock *prevBlock = m_starBlockList[ currentRegion ]->block( i - 1 );
+            StarBlock *block = m_starBlockList[ currentRegion ]->block( i );
+
+            if( i == 1 )
+                if( !m_StarBlockFactory.markFirst( block ) )
+                    kDebug() << "markFirst failed in trixel" << currentRegion;
+            if( i > 1 )
+                if( !m_StarBlockFactory.markNext( prevBlock, block ) )
+                    kDebug() << "markNext failed in trixel" << currentRegion << "while marking block" << i;
+            if( i + 1 < m_starBlockList[ currentRegion ]->getBlockCount() 
+                && m_starBlockList[ currentRegion ]->block( i + 1 )->getFaintMag() < maglim )
+                break;
+        }
+    }
+
+    t_updateCache = t.restart();
+
+    region.reset();
+
     while ( region.hasNext() ) {
         ++nTrixels;
         Trixel currentRegion = region.next();
@@ -310,23 +334,6 @@
         //                 <<  m_starBlockList[ currentRegion ]->getBlockCount() << " blocks" << endl;
 
 
-        for( int i = 1; i < m_starBlockList[ currentRegion ]->getBlockCount(); ++i ) {
-            StarBlock *prevBlock = m_starBlockList[ currentRegion ]->block( i - 1 );
-            StarBlock *block = m_starBlockList[ currentRegion ]->block( i );
-
-            if( i == 1 )
-                if( !m_StarBlockFactory.markFirst( block ) )
-                    kDebug() << "markFirst failed in trixel" << currentRegion;
-            if( i > 1 )
-                if( !m_StarBlockFactory.markNext( prevBlock, block ) )
-                    kDebug() << "markNext failed in trixel" << currentRegion << "while marking block" << i;
-            if( i + 1 < m_starBlockList[ currentRegion ]->getBlockCount() 
-                && m_starBlockList[ currentRegion ]->block( i + 1 )->getFaintMag() < maglim )
-                break;
-        }
-
-        t_updateCache += t.restart();
-
         for( int i = 0; i < m_starBlockList[ currentRegion ]->getBlockCount(); ++i ) {
             StarBlock *block = m_starBlockList[ currentRegion ]->block( i );
             //            kDebug() << "---> Drawing stars from block " << i << " of trixel " << 


More information about the Kstars-devel mailing list