mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 20:26:43 +00:00 
			
		
		
		
	Improve scene loading performance by creating collision objects with the correct rotation right away instead of adjusting it later
This commit is contained in:
		
							parent
							
								
									739a76f5fb
								
							
						
					
					
						commit
						1447bfa215
					
				
					 1 changed files with 24 additions and 19 deletions
				
			
		|  | @ -29,6 +29,26 @@ | |||
| namespace | ||||
| { | ||||
| 
 | ||||
|     void setNodeRotation(const MWWorld::Ptr& ptr, MWRender::RenderingManager& rendering, bool inverseRotationOrder) | ||||
|     { | ||||
|         if (!ptr.getRefData().getBaseNode()) | ||||
|             return; | ||||
| 
 | ||||
|         osg::Quat worldRotQuat(ptr.getRefData().getPosition().rot[2], osg::Vec3(0,0,-1)); | ||||
|         if (!ptr.getClass().isActor()) | ||||
|         { | ||||
|             float xr = ptr.getRefData().getPosition().rot[0]; | ||||
|             float yr = ptr.getRefData().getPosition().rot[1]; | ||||
|             if (!inverseRotationOrder) | ||||
|                 worldRotQuat = worldRotQuat * osg::Quat(yr, osg::Vec3(0,-1,0)) * | ||||
|                     osg::Quat(xr, osg::Vec3(-1,0,0)); | ||||
|             else | ||||
|                 worldRotQuat = osg::Quat(xr, osg::Vec3(-1,0,0)) * osg::Quat(yr, osg::Vec3(0,-1,0)) * worldRotQuat; | ||||
|         } | ||||
| 
 | ||||
|         rendering.rotateObject(ptr, worldRotQuat); | ||||
|     } | ||||
| 
 | ||||
|     void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, | ||||
|                    MWRender::RenderingManager& rendering) | ||||
|     { | ||||
|  | @ -37,6 +57,8 @@ namespace | |||
|         if (id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker") | ||||
|             model = ""; // marker objects that have a hardcoded function in the game logic, should be hidden from the player
 | ||||
|         ptr.getClass().insertObjectRendering(ptr, model, rendering); | ||||
|         setNodeRotation(ptr, rendering, false); | ||||
| 
 | ||||
|         ptr.getClass().insertObject (ptr, model, physics); | ||||
| 
 | ||||
|         if (ptr.getClass().isActor()) | ||||
|  | @ -46,23 +68,8 @@ namespace | |||
|     void updateObjectRotation (const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, | ||||
|                                     MWRender::RenderingManager& rendering, bool inverseRotationOrder) | ||||
|     { | ||||
|         if (ptr.getRefData().getBaseNode() != NULL) | ||||
|         { | ||||
|             osg::Quat worldRotQuat(ptr.getRefData().getPosition().rot[2], osg::Vec3(0,0,-1)); | ||||
|             if (!ptr.getClass().isActor()) | ||||
|             { | ||||
|                 float xr = ptr.getRefData().getPosition().rot[0]; | ||||
|                 float yr = ptr.getRefData().getPosition().rot[1]; | ||||
|                 if (!inverseRotationOrder) | ||||
|                     worldRotQuat = worldRotQuat * osg::Quat(yr, osg::Vec3(0,-1,0)) * | ||||
|                         osg::Quat(xr, osg::Vec3(-1,0,0)); | ||||
|                 else | ||||
|                     worldRotQuat = osg::Quat(xr, osg::Vec3(-1,0,0)) * osg::Quat(yr, osg::Vec3(0,-1,0)) * worldRotQuat; | ||||
|             } | ||||
| 
 | ||||
|             rendering.rotateObject(ptr, worldRotQuat); | ||||
|             physics.updateRotation(ptr); | ||||
|         } | ||||
|         setNodeRotation(ptr, rendering, inverseRotationOrder); | ||||
|         physics.updateRotation(ptr); | ||||
|     } | ||||
| 
 | ||||
|     void updateObjectScale(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, | ||||
|  | @ -130,7 +137,6 @@ namespace | |||
|                 try | ||||
|                 { | ||||
|                     addObject(ptr, mPhysics, mRendering); | ||||
|                     updateObjectRotation(ptr, mPhysics, mRendering, false); | ||||
|                 } | ||||
|                 catch (const std::exception& e) | ||||
|                 { | ||||
|  | @ -602,7 +608,6 @@ namespace MWWorld | |||
|         try | ||||
|         { | ||||
|             addObject(ptr, *mPhysics, mRendering); | ||||
|             updateObjectRotation(ptr, false); | ||||
|             MWBase::Environment::get().getWorld()->scaleObject(ptr, ptr.getCellRef().getScale()); | ||||
|         } | ||||
|         catch (std::exception& e) | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue