Panda3D

Public Member Functions | Public Attributes | List of all members
InternalLightManager Class Reference

Internal class used for handling lights and shadows. More...

`#include "internalLightManager.h"`

## Public Member Functions
| InternalLightManager ()
| Constructs the light manager. More...
void | add_light (PT(RPLight) light)
| Adds a new light. More...
int | get_max_light_index () const
size_t | get_num_lights () const
size_t | get_num_shadow_sources () const
ShadowManager * | get_shadow_manager () const
void | remove_light (PT(RPLight) light)
| Removes a light. More...
void | set_camera_pos (const LPoint3 &pos)
| Sets the camera position. More...
void | set_command_list (GPUCommandList *cmd_list)
| Sets a handle to the command list. More...
void | set_shadow_manager (ShadowManager *mgr)
void | set_shadow_update_distance (PN_stdfloat dist)
| Sets the maximum shadow update distance. More...
void | update ()
| Main update method. More...

## Public Attributes
| get_max_light_index
| RenderPipeline. More...
| get_num_lights
| Returns the amount of stored lights. More...
| get_num_shadow_sources
| Returns the amount of shadow sources. More...
| get_shadow_manager
| Returns the internal used ShadowManager. More...
| set_shadow_manager
| Sets the handle to the shadow manager. More...

## Detailed Description

Internal class used for handling lights and shadows.

This is the internal class used by the pipeline to handle all lights and shadows. It stores references to the lights, manages handling the light and shadow slots, and also communicates with the GPU with the GPUCommandQueue to store light and shadow source data.

Definition at line 50 of file internalLightManager.h.

## Constructor & Destructor Documentation

## ◆ InternalLightManager()

InternalLightManager::InternalLightManager | ( |  | ) |

Constructs the light manager.

This constructs the light manager, initializing the light and shadow storage. You should set a command list and shadow manager before calling InternalLightManager::update. s

Definition at line 43 of file internalLightManager.cxx.

## Member Function Documentation

## ◆ add_light()

void InternalLightManager::add_light | ( | PT(RPLight) | light | ) |

Adds a new light.

This adds a new light to the list of lights. This will throw an error and return if the light is already attached. You may only call this after the ShadowManager was already set.

While the light is attached, the light manager keeps a reference to it, so the light does not get destructed.

This also setups the shadows on the light, in case shadows are enabled. While a light is attached, you can not change whether it casts shadows or not. To do so, detach the light, change the setting, and re-add the light.

In case no free light slot is available, an error will be printed and no action will be performed.

If no shadow manager was set, an assertion will be triggered.

Parameters

  light | The light to add.

Definition at line 69 of file internalLightManager.cxx.

## ◆ remove_light()

void InternalLightManager::remove_light | ( | PT(RPLight) | light | ) |

Removes a light.

This detaches a light. This prevents it from being rendered, and also cleans up all resources used by that light. If no reference is kept on the python side, the light will also get destructed.

If the light was not previously attached with InternalLightManager::add_light, an error will be triggered and nothing happens.

In case the light was set to cast shadows, all shadow sources are cleaned up, and their regions in the shadow atlas are freed.

All resources used by the light in the light and shadow storage are also cleaned up, by emitting cleanup GPUCommands.

If no shadow manager was set, an assertion will be triggered.

Parameters

  light | [description]

Definition at line 171 of file internalLightManager.cxx.

## ◆ set_camera_pos()

void InternalLightManager::set_camera_pos | ( | const LPoint3 & | pos | ) |
| inline

Sets the camera position.

This sets the camera position, which will be used to determine which shadow sources have to get updated

Parameters

  mat | View projection mat

Definition at line 117 of file internalLightManager.I.

## ◆ set_command_list()

void InternalLightManager::set_command_list | ( | GPUCommandList * | cmd_list | ) |
| inline

Sets a handle to the command list.

This sets a handle to the global GPUCommandList. This is required to emit GPUCommands, which are used for attaching and detaching lights, as well as shadow source updates.

The cmd_list should be a handle to a GPUCommandList handle, and will be stored somewhere on the python side most likely. The light manager does not keep a reference to it, so the python side should make sure to keep one.

Be sure to call this before the InternalLightManager::update() method is called, otherwise an assertion will get triggered.

Parameters

  cmd_list | The GPUCommandList instance

Definition at line 106 of file internalLightManager.I.

## ◆ set_shadow_update_distance()

void InternalLightManager::set_shadow_update_distance | ( | PN_stdfloat | dist | ) |
| inline

Sets the maximum shadow update distance.

This controls the maximum distance until which shadows are updated. If a shadow source is past that distance, it is ignored and no longer recieves updates until it is in range again

Parameters

  dist | Distance in world space units

Definition at line 129 of file internalLightManager.I.

## ◆ update()

void InternalLightManager::update | ( |  | ) |

Main update method.

This is the main update method of the InternalLightManager. It processes all lights and shadow sources, updates them, and notifies the GPU about it. This should be called on a per-frame basis.

If the InternalLightManager was not initialized yet, an assertion is thrown.

Definition at line 437 of file internalLightManager.cxx.

## Member Data Documentation

## ◆ get_max_light_index

int InternalLightManager::get_max_light_index
| inline

RenderPipeline.

Copyright (c) 2014-2016 tobspr tobia.nosp@m.s.sp.nosp@m.ringe.nosp@m.r1@g.nosp@m.mail..nosp@m.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Returns the maximum light index

This returns the maximum light index (also called slot). Any lights after that slot are guaranteed to be zero-lights. This is useful when iterating over the list of lights, because iteration can be stopped when the maximum light index is reached.

The maximum light index points to the last slot which is used. If no lights are attached, -1 is returned. If one light is attached at slot 0, the index is 0, if two are attached at the slots 0 and 1, the index is 1, and so on.

If, for example, two lights are attached at the slots 2 and 5, then the index will be 5. Keep in mind that the max-index is not an indicator for how many lights are attached. Also, zero lights still may occur when iterating over the light lists

Returns
  Maximum light index

Definition at line 62 of file internalLightManager.h.

## ◆ get_num_lights

size_t InternalLightManager::get_num_lights
| inline

Returns the amount of stored lights.

This returns the amount of stored lights. This behaves unlike InternalLightManager::get_max_light_index, and instead returns the true amount of lights, which is completely unrelated to the amount of used slots.

Returns
  Amount of stored lights

Definition at line 65 of file internalLightManager.h.

## ◆ get_num_shadow_sources

size_t InternalLightManager::get_num_shadow_sources
| inline

Returns the amount of shadow sources.

This returns the total amount of stored shadow sources. This does not denote the amount of updated sources, but instead takes into account all sources, even those out of frustum.

Returns
  Amount of shadow sources.

Definition at line 68 of file internalLightManager.h.

## ◆ get_shadow_manager

ShadowManager * InternalLightManager::get_shadow_manager
| inline

Returns the internal used ShadowManager.

This returns a handle to the internally used shadow manager

Returns
  Shadow manager

Definition at line 72 of file internalLightManager.h.

## ◆ set_shadow_manager

void InternalLightManager::set_shadow_manager
| inline

Sets the handle to the shadow manager.

This sets the handle to the global shadow manager. It is usually constructed on the python side, so we need to get a handle to it.

The manager should be a handle to a ShadowManager instance, and will be stored somewhere on the python side most likely. The light manager does not keep a reference to it, so the python side should make sure to keep one.

Be sure to call this before the InternalLightManager::update() method is called, otherwise an assertion will get triggered.

Parameters

  mgr | The ShadowManager instance

Definition at line 72 of file internalLightManager.h.

The documentation for this class was generated from the following files:

- contrib/src/rplight/internalLightManager.h
- contrib/src/rplight/internalLightManager.cxx
- contrib/src/rplight/internalLightManager.I