mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 02:26:38 +00:00 
			
		
		
		
	Change the comparison of positions to avoid a problem if both positions are large numbers.
This commit is contained in:
		
							parent
							
								
									0037fd78c1
								
							
						
					
					
						commit
						26817e9cc5
					
				
					 1 changed files with 5 additions and 2 deletions
				
			
		|  | @ -202,7 +202,8 @@ namespace MWPhysics | ||||||
| 
 | 
 | ||||||
|         for (int iterations = 0; iterations < sMaxIterations && remainingTime > 0.0001f; ++iterations) |         for (int iterations = 0; iterations < sMaxIterations && remainingTime > 0.0001f; ++iterations) | ||||||
|         { |         { | ||||||
|             osg::Vec3f nextpos = newPosition + velocity * remainingTime; |             osg::Vec3f diff = velocity * remainingTime; | ||||||
|  |             osg::Vec3f nextpos = newPosition + diff; | ||||||
|             bool underwater = newPosition.z() < swimlevel; |             bool underwater = newPosition.z() < swimlevel; | ||||||
| 
 | 
 | ||||||
|             // If not able to fly, don't allow to swim up into the air
 |             // If not able to fly, don't allow to swim up into the air
 | ||||||
|  | @ -214,7 +215,9 @@ namespace MWPhysics | ||||||
|                 continue; // velocity updated, calculate nextpos again
 |                 continue; // velocity updated, calculate nextpos again
 | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if ((newPosition - nextpos).length2() > std::numeric_limits<float>::epsilon()) |             // Note, we use an epsilon of 1e-6 instead of std::numeric_limits<float>::epsilon() to avoid doing extremely 
 | ||||||
|  |             // small steps. But if we make it any larger we'll start rejecting subtle movements from e.g. idle animations.
 | ||||||
|  |             if (diff.length2() > 1e-6 && (newPosition - nextpos).length2() > 1e-6) | ||||||
|             { |             { | ||||||
|                 // trace to where character would go if there were no obstructions
 |                 // trace to where character would go if there were no obstructions
 | ||||||
|                 tracer.doTrace(actor.mCollisionObject, newPosition, nextpos, collisionWorld, actor.mIsOnGround); |                 tracer.doTrace(actor.mCollisionObject, newPosition, nextpos, collisionWorld, actor.mIsOnGround); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue