28 #include "tagStateManager.h" 33 NotifyCategoryDef(tagstatemgr,
"");
47 nassertv(DCAST(
Camera, main_cam_node.
node()) !=
nullptr);
48 _main_cam_node = main_cam_node;
54 _containers[
"shadow"] = StateContainer(
"Shadows", 2,
false);
55 _containers[
"voxelize"] = StateContainer(
"Voxelize", 3,
false);
56 _containers[
"envmap"] = StateContainer(
"Envmap", 4,
true);
57 _containers[
"forward"] = StateContainer(
"Forward", 5,
true);
82 const std::string &name,
int sort) {
83 if (tagstatemgr_cat.is_spam()) {
84 tagstatemgr_cat.spam() <<
"Constructing new state " << name
85 <<
" with shader " << shader << endl;
92 if (!container.write_color) {
93 state = state->set_attrib(ColorWriteAttrib::make(ColorWriteAttrib::C_off), 10000);
95 state = state->set_attrib(ShaderAttrib::make(shader, sort), sort);
98 if (container.tag_states.count(name) != 0) {
99 tagstatemgr_cat.warning() <<
"Overriding existing state " << name << endl;
104 container.tag_states[name] = state;
107 np.
set_tag(container.tag_name, name);
110 for (
size_t i = 0; i < container.cameras.size(); ++i) {
111 container.cameras[i]->set_tag_state(name, state);
123 if (tagstatemgr_cat.is_info()) {
124 tagstatemgr_cat.info() <<
"cleaning up states" << endl;
128 DCAST(
Camera, _main_cam_node.
node())->clear_tag_states();
132 cleanup_container_states(_containers[
"shadow"]);
133 cleanup_container_states(_containers[
"voxelize"]);
134 cleanup_container_states(_containers[
"envmap"]);
135 cleanup_container_states(_containers[
"forward"]);
145 void TagStateManager::
146 cleanup_container_states(StateContainer& container) {
147 for (
size_t i = 0; i < container.cameras.size(); ++i) {
148 container.cameras[i]->clear_tag_states();
150 container.tag_states.clear();
163 source->set_tag_state_key(container.tag_name);
168 CPT(
RenderState) state = RenderState::make_empty();
170 if (!container.write_color) {
171 state = state->set_attrib(ColorWriteAttrib::make(ColorWriteAttrib::C_off), 10000);
176 container.cameras.push_back(source);
189 CameraList& cameras = container.cameras;
192 if (std::find(cameras.begin(), cameras.end(), source) == cameras.end()) {
193 tagstatemgr_cat.error()
194 <<
"Called unregister_camera but camera was never registered!" << endl;
199 cameras.erase(std::remove(cameras.begin(), cameras.end(), source), cameras.end());
static BitMask< WType, nbits > bit(int index)
Returns a BitMask with only the indicated bit on.
void clear_tag_states()
Removes all associations established by previous calls to set_tag_state().
bool is_empty() const
Returns true if the NodePath contains no nodes.
set_initial_state
Sets the initial state which is applied to all nodes in the scene, as if it were set at the top of th...
void set_tag(const std::string &key, const std::string &value)
Associates a user-defined value with a user-defined key which is stored on the node.
set_camera_mask
Changes the set of bits that represent the subset of the scene graph the camera will render.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
PandaNode * node() const
Returns the referenced node of the path.
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...