Panda3D
Loading...
Searching...
No Matches
internalLightManager.h
1/**
2 *
3 * RenderPipeline
4 *
5 * Copyright (c) 2014-2016 tobspr <tobias.springer1@gmail.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 *
25 */
26
27#ifndef INTERNALLIGHTMANAGER_H
28#define INTERNALLIGHTMANAGER_H
29
30#include "referenceCount.h"
31#include "rpLight.h"
32#include "shadowSource.h"
33#include "shadowAtlas.h"
34#include "shadowManager.h"
35#include "pointerSlotStorage.h"
36#include "gpuCommandList.h"
37
38#define MAX_LIGHT_COUNT 65535
39#define MAX_SHADOW_SOURCES 2048
40
41NotifyCategoryDecl(lightmgr, EXPORT_CLASS, EXPORT_TEMPL);
42
43/**
44 * @brief Internal class used for handling lights and shadows.
45 * @details This is the internal class used by the pipeline to handle all
46 * lights and shadows. It stores references to the lights, manages handling
47 * the light and shadow slots, and also communicates with the GPU with the
48 * GPUCommandQueue to store light and shadow source data.
49 */
51PUBLISHED:
53
54 void add_light(PT(RPLight) light);
55 void remove_light(PT(RPLight) light);
56
57 void update();
58 inline void set_camera_pos(const LPoint3 &pos);
59 inline void set_shadow_update_distance(PN_stdfloat dist);
60
61 inline int get_max_light_index() const;
62 MAKE_PROPERTY(max_light_index, get_max_light_index);
63
64 inline size_t get_num_lights() const;
65 MAKE_PROPERTY(num_lights, get_num_lights);
66
67 inline size_t get_num_shadow_sources() const;
68 MAKE_PROPERTY(num_shadow_sources, get_num_shadow_sources);
69
70 inline void set_shadow_manager(ShadowManager* mgr);
71 inline ShadowManager* get_shadow_manager() const;
72 MAKE_PROPERTY(shadow_manager, get_shadow_manager, set_shadow_manager);
73
74 inline void set_command_list(GPUCommandList *cmd_list);
75
76protected:
77
78 void gpu_update_light(RPLight* light);
79 void gpu_update_source(ShadowSource* source);
80 void gpu_remove_light(RPLight* light);
81 void gpu_remove_consecutive_sources(ShadowSource *first_source, size_t num_sources);
82
83 void setup_shadows(RPLight* light);
84 bool compare_shadow_sources(const ShadowSource* a, const ShadowSource* b) const;
85
86 void update_lights();
87 void update_shadow_sources();
88
89 GPUCommandList* _cmd_list;
90 ShadowManager* _shadow_manager;
91
94
95 LPoint3 _camera_pos;
96 float _shadow_update_distance;
97
98};
99
100#include "internalLightManager.I"
101
102#endif // INTERNALLIGHTMANAGER_H
RenderPipeline.
Internal class used for handling lights and shadows.
void set_camera_pos(const LPoint3 &pos)
Sets the camera position.
get_num_lights
Returns the amount of stored lights.
void set_shadow_update_distance(PN_stdfloat dist)
Sets the maximum shadow update distance.
void add_light(PT(RPLight) light)
Adds a new light.
void remove_light(PT(RPLight) light)
Removes a light.
void update()
Main update method.
get_shadow_manager
Returns the internal used ShadowManager.
InternalLightManager()
Constructs the light manager.
get_num_shadow_sources
Returns the amount of shadow sources.
get_max_light_index
RenderPipeline.
void set_command_list(GPUCommandList *cmd_list)
Sets a handle to the command list.
set_shadow_manager
Sets the handle to the shadow manager.
Class to keep a list of pointers and nullpointers.
RenderPipeline.
Definition rpLight.h:41
RenderPipeline.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.