Panda3D
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends
GeomMunger Class Reference

Objects of this class are used to convert vertex data from a Geom into a format suitable for passing to the rendering backend. More...

#include "geomMunger.h"

Inheritance diagram for GeomMunger:
TypedReferenceCount GeomEnums TypedObject ReferenceCount MemoryBase MemoryBase StateMunger StandardMunger DXGeomMunger8 DXGeomMunger9 TinyGeomMunger

List of all members.

Classes

class  CacheEntry
class  Registry

Public Member Functions

 GeomMunger (GraphicsStateGuardianBase *gsg)
 GeomMunger (const GeomMunger &copy)
int compare_to (const GeomMunger &other) const
 Provides an arbitrary ordering among all unique GeomMungers, so we can store the essentially different ones in a big set and throw away the rest.
 CPT (GeomVertexFormat) munge_format(const GeomVertexFormat *format
 CPT (GeomVertexData) munge_data(const GeomVertexData *data) const
 CPT (GeomVertexFormat) premunge_format(const GeomVertexFormat *format) const
 CPT (GeomVertexData) premunge_data(const GeomVertexData *data) const
virtual TypeHandle force_init_type ()
int geom_compare_to (const GeomMunger &other) const
 Compares two GeomMungers, considering only whether they would produce a different answer to munge_format(), munge_data(), or munge_geom().
GraphicsStateGuardianBaseget_gsg () const
 Returns a pointer to the GSG that created this munger.
virtual TypeHandle get_type () const
bool is_registered () const
 Returns true if this munger has been registered, false if it has not.
bool munge_geom (CPT(Geom)&geom, CPT(GeomVertexData)&data, bool force, Thread *current_thread)
 Applies the indicated munger to the geom and its data, and returns a (possibly different) geom and data, according to the munger's whim.
void operator= (const GeomMunger &copy)
void premunge_geom (CPT(Geom)&geom, CPT(GeomVertexData)&data) const
 This is similar to munge_geom(), but it is done at load time, to optimize a model for eventual rendering on a particular GSG.
void remove_data (const GeomVertexData *data)
 Removes a prepared GeomVertexData from the cache.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96.
static PT (GeomMunger) register_munger(GeomMunger *munger
static void unregister_mungers_for_gsg (GraphicsStateGuardianBase *gsg)
 Removes all the mungers from the registry that are associated with the indicated GSG.

Public Attributes

const GeomVertexAnimationSpec
&animation 
const
static Threadcurrent_thread

Protected Member Functions

virtual int compare_to_impl (const GeomMunger *other) const
 Called to compare two GeomMungers who are known to be of the same type, for an apples-to-apples comparison.
 CPT (GeomVertexFormat) do_munge_format(const GeomVertexFormat *format
virtual CPT (GeomVertexFormat) munge_format_impl(const GeomVertexFormat *orig
virtual CPT (GeomVertexData) munge_data_impl(const GeomVertexData *data)
 CPT (GeomVertexFormat) do_premunge_format(const GeomVertexFormat *format)
virtual CPT (GeomVertexFormat) premunge_format_impl(const GeomVertexFormat *orig)
virtual CPT (GeomVertexData) premunge_data_impl(const GeomVertexData *data)
virtual int geom_compare_to_impl (const GeomMunger *other) const
 Compares two GeomMungers, considering only whether they would produce a different answer to munge_format(), munge_data(), or munge_geom().
virtual void munge_geom_impl (CPT(Geom)&geom, CPT(GeomVertexData)&data, Thread *current_thread)
 Converts a Geom and/or its data as necessary.
virtual void premunge_geom_impl (CPT(Geom)&geom, CPT(GeomVertexData)&data)
 Converts a Geom and/or its data as necessary.
void unregister_myself ()
 Unregisters the GeomMunger, for instance when it is being destructed, or whenever it has become invalid for some reason.

Protected Attributes

const GeomVertexAnimationSpecanimation
virtual const
GeomVertexAnimationSpec
animation

Friends

class Geom

Detailed Description

Objects of this class are used to convert vertex data from a Geom into a format suitable for passing to the rendering backend.

Typically, the rendering backend will create a specialization of this class to handle its particular needs (e.g. DXGeomMunger). This class is necessary because DirectX and OpenGL have somewhat different requirements for vertex format.

This also performs runtime application of state changes to the vertex data; for instance, by scaling all of the color values in response to a ColorScaleAttrib.

A GeomMunger must be registered before it can be used, and once registered, the object is constant and cannot be changed. All registered GeomMungers that perform the same operation will have the same pointer.

Definition at line 57 of file geomMunger.h.


Member Function Documentation

int GeomMunger::compare_to ( const GeomMunger other) const [inline]

Provides an arbitrary ordering among all unique GeomMungers, so we can store the essentially different ones in a big set and throw away the rest.

Definition at line 162 of file geomMunger.I.

References compare_to_impl(), and TypeHandle::get_index().

int GeomMunger::compare_to_impl ( const GeomMunger other) const [protected, virtual]

Called to compare two GeomMungers who are known to be of the same type, for an apples-to-apples comparison.

This will never be called on two pointers of a different type.

Reimplemented in StandardMunger, DXGeomMunger8, DXGeomMunger9, and TinyGeomMunger.

Definition at line 357 of file geomMunger.cxx.

Referenced by compare_to().

int GeomMunger::geom_compare_to ( const GeomMunger other) const [inline]

Compares two GeomMungers, considering only whether they would produce a different answer to munge_format(), munge_data(), or munge_geom().

(They still might be different in other ways, but if they would produce the same answer, this function consider them to be the same.)

Definition at line 186 of file geomMunger.I.

References geom_compare_to_impl(), and TypeHandle::get_index().

int GeomMunger::geom_compare_to_impl ( const GeomMunger other) const [protected, virtual]

Compares two GeomMungers, considering only whether they would produce a different answer to munge_format(), munge_data(), or munge_geom().

(They still might be different in other ways, but if they would produce the same answer, this function will consider them to be the same.)

Reimplemented in StandardMunger, DXGeomMunger8, DXGeomMunger9, and TinyGeomMunger.

Definition at line 372 of file geomMunger.cxx.

Referenced by geom_compare_to().

Returns a pointer to the GSG that created this munger.

Reimplemented in StandardMunger.

Definition at line 23 of file geomMunger.I.

static void GeomMunger::init_type ( ) [inline, static]

This function is declared non-inline to work around a compiler bug in g++ 2.96.

Making it inline seems to cause problems in the optimizer.

Reimplemented from TypedReferenceCount.

Reimplemented in StandardMunger, DXGeomMunger8, DXGeomMunger9, TinyGeomMunger, and StateMunger.

Definition at line 164 of file geomMunger.h.

References TypedReferenceCount::init_type().

Referenced by StateMunger::init_type().

bool GeomMunger::is_registered ( ) const [inline]

Returns true if this munger has been registered, false if it has not.

It may not be used for a Geom until it has been registered, but once registered, it may no longer be modified.

Definition at line 36 of file geomMunger.I.

Referenced by unregister_myself().

bool GeomMunger::munge_geom ( CPT(Geom)&  geom,
CPT(GeomVertexData)&  data,
bool  force,
Thread current_thread 
)

Applies the indicated munger to the geom and its data, and returns a (possibly different) geom and data, according to the munger's whim.

The assumption is that for a particular geom and a particular munger, the result will always be the same; so this result may be cached.

If force is false, this may do nothing and return false if the vertex data is nonresident. If force is true, this will always return true, but it may have to block while the vertex data is paged in.

Definition at line 111 of file geomMunger.cxx.

References LightMutexDirect::acquire(), Geom::get_modified(), GeomVertexData::get_modified(), munge_geom_impl(), LightMutexDirect::release(), Geom::request_resident(), and GeomVertexData::request_resident().

Referenced by CullableObject::munge_geom().

void GeomMunger::munge_geom_impl ( CPT(Geom)&  geom,
CPT(GeomVertexData)&  data,
Thread current_thread 
) [protected, virtual]

Converts a Geom and/or its data as necessary.

Reimplemented in StandardMunger.

Definition at line 268 of file geomMunger.cxx.

Referenced by munge_geom().

void GeomMunger::premunge_geom ( CPT(Geom)&  geom,
CPT(GeomVertexData)&  data 
) const [inline]

This is similar to munge_geom(), but it is done at load time, to optimize a model for eventual rendering on a particular GSG.

At this point, we do not necessarily know the final render state that will be applied, so we cannot make any destructive changes to the geom, its data, or its format.

Unlike munge_geom(), this result is not cached, since the assumption is that this operation is performed at load time once for each model.

Definition at line 150 of file geomMunger.I.

void GeomMunger::premunge_geom_impl ( CPT(Geom)&  geom,
CPT(GeomVertexData)&  data 
) [protected, virtual]

Converts a Geom and/or its data as necessary.

Reimplemented in StandardMunger.

Definition at line 343 of file geomMunger.cxx.

void GeomMunger::remove_data ( const GeomVertexData data)

Removes a prepared GeomVertexData from the cache.

Definition at line 87 of file geomMunger.cxx.

Removes all the mungers from the registry that are associated with the indicated GSG.

Definition at line 67 of file geomMunger.I.

void GeomMunger::unregister_myself ( ) [inline, protected]

Unregisters the GeomMunger, for instance when it is being destructed, or whenever it has become invalid for some reason.

This removes it from the registry so that it will no longer be available to be returned by register_munger().

It is not an error to call this if the munger has already been unregistered.

Definition at line 212 of file geomMunger.I.

References is_registered().

Referenced by DXGeomMunger8::wp_callback(), and DXGeomMunger9::wp_callback().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations