--------------------------------- PlanetCameraLinkSystem::Process Set the cameras clipping planes to the planets size
| 29 | // Set the cameras clipping planes to the planets size |
| 30 | // |
| 31 | void PlanetCameraLinkSystem::Process(ComponentRange<PlanetCameraLinkSystemView>& range) |
| 32 | { |
| 33 | for (PlanetCameraLinkSystemView& view : range) |
| 34 | { |
| 35 | PlanetComponent const* const planet = view.planet[view.link->planet]; |
| 36 | TransformComponent const* const planetTransform = view.planetTransform[view.link->planet]; |
| 37 | AtmosphereComponent const* const planetAtmo = view.planetAtmo[view.link->planet]; |
| 38 | |
| 39 | ET_ASSERT(planet != nullptr); |
| 40 | ET_ASSERT(planetTransform != nullptr); |
| 41 | ET_ASSERT(planetAtmo != nullptr); |
| 42 | |
| 43 | float const planetRad = planet->GetRadius(); |
| 44 | |
| 45 | float const radius = std::max(planetRad + planet->GetMaxHeight(), planetRad + planetAtmo->GetAtmosphereHeight()); |
| 46 | float const altitude = math::distance(planetTransform->GetPosition(), view.cameraTransform->GetPosition()) - planetRad; |
| 47 | |
| 48 | view.camera->SetFarClippingPlane((sqrtf(powf(planetRad + altitude, 2) - powf(planetRad, 2)) + sqrtf(powf(radius, 2) - powf(planetRad, 2))) * 10); |
| 49 | view.camera->SetNearClippingPlane(view.camera->GetFarPlane() * 0.000003f); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | |
| 54 | } // namespace fw |
nothing calls this directly
no test coverage detected