Fix to foreground orbits - spacecraft now look really cool!!

Report bugs, bug fixes and workarounds here.
Topic author
doctorjoe
Posts: 76
Joined: 23.05.2005
With us: 19 years 8 months
Location: Austin, Texas

Fix to foreground orbits - spacecraft now look really cool!!

Post #1by doctorjoe » 26.05.2005, 06:22

Here is another code snippet that fixes the problems with orbits in front of planets.

Code: Select all

Index: render.h
===================================================================
RCS file: /cvsroot/celestia/celestia/src/celengine/render.h,v
retrieving revision 1.64
diff -u -r1.64 render.h
--- render.h   11 Feb 2005 05:09:37 -0000   1.64
+++ render.h   26 May 2005 06:15:20 -0000
@@ -170,6 +170,8 @@
 
     void setFont(TextureFont*);
     TextureFont* getFont() const;
+    void renderOrbitColor(const Body *, bool);
+    void transformOrbits(const PlanetarySystem*);
 
  public:
     // Internal types
@@ -366,10 +368,18 @@
                        double jd);
 
     void renderOrbit(Body*, double);
-    void renderOrbits(PlanetarySystem*, const Selection&, double,
+    void renderOrbits(const PlanetarySystem*, const Selection&, double,
                       const Point3d&, const Point3d&);
-
-
+    void renderOrbits(const Observer& observer,
+            const Universe& universe,
+            const Selection& sel,
+            double t);
+    void renderForegroundOrbits(const PlanetarySystem* system,
+            const Point3f &center,
+            float distance,
+            int discSizeInPixels,
+            const Selection& sel,
+            double t);
  private:
     GLContext* context;
 
--- render.cpp.20050523   2005-05-23 21:00:47.000000000 -0500
+++ render.cpp   2005-05-26 01:09:56.000000000 -0500
@@ -983,8 +983,38 @@
     glEnd();
 }
 
+void Renderer::renderOrbitColor(const Body* body, bool selected)
+{
+  if (selected)
+    {
+      // Highlight the orbit of the selected object in red
+      glColor4f(1, 0, 0, 1);
+    }
+  else
+    {
+      switch (body->getClassification())
+   {
+   case Body::Moon:
+     glColor4f(0.0f, 0.2f, 0.5f, 1.0f);
+     break;
+   case Body::Asteroid:
+     glColor4f(0.35f, 0.2f, 0.0f, 1.0f);
+     break;
+   case Body::Comet:
+     glColor4f(0.0f, 0.5f, 0.5f, 1.0f);
+     break;
+   case Body::Spacecraft:
+     glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
+     break;
+   case Body::Planet:
+   default:
+     glColor4f(0.0f, 0.4f, 1.0f, 1.0f);
+     break;
+   }
+    }
+}
 
-void Renderer::renderOrbits(PlanetarySystem* planets,
+void Renderer::renderOrbits(const PlanetarySystem* planets,
                             const Selection& sel,
                             double t,
                             const Point3d& observerPos,
@@ -1001,75 +1031,52 @@
         Body* body = planets->getBody(i);
             
         // Only show orbits for major bodies or selected objects
-        if ((body->getClassification() & orbitMask) != 0 || body == sel.body())
-        {
-            if (body == sel.body())
-            {
-                // Highlight the orbit of the selected object in red
-                glColor4f(1, 0, 0, 1);
-            }
-            else
-            {
-                switch (body->getClassification())
-                {
-                case Body::Moon:
-                    glColor4f(0.0f, 0.2f, 0.5f, 1.0f);
-                    break;
-                case Body::Asteroid:
-                    glColor4f(0.35f, 0.2f, 0.0f, 1.0f);
-                    break;
-                case Body::Comet:
-                    glColor4f(0.0f, 0.5f, 0.5f, 1.0f);
-                    break;
-                case Body::Spacecraft:
-                    glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
-                    break;
-                case Body::Planet:
-                default:
-                    glColor4f(0.0f, 0.4f, 1.0f, 1.0f);
-                    break;
-                }
-            }
-           
-            float orbitRadiusInPixels =
-                (float) (body->getOrbit()->getBoundingRadius() /
-                         (distance * pixelSize));
-            if (orbitRadiusInPixels > minOrbitSize)
-            {
-                float farDistance =
-                    (float) (body->getOrbit()->getBoundingRadius() + distance);
-                farDistance = astro::kilometersToAU(farDistance);
-
-                // Set up the projection matrix so that the far plane is
-                // distant enough that the orbit won't be clipped.
-                glMatrixMode(GL_PROJECTION);
-                glLoadIdentity();
-                gluPerspective(fov,
-                               (float) windowWidth / (float) windowHeight,
-                               max( farDistance * 1e-6f, (float)(1e-5/2./tan(fov*3.14159/360.0)) ),
-                               farDistance * 1.1f );
-                glMatrixMode(GL_MODELVIEW);
-                renderOrbit(body, t);
-
-                if (body->getSatellites() != NULL)
-                {
-                    Point3d localPos = body->getOrbit()->positionAtTime(t);
-                    Quatd rotation =
-                        Quatd::yrotation(body->getRotationElements().ascendingNode) *
-                        Quatd::xrotation(body->getRotationElements().obliquity);
-                    double scale = astro::kilometersToAU(1.0);
-                    glPushMatrix();
-                    glTranslated(localPos.x * scale,
-                                 localPos.y * scale,
-                                 localPos.z * scale);
-                    glRotate(rotation);
-                    renderOrbits(body->getSatellites(), sel, t,
-                                 observerPos,
-                                 body->getHeliocentricPosition(t));
-                    glPopMatrix();
-                }
-            }
-        }
+        if ((body->getClassification() & orbitMask) == 0 && body != sel.body())
+     continue;
+   renderOrbitColor(body, body == sel.body());
+
+   
+   float orbitRadiusInPixels =
+     (float) (body->getOrbit()->getBoundingRadius() /
+         (distance * pixelSize));
+   if (orbitRadiusInPixels <= minOrbitSize)
+     continue;
+    
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   
+   float farDistance =
+     (float) (body->getOrbit()->getBoundingRadius() + distance);
+   farDistance = astro::kilometersToAU(farDistance);
+   
+   // Set up the projection matrix so that the far plane is
+   // distant enough that the orbit won't be clipped.
+   gluPerspective(fov,
+             (float) windowWidth / (float) windowHeight,
+             max( farDistance * 1e-6f,
+             (float)(1e-5/2./tan(fov*3.14159/360.0)) ),
+             farDistance * 1.1f );
+
+   glMatrixMode(GL_MODELVIEW);
+   renderOrbit(body, t);
+
+   if (body->getSatellites() == NULL)
+     continue;
+
+   Point3d localPos = body->getOrbit()->positionAtTime(t);
+   Quatd rotation =
+     Quatd::yrotation(body->getRotationElements().ascendingNode) *
+     Quatd::xrotation(body->getRotationElements().obliquity);
+   double scale = astro::kilometersToAU(1.0);
+   glPushMatrix();
+   glTranslated(localPos.x * scale,
+           localPos.y * scale,
+           localPos.z * scale);
+   glRotate(rotation);
+   renderOrbits(body->getSatellites(), sel, t,
+           observerPos,
+           body->getHeliocentricPosition(t));
+   glPopMatrix();
     }
 }
 
@@ -1088,6 +1095,124 @@
                    astro::microLightYearsToKilometers(v.z));
 }
 
+void Renderer::renderOrbits(const Observer& observer,
+             const Universe& universe,
+             const Selection& sel,
+             double t) {
+    // Render orbit paths
+    if ((renderFlags & ShowOrbits) != 0 && orbitMask != 0)
+    {
+        // Clear the keep flag for all orbits in the cache; if they're not
+        // used when rendering this frame, they'll get marked for
+        // recycling.
+        vector<CachedOrbit*>::const_iterator iter;
+        for (iter = orbitCache.begin(); iter != orbitCache.end(); iter++)
+            (*iter)->keep = false;
+
+        glDisable(GL_LIGHTING);
+        glDisable(GL_TEXTURE_2D);
+        if ((renderFlags & ShowSmoothLines) != 0)
+            enableSmoothLines();
+       
+        for (vector<const Star*>::const_iterator starIter = nearStars.begin();
+             starIter != nearStars.end(); starIter++)
+        {
+            const Star* sun = *starIter;
+            SolarSystem* solarSystem = universe.getSolarSystem(sun);
+
+            if (solarSystem != NULL)
+            {
+                Point3d obsPos = astrocentricPosition(observer.getPosition(),
+                                                      *sun, observer.getTime());
+                glPushMatrix();
+                glTranslatef((float) astro::kilometersToAU(-obsPos.x),
+                             (float) astro::kilometersToAU(-obsPos.y),
+                             (float) astro::kilometersToAU(-obsPos.z));
+                renderOrbits(solarSystem->getPlanets(), sel, t,
+                             obsPos, Point3d(0.0, 0.0, 0.0));
+                glPopMatrix();
+            }
+        }
+
+        if ((renderFlags & ShowSmoothLines) != 0)
+            disableSmoothLines();
+
+        // Mark for recycling all unused orbits in the cache
+        for (iter = orbitCache.begin(); iter != orbitCache.end(); iter++)
+        {
+            if (!(*iter)->keep)
+                (*iter)->body = NULL;
+        }
+    }
+}
+
+void Renderer::transformOrbits(const PlanetarySystem *system) {
+  if (system->getPrimaryBody()) {
+    const Body *body = system->getPrimaryBody();
+    transformOrbits(body->getSystem());
+    Quatd rotation =
+      Quatd::yrotation(body->getRotationElements().ascendingNode) *
+      Quatd::xrotation(body->getRotationElements().obliquity);
+    glRotate(rotation);     
+  }
+}
+
+void Renderer::renderForegroundOrbits(const PlanetarySystem* system,
+                  const Point3f &center, // km
+                  float distance, // km
+                  int discSizeInPixels,
+                  const Selection& sel,
+                  double t) {
+    // Render orbit paths

+    if ((renderFlags & ShowOrbits) == 0 || orbitMask == 0)
+      return;
+    if (system == NULL)
+      return;
+    if (discSizeInPixels < minOrbitSize)
+      return;
+
+    distance = astro::kilometersToAU(distance);
+    double scale = astro::kilometersToAU(1.0);
+    glPushMatrix();
+    glTranslated(center.x * scale,
+       center.y * scale,
+       center.z * scale);
+
+    glDisable(GL_LIGHTING);
+    glDisable(GL_TEXTURE_2D);
+    if ((renderFlags & ShowSmoothLines) != 0)
+      enableSmoothLines();
+    transformOrbits(system);
+   
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    gluPerspective(fov,
+         (float) windowWidth / (float) windowHeight,
+         max( distance * 1e-6f,
+         (float)(1e-5/2./tan(fov*3.14159/360.0)) ),
+         distance);
+   
+    glMatrixMode(GL_MODELVIEW);
+
+    int nBodies = system->getSystemSize();
+    for (int i = 0; i < nBodies; i++)
+    {
+        Body* body = system->getBody(i);
+
+        // Only show orbits for major bodies or selected objects
+        if ((body->getClassification() & orbitMask) == 0 &&
+       body != sel.body())
+     continue;
+   renderOrbitColor(body, body == sel.body());
+   renderOrbit(body, t);
+    }
+
+    if ((renderFlags & ShowSmoothLines) != 0)
+      disableSmoothLines();
+    glPopMatrix();
+}
+
 
 void Renderer::autoMag(float& faintestMag)
 {
@@ -1399,53 +1524,7 @@
         labelConstellations(*universe.getAsterisms(), observer);
 
     glPopMatrix();
-
-    // Render orbit paths
-    if ((renderFlags & ShowOrbits) != 0 && orbitMask != 0)
-    {
-        // Clear the keep flag for all orbits in the cache; if they're not
-        // used when rendering this frame, they'll get marked for
-        // recycling.
-        vector<CachedOrbit*>::const_iterator iter;
-        for (iter = orbitCache.begin(); iter != orbitCache.end(); iter++)
-            (*iter)->keep = false;
-
-        glDisable(GL_LIGHTING);
-        glDisable(GL_TEXTURE_2D);
-        if ((renderFlags & ShowSmoothLines) != 0)
-            enableSmoothLines();
-       
-        for (vector<const Star*>::const_iterator starIter = nearStars.begin();
-             starIter != nearStars.end(); starIter++)
-        {
-            const Star* sun = *starIter;
-            SolarSystem* solarSystem = universe.getSolarSystem(sun);
-
-            if (solarSystem != NULL)
-            {
-                Point3d obsPos = astrocentricPosition(observer.getPosition(),
-                                                      *sun, observer.getTime());
-                glPushMatrix();
-                glTranslatef((float) astro::kilometersToAU(-obsPos.x),
-                             (float) astro::kilometersToAU(-obsPos.y),
-                             (float) astro::kilometersToAU(-obsPos.z));
-                renderOrbits(solarSystem->getPlanets(), sel, now,
-                             obsPos, Point3d(0.0, 0.0, 0.0));
-                glPopMatrix();
-            }
-        }
-
-        if ((renderFlags & ShowSmoothLines) != 0)
-            disableSmoothLines();
-
-        // Mark for recycling all unused orbits in the cache
-        for (iter = orbitCache.begin(); iter != orbitCache.end(); iter++)
-        {
-            if (!(*iter)->keep)
-                (*iter)->body = NULL;
-        }
-    }
-
+    renderOrbits(observer, universe, sel, now);
     renderLabels();
 
     glPolygonMode(GL_FRONT, (GLenum) renderMode);
@@ -1713,6 +1792,14 @@
                                  observer.getOrientation(),
                                  lightSourceLists[renderList[i].solarSysIndex],
                                  nearPlaneDistance, farPlaneDistance);
+
+          renderForegroundOrbits(renderList[i].body->
+                  getSatellites(),
+                  renderList[i].position,
+                  renderList[i].distance,
+                  renderList[i].discSizeInPixels,
+                  sel,
+                  now);
                 }
             }
             else if (renderList[i].star != NULL)
@@ -1723,7 +1810,15 @@
                            renderList[i].appMag,
                            observer.getOrientation(),
                            now,
-                           nearPlaneDistance, farPlaneDistance);
+            nearPlaneDistance, farPlaneDistance);
+      SolarSystem *system =
+        universe.getSolarSystem(renderList[i].star);
+      renderForegroundOrbits(system->getPlanets(),
+                   renderList[i].position,
+                   renderList[i].distance,
+                   renderList[i].discSizeInPixels,
+                   sel,
+                   now);
             }
 
             // If this body is larger than a pixel, we rendered it as a mesh

BlindedByTheLight
Posts: 485
Joined: 19.03.2005
With us: 19 years 10 months
Location: Los Angeles, CA

Post #2by BlindedByTheLight » 28.05.2005, 03:32

Okay... I feel REALLY stupid for asking this question because I have a feeling - in order to properly utilize this code, several different skills need to be mastered - but I'll ask anyway...

Is it possible for someone to create an "Incorporating Code Fixes Into Celestia For Dummies" step-by-step guide?

Or does it require too many complicated steps?
Steven Binder, Mac OS X 10.4.10

BlindedByTheLight
Posts: 485
Joined: 19.03.2005
With us: 19 years 10 months
Location: Los Angeles, CA

Post #3by BlindedByTheLight » 31.05.2005, 07:47

If it helps things.. I have already learned the fine art of compiling my own Xcode cvs developer build from dirkpitt (I apologize if I phrased that incorrectly but, hopefully, you can follow it). Anyhoo, I'm guessing, in order to implement this fix... I need to do some cutting and pasting to some of the pre-compiled files? Then build again? Or am I over-simplifying things?

Thanks,
Steven
Steven Binder, Mac OS X 10.4.10

Avatar
dirkpitt
Developer
Posts: 674
Joined: 24.10.2004
With us: 20 years 3 months

Post #4by dirkpitt » 31.05.2005, 08:49

BlindedByTheLight wrote:Anyhoo, I'm guessing, in order to implement this fix... I need to do some cutting and pasting to some of the pre-compiled files?


The above text appears to be in standard "patch" format, which can be applied semi-automatically to existing file(s) using the "patch" command.

I haven't gotten around to trying out the above patch yet, but you'd have to:
1. Copy and paste the patch into a file inside the directory celestia/src/celengine,
2. Open up Terminal in said directory ("cd celestia/src/celengine"),
3. Apply the patch using "patch -p0 < patchfile.diff", assuming you saved the patch as "patchfile.diff",
4. Build

I'd make a backup copy of the affected files beforehand just in case. These appear to be render.h and render.cpp.

BlindedByTheLight
Posts: 485
Joined: 19.03.2005
With us: 19 years 10 months
Location: Los Angeles, CA

Post #5by BlindedByTheLight » 01.06.2005, 01:52

I got the following error... when trying to apply the patch:

Steven-Binders-Computer:~/celestia/src/celengine stevenbinder$ patch -p0 < patchfile.diff
(Patch is indented 1 space.)
can't find file to patch at input line 8
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
| Index: render.h
| ===================================================================
| RCS file: /cvsroot/celestia/celestia/src/celengine/render.h,v
| retrieving revision 1.64
| diff -u -r1.64 render.h
| --- render.h? ?11 Feb 2005 05:09:37 -0000? ?1.64
| +++ render.h? ?26 May 2005 06:15:20 -0000
--------------------------
File to patch:


But I think I may have introduced some weird symbols in the way I cut & pasted the document (straight into TextEdit - which I turned into a text-only document). Still... when I opened the file in Word and hit "show paragraphs", there were weird hidden symbols where it looked like there should be only spaces. So I cleaned those symbols out and ran Terminal again... but it was a step backwards b/c I got this:

patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.


I still guessing I'm screwing up pulling the patch off the web (which is really embarrassing for me...) But thoughts anyone?
Steven Binder, Mac OS X 10.4.10

Avatar
dirkpitt
Developer
Posts: 674
Joined: 24.10.2004
With us: 20 years 3 months

Post #6by dirkpitt » 02.06.2005, 02:51

I finally tested the patch. It works of course, but there is a crashing bug: in the line that says "renderForegroundOrbits(system->getPlanets()...", system can be null in certain cases. An "if (system) renderForegroundOrbits(..." fixes the issue.

I haven't benchmarked the code yet, will see how performance is with dozens of satellites strung around Earth.

Avatar
dirkpitt
Developer
Posts: 674
Joined: 24.10.2004
With us: 20 years 3 months

Post #7by dirkpitt » 02.06.2005, 08:04

An informal benchmark suggests that the speed difference between using and not using the patch
is there, but not very noticeable. Rotating around earth with ~890 satellites (geosync + Iridium)
takes about 0.03s / frame (about 20-30% of total frame time). After applying the patch,
orbit rendering is 0.04s / frame. The difference of 0.01s / frame is still only ~1% of total
frame time, which seems acceptable.

BlindedByTheLight
Posts: 485
Joined: 19.03.2005
With us: 19 years 10 months
Location: Los Angeles, CA

Post #8by BlindedByTheLight » 02.06.2005, 09:34

I haven't gotten around to trying out the above patch yet, but you'd have to:
1. Copy and paste the patch into a file inside the directory celestia/src/celengine,

So Dirkpitt... did you just copy and paste the text straight off Safari (I assume) and paste it into a TextEdit file? Or did you paste it into some kind of Xcode template?

I tried using Xcode's New Empty File and got this--->

Last login: Thu Jun 2 02:39:19 on console
Welcome to Darwin!
Steven-Binders-Computer:~ stevenbinder$ cd celestia/src/celengine
Steven-Binders-Computer:~/celestia/src/celengine stevenbinder$ patch -p0 < patchfile.diff
patching file render.h
Hunk #1 FAILED at 170.
Hunk #2 FAILED at 368.
2 out of 2 hunks FAILED -- saving rejects to file render.h.rej
patching file render.cpp
Hunk #1 FAILED at 983.
Hunk #2 FAILED at 1031.
Hunk #3 FAILED at 1095.
Hunk #4 FAILED at 1524.
Hunk #5 FAILED at 1792.
patch unexpectedly ends in middle of line
Hunk #6 FAILED at 1810.
6 out of 6 hunks FAILED -- saving rejects to file render.cpp.rej
Steven-Binders-Computer:~/celestia/src/celengine stevenbinder$


Any thoughts?
Steven Binder, Mac OS X 10.4.10

BlindedByTheLight
Posts: 485
Joined: 19.03.2005
With us: 19 years 10 months
Location: Los Angeles, CA

Post #9by BlindedByTheLight » 02.06.2005, 10:37

So I've been doing some research and I'm starting to get the feeling my patching has been failing (in the hunk department) because the patch is not seeing the code it is expecting in the files I am patching. The files I downloaded from sourceforge are via this protocol:

In the mean time, try these abbreviated instructions:
(0. If not already done so, install Xcode tools from the OS X CD/DVD)
1. Open Terminal
2. type, or paste in: cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/celestia login
3. As the Password: prompt, hit return
4. Type: cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/celestia co celestia
(the "co" indeed means "check out")
5. Wait for a while, until the download is complete


...but I'm starting to suspect this patch was written for an earlier version of Celestia (maybe 1.4pre6 or 1.32). Is that the case? And, if so, how do I get that version into an Xcode-readable format? I've been noodling around... but can't seem to do it. If that even is my problem...
Steven Binder, Mac OS X 10.4.10

BlindedByTheLight
Posts: 485
Joined: 19.03.2005
With us: 19 years 10 months
Location: Los Angeles, CA

Post #10by BlindedByTheLight » 02.06.2005, 11:30

Alright, definitely thinking my cut & pasting is injecting strange characters that is screwing the process up. Why? Because when I switched for Firefox and cut & paste the code snippet (directly an Xcode "New Empty File" doc) I got further along...

Last login: Thu Jun 2 04:25:41 on ttyp1
Welcome to Darwin!
Steven-Binders-Computer:~ stevenbinder$ cd celestia/src/celengine
Steven-Binders-Computer:~/celestia/src/celengine stevenbinder$ patch -p0 < patchfile.diff
patching file render.h
patching file render.cpp
Hunk #2 FAILED at 1031.
Hunk #4 FAILED at 1524.
patch unexpectedly ends in middle of line
Hunk #6 succeeded at 1810 with fuzz 1.
2 out of 6 hunks FAILED -- saving rejects to file render.cpp.rej
Steven-Binders-Computer:~/celestia/src/celengine stevenbinder$


...yet two of the hunks in the render.cpp patch STILL failed. Is it me? It is, isn't it? :)

POST-SCRIPT: And yet...after all my screwing around, I just figured I'd try to build Celestia with hunky failure... and it seems the orbit problem has been fixed after all.... go figure. :)
Steven Binder, Mac OS X 10.4.10

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 20 years

Post #11by ElChristou » 02.06.2005, 11:41

dirkpitt wrote:An informal benchmark suggests that the speed difference between using and not using the patch
is there, but not very noticeable. Rotating around earth with ~890 satellites (geosync + Iridium)
takes about 0.03s / frame (about 20-30% of total frame time). After applying the patch,
orbit rendering is 0.04s / frame. The difference of 0.01s / frame is still only ~1% of total
frame time, which seems acceptable.


So do you think this patch can be included to the actual code of Celestia? It would be cool to see this problem solved once for all...
Image

BlindedByTheLight
Posts: 485
Joined: 19.03.2005
With us: 19 years 10 months
Location: Los Angeles, CA

Post #12by BlindedByTheLight » 04.06.2005, 23:48

ElChristou... once I got the kinks worked out, it was REALLY easy to apply the patch and compile my own version.

Check out this link:

http://www.celestiaproject.net/forum/viewtopic ... vs+commits

Dirkpitt lays out some pretty simply instructions for connecting to the CVS site in that threat... and, in this thread, there are instructions for applying the patch. The biggest problem I had applying the patch was the cutting and pasting of the patch from the web-site into a text document... some funky symbols got thrown in. As for those errors I was getting when I finally got it to work... well, I went ahead and re-compiled Celestia anyway... and the orbit fix seemed to work fine. Things, of course, will be a lot easier if and when dirkpitt commits the fix to sourceforge... but for now, not too much work for a pretty cool feature.

Now if only some coder could add a GOTO "start-time" for a spaceship that only exists in a certain time frame... I'd REALLY be happy. :)
Steven Binder, Mac OS X 10.4.10

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 20 years

Post #13by ElChristou » 05.06.2005, 02:18

BlindedByTheLight wrote:...ElChristou... once I got the kinks worked out, it was REALLY easy to apply the patch and compile my own version...


Tx Steve.

In fact I know that you have learned how to compile quite recently, an I have to do the same before thinking in this patch...
But unfortunatly for now I don't have time to do all I want (I know that first I must install X11, learning how to compile, etc.)... Later perhaps I will ask you for advices on those topics.
For now I just want to know if this patch is good enough to be proposed to Chris to enter the actual code of Celestia...

Tx again,

Bye
Image

Avatar
dirkpitt
Developer
Posts: 674
Joined: 24.10.2004
With us: 20 years 3 months

Post #14by dirkpitt » 05.06.2005, 03:20

ElChristou wrote:But unfortunatly for now I don't have time to do all I want (I know that first I must install X11, learning how to compile, etc.)... Later perhaps I will ask you for advices on those topics.
For now I just want to know if this patch is good enough to be proposed to Chris to enter the actual code of Celestia...


X11 is not needed. Instead, you need Xcode Tools installed.

I'm convinced that this patch performs well enough under most conditions that it'd be a nice addition to Celestia, although YMMV. It's not really my call as to whether this patch gets committed or not.

BlindedByTheLight
Posts: 485
Joined: 19.03.2005
With us: 19 years 10 months
Location: Los Angeles, CA

Post #15by BlindedByTheLight » 05.06.2005, 06:50

Dirkpitt -

Just curious... who decides whether a patch gets committed? By committed, I assume you mean uploaded to sourceforge but how does the Decider (I'm assuming it's Chris?) decide if the tweak HASN'T been uploaded yet? Do you e-mail it to him and he tries it out then gives the okay and you upload it?

Thanks (again for everything),
Steve
Steven Binder, Mac OS X 10.4.10

Topic author
doctorjoe
Posts: 76
Joined: 23.05.2005
With us: 19 years 8 months
Location: Austin, Texas

Post #16by doctorjoe » 06.06.2005, 00:08

I'm actually pretty curious myself as to the procedure for getting patches incorporated into main tree. So far I've submitted three major patches....

1) displaying rings on hardware with small texture buffers
2) fixing foreground orbits
3) displaying virtual textures on hardware with small texture buffers.

There are about six or seven extensions I'd like to work on (precession of axes seems to be the main one, and some extensions to code for special relativity), but this is difficult without knowing the process for getting items into the main build tree.

BlindedByTheLight
Posts: 485
Joined: 19.03.2005
With us: 19 years 10 months
Location: Los Angeles, CA

Post #17by BlindedByTheLight » 06.06.2005, 01:07

First off - thanks doctorjoe... nice patch. A few questions for ya... since you're the author.

1) Is this patch supposed to fix orbits in front of stars? Because on my computer, planet orbit lines are still behind stars.

2) Do you have any tips on pulling your patch off the web? I've had to copy it into Microsoft Word, pull out some extra spaces that seem to have crept in, and also find/replace some strange characters that also crept it. Can you recommend an easier way?

3) When I applied the patch (via dirkpitt's instructions) I got this:

Last login: Thu Jun 2 04:25:41 on ttyp1
Welcome to Darwin!
Steven-Binders-Computer:~ stevenbinder$ cd celestia/src/celengine
Steven-Binders-Computer:~/celestia/src/celengine stevenbinder$ patch -p0 < patchfile.diff
patching file render.h
patching file render.cpp
Hunk #2 FAILED at 1031.
Hunk #4 FAILED at 1524.
patch unexpectedly ends in middle of line
Hunk #6 succeeded at 1810 with fuzz 1.
2 out of 6 hunks FAILED -- saving rejects to file render.cpp.rej
Steven-Binders-Computer:~/celestia/src/celengine stevenbinder$


Is that normal? The patch still seems to work (except for the sun - which now I'm wondering if the two occurences are connected). Any thoughts?

Thanks again,
Steve

P.S. Since your a coder... got another development suggestion for ya... :)

http://celestiaproject.net/forum/viewtopic.php ... +spaceship

It's kinda filled with a long-winded (my wind) suggestion - but a quickie-fix would be just a simple "Go To" start time keyboard short-cut. Something that pulls the start time off the spaceship's SSC and automatically sets Celestia to that time...
Steven Binder, Mac OS X 10.4.10

Topic author
doctorjoe
Posts: 76
Joined: 23.05.2005
With us: 19 years 8 months
Location: Austin, Texas

Post #18by doctorjoe » 06.06.2005, 03:13

1) What the patch does is to redraw the orbits twice, and right now the code checks to see if the central object is a certain fraction of the orbit before redrawing the lines in front of the object. I suspect this condition excludes most planet orbits. The reason for this condition is that if you are looking at Jupiter, you want the orbits of Jupiter's satellites to get redrawn in front of Jupiter, but you don't want Jupiter's orbit to get redrawn in front of Jupiter.

If you give me a test case where the patch fails, I'll see if I can modify to be a bit smarter.

2) The patch should apply cleanly off of the latest CVS. If you are patching against the latest CVS and having problems, let me know.

3) Also, I don't have CVS check in privileges, and I'd rather get my current pending patches either accepted or rejected before working on adding other functionality.

Topic author
doctorjoe
Posts: 76
Joined: 23.05.2005
With us: 19 years 8 months
Location: Austin, Texas

Post #19by doctorjoe » 06.06.2005, 04:09

Here's a patch that displays start/stop dates and moves to the start date if you press shift-G

[code]
Index: src/celengine/body.cpp
===================================================================
RCS file: /cvsroot/celestia/celestia/src/celengine/body.cpp,v
retrieving revision 1.36
diff -u -r1.36 body.cpp
--- src/celengine/body.cpp 20 Oct 2004 06:55:50 -0000 1.36
+++ src/celengine/body.cpp 6 Jun 2005 04:08:11 -0000
@@ -33,8 +33,8 @@
// protos(-numeric_limits<double>::infinity()),
// eschatos(numeric_limits<double>::infinity()),
// Do it the ugly way instead:
- protos(-1.0e+50),
- eschatos(1.0e+50),
+ protos(-HUGE_NUMBER),
+ eschatos(HUGE_NUMBER),
model(InvalidResource),
surface(Color(1.0f, 1.0f, 1.0f)),
atmosphere(NULL),
Index: src/celengine/body.h
===================================================================
RCS file: /cvsroot/celestia/celestia/src/celengine/body.h,v
retrieving revision 1.32
diff -u -r1.32 body.h
--- src/celengine/body.h 20 Oct 2004 06:55:50 -0000 1.32
+++ src/celengine/body.h 6 Jun 2005 04:08:11 -0000
@@ -82,6 +82,7 @@
public:
Body(PlanetarySystem*);
~Body();
+ static const double HUGE_NUMBER = 1e+50;

enum
{
Index: src/celengine/simulation.cpp
===================================================================
RCS file: /cvsroot/celestia/celestia/src/celengine/simulation.cpp,v
retrieving revision 1.34
diff -u -r1.34 simulation.cpp
--- src/celengine/simulation.cpp 11 Jan 2004 16:15:24 -0000 1.34
+++ src/celengine/simulation.cpp 6 Jun 2005 04:08:11 -0000
@@ -280,6 +280,17 @@
return activeObserver->getTargetSpeed();
}

+void Simulation::gotoSelectionStartTime() {
+ Body *body = selection.body();
+ if (body != NULL) {
+ double start, finish;
+ body->getLifespan(start, finish);
+ if (start != -Body::HUGE_NUMBER) {
+ setTime(start);
+ }
+ }
+}
+
void Simulation::gotoSelection(double gotoTime,
Vec3f up,
astro::CoordinateSystem upFrame)
Index: src/celestia/celestiacore.cpp
===================================================================
RCS file: /cvsroot/celestia/celestia/src/celestia/celestiacore.cpp,v
retrieving revision 1.179
diff -u -r1.179 celestiacore.cpp
--- src/celestia/celestiacore.cpp 2 Jun 2005 06:52:31 -0000 1.179
+++ src/celestia/celestiacore.cpp 6 Jun 2005 04:08:14 -0000
@@ -1676,6 +1676,8 @@

case 'G':
addToHistory();
+ if (c == 'G')
+ sim->gotoSelectionStartTime();
if (sim->getFrame().coordSys == astro::Universal)
sim->follow();
sim->gotoSelection(5.0, Vec3f(0, 1, 0), astro::ObserverLocal);
@@ -2781,6 +2783,17 @@

displayApparentDiameter(overlay, body.getRadius(), kmDistance);

+ double start, finish;
+ body.getLifespan(start, finish);
+ if (start != -Body::HUGE_NUMBER) {
+ overlay << "Start time: " <<
+ astro::Date(start) << " UTC" << endl;
+ }
+ if (finish != Body::HUGE_NUMBER) {
+ overlay << "Finish time: " <<
+ astro::Date(finish) << " UTC" << endl;
+ }
+
if (detail > 1)
{
overlay << "Day length: ";

Avatar
dirkpitt
Developer
Posts: 674
Joined: 24.10.2004
With us: 20 years 3 months

Post #20by dirkpitt » 06.06.2005, 04:39

Cham alerted me to an edge case where the foreground and background orbits do not coincide. To reproduce, here is a cel url showing Triton's orbit:

cel://SyncOrbit/Sol:Neptune:Triton/2005-06-06T04:30:38.50573?x=0rBYqrfpuvYRDg&y=CrN2AVq05vj+/////////w&z=DFhcRnl1gIlLAQ&ow=0.111311&ox=0.751519&oy=-0.502400&oz=0.412823&select=Sol:Neptune:Triton&fov=20.802254&ts=0.000000&ltd=0&rf=55203&lm=1

Some sort of numerical precision error, or an atomicity issue seems to be at work here.


Return to “Bugs”