]> Git trees. - libqmvoc.git/commitdiff
Add intelligent (so to speak) level-of-detail handling in Kalzium's
authorBenoît Jacob <jacob.benoit.1@gmail.com>
Sun, 25 Jun 2006 13:08:39 +0000 (13:08 +0000)
committerBenoît Jacob <jacob.benoit.1@gmail.com>
Sun, 25 Jun 2006 13:08:39 +0000 (13:08 +0000)
OpenGL engine. For instance smaller spheres will be drawn with smaller
detail level.

CCMAIL: cniehaus@gmx.de

M    kalzium/src/kalziumglwidget.cpp

svn path=/trunk/KDE/kdeedu/kalzium/src/kalziumglwidget.cpp; revision=554822

kalzium/kalziumglwidget.cpp

index cd22ecdb0bb14816390de5e2ed72c310278b30d5..7dfb285171b1e02b442d9940618be51ccf5c6d47 100644 (file)
@@ -275,8 +275,22 @@ void KalziumGLWidget::mouseMoveEvent( QMouseEvent * event )
 
 void KalziumGLWidget::setupObjects()
 {
-       m_sphere.setup( 3 * ( m_detail + 1 ), atomRadius() );
-       m_cylinder.setup( 8 * ( m_detail + 1 ), bondRadius() );
+       int sphere_detail, cylinder_faces;
+
+       if( m_atomRadiusCoeff < 0.05) sphere_detail = 1;
+       else if( m_atomRadiusCoeff < 0.30) sphere_detail = 2;
+       else sphere_detail = 3;
+
+       sphere_detail *= ( m_detail + 1 );
+
+       if( m_bondRadiusCoeff < 0.02) cylinder_faces = 4;
+       else if( m_bondRadiusCoeff < 0.10) cylinder_faces = 6;
+       else cylinder_faces = 8;
+
+       cylinder_faces *= ( m_detail + 1 );
+
+       m_sphere.setup( sphere_detail, atomRadius() );
+       m_cylinder.setup( cylinder_faces, bondRadius() );
 }
 
 void KalziumGLWidget::drawSphere( GLdouble x, GLdouble y, GLdouble z,