MCPcopy Create free account
hub / github.com/Illation/ETEngine / Process

Method Process

Engine/source/EtFramework/Systems/PlanetCameraClippingSystem.cpp:31–51  ·  view source on GitHub ↗

--------------------------------- PlanetCameraLinkSystem::Process Set the cameras clipping planes to the planets size

Source from the content-addressed store, hash-verified

29// Set the cameras clipping planes to the planets size
30//
31void 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

Callers

nothing calls this directly

Calls 6

GetAtmosphereHeightMethod · 0.80
SetFarClippingPlaneMethod · 0.80
SetNearClippingPlaneMethod · 0.80
GetRadiusMethod · 0.45
GetMaxHeightMethod · 0.45
GetFarPlaneMethod · 0.45

Tested by

no test coverage detected