mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
add SceneGraphReducer::decompose()
This commit is contained in:
parent
7400cfacab
commit
dd03048f6e
@ -514,6 +514,38 @@ check_valid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomNode::decompose
|
||||
// Access: Published
|
||||
// Description: Calls decompose() on each Geom with the GeomNode.
|
||||
// This decomposes higher-order primitive types, like
|
||||
// triangle strips, into lower-order types like indexed
|
||||
// triangles. Normally there is no reason to do this,
|
||||
// but it can be useful as an early preprocessing step,
|
||||
// to allow a later call to unify() to proceed more
|
||||
// quickly.
|
||||
//
|
||||
// See also SceneGraphReducer::decompose(), which is the
|
||||
// normal way this is called.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GeomNode::
|
||||
decompose() {
|
||||
Thread *current_thread = Thread::get_current_thread();
|
||||
OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) {
|
||||
CDStageWriter cdata(_cycler, pipeline_stage, current_thread);
|
||||
|
||||
GeomList::iterator gi;
|
||||
PT(GeomList) geoms = cdata->modify_geoms();
|
||||
for (gi = geoms->begin(); gi != geoms->end(); ++gi) {
|
||||
GeomEntry &entry = (*gi);
|
||||
nassertv(entry._geom.test_ref_count_integrity());
|
||||
PT(Geom) geom = entry._geom.get_write_pointer();
|
||||
geom->decompose_in_place();
|
||||
}
|
||||
}
|
||||
CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomNode::unify
|
||||
// Access: Published
|
||||
|
@ -80,6 +80,7 @@ PUBLISHED:
|
||||
INLINE void remove_all_geoms();
|
||||
bool check_valid() const;
|
||||
|
||||
void decompose();
|
||||
void unify(int max_indices, bool preserve_order);
|
||||
|
||||
void write_geoms(ostream &out, int indent_level) const;
|
||||
|
@ -280,7 +280,7 @@ set_color(Geom *geom, const Colorf &color) {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomTransformer::transform_texcoords
|
||||
// Function: GeomTransformer::set_color
|
||||
// Access: Public
|
||||
// Description: Overrides the color indicated within the GeomNode
|
||||
// with the given replacement color. Returns true if
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "plist.h"
|
||||
#include "pmap.h"
|
||||
#include "geomNode.h"
|
||||
#include "config_gobj.h"
|
||||
#include "thread.h"
|
||||
|
||||
PStatCollector SceneGraphReducer::_flatten_collector("*:Flatten:flatten");
|
||||
@ -166,6 +167,28 @@ unify(PandaNode *root, bool preserve_order) {
|
||||
r_unify(root, max_indices, preserve_order);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SceneGraphReducer::decompose
|
||||
// Access: Published
|
||||
// Description: 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.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void SceneGraphReducer::
|
||||
decompose(PandaNode *root) {
|
||||
if (!preserve_triangle_strips) {
|
||||
PStatTimer timer(_unify_collector);
|
||||
r_decompose(root);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SceneGraphReducer::r_apply_attribs
|
||||
// Access: Protected
|
||||
@ -845,6 +868,25 @@ r_unify(PandaNode *node, int max_indices, bool preserve_order) {
|
||||
Thread::consider_yield();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SceneGraphReducer::r_decompose
|
||||
// Access: Private
|
||||
// Description: The recursive implementation of decompose().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void SceneGraphReducer::
|
||||
r_decompose(PandaNode *node) {
|
||||
if (node->is_geom_node()) {
|
||||
GeomNode *geom_node = DCAST(GeomNode, node);
|
||||
geom_node->decompose();
|
||||
}
|
||||
|
||||
PandaNode::Children children = node->get_children();
|
||||
int num_children = children.get_num_children();
|
||||
for (int i = 0; i < num_children; ++i) {
|
||||
r_decompose(children.get_child(i));
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: SceneGraphReducer::r_premunge
|
||||
// Access: Private
|
||||
|
@ -139,6 +139,8 @@ PUBLISHED:
|
||||
int remove_column(PandaNode *root, const InternalName *column);
|
||||
|
||||
INLINE int make_compatible_format(PandaNode *root, int collect_bits = ~0);
|
||||
void decompose(PandaNode *root);
|
||||
|
||||
INLINE int collect_vertex_data(PandaNode *root, int collect_bits = ~0);
|
||||
INLINE int make_nonindexed(PandaNode *root, int nonindexed_bits = ~0);
|
||||
void unify(PandaNode *root, bool preserve_order);
|
||||
@ -177,6 +179,7 @@ protected:
|
||||
GeomTransformer &transformer, bool format_only);
|
||||
int r_make_nonindexed(PandaNode *node, int collect_bits);
|
||||
void r_unify(PandaNode *node, int max_indices, bool preserve_order);
|
||||
void r_decompose(PandaNode *node);
|
||||
|
||||
void r_premunge(PandaNode *node, const RenderState *state);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user