Panda3D
Public Member Functions | Public Attributes | List of all members
ShadowManager Class Reference
Inheritance diagram for ShadowManager:
ReferenceCount MemoryBase

Public Member Functions

 ShadowManager ()
 Constructs a new shadow atlas. More...
 
 ~ShadowManager ()
 Destructs the ShadowManager. More...
 
bool add_update (const ShadowSource *source)
 Adds a new shadow update. More...
 
ShadowAtlasget_atlas () const
 
size_t get_atlas_size () const
 
size_t get_num_update_slots_left () const
 
void init ()
 Initializes the ShadowManager. More...
 
void set_atlas_graphics_output (GraphicsOutput *graphics_output)
 Sets the handle to the Shadow targets output. More...
 
void set_atlas_size (size_t atlas_size)
 
void set_max_updates (size_t max_updates)
 RenderPipeline. More...
 
void set_scene (NodePath scene_parent)
 Sets the target scene. More...
 
void set_tag_state_manager (TagStateManager *tag_mgr)
 Sets the handle to the TagStageManager. More...
 
void update ()
 Updates the ShadowManager. More...
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

Public Attributes

 get_atlas
 Returns a handle to the shadow atlas. More...
 
 get_atlas_size
 Returns the shadow atlas size. More...
 
 get_num_update_slots_left
 Returns how many update slots are left. More...
 
 set_atlas_size
 Sets the shadow atlas size. More...
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

Detailed Description

Definition at line 46 of file shadowManager.h.

Constructor & Destructor Documentation

◆ ShadowManager()

ShadowManager::ShadowManager ( )

Constructs a new shadow atlas.

This constructs a new shadow atlas. There are a set of properties which should be set before calling ShadowManager::init, see the set-Methods. After all properties are set, ShadowManager::init should get called. ShadowManager::update should get called on a per frame basis.

Definition at line 39 of file shadowManager.cxx.

◆ ~ShadowManager()

ShadowManager::~ShadowManager ( )

Destructs the ShadowManager.

This destructs the shadow manager, clearing all resources used

Definition at line 51 of file shadowManager.cxx.

Member Function Documentation

◆ add_update()

bool ShadowManager::add_update ( const ShadowSource source)
inline

Adds a new shadow update.

This adds a new update to the update queue. When the queue is already full, this method returns false, otherwise it returns true. The next time the manager is updated, the shadow source will recieve an update of its shadow map.

Parameters
sourceThe shadow source to update
Returns
Whether the shadow source udpate was sucessfully queued.

Definition at line 167 of file shadowManager.I.

◆ init()

void ShadowManager::init ( )

Initializes the ShadowManager.

This initializes the ShadowManager. All properties should have been set before calling this, otherwise assertions will get triggered.

This setups everything required for rendering shadows, including the shadow atlas and the various shadow cameras. After calling this method, no properties can be changed anymore.

Definition at line 69 of file shadowManager.cxx.

◆ set_atlas_graphics_output()

void ShadowManager::set_atlas_graphics_output ( GraphicsOutput graphics_output)
inline

Sets the handle to the Shadow targets output.

This sets the handle to the GraphicsOutput of the shadow atlas. Usually this is RenderTarget.get_internal_buffer(), whereas the RenderTarget is the target of the ShadowStage.

This is used for creating display regions and attaching cameras to them, for performing shadow updates.

This has to get called before ShadowManager::init, otherwise an assertion will be triggered.

Parameters
graphics_output[description]

Definition at line 149 of file shadowManager.I.

◆ set_max_updates()

void ShadowManager::set_max_updates ( size_t  max_updates)
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. Sets the maximum amount of updates per frame.

This controls the maximum amount of updated ShadowSources per frame. The ShadowManager will take the first <max_updates> ShadowSources, and generate shadow maps for them every frame. If there are more ShadowSources waiting to get updated than available updates, the sources are sorted by priority, and the update of the less important sources is delayed to the next frame.

If the update count is set too low, and there are a lot of ShadowSources waiting to get updated, artifacts will occur, and there might be ShadowSources which never get updated, due to low priority.

If an update count of 0 is passed, no updates will happen. This also means that there are no shadows. This is not recommended.

If an update count < 0 is passed, undefined behaviour occurs.

This method has to get called before ShadowManager::init, otherwise an assertion will get triggered.

Parameters
max_updatesMaximum amoumt of updates

Definition at line 51 of file shadowManager.I.

◆ set_scene()

void ShadowManager::set_scene ( NodePath  scene_parent)
inline

Sets the target scene.

This sets the target scene for rendering shadows. All shadow cameras will be parented to this scene to render shadows.

Usually the scene will be ShowBase.render. If the scene is an empty or invalid NodePath, an assertion will be triggered.

This method has to get called before calling ShadowManager::init, or an assertion will get triggered.

Parameters
scene_parentThe target scene

Definition at line 113 of file shadowManager.I.

◆ set_tag_state_manager()

void ShadowManager::set_tag_state_manager ( TagStateManager tag_mgr)
inline

Sets the handle to the TagStageManager.

This sets the handle to the TagStateManager used by the pipeline. Usually this is RenderPipeline.get_tag_mgr().

This has to get called before ShadowManager::init, otherwise an assertion will get triggered.

Parameters
tag_mgr[description]

Definition at line 129 of file shadowManager.I.

◆ update()

void ShadowManager::update ( )

Updates the ShadowManager.

This updates the ShadowManager, processing all shadow sources which need to get updated.

This first collects all sources which require an update, sorts them by priority, and then processes the first <max_updates> ShadowSources.

This may not get called before ShadowManager::init, or an assertion will be thrown.

Definition at line 120 of file shadowManager.cxx.

Member Data Documentation

◆ get_atlas

ShadowAtlas * ShadowManager::get_atlas
inline

Returns a handle to the shadow atlas.

This returns a handle to the internal shadow atlas instance. This is only valid after calling ShadowManager::init. Calling this earlier will trigger an assertion and undefined behaviour.

Returns
The internal ShadowAtlas instance

Definition at line 64 of file shadowManager.h.

◆ get_atlas_size

size_t ShadowManager::get_atlas_size
inline

Returns the shadow atlas size.

This returns the shadow atlas size previously set with ShadowManager::set_atlas_size.

Returns
Shadow atlas size in pixels

Definition at line 58 of file shadowManager.h.

◆ get_num_update_slots_left

size_t ShadowManager::get_num_update_slots_left
inline

Returns how many update slots are left.

This returns how many update slots are left. You can assume the next n calls to add_update will succeed, whereas n is the value returned by this function.

Returns
Number of update slots left.

Definition at line 61 of file shadowManager.h.

◆ set_atlas_size

void ShadowManager::set_atlas_size
inline

Sets the shadow atlas size.

This sets the desired shadow atlas size. It should be big enough to store all important shadow sources, with some buffer, because the shadow maps usually won't be fitted perfectly, so gaps can occur.

This has to get called before calling ShadowManager::init. When calling this method after initialization, an assertion will get triggered.

Parameters
atlas_sizeSize of the shadow atlas in pixels

Definition at line 58 of file shadowManager.h.


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