From fb2caaff9fe15d514ebd944a152cbebc38f3fe17 Mon Sep 17 00:00:00 2001
From: Oliver Bock <oliver.bock@aei.mpg.de>
Date: Thu, 29 Jan 2009 02:01:07 +0100
Subject: [PATCH] Ensure that orbital planes overlap nicely

---
 src/pulsaranimationwidget.cpp | 36 ++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/pulsaranimationwidget.cpp b/src/pulsaranimationwidget.cpp
index 8bb08dd..decb8c8 100644
--- a/src/pulsaranimationwidget.cpp
+++ b/src/pulsaranimationwidget.cpp
@@ -304,23 +304,33 @@ void PulsarAnimationWidget::paintGL()
 	if(m_cameraInteraction) {
 		glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
 
-		// companion
-		glPushMatrix();
-			glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
-			glTranslatef(0.0f, 0.0f, 0.0f);
-			gluDisk(m_quadricCompanionOrbitPlane,
-					m_companionSemiMajorAxis - 0.25f,
-					m_companionSemiMajorAxis + 0.25f,
-					64, 1);
-		glPopMatrix();
+		static float sizeOffset = 0.25f;
+
+		// companion's plane (only if not identical with pulsar's)
+		if(m_companionSemiMajorAxis != m_pulsarSemiMajorAxis) {
+			glPushMatrix();
+				glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
+
+				// separate them slightly in case of overlap
+				// based on ugly mass diff check (no collision detection)
+				// single known problematic pair: (m_c=1.4, m_p=1.5)
+				if((int)(10*(m_pulsarMass-m_companionMass)+0.5f) == 1){
+					glTranslatef(0.0f, 0.0f, 0.01f);
+				}
+
+				gluDisk(m_quadricCompanionOrbitPlane,
+						m_companionSemiMajorAxis - sizeOffset,
+						m_companionSemiMajorAxis + sizeOffset,
+						64, 1);
+			glPopMatrix();
+		}
 
-		// pulsar
+		// pulsar's plane
 		glPushMatrix();
 			glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
-			glTranslatef(0.0f, 0.0f, 0.1f);
 			gluDisk(m_quadricPulsarOrbitPlane,
-					m_pulsarSemiMajorAxis - 0.25f,
-					m_pulsarSemiMajorAxis + 0.25f,
+					m_pulsarSemiMajorAxis - sizeOffset,
+					m_pulsarSemiMajorAxis + sizeOffset,
 					64, 1);
 		glPopMatrix();
 	}
-- 
GitLab