SceneGraphReducer

from panda3d.core import SceneGraphReducer
class SceneGraphReducer

Bases: DTOOL_SUPER_BASE

An interface for simplifying (“flattening”) scene graphs by eliminating unneeded nodes and collapsing out unneeded state changes and transforms.

This class is designed so that it may be inherited from and specialized, if needed, to fine-tune the flattening behavior, but normally the default behavior is sufficient.

Inheritance diagram

Inheritance diagram of SceneGraphReducer

CSGeomNode = 1
CSOther = 4
CSRecurse = 8
CSWithinRadius = 2
CS_geom_node = 1
CS_other = 4
CS_recurse = 8
CS_within_radius = 2
CVDAnimationType = 128
CVDAvoidDynamic = 8
CVDFormat = 32
CVDModel = 2
CVDName = 1
CVDOneNodeOnly = 16
CVDTransform = 4
CVDUsageHint = 64
CVD_animation_type = 128
CVD_avoid_dynamic = 8
CVD_format = 32
CVD_model = 2
CVD_name = 1
CVD_one_node_only = 16
CVD_transform = 4
CVD_usage_hint = 64
MNAvoidAnimated = 2
MNAvoidDynamic = 4
MNCompositeOnly = 1
MN_avoid_animated = 2
MN_avoid_dynamic = 4
MN_composite_only = 1
TTApplyTextureColor = 64
TTClipPlane = 16
TTColor = 2
TTColorScale = 4
TTCullFace = 32
TTOther = 128
TTTexMatrix = 8
TTTransform = 1
TT_apply_texture_color = 64
TT_clip_plane = 16
TT_color = 2
TT_color_scale = 4
TT_cull_face = 32
TT_other = 128
TT_tex_matrix = 8
TT_transform = 1
__init__(*args, **kwargs)
applyAttribs()

C++ Interface: apply_attribs(const SceneGraphReducer self, PandaNode node, int attrib_types)

/**
  • Walks the scene graph, accumulating attribs of the indicated types,

  • applying them to the vertices, and removing them from the scene graph.

  • This has a performance optimization benefit in itself, but is especially

  • useful to pave the way for a call to flatten() and greatly improve the

  • effectiveness of the flattening operation.

  • Multiply instanced geometry is duplicated before the attribs are applied.

  • Of course, this operation does make certain dynamic operations impossible.

*/

/**
  • This flavor of apply_attribs() can be called recursively from within

  • another flatten process (e.g. from

  • PandaNode::apply_attribs_to_vertices()). The parameters were presumably

  • received from a parent SceneGraphReducer object.

*/

apply_attribs()

C++ Interface: apply_attribs(const SceneGraphReducer self, PandaNode node, int attrib_types)

/**
  • Walks the scene graph, accumulating attribs of the indicated types,

  • applying them to the vertices, and removing them from the scene graph.

  • This has a performance optimization benefit in itself, but is especially

  • useful to pave the way for a call to flatten() and greatly improve the

  • effectiveness of the flattening operation.

  • Multiply instanced geometry is duplicated before the attribs are applied.

  • Of course, this operation does make certain dynamic operations impossible.

*/

/**
  • This flavor of apply_attribs() can be called recursively from within

  • another flatten process (e.g. from

  • PandaNode::apply_attribs_to_vertices()). The parameters were presumably

  • received from a parent SceneGraphReducer object.

*/

checkLiveFlatten()

C++ Interface: check_live_flatten(const SceneGraphReducer self, PandaNode node)

/**
  • In a non-release build, returns false if the node is correctly not in a

  • live scene graph. (Calling flatten on a node that is part of a live scene

  • graph, for instance, a node somewhere under render, can cause problems in a

  • multithreaded environment.)

  • If allow_live_flatten is true, or in a release build, this always returns

  • true.

*/

check_live_flatten()

C++ Interface: check_live_flatten(const SceneGraphReducer self, PandaNode node)

/**
  • In a non-release build, returns false if the node is correctly not in a

  • live scene graph. (Calling flatten on a node that is part of a live scene

  • graph, for instance, a node somewhere under render, can cause problems in a

  • multithreaded environment.)

  • If allow_live_flatten is true, or in a release build, this always returns

  • true.

*/

clearGsg()

C++ Interface: clear_gsg(const SceneGraphReducer self)

/**
  • Specifies that no particular GraphicsStateGuardian will be used to guide

  • the optimization. The SceneGraphReducer will instead use config variables

  • such as max-collect-vertices and max-collect-indices.

*/

clear_gsg()

C++ Interface: clear_gsg(const SceneGraphReducer self)

/**
  • Specifies that no particular GraphicsStateGuardian will be used to guide

  • the optimization. The SceneGraphReducer will instead use config variables

  • such as max-collect-vertices and max-collect-indices.

*/

collectVertexData()

C++ Interface: collect_vertex_data(const SceneGraphReducer self, PandaNode root, int collect_bits)

/**
  • Collects all different GeomVertexData blocks that have compatible formats

  • at this node and below into a single, unified block (or at least multiple

  • larger blocks). This is intended to reduce rendering overhead incurred by

  • switching vertex buffers. It can also make a subsequent call to unify()

  • much more effective than it would have been otherwise.

  • The set of bits passed in collect_bits indicates which properties are used

  • to differentiate GeomVertexData blocks. If it is 0, then more blocks will

  • be combined together than if it is nonzero.

*/

collect_vertex_data()

C++ Interface: collect_vertex_data(const SceneGraphReducer self, PandaNode root, int collect_bits)

/**
  • Collects all different GeomVertexData blocks that have compatible formats

  • at this node and below into a single, unified block (or at least multiple

  • larger blocks). This is intended to reduce rendering overhead incurred by

  • switching vertex buffers. It can also make a subsequent call to unify()

  • much more effective than it would have been otherwise.

  • The set of bits passed in collect_bits indicates which properties are used

  • to differentiate GeomVertexData blocks. If it is 0, then more blocks will

  • be combined together than if it is nonzero.

*/

decompose()

C++ Interface: decompose(const SceneGraphReducer self, PandaNode root)

/**
  • Calls decompose() on every GeomNode at this level and below.

  • There is usually no reason to call this explicitly, since unify() will do

  • this anyway if it needs to be done. However, calling it ahead of time can

  • make that future call to unify() run a little bit faster.

  • This operation has no effect if the config variable preserve-triangle-

  • strips has been set true.

*/

flatten()

C++ Interface: flatten(const SceneGraphReducer self, PandaNode root, int combine_siblings_bits)

/**
  • Simplifies the graph by removing unnecessary nodes and nodes.

  • In general, a node (and its parent node) is a candidate for removal if the

  • node has no siblings and the node has no special properties.

  • If combine_siblings_bits is nonzero, some sibling nodes (according to the

  • bits set in combine_siblings_bits) may also be collapsed into a single

  • node. This will further reduce scene graph complexity, sometimes

  • substantially, at the cost of reduced spatial separation.

  • Returns the number of nodes removed from the graph.

*/

getCombineRadius()

C++ Interface: get_combine_radius(SceneGraphReducer self)

/**
  • Returns the radius that is used in conjunction with CS_within_radius. See

  • set_combine_radius().

*/

getGsg()

C++ Interface: get_gsg(SceneGraphReducer self)

/**
  • Returns the particular GraphicsStateGuardian that this object will attempt

  • to optimize to. See set_gsg().

*/

get_combine_radius()

C++ Interface: get_combine_radius(SceneGraphReducer self)

/**
  • Returns the radius that is used in conjunction with CS_within_radius. See

  • set_combine_radius().

*/

get_gsg()

C++ Interface: get_gsg(SceneGraphReducer self)

/**
  • Returns the particular GraphicsStateGuardian that this object will attempt

  • to optimize to. See set_gsg().

*/

makeCompatibleFormat()

C++ Interface: make_compatible_format(const SceneGraphReducer self, PandaNode root, int collect_bits)

/**
  • Walks through the tree at this node and below and unifies the

  • GeomVertexFormat for any GeomVertexData objects that are found, so that all

  • eligible vdatas (according to collect_bits; see collect_vertex_data) will

  • share the same vertex format.

  • This will add unused columns where necessary to match formats. It can

  • result in suboptimal performance if used needlessly.

  • There is usually no reason to call this explicitly, since

  • collect_vertex_data() will do this anyway if it has not been done already.

  • However, calling it ahead of time can make that future call to

  • collect_vertex_data() run a little bit faster.

  • The return value is the number of vertex datas modified.

*/

makeCompatibleState()

C++ Interface: make_compatible_state(const SceneGraphReducer self, PandaNode root)

/**
  • Searches for GeomNodes that contain multiple Geoms that differ only in

  • their ColorAttribs. If such a GeomNode is found, then all the colors are

  • pushed down into the vertices. This makes it feasible for the geoms to be

  • unified later.

*/

makeNonindexed()

C++ Interface: make_nonindexed(const SceneGraphReducer self, PandaNode root, int nonindexed_bits)

/**
  • Converts indexed geometry to nonindexed geometry at the indicated node and

  • below, by duplicating vertices where necessary. The parameter

  • nonindexed_bits is a union of bits defined in

  • SceneGraphReducer::MakeNonindexed, which specifes which types of geometry

  • to avoid making nonindexed.

*/

make_compatible_format()

C++ Interface: make_compatible_format(const SceneGraphReducer self, PandaNode root, int collect_bits)

/**
  • Walks through the tree at this node and below and unifies the

  • GeomVertexFormat for any GeomVertexData objects that are found, so that all

  • eligible vdatas (according to collect_bits; see collect_vertex_data) will

  • share the same vertex format.

  • This will add unused columns where necessary to match formats. It can

  • result in suboptimal performance if used needlessly.

  • There is usually no reason to call this explicitly, since

  • collect_vertex_data() will do this anyway if it has not been done already.

  • However, calling it ahead of time can make that future call to

  • collect_vertex_data() run a little bit faster.

  • The return value is the number of vertex datas modified.

*/

make_compatible_state()

C++ Interface: make_compatible_state(const SceneGraphReducer self, PandaNode root)

/**
  • Searches for GeomNodes that contain multiple Geoms that differ only in

  • their ColorAttribs. If such a GeomNode is found, then all the colors are

  • pushed down into the vertices. This makes it feasible for the geoms to be

  • unified later.

*/

make_nonindexed()

C++ Interface: make_nonindexed(const SceneGraphReducer self, PandaNode root, int nonindexed_bits)

/**
  • Converts indexed geometry to nonindexed geometry at the indicated node and

  • below, by duplicating vertices where necessary. The parameter

  • nonindexed_bits is a union of bits defined in

  • SceneGraphReducer::MakeNonindexed, which specifes which types of geometry

  • to avoid making nonindexed.

*/

premunge()

C++ Interface: premunge(const SceneGraphReducer self, PandaNode root, const RenderState initial_state)

/**
  • Walks the scene graph rooted at this node and below, and uses the indicated

  • GSG to premunge every Geom found to optimize it for eventual rendering on

  • the indicated GSG. If there is no GSG indicated for the SceneGraphReducer,

  • this is a no-op.

  • This operation will also apply to stashed children.

*/

removeColumn()

C++ Interface: remove_column(const SceneGraphReducer self, PandaNode root, const InternalName column)

/**
  • Removes the indicated data column from any GeomVertexDatas found at the

  • indicated root and below. Returns the number of GeomNodes modified.

*/

removeUnusedVertices()

C++ Interface: remove_unused_vertices(const SceneGraphReducer self, PandaNode root)

/**
  • Removes any vertices in GeomVertexDatas that are no longer used at this

  • level and below. This requires remapping vertex indices in all of the

  • GeomPrimitives, to remove holes in the GeomVertexDatas. It is normally not

  • necessary to call this explicitly.

*/

remove_column()

C++ Interface: remove_column(const SceneGraphReducer self, PandaNode root, const InternalName column)

/**
  • Removes the indicated data column from any GeomVertexDatas found at the

  • indicated root and below. Returns the number of GeomNodes modified.

*/

remove_unused_vertices()

C++ Interface: remove_unused_vertices(const SceneGraphReducer self, PandaNode root)

/**
  • Removes any vertices in GeomVertexDatas that are no longer used at this

  • level and below. This requires remapping vertex indices in all of the

  • GeomPrimitives, to remove holes in the GeomVertexDatas. It is normally not

  • necessary to call this explicitly.

*/

setCombineRadius()

C++ Interface: set_combine_radius(const SceneGraphReducer self, float combine_radius)

/**
  • Specifies the radius that is used in conjunction with CS_within_radius to

  • decide whether a subgraph’s siblings should be combined into a single node

  • or not.

  • If the CS_within_radius bit is included in the combine_siblings_bits

  • parameter passed to flatten, than any nodes whose bounding volume is

  • smaller than the indicated radius will be combined together (as if CS_other

  • were set).

*/

setGsg()

C++ Interface: set_gsg(const SceneGraphReducer self, GraphicsStateGuardianBase gsg)

/**
  • Specifies the particular GraphicsStateGuardian that this object will

  • attempt to optimize to. The GSG may specify parameters such as maximum

  • number of vertices per vertex data, max number of vertices per primitive,

  • and whether triangle strips are preferred. It also affects the types of

  • vertex column data that is created by premunge().

*/

set_combine_radius()

C++ Interface: set_combine_radius(const SceneGraphReducer self, float combine_radius)

/**
  • Specifies the radius that is used in conjunction with CS_within_radius to

  • decide whether a subgraph’s siblings should be combined into a single node

  • or not.

  • If the CS_within_radius bit is included in the combine_siblings_bits

  • parameter passed to flatten, than any nodes whose bounding volume is

  • smaller than the indicated radius will be combined together (as if CS_other

  • were set).

*/

set_gsg()

C++ Interface: set_gsg(const SceneGraphReducer self, GraphicsStateGuardianBase gsg)

/**
  • Specifies the particular GraphicsStateGuardian that this object will

  • attempt to optimize to. The GSG may specify parameters such as maximum

  • number of vertices per vertex data, max number of vertices per primitive,

  • and whether triangle strips are preferred. It also affects the types of

  • vertex column data that is created by premunge().

*/

unify()

C++ Interface: unify(const SceneGraphReducer self, PandaNode root, bool preserve_order)

/**
  • Calls unify() on every GeomNode at this level and below. This attempts to

  • reduce the total number of individual Geoms and GeomPrimitives by combining

  • these objects wherever possible. See GeomNode::unify().

*/