Merge lp:~georg-zotti/stellarium/gz_comet-tail-extinction into lp:stellarium
- gz_comet-tail-extinction
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 7129 |
Proposed branch: | lp:~georg-zotti/stellarium/gz_comet-tail-extinction |
Merge into: | lp:stellarium |
Diff against target: |
611 lines (+161/-94) 11 files modified
src/core/StelApp.hpp (+2/-1) src/core/StelPainter.cpp (+2/-1) src/core/StelProjector.cpp (+1/-1) src/core/StelProjector.hpp (+2/-2) src/core/StelToneReproducer.hpp (+5/-5) src/core/modules/Comet.cpp (+125/-68) src/core/modules/Comet.hpp (+14/-6) src/core/modules/MilkyWay.cpp (+1/-1) src/core/modules/MinorPlanet.cpp (+0/-1) src/core/modules/Planet.cpp (+5/-5) src/core/modules/Planet.hpp (+4/-3) |
To merge this branch: | bzr merge lp:~georg-zotti/stellarium/gz_comet-tail-extinction |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Fabien Chéreau | Approve | ||
Review via email: mp+241181@code.launchpad.net |
Commit message
Improved brightness control and colors for comet tails: extinction and twilight mixing.
Description of the change
My original comet tails of winter 2013/14 had one big flaw: brightness was computed globally. This made them almost pop out of twilight in full length, and bright comets were just too bright.
This branch has I think much better brightness balancing (query atmosphere and eye adaptation), and can reduce/influence tail brightness not only by vertex-wise extinction, but also by vertex-wise adaptation of tail length visibility to overall sky brightness. The increase in quality can at least be called "significant" IMHO.
To test, I recommend you copy ssystem_
Preview Diff
1 | === modified file 'src/core/StelApp.hpp' | |||
2 | --- src/core/StelApp.hpp 2014-11-04 10:59:12 +0000 | |||
3 | +++ src/core/StelApp.hpp 2014-11-08 17:16:48 +0000 | |||
4 | @@ -148,7 +148,8 @@ | |||
5 | 148 | void update(double deltaTime); | 148 | void update(double deltaTime); |
6 | 149 | 149 | ||
7 | 150 | //! Draw all registered StelModule in the order defined by the order lists. | 150 | //! Draw all registered StelModule in the order defined by the order lists. |
9 | 151 | //! @return the max squared distance in pixels that any object has travelled since the last update. | 151 | // 2014-11: OLD COMMENT? What does a void return? |
10 | 152 | // @return the max squared distance in pixels that any object has travelled since the last update. | ||
11 | 152 | void draw(); | 153 | void draw(); |
12 | 153 | 154 | ||
13 | 154 | //! Call this when the size of the GL window has changed. | 155 | //! Call this when the size of the GL window has changed. |
14 | 155 | 156 | ||
15 | === modified file 'src/core/StelPainter.cpp' | |||
16 | --- src/core/StelPainter.cpp 2014-11-04 12:15:15 +0000 | |||
17 | +++ src/core/StelPainter.cpp 2014-11-08 17:16:48 +0000 | |||
18 | @@ -544,7 +544,7 @@ | |||
19 | 544 | 544 | ||
20 | 545 | // Translate/rotate | 545 | // Translate/rotate |
21 | 546 | if (!noGravity) | 546 | if (!noGravity) |
23 | 547 | angleDeg += prj->defautAngleForGravityText; | 547 | angleDeg += prj->defaultAngleForGravityText; |
24 | 548 | 548 | ||
25 | 549 | if (std::fabs(angleDeg)>1.f) | 549 | if (std::fabs(angleDeg)>1.f) |
26 | 550 | { | 550 | { |
27 | @@ -1357,6 +1357,7 @@ | |||
28 | 1357 | break; | 1357 | break; |
29 | 1358 | case SphericalPolygonDrawModeFill: | 1358 | case SphericalPolygonDrawModeFill: |
30 | 1359 | case SphericalPolygonDrawModeTextureFill: | 1359 | case SphericalPolygonDrawModeTextureFill: |
31 | 1360 | case SphericalPolygonDrawModeTextureFillColormodulated: | ||
32 | 1360 | glEnable(GL_CULL_FACE); | 1361 | glEnable(GL_CULL_FACE); |
33 | 1361 | // The polygon is already tesselated as triangles | 1362 | // The polygon is already tesselated as triangles |
34 | 1362 | if (doSubDivise || prj->intersectViewportDiscontinuity(poly->getBoundingCap())) | 1363 | if (doSubDivise || prj->intersectViewportDiscontinuity(poly->getBoundingCap())) |
35 | 1363 | 1364 | ||
36 | === modified file 'src/core/StelProjector.cpp' | |||
37 | --- src/core/StelProjector.cpp 2013-10-01 22:05:10 +0000 | |||
38 | +++ src/core/StelProjector.cpp 2014-11-08 17:16:48 +0000 | |||
39 | @@ -116,7 +116,7 @@ | |||
40 | 116 | viewportCenter = params.viewportCenter; | 116 | viewportCenter = params.viewportCenter; |
41 | 117 | viewportCenter *= devicePixelsPerPixel; | 117 | viewportCenter *= devicePixelsPerPixel; |
42 | 118 | gravityLabels = params.gravityLabels; | 118 | gravityLabels = params.gravityLabels; |
44 | 119 | defautAngleForGravityText = params.defautAngleForGravityText; | 119 | defaultAngleForGravityText = params.defautAngleForGravityText; |
45 | 120 | flipHorz = params.flipHorz ? -1.f : 1.f; | 120 | flipHorz = params.flipHorz ? -1.f : 1.f; |
46 | 121 | flipVert = params.flipVert ? -1.f : 1.f; | 121 | flipVert = params.flipVert ? -1.f : 1.f; |
47 | 122 | viewportFovDiameter = params.viewportFovDiameter * devicePixelsPerPixel; | 122 | viewportFovDiameter = params.viewportFovDiameter * devicePixelsPerPixel; |
48 | 123 | 123 | ||
49 | === modified file 'src/core/StelProjector.hpp' | |||
50 | --- src/core/StelProjector.hpp 2014-10-16 17:32:50 +0000 | |||
51 | +++ src/core/StelProjector.hpp 2014-11-08 17:16:48 +0000 | |||
52 | @@ -291,7 +291,7 @@ | |||
53 | 291 | oneOverZNearMinusZFar(0.f), | 291 | oneOverZNearMinusZFar(0.f), |
54 | 292 | viewportFovDiameter(0.f), | 292 | viewportFovDiameter(0.f), |
55 | 293 | gravityLabels(true), | 293 | gravityLabels(true), |
57 | 294 | defautAngleForGravityText(0.f), | 294 | defaultAngleForGravityText(0.f), |
58 | 295 | devicePixelsPerPixel(1.f) {;} | 295 | devicePixelsPerPixel(1.f) {;} |
59 | 296 | 296 | ||
60 | 297 | //! Return whether the projection presents discontinuities. Used for optimization. | 297 | //! Return whether the projection presents discontinuities. Used for optimization. |
61 | @@ -317,7 +317,7 @@ | |||
62 | 317 | Vec2f viewportCenter; // Viewport center in screen pixel | 317 | Vec2f viewportCenter; // Viewport center in screen pixel |
63 | 318 | float viewportFovDiameter; // diameter of the FOV disk in pixel | 318 | float viewportFovDiameter; // diameter of the FOV disk in pixel |
64 | 319 | bool gravityLabels; // should label text align with the horizon? | 319 | bool gravityLabels; // should label text align with the horizon? |
66 | 320 | float defautAngleForGravityText; // a rotation angle to apply to gravity text (only if gravityLabels is set to false) | 320 | float defaultAngleForGravityText; // a rotation angle to apply to gravity text (only if gravityLabels is set to false) |
67 | 321 | SphericalCap boundingCap; // Bounding cap of the whole viewport | 321 | SphericalCap boundingCap; // Bounding cap of the whole viewport |
68 | 322 | float devicePixelsPerPixel; // The number of device pixel per "Device Independent Pixels" (value is usually 1, but 2 for mac retina screens) | 322 | float devicePixelsPerPixel; // The number of device pixel per "Device Independent Pixels" (value is usually 1, but 2 for mac retina screens) |
69 | 323 | 323 | ||
70 | 324 | 324 | ||
71 | === modified file 'src/core/StelToneReproducer.hpp' | |||
72 | --- src/core/StelToneReproducer.hpp 2014-11-04 10:59:12 +0000 | |||
73 | +++ src/core/StelToneReproducer.hpp 2014-11-08 17:16:48 +0000 | |||
74 | @@ -79,7 +79,7 @@ | |||
75 | 79 | //! It is the parameter to modify to simulate aperture*exposition time | 79 | //! It is the parameter to modify to simulate aperture*exposition time |
76 | 80 | //! @param scale the global input scale | 80 | //! @param scale the global input scale |
77 | 81 | void setInputScale(float scale=1.f); | 81 | void setInputScale(float scale=1.f); |
79 | 82 | //! Get the global scale applied to input lumiances, i.e before the adaptation | 82 | //! Get the global scale applied to input luminances, i.e before the adaptation |
80 | 83 | float getInputScale() const | 83 | float getInputScale() const |
81 | 84 | { | 84 | { |
82 | 85 | return inputScale; | 85 | return inputScale; |
83 | @@ -125,14 +125,14 @@ | |||
84 | 125 | 125 | ||
85 | 126 | //! Return adapted luminance from world to display with 1 corresponding to full display white | 126 | //! Return adapted luminance from world to display with 1 corresponding to full display white |
86 | 127 | //! @param worldLuminance the world luminance to convert in cd/m^2 | 127 | //! @param worldLuminance the world luminance to convert in cd/m^2 |
88 | 128 | //! @return the converted display luminance with 1 corresponding to full display white. The value can be more than 1 when saturation.. | 128 | //! @return the converted display luminance with 1 corresponding to full display white. The value can be more than 1 when saturated. |
89 | 129 | float adaptLuminanceScaled(float worldLuminance) const | 129 | float adaptLuminanceScaled(float worldLuminance) const |
90 | 130 | { | 130 | { |
91 | 131 | return adaptLuminance(worldLuminance)*oneOverMaxdL; | 131 | return adaptLuminance(worldLuminance)*oneOverMaxdL; |
92 | 132 | } | 132 | } |
93 | 133 | 133 | ||
94 | 134 | //! Return adapted luminance from display to world with 1 corresponding to full display white | 134 | //! Return adapted luminance from display to world with 1 corresponding to full display white |
96 | 135 | //! @param displayLuminance the display luminance with 1 corresponding to full display white. The value can be more than 1 when saturation.. | 135 | //! @param displayLuminance the display luminance with 1 corresponding to full display white. The value can be more than 1 when saturated. |
97 | 136 | //! @return the converted world luminance in cd/m^2 | 136 | //! @return the converted world luminance in cd/m^2 |
98 | 137 | float reverseAdaptLuminanceScaled(float displayLuminance) const | 137 | float reverseAdaptLuminanceScaled(float displayLuminance) const |
99 | 138 | { | 138 | { |
100 | @@ -141,8 +141,8 @@ | |||
101 | 141 | 141 | ||
102 | 142 | //! Return adapted ln(luminance) from world to display with 1 corresponding to full display white | 142 | //! Return adapted ln(luminance) from world to display with 1 corresponding to full display white |
103 | 143 | //! @param lnWorldLuminance the world luminance to convert in ln(cd/m^2) | 143 | //! @param lnWorldLuminance the world luminance to convert in ln(cd/m^2) |
106 | 144 | //! @param pFact the power at whihc the result should be set. The default is 0.5 and therefore return the square root of the adapted luminance | 144 | //! @param pFact the power at which the result should be set. The default is 0.5 and therefore return the square root of the adapted luminance |
107 | 145 | //! @return the converted display set at the pFact power. Luminance with 1 corresponding to full display white. The value can be more than 1 when saturation.. | 145 | //! @return the converted display set at the pFact power. Luminance with 1 corresponding to full display white. The value can be more than 1 when saturated. |
108 | 146 | float adaptLuminanceScaledLn(float lnWorldLuminance, float pFact=0.5f) const | 146 | float adaptLuminanceScaledLn(float lnWorldLuminance, float pFact=0.5f) const |
109 | 147 | { | 147 | { |
110 | 148 | const float lnPix0p0001 = -8.0656104861f; | 148 | const float lnPix0p0001 = -8.0656104861f; |
111 | 149 | 149 | ||
112 | === modified file 'src/core/modules/Comet.cpp' | |||
113 | --- src/core/modules/Comet.cpp 2014-10-19 05:54:43 +0000 | |||
114 | +++ src/core/modules/Comet.cpp 2014-11-08 17:16:48 +0000 | |||
115 | @@ -1,6 +1,7 @@ | |||
116 | 1 | /* | 1 | /* |
117 | 2 | * Stellarium | 2 | * Stellarium |
118 | 3 | * Copyright (C) 2010 Bogdan Marinov | 3 | * Copyright (C) 2010 Bogdan Marinov |
119 | 4 | * Copyright (C) 2014 Georg Zotti (Tails) | ||
120 | 4 | * | 5 | * |
121 | 5 | * This program is free software; you can redistribute it and/or | 6 | * This program is free software; you can redistribute it and/or |
122 | 6 | * modify it under the terms of the GNU General Public License | 7 | * modify it under the terms of the GNU General Public License |
123 | @@ -26,6 +27,7 @@ | |||
124 | 26 | 27 | ||
125 | 27 | #include "StelTexture.hpp" | 28 | #include "StelTexture.hpp" |
126 | 28 | #include "StelTextureMgr.hpp" | 29 | #include "StelTextureMgr.hpp" |
127 | 30 | #include "StelToneReproducer.hpp" | ||
128 | 29 | #include "StelTranslator.hpp" | 31 | #include "StelTranslator.hpp" |
129 | 30 | #include "StelUtils.hpp" | 32 | #include "StelUtils.hpp" |
130 | 31 | #include "StelFileMgr.hpp" | 33 | #include "StelFileMgr.hpp" |
131 | @@ -71,6 +73,7 @@ | |||
132 | 71 | true, //halo | 73 | true, //halo |
133 | 72 | pTypeStr), | 74 | pTypeStr), |
134 | 73 | tailActive(false), | 75 | tailActive(false), |
135 | 76 | tailBright(false), | ||
136 | 74 | dustTailWidthFactor(dustTailWidthFact), | 77 | dustTailWidthFactor(dustTailWidthFact), |
137 | 75 | dustTailLengthFactor(dustTailLengthFact), | 78 | dustTailLengthFactor(dustTailLengthFact), |
138 | 76 | dustTailBrightnessFactor(dustTailBrightnessFact) | 79 | dustTailBrightnessFactor(dustTailBrightnessFact) |
139 | @@ -90,6 +93,8 @@ | |||
140 | 90 | gastailVertexArr.clear(); | 93 | gastailVertexArr.clear(); |
141 | 91 | dusttailVertexArr.clear(); | 94 | dusttailVertexArr.clear(); |
142 | 92 | comaVertexArr.clear(); | 95 | comaVertexArr.clear(); |
143 | 96 | gastailColorArr.clear(); | ||
144 | 97 | dusttailColorArr.clear(); | ||
145 | 93 | 98 | ||
146 | 94 | //Comet specific members | 99 | //Comet specific members |
147 | 95 | absoluteMagnitude = 0; | 100 | absoluteMagnitude = 0; |
148 | @@ -281,19 +286,27 @@ | |||
149 | 281 | return apparentMagnitude; | 286 | return apparentMagnitude; |
150 | 282 | } | 287 | } |
151 | 283 | 288 | ||
155 | 284 | // Compute the position in the parent Planet coordinate system | 289 | void Comet::update(int deltaTime) |
153 | 285 | // Actually call the provided function to compute the ecliptical position, and buildup the tails! | ||
154 | 286 | void Comet::computePosition(const double date) | ||
156 | 287 | { | 290 | { |
160 | 288 | Planet::computePosition(date); | 291 | Planet::update(deltaTime); |
161 | 289 | //GZ: I think we can make deltaJD adaptive, depending on distance to sun! For some reason though, this leads to a crash! | 292 | |
162 | 290 | //deltaJD=StelCore::JD_SECOND * qMax(1.0, qMin(eclipticPos.length(), 20.0)); | 293 | // The rest used to be in computePosition(), but is better in update(). Unfortunately we need date (JD). |
163 | 294 | StelCore* core=StelApp::getInstance().getCore(); | ||
164 | 295 | double date=core->getJDay(); | ||
165 | 296 | |||
166 | 297 | // The CometOrbit is in fact available in userDataPtr! | ||
167 | 298 | CometOrbit* orbit=(CometOrbit*)userDataPtr; | ||
168 | 299 | Q_ASSERT(orbit); | ||
169 | 300 | if (!orbit->objectDateValid(core->getJDay())) return; // don't do anything if out of useful date range. This allows having hundreds of comet elements. | ||
170 | 301 | |||
171 | 302 | |||
172 | 303 | //GZ: I think we can make deltaJDtail adaptive, depending on distance to sun! For some reason though, this leads to a crash! | ||
173 | 304 | //deltaJDtail=StelCore::JD_SECOND * qMax(1.0, qMin(eclipticPos.length(), 20.0)); | ||
174 | 291 | 305 | ||
175 | 292 | if (fabs(lastJDtail-date)>deltaJDtail) | 306 | if (fabs(lastJDtail-date)>deltaJDtail) |
176 | 293 | { | 307 | { |
177 | 294 | lastJDtail=date; | 308 | lastJDtail=date; |
178 | 295 | 309 | ||
179 | 296 | // GZ: Moved from draw() :-) | ||
180 | 297 | // The CometOrbit is in fact available in userDataPtr! | 310 | // The CometOrbit is in fact available in userDataPtr! |
181 | 298 | CometOrbit* orbit=(CometOrbit*)userDataPtr; | 311 | CometOrbit* orbit=(CometOrbit*)userDataPtr; |
182 | 299 | Q_ASSERT(orbit); | 312 | Q_ASSERT(orbit); |
183 | @@ -301,11 +314,10 @@ | |||
184 | 301 | 314 | ||
185 | 302 | if (orbit->getUpdateTails()){ | 315 | if (orbit->getUpdateTails()){ |
186 | 303 | // Compute lengths and orientations from orbit object, but only if required. | 316 | // Compute lengths and orientations from orbit object, but only if required. |
187 | 304 | // This part moved from draw() to keep draw() free from too much computation. | ||
188 | 305 | tailFactors=getComaDiameterAndTailLengthAU(); | 317 | tailFactors=getComaDiameterAndTailLengthAU(); |
189 | 306 | 318 | ||
190 | 307 | // Note that we use a diameter larger than what the formula returns. A scale factor of 1.2 is ad-hoc/empirical (GZ), but may look better. | 319 | // Note that we use a diameter larger than what the formula returns. A scale factor of 1.2 is ad-hoc/empirical (GZ), but may look better. |
192 | 308 | computeComa(1.0f*tailFactors[0]); | 320 | computeComa(1.0f*tailFactors[0]); // TBD: APPARENTLY NO SCALING? REMOVE 1.0 and note above. |
193 | 309 | 321 | ||
194 | 310 | tailActive = (tailFactors[1] > tailFactors[0]); // Inhibit tails drawing if too short. Would be nice to include geometric projection angle, but this is too costly. | 322 | tailActive = (tailFactors[1] > tailFactors[0]); // Inhibit tails drawing if too short. Would be nice to include geometric projection angle, but this is too costly. |
195 | 311 | 323 | ||
196 | @@ -318,10 +330,10 @@ | |||
197 | 318 | 330 | ||
198 | 319 | // Find valid parameters to create paraboloid vertex arrays: dustTail, gasTail. | 331 | // Find valid parameters to create paraboloid vertex arrays: dustTail, gasTail. |
199 | 320 | computeParabola(gasparameter, gasTailEndRadius, -0.5f*gasparameter, gastailVertexArr, tailTexCoordArr, tailIndices); | 332 | computeParabola(gasparameter, gasTailEndRadius, -0.5f*gasparameter, gastailVertexArr, tailTexCoordArr, tailIndices); |
202 | 321 | // This was for a rotated straight parabola: | 333 | //gastailColorArr.fill(Vec3f(0.3,0.3,0.3), gastailVertexArr.length()); |
201 | 322 | //computeParabola(dustparameter, 2.0f*tailFactors[0], -0.5f*dustparameter, dusttailVertexArr, dusttailTexCoordArr, dusttailIndices); | ||
203 | 323 | // Now we make a skewed parabola. Skew factor (xOffset, last arg) is rather ad-hoc/empirical. TBD later: Find physically correct solution. | 334 | // Now we make a skewed parabola. Skew factor (xOffset, last arg) is rather ad-hoc/empirical. TBD later: Find physically correct solution. |
204 | 324 | computeParabola(dustparameter, dustTailWidthFactor*gasTailEndRadius, -0.5f*dustparameter, dusttailVertexArr, tailTexCoordArr, tailIndices, 25.0f*orbit->getVelocity().length()); | 335 | computeParabola(dustparameter, dustTailWidthFactor*gasTailEndRadius, -0.5f*dustparameter, dusttailVertexArr, tailTexCoordArr, tailIndices, 25.0f*orbit->getVelocity().length()); |
205 | 336 | //dusttailColorArr.fill(Vec3f(0.3,0.3,0.3), dusttailVertexArr.length()); | ||
206 | 325 | 337 | ||
207 | 326 | 338 | ||
208 | 327 | // 2014-08 for 0.13.1 Moved from drawTail() to save lots of computation per frame (There *are* folks downloading all 730 MPC current comet elements...) | 339 | // 2014-08 for 0.13.1 Moved from drawTail() to save lots of computation per frame (There *are* folks downloading all 730 MPC current comet elements...) |
209 | @@ -336,7 +348,7 @@ | |||
210 | 336 | // In addition, we let the dust tail already start with a light tilt. | 348 | // In addition, we let the dust tail already start with a light tilt. |
211 | 337 | dustTailRot=gasTailRot * Mat4d::zrotation(atan2(velocity[1], velocity[0]) + M_PI) * Mat4d::yrotation(5.0f*velocity.length()); | 349 | dustTailRot=gasTailRot * Mat4d::zrotation(atan2(velocity[1], velocity[0]) + M_PI) * Mat4d::yrotation(5.0f*velocity.length()); |
212 | 338 | 350 | ||
214 | 339 | // TODO: If we want to be even faster, rotate vertex arrays here and not in drawTail()! | 351 | // Rotate vertex arrays: |
215 | 340 | Vec3d* gasVertices=(Vec3d*) (gastailVertexArr.data()); | 352 | Vec3d* gasVertices=(Vec3d*) (gastailVertexArr.data()); |
216 | 341 | Vec3d* dustVertices=(Vec3d*) (dusttailVertexArr.data()); | 353 | Vec3d* dustVertices=(Vec3d*) (dusttailVertexArr.data()); |
217 | 342 | for (int i=0; i<COMET_TAIL_SLICES*COMET_TAIL_STACKS+1; ++i) | 354 | for (int i=0; i<COMET_TAIL_SLICES*COMET_TAIL_STACKS+1; ++i) |
218 | @@ -345,34 +357,105 @@ | |||
219 | 345 | dustVertices[i].transfo4d(dustTailRot); | 357 | dustVertices[i].transfo4d(dustTailRot); |
220 | 346 | } | 358 | } |
221 | 347 | } | 359 | } |
222 | 348 | |||
223 | 349 | orbit->setUpdateTails(false); // don't update until position has been recalculated elsewhere | 360 | orbit->setUpdateTails(false); // don't update until position has been recalculated elsewhere |
224 | 350 | } | 361 | } |
228 | 351 | // Note: we can make deltaJDtail adaptive, depending on distance to sun! | 362 | } |
229 | 352 | //deltaJDtail=5.0*StelCore::JD_MINUTE * qMax(0.01, qMin(eclipticPos.length(), 20.0)); | 363 | |
230 | 353 | } | 364 | // And also update magnitude and tail brightness/extinction here. |
231 | 365 | const bool withAtmosphere=(core->getSkyDrawer()->getFlagHasAtmosphere()); | ||
232 | 366 | |||
233 | 367 | StelToneReproducer* eye = core->getToneReproducer(); | ||
234 | 368 | float lum = core->getSkyDrawer()->surfacebrightnessToLuminance(getVMagnitude(core)+13.0f); // How to calibrate? | ||
235 | 369 | // Get the luminance scaled between 0 and 1 | ||
236 | 370 | float aLum =eye->adaptLuminanceScaled(lum); | ||
237 | 371 | |||
238 | 372 | |||
239 | 373 | // To make comet more apparent in overviews, take field of view into account: | ||
240 | 374 | const float fov=core->getProjection(core->getAltAzModelViewTransform())->getFov(); | ||
241 | 375 | if (fov>20) | ||
242 | 376 | aLum*= (fov/20.0f); | ||
243 | 377 | |||
244 | 378 | // Now inhibit tail drawing if still too dim. | ||
245 | 379 | if (aLum<0.002f) | ||
246 | 380 | { | ||
247 | 381 | // Far too dim: don't even show tail... | ||
248 | 382 | tailBright=false; | ||
249 | 383 | return; | ||
250 | 384 | } else | ||
251 | 385 | tailBright=true; | ||
252 | 386 | |||
253 | 387 | // Separate factors, but avoid overly bright tails. I limit to about 0.7 for overlapping both tails which should not exceed full-white. | ||
254 | 388 | float gasMagFactor=qMin(0.9f*aLum, 0.7f); | ||
255 | 389 | float dustMagFactor=qMin(dustTailBrightnessFactor*aLum, 0.7f); | ||
256 | 390 | |||
257 | 391 | Vec3f gasColor(0.15f*gasMagFactor,0.35f*gasMagFactor,0.6f*gasMagFactor); // Orig color 0.15/0.15/0.6 | ||
258 | 392 | Vec3f dustColor(dustMagFactor, dustMagFactor,0.6f*dustMagFactor); | ||
259 | 393 | |||
260 | 394 | if (withAtmosphere) | ||
261 | 395 | { | ||
262 | 396 | Extinction extinction=core->getSkyDrawer()->getExtinction(); | ||
263 | 397 | |||
264 | 398 | // Not only correct the color values for extinction, but for twilight conditions, also make tail end less visible. | ||
265 | 399 | // I consider sky brightness over 1cd/m^2 as reason to shorten tail. | ||
266 | 400 | // Below this brightness, the tail brightness loss by this method is insignificant: | ||
267 | 401 | // Just counting through the vertices might make a spiral apperance. Maybe even better than stackwise? Let's see... | ||
268 | 402 | const float avgAtmLum=GETSTELMODULE(LandscapeMgr)->getAtmosphereAverageLuminance(); | ||
269 | 403 | const float brightnessDecreasePerVertexFromHead=1.0f/(COMET_TAIL_SLICES*COMET_TAIL_STACKS) * avgAtmLum; | ||
270 | 404 | float brightnessPerVertexFromHead=1.0f; | ||
271 | 405 | |||
272 | 406 | gastailColorArr.clear(); | ||
273 | 407 | dusttailColorArr.clear(); | ||
274 | 408 | for (int i=0; i<gastailVertexArr.size(); ++i) | ||
275 | 409 | { | ||
276 | 410 | // Gastail extinction: | ||
277 | 411 | Vec3d vertAltAz=core->j2000ToAltAz(gastailVertexArr.at(i), StelCore::RefractionOn); | ||
278 | 412 | vertAltAz.normalize(); | ||
279 | 413 | Q_ASSERT(fabs(vertAltAz.lengthSquared()-1.0) < 0.001); | ||
280 | 414 | float oneMag=0.0f; | ||
281 | 415 | extinction.forward(vertAltAz, &oneMag); | ||
282 | 416 | float extinctionFactor=std::pow(0.4f, oneMag); // drop of one magnitude: factor 2.5 or 40% | ||
283 | 417 | gastailColorArr.append(gasColor*extinctionFactor* brightnessPerVertexFromHead); | ||
284 | 418 | |||
285 | 419 | // dusttail extinction: | ||
286 | 420 | vertAltAz=core->j2000ToAltAz(dusttailVertexArr.at(i), StelCore::RefractionOn); | ||
287 | 421 | vertAltAz.normalize(); | ||
288 | 422 | Q_ASSERT(fabs(vertAltAz.lengthSquared()-1.0) < 0.001); | ||
289 | 423 | oneMag=0.0f; | ||
290 | 424 | extinction.forward(vertAltAz, &oneMag); | ||
291 | 425 | extinctionFactor=std::pow(0.4f, oneMag); // drop of one magnitude: factor 2.5 or 40% | ||
292 | 426 | dusttailColorArr.append(dustColor*extinctionFactor * brightnessPerVertexFromHead); | ||
293 | 427 | |||
294 | 428 | brightnessPerVertexFromHead-=brightnessDecreasePerVertexFromHead; | ||
295 | 429 | } | ||
296 | 430 | } | ||
297 | 431 | else // no atmosphere: set all vertices to same brightness. | ||
298 | 432 | { | ||
299 | 433 | gastailColorArr.fill(gasColor, gastailVertexArr.length()); | ||
300 | 434 | dusttailColorArr.fill(dustColor, dusttailVertexArr.length()); | ||
301 | 435 | } | ||
302 | 436 | //qDebug() << "Comet " << getEnglishName() << "JD: " << date << "gasR" << gasColor[0] << " dustR" << dustColor[0]; | ||
303 | 354 | } | 437 | } |
304 | 355 | 438 | ||
305 | 356 | 439 | ||
307 | 357 | // Draw the Comet and all the related infos : name, circle etc... GZ: Taken from Planet.cpp 2013-11-05 and extended | 440 | // Draw the Comet and all the related infos: name, circle etc... GZ: Taken from Planet.cpp 2013-11-05 and extended |
308 | 358 | void Comet::draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont) | 441 | void Comet::draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont) |
309 | 359 | { | 442 | { |
310 | 360 | if (hidden) | 443 | if (hidden) |
311 | 361 | return; | 444 | return; |
312 | 362 | if (getEnglishName() == core->getCurrentLocation().planetName) | 445 | if (getEnglishName() == core->getCurrentLocation().planetName) |
314 | 363 | { // GZ: Maybe even don't do that? E.g., draw tail while riding the comet? Decide later. | 446 | { // Maybe even don't do that? E.g., draw tail while riding the comet? Decide later. |
315 | 364 | return; | 447 | return; |
316 | 365 | } | 448 | } |
317 | 366 | 449 | ||
320 | 367 | // GZ: If comet is too faint to be seen, don't bother rendering. (oops, should have been here in 2014-01... ;-) | 450 | // If comet is too faint to be seen, don't bother rendering. (Massive speedup if people have hundreds of comets!) |
321 | 368 | if ((getVMagnitude(core)-2.0f) > core->getSkyDrawer()->getLimitMagnitude()) | 451 | if ((getVMagnitude(core)+2.0f) > core->getSkyDrawer()->getLimitMagnitude()) |
322 | 369 | { | 452 | { |
323 | 370 | return; | 453 | return; |
324 | 371 | } | 454 | } |
325 | 372 | // The CometOrbit is in fact available in userDataPtr! | 455 | // The CometOrbit is in fact available in userDataPtr! |
326 | 373 | CometOrbit* orbit=(CometOrbit*)userDataPtr; | 456 | CometOrbit* orbit=(CometOrbit*)userDataPtr; |
327 | 374 | Q_ASSERT(orbit); | 457 | Q_ASSERT(orbit); |
329 | 375 | if (!orbit->objectDateValid(core->getJDay())) return; // don't draw at all out of useful date range. This allows having hundreds of comet elements. | 458 | if (!orbit->objectDateValid(core->getJDay())) return; // don't draw at all if out of useful date range. This allows having hundreds of comet elements. |
330 | 376 | 459 | ||
331 | 377 | Mat4d mat = Mat4d::translation(eclipticPos) * rotLocalToParent; | 460 | Mat4d mat = Mat4d::translation(eclipticPos) * rotLocalToParent; |
332 | 378 | // This removed totally the Planet shaking bug!!! | 461 | // This removed totally the Planet shaking bug!!! |
333 | @@ -408,8 +491,8 @@ | |||
334 | 408 | 491 | ||
335 | 409 | draw3dModel(core,transfo,screenSz); | 492 | draw3dModel(core,transfo,screenSz); |
336 | 410 | } | 493 | } |
339 | 411 | // tails should also be drawn if comet core is off-screen... | 494 | // but tails should also be drawn if comet core is off-screen... |
340 | 412 | if (tailActive) | 495 | if (tailActive && tailBright) |
341 | 413 | { | 496 | { |
342 | 414 | drawTail(core,transfo,true); // gas tail | 497 | drawTail(core,transfo,true); // gas tail |
343 | 415 | drawTail(core,transfo,false); // dust tail | 498 | drawTail(core,transfo,false); // dust tail |
344 | @@ -420,46 +503,24 @@ | |||
345 | 420 | } | 503 | } |
346 | 421 | 504 | ||
347 | 422 | void Comet::drawTail(StelCore* core, StelProjector::ModelViewTranformP transfo, bool gas) | 505 | void Comet::drawTail(StelCore* core, StelProjector::ModelViewTranformP transfo, bool gas) |
349 | 423 | { | 506 | { |
350 | 424 | StelPainter* sPainter = new StelPainter(core->getProjection(transfo)); | 507 | StelPainter* sPainter = new StelPainter(core->getProjection(transfo)); |
351 | 425 | glEnable(GL_BLEND); | 508 | glEnable(GL_BLEND); |
352 | 426 | glBlendFunc(GL_ONE, GL_ONE); | 509 | glBlendFunc(GL_ONE, GL_ONE); |
353 | 427 | glDisable(GL_CULL_FACE); | 510 | glDisable(GL_CULL_FACE); |
354 | 428 | 511 | ||
355 | 429 | // GZ: If we use getVMagnitudeWithExtinction(), a head extincted in the horizon mist can completely hide an otherwise frighteningly long tail. | ||
356 | 430 | // we must use unextincted mag, but mix/dim with atmosphere/sky brightness. | ||
357 | 431 | // In addition, light falloff is a bit reduced for better visibility. Power basis should be 0.4, we use 0.6. | ||
358 | 432 | float magFactor=std::pow(0.6f , getVMagnitude(core)); | ||
359 | 433 | if (core->getSkyDrawer()->getFlagHasAtmosphere()) | ||
360 | 434 | { | ||
361 | 435 | // Mix with sky brightness and light pollution: This is very ad-hoc, if someone finds a better solution, please go ahead! | ||
362 | 436 | // Light pollution: | ||
363 | 437 | float bortleIndexFactor=0.1f * (11 - core->getSkyDrawer()->getBortleScaleIndex()); | ||
364 | 438 | magFactor*= bortleIndexFactor*bortleIndexFactor; // GZ-Guesstimate for light pollution influence | ||
365 | 439 | // sky brightness: This is about 10 for twilight where bright comet tails should already be visible. Dark night is close to 0. | ||
366 | 440 | float avgAtmLum=GETSTELMODULE(LandscapeMgr)->getAtmosphereAverageLuminance(); | ||
367 | 441 | float atmLumFactor=(15.0f-avgAtmLum)/15.0f; if (atmLumFactor<0.05f) atmLumFactor=0.05f; //atmLumFactor=std::sqrt(atmLumFactor); | ||
368 | 442 | magFactor*=atmLumFactor*atmLumFactor; | ||
369 | 443 | } | ||
370 | 444 | magFactor*=(gas? 0.9 : dustTailBrightnessFactor); // TBD: empirical adjustment for texture brightness. | ||
371 | 445 | magFactor=qMin(magFactor, 1.05f); // Limit excessively bright display. | ||
372 | 446 | |||
373 | 447 | tailTexture->bind(); | 512 | tailTexture->bind(); |
374 | 448 | 513 | ||
375 | 449 | if (gas) { | 514 | if (gas) { |
378 | 450 | sPainter->setColor(0.15f*magFactor,0.15f*magFactor,0.6f*magFactor); | 515 | sPainter->setArrays((Vec3d*)gastailVertexArr.constData(), (Vec2f*)tailTexCoordArr.constData(), (Vec3f*)gastailColorArr.constData()); |
377 | 451 | sPainter->setArrays((Vec3d*)gastailVertexArr.constData(), (Vec2f*)tailTexCoordArr.constData()); | ||
379 | 452 | sPainter->drawFromArray(StelPainter::Triangles, tailIndices.size(), 0, true, tailIndices.constData()); | 516 | sPainter->drawFromArray(StelPainter::Triangles, tailIndices.size(), 0, true, tailIndices.constData()); |
380 | 453 | 517 | ||
381 | 454 | } else { | 518 | } else { |
384 | 455 | sPainter->setColor(magFactor, magFactor,0.6f*magFactor); | 519 | sPainter->setArrays((Vec3d*)dusttailVertexArr.constData(), (Vec2f*)tailTexCoordArr.constData(), (Vec3f*)dusttailColorArr.constData()); |
383 | 456 | sPainter->setArrays((Vec3d*)dusttailVertexArr.constData(), (Vec2f*)tailTexCoordArr.constData()); | ||
385 | 457 | sPainter->drawFromArray(StelPainter::Triangles, tailIndices.size(), 0, true, tailIndices.constData()); | 520 | sPainter->drawFromArray(StelPainter::Triangles, tailIndices.size(), 0, true, tailIndices.constData()); |
386 | 458 | } | 521 | } |
387 | 459 | glDisable(GL_BLEND); | 522 | glDisable(GL_BLEND); |
388 | 460 | 523 | ||
389 | 461 | |||
390 | 462 | |||
391 | 463 | if (sPainter) | 524 | if (sPainter) |
392 | 464 | delete sPainter; | 525 | delete sPainter; |
393 | 465 | sPainter=NULL; | 526 | sPainter=NULL; |
394 | @@ -478,16 +539,13 @@ | |||
395 | 478 | glBlendFunc(GL_ONE, GL_ONE); | 539 | glBlendFunc(GL_ONE, GL_ONE); |
396 | 479 | glDisable(GL_CULL_FACE); | 540 | glDisable(GL_CULL_FACE); |
397 | 480 | 541 | ||
406 | 481 | // GZ: For the coma, we can use extinction via atmosphere. | 542 | StelToneReproducer* eye = core->getToneReproducer(); |
407 | 482 | // In addition, light falloff is a bit reduced for better visibility. Power basis should be 0.4, we use 0.6. | 543 | float lum = core->getSkyDrawer()->surfacebrightnessToLuminance(getVMagnitudeWithExtinction(core)+11.0f); // How to calibrate? |
408 | 483 | float minSkyMag=core->getSkyDrawer()->getLimitMagnitude(); | 544 | // Get the luminance scaled between 0 and 1 |
409 | 484 | float mag100pct=minSkyMag-6.0f; // should be 5, but let us draw it a bit brighter. | 545 | float aLum =eye->adaptLuminanceScaled(lum); |
410 | 485 | float magDrop=getVMagnitudeWithExtinction(core)-mag100pct; | 546 | float magFactor=qMin(qMax(aLum, 0.25f), 2.0f); |
403 | 486 | float magFactor=std::pow(0.6f , magDrop); | ||
404 | 487 | magFactor=qMin(magFactor, 2.0f); // Limit excessively bright display. | ||
405 | 488 | |||
411 | 489 | comaTexture->bind(); | 547 | comaTexture->bind(); |
413 | 490 | sPainter->setColor(magFactor,magFactor,0.6f*magFactor); | 548 | sPainter->setColor(0.3f*magFactor,0.7*magFactor,magFactor); |
414 | 491 | sPainter->setArrays((Vec3d*)comaVertexArr.constData(), (Vec2f*)comaTexCoordArr.constData()); | 549 | sPainter->setArrays((Vec3d*)comaVertexArr.constData(), (Vec2f*)comaTexCoordArr.constData()); |
415 | 492 | sPainter->drawFromArray(StelPainter::Triangles, comaVertexArr.size()/3); | 550 | sPainter->drawFromArray(StelPainter::Triangles, comaVertexArr.size()/3); |
416 | 493 | 551 | ||
417 | @@ -521,11 +579,11 @@ | |||
418 | 521 | // Parabola equation: z=x²/2p. | 579 | // Parabola equation: z=x²/2p. |
419 | 522 | // xOffset for the dust tail, this may introduce a bend. Units are x per sqrt(z). | 580 | // xOffset for the dust tail, this may introduce a bend. Units are x per sqrt(z). |
420 | 523 | void Comet::computeParabola(const float parameter, const float radius, const float zshift, | 581 | void Comet::computeParabola(const float parameter, const float radius, const float zshift, |
422 | 524 | QVector<double>& vertexArr, QVector<float>& texCoordArr, QVector<unsigned short> &indices, const float xOffset) { | 582 | QVector<Vec3d>& vertexArr, QVector<float>& texCoordArr, QVector<unsigned short> &indices, const float xOffset) { |
423 | 525 | 583 | ||
427 | 526 | // GZ: keep the array and replace contents. However, using replace() is only slightly faster. | 584 | // keep the array and replace contents. However, using replace() is only slightly faster. |
428 | 527 | if (vertexArr.length() < (3*(COMET_TAIL_SLICES*COMET_TAIL_STACKS+1))) | 585 | if (vertexArr.length() < ((COMET_TAIL_SLICES*COMET_TAIL_STACKS+1))) |
429 | 528 | vertexArr.resize(3*(COMET_TAIL_SLICES*COMET_TAIL_STACKS+1)); | 586 | vertexArr.resize((COMET_TAIL_SLICES*COMET_TAIL_STACKS+1)); |
430 | 529 | if (createTailIndices) indices.clear(); | 587 | if (createTailIndices) indices.clear(); |
431 | 530 | if (createTailTextureCoords) texCoordArr.clear(); | 588 | if (createTailTextureCoords) texCoordArr.clear(); |
432 | 531 | int i; | 589 | int i; |
433 | @@ -541,8 +599,8 @@ | |||
434 | 541 | ya[i]=cos(i*da); | 599 | ya[i]=cos(i*da); |
435 | 542 | } | 600 | } |
436 | 543 | 601 | ||
439 | 544 | vertexArr.replace(0, 0.0); vertexArr.replace(1, 0.0); vertexArr.replace(2, zshift); | 602 | vertexArr.replace(0, Vec3d(0.0, 0.0, zshift)); |
440 | 545 | int vertexArrIndex=3; | 603 | int vertexArrIndex=1; |
441 | 546 | if (createTailTextureCoords) texCoordArr << 0.5f << 0.5f; | 604 | if (createTailTextureCoords) texCoordArr << 0.5f << 0.5f; |
442 | 547 | // define the indices lying on circles, starting at 1: odd rings have 1/slices+1/2slices, even-numbered rings straight 1/slices | 605 | // define the indices lying on circles, starting at 1: odd rings have 1/slices+1/2slices, even-numbered rings straight 1/slices |
443 | 548 | // inner ring#1 | 606 | // inner ring#1 |
444 | @@ -553,9 +611,7 @@ | |||
445 | 553 | for (i=ring & 1; i<2*COMET_TAIL_SLICES; i+=2) { // i.e., ring1 has shifted vertices, ring2 has even ones. | 611 | for (i=ring & 1; i<2*COMET_TAIL_SLICES; i+=2) { // i.e., ring1 has shifted vertices, ring2 has even ones. |
446 | 554 | x=xa[i]*radius*ring/COMET_TAIL_STACKS; | 612 | x=xa[i]*radius*ring/COMET_TAIL_STACKS; |
447 | 555 | y=ya[i]*radius*ring/COMET_TAIL_STACKS; | 613 | y=ya[i]*radius*ring/COMET_TAIL_STACKS; |
451 | 556 | vertexArr.replace(vertexArrIndex++, x+xShift); | 614 | vertexArr.replace(vertexArrIndex++, Vec3d(x+xShift, y, z)); |
449 | 557 | vertexArr.replace(vertexArrIndex++, y); | ||
450 | 558 | vertexArr.replace(vertexArrIndex++, z); | ||
452 | 559 | if (createTailTextureCoords) texCoordArr << 0.5+ 0.5*x/radius << 0.5+0.5*y/radius; | 615 | if (createTailTextureCoords) texCoordArr << 0.5+ 0.5*x/radius << 0.5+0.5*y/radius; |
453 | 560 | } | 616 | } |
454 | 561 | } | 617 | } |
455 | @@ -591,10 +647,11 @@ | |||
456 | 591 | createTailTextureCoords=false; | 647 | createTailTextureCoords=false; |
457 | 592 | } | 648 | } |
458 | 593 | 649 | ||
459 | 650 | |||
460 | 594 | // These are to avoid having index arrays for each comet when all are equal. | 651 | // These are to avoid having index arrays for each comet when all are equal. |
461 | 595 | bool Comet::createTailIndices=true; | 652 | bool Comet::createTailIndices=true; |
462 | 596 | bool Comet::createTailTextureCoords=true; | 653 | bool Comet::createTailTextureCoords=true; |
463 | 597 | StelTextureSP Comet::comaTexture; | 654 | StelTextureSP Comet::comaTexture; |
464 | 598 | StelTextureSP Comet::tailTexture; | 655 | StelTextureSP Comet::tailTexture; |
467 | 599 | QVector<float> Comet::tailTexCoordArr; // computed only once FOR ALL COMETS! | 656 | QVector<float> Comet::tailTexCoordArr; // computed only once for all Comets. |
468 | 600 | QVector<unsigned short> Comet::tailIndices; // computed only once FOR ALL COMETS! | 657 | QVector<unsigned short> Comet::tailIndices; // computed only once for all Comets. |
469 | 601 | 658 | ||
470 | === modified file 'src/core/modules/Comet.hpp' | |||
471 | --- src/core/modules/Comet.hpp 2014-08-31 08:35:52 +0000 | |||
472 | +++ src/core/modules/Comet.hpp 2014-11-08 17:16:48 +0000 | |||
473 | @@ -32,6 +32,7 @@ | |||
474 | 32 | 2013-12: GZ: New algorithms for position computation following Paul Heafner: Fundamental Ephemeris Computations (Willmann-Bell 1999). | 32 | 2013-12: GZ: New algorithms for position computation following Paul Heafner: Fundamental Ephemeris Computations (Willmann-Bell 1999). |
475 | 33 | 2014-01: GZ: Parabolic tails appropriately scaled/rotated. Much is currently empirical, leaving room for physics-based improvements. | 33 | 2014-01: GZ: Parabolic tails appropriately scaled/rotated. Much is currently empirical, leaving room for physics-based improvements. |
476 | 34 | 2014-08: GZ: speedup in case hundreds of comets are loaded. | 34 | 2014-08: GZ: speedup in case hundreds of comets are loaded. |
477 | 35 | 2014-11: GZ: tail extinction, better brightness balance. | ||
478 | 35 | */ | 36 | */ |
479 | 36 | class Comet : public Planet | 37 | class Comet : public Planet |
480 | 37 | { | 38 | { |
481 | @@ -91,11 +92,15 @@ | |||
482 | 91 | virtual double getSiderealPeriod() const; | 92 | virtual double getSiderealPeriod() const; |
483 | 92 | 93 | ||
484 | 93 | //! GZ: override from Planet: extend with tail details. | 94 | //! GZ: override from Planet: extend with tail details. |
486 | 94 | virtual void computePosition(const double date); | 95 | //virtual void computePosition(const double date); |
487 | 95 | 96 | ||
488 | 96 | //! re-implementation of Planet's draw() | 97 | //! re-implementation of Planet's draw() |
489 | 97 | virtual void draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont); | 98 | virtual void draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont); |
490 | 98 | 99 | ||
491 | 100 | // re-implementation of Planet's update() to prepare tails (extinction etc). @param deltaTime: ms (since last call) | ||
492 | 101 | // TODO: computePosition can be removed and things added here! | ||
493 | 102 | virtual void update(int deltaTime); | ||
494 | 103 | |||
495 | 99 | private: | 104 | private: |
496 | 100 | //! @returns estimates for (Coma diameter [AU], gas tail length [AU]). | 105 | //! @returns estimates for (Coma diameter [AU], gas tail length [AU]). |
497 | 101 | //! Using the formula from Guide found by the GSoC2012 initiative at http://www.projectpluto.com/update7b.htm#comet_tail_formula | 106 | //! Using the formula from Guide found by the GSoC2012 initiative at http://www.projectpluto.com/update7b.htm#comet_tail_formula |
498 | @@ -117,7 +122,7 @@ | |||
499 | 117 | //! @param colorArr vertex colors (if not textured) r0, g0, b0, r1, g1, b1, ... | 122 | //! @param colorArr vertex colors (if not textured) r0, g0, b0, r1, g1, b1, ... |
500 | 118 | //! @param indices into the former arrays (zero-starting), triplets forming triangles: t0,0, t0,1, t0,2, t1,0, t1,1, t1,2, ... | 123 | //! @param indices into the former arrays (zero-starting), triplets forming triangles: t0,0, t0,1, t0,2, t1,0, t1,1, t1,2, ... |
501 | 119 | //! @param xOffset for the dust tail, this may introduce a bend. Units are x per sqrt(z). | 124 | //! @param xOffset for the dust tail, this may introduce a bend. Units are x per sqrt(z). |
503 | 120 | void computeParabola(const float parameter, const float topradius, const float zshift, QVector<double>& vertexArr, QVector<float>& texCoordArr, QVector<unsigned short>& indices, const float xOffset=0.0f); | 125 | void computeParabola(const float parameter, const float topradius, const float zshift, QVector<Vec3d>& vertexArr, QVector<float>& texCoordArr, QVector<unsigned short>& indices, const float xOffset=0.0f); |
504 | 121 | 126 | ||
505 | 122 | double absoluteMagnitude; | 127 | double absoluteMagnitude; |
506 | 123 | double slopeParameter; | 128 | double slopeParameter; |
507 | @@ -127,9 +132,10 @@ | |||
508 | 127 | 132 | ||
509 | 128 | //GZ Tail additions | 133 | //GZ Tail additions |
510 | 129 | Vec2f tailFactors; // result of latest call to getComaDiameterAndTailLengthAU(); Results cached here for infostring. [0]=Coma diameter, [1] gas tail length. | 134 | Vec2f tailFactors; // result of latest call to getComaDiameterAndTailLengthAU(); Results cached here for infostring. [0]=Coma diameter, [1] gas tail length. |
512 | 130 | bool tailActive; //! true if there is a tail worth bothering (longer than COMET_MIN_TAIL_LENGTH_AU)? Drawing tails is quite costly. | 135 | bool tailActive; //! true if there is a tail long enough to be worth drawing. Drawing tails is quite costly. |
513 | 136 | bool tailBright; //! true if tail is bright enough to draw. | ||
514 | 131 | double deltaJDtail; //! like deltaJD, but time difference between tail geometry updates. | 137 | double deltaJDtail; //! like deltaJD, but time difference between tail geometry updates. |
516 | 132 | double lastJDtail; //! like lastJD, but time of last tail geometry update. | 138 | double lastJDtail; //! like lastJD, but time of last tail geometry update. |
517 | 133 | Mat4d gasTailRot; //! rotation matrix for gas tail parabola | 139 | Mat4d gasTailRot; //! rotation matrix for gas tail parabola |
518 | 134 | Mat4d dustTailRot; //! rotation matrix for the skewed dust tail parabola | 140 | Mat4d dustTailRot; //! rotation matrix for the skewed dust tail parabola |
519 | 135 | float dustTailWidthFactor; //!< empirical individual broadening of the dust tail end, compared to the gas tail end. Actually, dust tail width=2*comaWidth*dustTailWidthFactor. Default 1.5 | 141 | float dustTailWidthFactor; //!< empirical individual broadening of the dust tail end, compared to the gas tail end. Actually, dust tail width=2*comaWidth*dustTailWidthFactor. Default 1.5 |
520 | @@ -142,8 +148,10 @@ | |||
521 | 142 | static bool createTailIndices; | 148 | static bool createTailIndices; |
522 | 143 | static bool createTailTextureCoords; | 149 | static bool createTailTextureCoords; |
523 | 144 | 150 | ||
526 | 145 | QVector<double> gastailVertexArr; // computed frequently, describes parabolic shape (along z axis) of gas tail. | 151 | QVector<Vec3d> gastailVertexArr; // computed frequently, describes parabolic shape (along z axis) of gas tail. |
527 | 146 | QVector<double> dusttailVertexArr; // computed frequently, describes parabolic shape (along z axis) of dust tail. | 152 | QVector<Vec3d> dusttailVertexArr; // computed frequently, describes parabolic shape (along z axis) of dust tail. |
528 | 153 | QVector<Vec3f> gastailColorArr; // NEW computed for every 5 mins, modulates gas tail brightness for extinction | ||
529 | 154 | QVector<Vec3f> dusttailColorArr; // NEW computed for every 5 mins, modulates dust tail brightness for extinction | ||
530 | 147 | static QVector<float> tailTexCoordArr; // computed only once for all comets! | 155 | static QVector<float> tailTexCoordArr; // computed only once for all comets! |
531 | 148 | static QVector<unsigned short> tailIndices; // computed only once for all comets! | 156 | static QVector<unsigned short> tailIndices; // computed only once for all comets! |
532 | 149 | static StelTextureSP comaTexture; | 157 | static StelTextureSP comaTexture; |
533 | 150 | 158 | ||
534 | === modified file 'src/core/modules/MilkyWay.cpp' | |||
535 | --- src/core/modules/MilkyWay.cpp 2014-10-27 22:40:49 +0000 | |||
536 | +++ src/core/modules/MilkyWay.cpp 2014-11-08 17:16:48 +0000 | |||
537 | @@ -128,7 +128,7 @@ | |||
538 | 128 | for (int i=0; i<vertexArray->vertex.size(); ++i) | 128 | for (int i=0; i<vertexArray->vertex.size(); ++i) |
539 | 129 | { | 129 | { |
540 | 130 | Vec3d vertAltAz=core->j2000ToAltAz(vertexArray->vertex.at(i), StelCore::RefractionOn); | 130 | Vec3d vertAltAz=core->j2000ToAltAz(vertexArray->vertex.at(i), StelCore::RefractionOn); |
542 | 131 | Q_ASSERT(vertAltAz.lengthSquared()-1.0 < 0.001f); | 131 | Q_ASSERT(fabs(vertAltAz.lengthSquared()-1.0) < 0.001); |
543 | 132 | 132 | ||
544 | 133 | float oneMag=0.0f; | 133 | float oneMag=0.0f; |
545 | 134 | extinction.forward(vertAltAz, &oneMag); | 134 | extinction.forward(vertAltAz, &oneMag); |
546 | 135 | 135 | ||
547 | === modified file 'src/core/modules/MinorPlanet.cpp' | |||
548 | --- src/core/modules/MinorPlanet.cpp 2014-08-31 10:34:41 +0000 | |||
549 | +++ src/core/modules/MinorPlanet.cpp 2014-11-08 17:16:48 +0000 | |||
550 | @@ -293,7 +293,6 @@ | |||
551 | 293 | //Calculate phase angle | 293 | //Calculate phase angle |
552 | 294 | //(Code copied from Planet::getVMagnitude()) | 294 | //(Code copied from Planet::getVMagnitude()) |
553 | 295 | //(this is actually vector subtraction + the cosine theorem :)) | 295 | //(this is actually vector subtraction + the cosine theorem :)) |
554 | 296 | // GZ Try now in float... speed difference is negligible, though. | ||
555 | 297 | const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipticPos(); | 296 | const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipticPos(); |
556 | 298 | const float observerRq = observerHelioPos.lengthSquared(); | 297 | const float observerRq = observerHelioPos.lengthSquared(); |
557 | 299 | const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); | 298 | const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); |
558 | 300 | 299 | ||
559 | === modified file 'src/core/modules/Planet.cpp' | |||
560 | --- src/core/modules/Planet.cpp 2014-11-05 14:49:44 +0000 | |||
561 | +++ src/core/modules/Planet.cpp 2014-11-08 17:16:48 +0000 | |||
562 | @@ -679,7 +679,7 @@ | |||
563 | 679 | double Planet::computeDistance(const Vec3d& obsHelioPos) | 679 | double Planet::computeDistance(const Vec3d& obsHelioPos) |
564 | 680 | { | 680 | { |
565 | 681 | distance = (obsHelioPos-getHeliocentricEclipticPos()).length(); | 681 | distance = (obsHelioPos-getHeliocentricEclipticPos()).length(); |
567 | 682 | // GZ: improve fps by juggling updates for asteroids. They must be fast if close to observer, but can be slow if further away. | 682 | // improve fps by juggling updates for asteroids. They must be fast if close to observer, but can be slow if further away. |
568 | 683 | if (pType == Planet::isAsteroid) | 683 | if (pType == Planet::isAsteroid) |
569 | 684 | deltaJD=distance*StelCore::JD_SECOND; | 684 | deltaJD=distance*StelCore::JD_SECOND; |
570 | 685 | return distance; | 685 | return distance; |
571 | @@ -928,11 +928,11 @@ | |||
572 | 928 | { | 928 | { |
573 | 929 | if (hidden) | 929 | if (hidden) |
574 | 930 | return; | 930 | return; |
576 | 931 | // GZ: Try to improve speed for minor planets: test if visible at all. | 931 | // Try to improve speed for minor planets: test if visible at all. |
577 | 932 | // For a full catalog of NEAs (11000 objects), with this and resetting deltaJD according to distance, rendering time went 4.5fps->12fps. | 932 | // For a full catalog of NEAs (11000 objects), with this and resetting deltaJD according to distance, rendering time went 4.5fps->12fps. |
581 | 933 | // AW: Apply this rule to asteroids only | 933 | // TBD: Note that taking away the asteroids at this stage breaks dim-asteroid occultation of stars! |
582 | 934 | // Note that taking away the asteroids at this stage breaks dim-asteroid occultation of stars! | 934 | // Maybe make another configurable flag for those interested? |
583 | 935 | if (((getVMagnitude(core)-1.0f) > core->getSkyDrawer()->getLimitMagnitude()) && pType==Planet::isAsteroid) | 935 | if (((getVMagnitude(core)+1.0f) > core->getSkyDrawer()->getLimitMagnitude()) && pType==Planet::isAsteroid) |
584 | 936 | { | 936 | { |
585 | 937 | return; | 937 | return; |
586 | 938 | } | 938 | } |
587 | 939 | 939 | ||
588 | === modified file 'src/core/modules/Planet.hpp' | |||
589 | --- src/core/modules/Planet.hpp 2014-11-01 15:03:47 +0000 | |||
590 | +++ src/core/modules/Planet.hpp 2014-11-08 17:16:48 +0000 | |||
591 | @@ -192,7 +192,8 @@ | |||
592 | 192 | 192 | ||
593 | 193 | // Compute the position in the parent Planet coordinate system | 193 | // Compute the position in the parent Planet coordinate system |
594 | 194 | void computePositionWithoutOrbits(const double dateJD); | 194 | void computePositionWithoutOrbits(const double dateJD); |
596 | 195 | virtual void computePosition(const double dateJD);// GZ: gets overridden in Comet! | 195 | //virtual void computePosition(const double dateJD);// GZ: gets overridden in Comet! |
597 | 196 | void computePosition(const double dateJD);// GZ: gets overridden in Comet! | ||
598 | 196 | 197 | ||
599 | 197 | // Compute the transformation matrix from the local Planet coordinate to the parent Planet coordinate | 198 | // Compute the transformation matrix from the local Planet coordinate to the parent Planet coordinate |
600 | 198 | void computeTransMatrix(double date); | 199 | void computeTransMatrix(double date); |
601 | @@ -237,8 +238,8 @@ | |||
602 | 237 | static void setLabelColor(const Vec3f& lc) {labelColor = lc;} | 238 | static void setLabelColor(const Vec3f& lc) {labelColor = lc;} |
603 | 238 | static const Vec3f& getLabelColor(void) {return labelColor;} | 239 | static const Vec3f& getLabelColor(void) {return labelColor;} |
604 | 239 | 240 | ||
607 | 240 | // update displayed elements. @param deltaTime: ms (?) | 241 | // update displayed elements. @param deltaTime: ms (since last call) |
608 | 241 | void update(int deltaTime); | 242 | virtual void update(int deltaTime); |
609 | 242 | 243 | ||
610 | 243 | void setFlagHints(bool b){hintFader = b;} | 244 | void setFlagHints(bool b){hintFader = b;} |
611 | 244 | bool getFlagHints(void) const {return hintFader;} | 245 | bool getFlagHints(void) const {return hintFader;} |
Looks good to me :)