// Manage physics from this loop
// Please don't alter the Ogre scene manager directly. Instead use the designated methods (setPositionX, setPositionY, setPositionZ, setRoll, setPitch, setYaw, animate)
void loop(Ogre::SceneManager* smgr){
	int dir = 1;
	int timeStep = 10;
	while(true){
		// If the message array has any elements, the render loop is applying changes from physics loop
		// If so, abort this timestep
		if((*::message).size() == 1){
			continue;
		}
		Sleep(timeStep);
		Ogre::SceneManager::MovableObjectIterator iterator = smgr->getMovableObjectIterator("Entity");
		while(iterator.hasMoreElements()){
			// If the message array has any elements, the render loop is applying changes from physics loop
			// If so, abort this timestep
			if((*::message).size() == 1){
				continue;
			}
			Ogre::Entity* entity = static_cast<Ogre::Entity*>(iterator.getNext());

			// <>< <>< Make the cute fishy swim <>< <><
			// This only moves fish
			if(entity->hasAnimationState("swim")){
			
				Ogre::SceneNode* sceneNode = entity->getParentSceneNode();

				// Update position
				Ogre::Vector3 pos = sceneNode->getPosition();
				if(pos.x > 120){
					dir = -1;
					setYaw(entity, 180);
				}
				if(pos.x < -120){
					dir = 1;
					setYaw(entity, 180);
				}
				setPositionX(entity, sceneNode->getPosition().x + dir);
				animate(entity, "swim");
			}

		}
	}
}