InternalLightManager

from panda3d._rplight import InternalLightManager
class InternalLightManager

Bases: DTOOL_SUPER_BASE

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.

Inheritance diagram

Inheritance diagram of InternalLightManager

__init__(*args, **kwargs)
addLight()

C++ Interface: add_light(const InternalLightManager self, RPLight light)

/**
  • @brief Adds a new light.

  • @details 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.

  • @param light The light to add.

*/

add_light()

C++ Interface: add_light(const InternalLightManager self, RPLight light)

/**
  • @brief Adds a new light.

  • @details 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.

  • @param light The light to add.

*/

getMaxLightIndex()

C++ Interface: get_max_light_index(InternalLightManager self)

/**
  • @brief Returns the maximum light index

  • @details 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

  • @return Maximum light index

*/

getNumLights()

C++ Interface: get_num_lights(InternalLightManager self)

/**
  • @brief Returns the amount of stored lights.

  • @details 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.

  • @return Amount of stored lights

*/

getNumShadowSources()

C++ Interface: get_num_shadow_sources(InternalLightManager self)

/**
  • @brief Returns the amount of shadow sources.

  • @details 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.

  • @return Amount of shadow sources.

*/

getShadowManager()

C++ Interface: get_shadow_manager(InternalLightManager self)

/**
  • @brief Returns the internal used ShadowManager

  • @details This returns a handle to the internally used shadow manager

  • @return Shadow manager

*/

get_max_light_index()

C++ Interface: get_max_light_index(InternalLightManager self)

/**
  • @brief Returns the maximum light index

  • @details 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

  • @return Maximum light index

*/

get_num_lights()

C++ Interface: get_num_lights(InternalLightManager self)

/**
  • @brief Returns the amount of stored lights.

  • @details 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.

  • @return Amount of stored lights

*/

get_num_shadow_sources()

C++ Interface: get_num_shadow_sources(InternalLightManager self)

/**
  • @brief Returns the amount of shadow sources.

  • @details 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.

  • @return Amount of shadow sources.

*/

get_shadow_manager()

C++ Interface: get_shadow_manager(InternalLightManager self)

/**
  • @brief Returns the internal used ShadowManager

  • @details This returns a handle to the internally used shadow manager

  • @return Shadow manager

*/

max_light_index
num_lights
num_shadow_sources
removeLight()

C++ Interface: remove_light(const InternalLightManager self, RPLight light)

/**
  • @brief Removes a light

  • @details 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.

  • @param light [description]

*/

remove_light()

C++ Interface: remove_light(const InternalLightManager self, RPLight light)

/**
  • @brief Removes a light

  • @details 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.

  • @param light [description]

*/

setCameraPos()

C++ Interface: set_camera_pos(const InternalLightManager self, const LPoint3f pos)

/**
  • @brief Sets the camera position

  • @details This sets the camera position, which will be used to determine which

  • shadow sources have to get updated

  • @param mat View projection mat

*/

setCommandList()

C++ Interface: set_command_list(const InternalLightManager self, GPUCommandList cmd_list)

/**
  • @brief Sets a handle to the command list

  • @details 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.

  • @param cmd_list The GPUCommandList instance

*/

setShadowManager()

C++ Interface: set_shadow_manager(const InternalLightManager self, ShadowManager mgr)

/**
  • @brief Sets the handle to the shadow manager

  • @details 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.

  • @param mgr The ShadowManager instance

*/

setShadowUpdateDistance()

C++ Interface: set_shadow_update_distance(const InternalLightManager self, float dist)

/**
  • @brief Sets the maximum shadow update distance

  • @details 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

  • @param dist Distance in world space units

*/

set_camera_pos()

C++ Interface: set_camera_pos(const InternalLightManager self, const LPoint3f pos)

/**
  • @brief Sets the camera position

  • @details This sets the camera position, which will be used to determine which

  • shadow sources have to get updated

  • @param mat View projection mat

*/

set_command_list()

C++ Interface: set_command_list(const InternalLightManager self, GPUCommandList cmd_list)

/**
  • @brief Sets a handle to the command list

  • @details 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.

  • @param cmd_list The GPUCommandList instance

*/

set_shadow_manager()

C++ Interface: set_shadow_manager(const InternalLightManager self, ShadowManager mgr)

/**
  • @brief Sets the handle to the shadow manager

  • @details 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.

  • @param mgr The ShadowManager instance

*/

set_shadow_update_distance()

C++ Interface: set_shadow_update_distance(const InternalLightManager self, float dist)

/**
  • @brief Sets the maximum shadow update distance

  • @details 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

  • @param dist Distance in world space units

*/

shadow_manager
update()

C++ Interface: update(const InternalLightManager self)

/**
  • @brief Main update method

  • @details 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.

*/