mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-30 02:56:44 +00:00 
			
		
		
		
	Fix exterior sun direction/position (bug #4898)
This commit is contained in:
		
							parent
							
								
									961c53f1c4
								
							
						
					
					
						commit
						1f26485c47
					
				
					 3 changed files with 12 additions and 8 deletions
				
			
		|  | @ -16,6 +16,7 @@ | ||||||
|     Bug #4754: Stack of ammunition cannot be equipped partially |     Bug #4754: Stack of ammunition cannot be equipped partially | ||||||
|     Bug #4816: GetWeaponDrawn returns 1 before weapon is attached |     Bug #4816: GetWeaponDrawn returns 1 before weapon is attached | ||||||
|     Bug #4822: Non-weapon equipment and body parts can't inherit time from parent animation |     Bug #4822: Non-weapon equipment and body parts can't inherit time from parent animation | ||||||
|  |     Bug #4898: Odd/Incorrect lighting on meshes | ||||||
|     Bug #5057: Weapon swing sound plays at same pitch whether it hits or misses |     Bug #5057: Weapon swing sound plays at same pitch whether it hits or misses | ||||||
|     Bug #5062: Root bone rotations for NPC animation don't work the same as for creature animation |     Bug #5062: Root bone rotations for NPC animation don't work the same as for creature animation | ||||||
|     Bug #5066: Quirks with starting and stopping scripted animations |     Bug #5066: Quirks with starting and stopping scripted animations | ||||||
|  |  | ||||||
|  | @ -716,6 +716,9 @@ namespace MWRender | ||||||
|         // need to wrap this in a StateUpdater?
 |         // need to wrap this in a StateUpdater?
 | ||||||
|         mSunLight->setPosition(osg::Vec4(position.x(), position.y(), position.z(), 0)); |         mSunLight->setPosition(osg::Vec4(position.x(), position.y(), position.z(), 0)); | ||||||
| 
 | 
 | ||||||
|  |         // The sun is not synchronized with the sunlight because sunlight origin can't reach the horizon
 | ||||||
|  |         // This is based on exterior sun orbit and won't make sense for interiors, see WeatherManager::update
 | ||||||
|  |         position.z() = 400.f - std::abs(position.x()); | ||||||
|         mSky->setSunDirection(position); |         mSky->setSunDirection(position); | ||||||
| 
 | 
 | ||||||
|         mPostProcessor->getStateUpdater()->setSunPos(mSunLight->getPosition(), mNight); |         mPostProcessor->getStateUpdater()->setSunPos(mSunLight->getPosition(), mNight); | ||||||
|  |  | ||||||
|  | @ -752,21 +752,21 @@ namespace MWWorld | ||||||
|             const float dayDuration = adjustedNightStart - mSunriseTime; |             const float dayDuration = adjustedNightStart - mSunriseTime; | ||||||
|             const float nightDuration = 24.f - dayDuration; |             const float nightDuration = 24.f - dayDuration; | ||||||
| 
 | 
 | ||||||
|             double theta; |             float orbit; | ||||||
|             if (!is_night) |             if (!is_night) | ||||||
|             { |             { | ||||||
|                 theta = static_cast<float>(osg::PI) * (adjustedHour - mSunriseTime) / dayDuration; |                 float t = (adjustedHour - mSunriseTime) / dayDuration; | ||||||
|  |                 orbit = 1.f - 2.f * t; | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
|                 theta = static_cast<float>(osg::PI) |                 float t = (adjustedHour - adjustedNightStart) / nightDuration; | ||||||
|                     - static_cast<float>(osg::PI) * (adjustedHour - adjustedNightStart) / nightDuration; |                 orbit = 2.f * t - 1.f; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             osg::Vec3f final(static_cast<float>(cos(theta)), |             // Hardcoded constant from Morrowind
 | ||||||
|                 -0.268f, // approx tan( -15 degrees )
 |             const osg::Vec3f sunDir(-400.f * orbit, 75.f, -100.f); | ||||||
|                 static_cast<float>(sin(theta))); |             mRendering.setSunDirection(sunDir); | ||||||
|             mRendering.setSunDirection(final * -1); |  | ||||||
|             mRendering.setNight(is_night); |             mRendering.setNight(is_night); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue