| 1099 | } |
| 1100 | |
| 1101 | void World::SwitchCameraTo(Object* vehicle, CameraType camType) |
| 1102 | { |
| 1103 | bool change = (vehicle != _cameraOn); |
| 1104 | float changeDist2 = 1e10; |
| 1105 | if (vehicle && _cameraOn) |
| 1106 | { |
| 1107 | changeDist2 = vehicle->Position().Distance2(_cameraOn->Position()); |
| 1108 | } |
| 1109 | if (vehicle != _cameraOn || _camTypeMain != camType) |
| 1110 | { |
| 1111 | Object* oldCameraOn = _cameraOn; |
| 1112 | _cameraOn = vehicle; |
| 1113 | _camType = _camTypeMain = camType; |
| 1114 | InitCameraPars(); |
| 1115 | SetActiveChannels(); |
| 1116 | if (change) |
| 1117 | { |
| 1118 | EntityAI* ai = dyn_cast<EntityAI>(vehicle); |
| 1119 | if (_ui && ai) |
| 1120 | { |
| 1121 | Person* player = PlayerOn(); |
| 1122 | if (player == ai || oldCameraOn == player) |
| 1123 | { |
| 1124 | InputSubsystem::Instance().ResetLookAroundToggle(); |
| 1125 | } |
| 1126 | ai->ResetFF(); |
| 1127 | _ui->ResetVehicle(ai); |
| 1128 | } |
| 1129 | } |
| 1130 | LOG_DEBUG(World, "Camera switched to {}", (const char*)vehicle->GetDebugName()); |
| 1131 | } |
| 1132 | _nearImportanceDistributionTime = Glob.time - 60; |
| 1133 | _farImportanceDistributionTime = Glob.time - 60; |
| 1134 | if (vehicle && change && changeDist2 > Square(400)) |
| 1135 | { |
| 1136 | _scene.GetLandscape()->FillCache(*vehicle); |
| 1137 | } |
| 1138 | } |
| 1139 | |
| 1140 | static void KeepNZone(float& value, float cursor, float pos, float size, float fov) |
| 1141 | { |
no test coverage detected