15 #include "renderEffect.h"
16 #include "bamReader.h"
18 #include "config_pgraph.h"
30 if (_effects == (Effects *)NULL) {
36 _effects =
new Effects;
38 _saved_entry = _effects->end();
69 if (_saved_entry != _effects->end()) {
84 _effects->erase(_saved_entry);
85 _saved_entry = _effects->end();
110 prepare_flatten_transform(const TransformState *net_transform)
const {
111 return net_transform;
122 safe_to_combine()
const {
147 has_cull_callback()
const {
208 output(ostream &out)
const {
218 write(ostream &out,
int indent_level)
const {
219 indent(out, indent_level) << *
this <<
"\n";
231 if (_effects == (
Effects *)NULL) {
234 return _effects->size();
246 out << _effects->size() <<
" effects:\n";
247 Effects::const_iterator si;
248 for (si = _effects->begin(); si != _effects->end(); ++si) {
250 effect->write(out, 2);
264 if (_effects->empty()) {
268 Effects::const_iterator si = _effects->begin();
269 Effects::const_iterator snext = si;
271 while (snext != _effects->end()) {
272 if ((*si)->compare_to(*(*snext)) >= 0) {
274 <<
"RenderEffects out of order!\n";
275 (*si)->write(pgraph_cat.error(
false), 2);
276 (*snext)->write(pgraph_cat.error(
false), 2);
306 nassertr(effect->_saved_entry == _effects->end(), effect);
309 if (paranoid_const) {
310 nassertr(validate_effects(), effect);
318 pair<Effects::iterator,
bool> result = _effects->insert(effect);
322 effect->_saved_entry = result.first;
328 return *(result.first);
384 if (pointer == effect) {
static int get_num_effects()
Returns the total number of unique RenderEffect objects allocated in the world.
A basic node of the scene graph or data graph.
virtual bool has_adjust_transform() const
Should be overridden by derived classes to return true if adjust_transform() has been defined...
virtual void cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState)&node_transform, CPT(RenderState)&node_state) const
If has_cull_callback() returns true, this function will be called during the cull traversal to perfor...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static bool validate_effects()
Ensures that the cache is still stored in sorted order.
Base class for objects that can be written to and read from Bam files.
virtual void adjust_transform(CPT(TransformState)&net_transform, CPT(TransformState)&node_transform, PandaNode *node) const
Performs some operation on the node's apparent net and/or local transforms.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is the base class for a number of special render effects that may be set on scene graph nodes to...
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
virtual bool unref() const
Explicitly decrements the reference count.
This is a 4-by-4 transform matrix.
static TypedWritable * change_this(TypedWritable *old_ptr, BamReader *manager)
Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointe...
void register_finalize(TypedWritable *whom)
Should be called by an object reading itself from the Bam file to indicate that this particular objec...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static void list_effects(ostream &out)
Lists all of the RenderEffects in the cache to the output stream, one per line.
This is our own Panda specialization on the default STL set.
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
virtual ~RenderEffect()
The destructor is responsible for removing the RenderEffect from the global set if it is there...
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of RenderEffect by calling the...
int get_ref_count() const
Returns the current reference count.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...