*** empty log message ***

This commit is contained in:
David Rose 2001-01-30 17:42:42 +00:00
parent e7b772d16f
commit 91d07d9209
13 changed files with 140 additions and 7 deletions

View File

@ -169,6 +169,17 @@ get_attributes() const {
return *_attrib;
}
////////////////////////////////////////////////////////////////////
// Function: CullState::get_transitions
// Access: Public
// Description: Returns the net transitions indicated by the
// CullState object.
////////////////////////////////////////////////////////////////////
INLINE const AllTransitionsWrapper &CullState::
get_transitions() const {
return _trans;
}
////////////////////////////////////////////////////////////////////
// Function: CullState::has_bin
// Access: Public

View File

@ -60,6 +60,7 @@ public:
INLINE void apply_to(const AllAttributesWrapper &initial_state);
INLINE const NodeAttributes &get_attributes() const;
INLINE const AllTransitionsWrapper &get_transitions() const;
INLINE bool has_bin() const;
INLINE GeomBin *get_bin() const;

View File

@ -19,10 +19,12 @@
////////////////////////////////////////////////////////////////////
INLINE void CullTraverser::
draw_geom(GeomNode *geom_node, const AllAttributesWrapper &initial_state) {
#ifndef NDEBUG
if (cull_cat.is_spam()) {
cull_cat.spam()
<< "Drawing " << *geom_node << " with state: " << initial_state << "\n";
}
#endif
nassertv(geom_node != (GeomNode *)NULL);
_gsg->set_state(initial_state.get_attributes(), true);
_gsg->prepare_display_region();
@ -56,10 +58,12 @@ draw_direct(const ArcChain &arc_chain,
const AllAttributesWrapper &initial_state) {
nassertv(!arc_chain.empty());
Node *node = arc_chain.back()->get_child();
#ifndef NDEBUG
if (cull_cat.is_spam()) {
cull_cat.spam()
<< "Drawing " << *node << " in direct mode.\n";
}
#endif
nassertv(node != (Node *)NULL);
DirectRenderTraverser drt(_gsg, _graph_type, arc_chain);
drt.traverse(node, initial_state, AllTransitionsWrapper());
@ -101,6 +105,7 @@ find_bin_state(const AllTransitionsWrapper &trans) {
// corresponding CullState that is (now) stored in the set.
pair<States::iterator, bool> result = _states.insert(cs);
#ifndef NDEBUG
if (cull_cat.is_spam()) {
if (result.second) {
// The insert succeeded, so the CullState was not there
@ -109,12 +114,17 @@ find_bin_state(const AllTransitionsWrapper &trans) {
<< "Created CullState " << (void *)cs << " for:\n";
trans.write(cull_cat.spam(false), 2);
} else {
CullState *found_cs = *result.first;
cull_cat.spam()
<< "Found existing CullState " << (void *)(*result.first)
<< " for:\n";
<< "Found existing CullState " << (void *)found_cs
<< " which has:\n";
found_cs->get_transitions().write(cull_cat.spam(false), 2);
cull_cat.spam(false)
<< "for:\n";
trans.write(cull_cat.spam(false), 2);
}
}
#endif
return *result.first;
}

View File

@ -9,6 +9,7 @@
#include <boundingSphere.h>
#include <notify.h>
#include <algorithm>
TypeHandle NodeRelation::_type_handle;
@ -401,6 +402,20 @@ compose_transitions_from(const NodeTransitions &trans) {
}
}
////////////////////////////////////////////////////////////////////
// Function: NodeRelation::adjust_all_proriorities
// Access: Public
// Description: Adds the indicated adjustment amount (which may be
// negative) to the priority for all transitions on the
// arc. If the priority would drop below zero, it is
// set to zero.
////////////////////////////////////////////////////////////////////
void NodeRelation::
adjust_all_priorities(int adjustment) {
_net_transitions.clear();
_transitions.adjust_all_priorities(adjustment, this);
}
////////////////////////////////////////////////////////////////////
// Function: NodeRelation::sub_render_trans
// Access: Public

View File

@ -98,6 +98,7 @@ PUBLISHED:
void compose_transitions_from(const NodeRelation *arc);
void copy_transitions_from(const NodeTransitions &trans);
void compose_transitions_from(const NodeTransitions &trans);
void adjust_all_priorities(int adjustment);
INLINE int compare_transitions_to(const NodeRelation *arc) const;
@ -214,6 +215,7 @@ private:
friend class Node;
friend class NodeTransitionWrapper;
friend class AllTransitionsWrapper;
friend class GraphPriorityAdjuster;
};
INLINE ostream &

View File

@ -117,12 +117,15 @@ compare_to(const NodeTransition &other) const {
TypeHandle my_handle = get_handle();
TypeHandle other_handle = other.get_handle();
if (my_handle == other_handle) {
return internal_compare_to(&other);
} else {
if (my_handle != other_handle) {
return
(my_handle < other_handle) ? -1 : 1;
} else if (_priority != other._priority) {
return _priority - other._priority;
} else {
return internal_compare_to(&other);
}
}

View File

@ -226,6 +226,35 @@ compare_to(const NodeTransitions &other) const {
other._transitions.begin(), other._transitions.end());
}
////////////////////////////////////////////////////////////////////
// Function: NodeTransitions::adjust_all_proriorities
// Access: Public
// Description: Adds the indicated adjustment amount (which may be
// negative) to the priority for all transitions on the
// arc. If the priority would drop below zero, it is
// set to zero.
////////////////////////////////////////////////////////////////////
void NodeTransitions::
adjust_all_priorities(int adjustment, NodeRelation *arc) {
Transitions::iterator ti;
for (ti = _transitions.begin(); ti != _transitions.end(); ++ti) {
nassertv((*ti).second != (NodeTransition *)NULL);
PT(NodeTransition) &trans = (*ti).second;
int new_priority = max(trans->_priority + adjustment, 0);
if (trans->_priority != new_priority) {
if (trans->get_ref_count() > 1) {
// Copy-on-write.
trans->removed_from_arc(arc);
trans = trans->make_copy();
trans->added_to_arc(arc);
}
trans->_priority = new_priority;
arc->changed_transition((*ti).first);
}
}
}
////////////////////////////////////////////////////////////////////
// Function: NodeTransitions::remove_all_from_arc
// Access: Public

View File

@ -40,6 +40,7 @@ public:
NodeRelation *to_arc);
void compose_transitions_from(const NodeTransitions &other,
NodeRelation *to_arc);
void adjust_all_priorities(int adjustment, NodeRelation *arc);
void clear();

View File

@ -1424,7 +1424,24 @@ has_transparency() const {
return _head->_arc->has_transition(TransparencyTransition::get_class_type());
}
////////////////////////////////////////////////////////////////////
// Function: NodePath::adjust_all_priorities
// Access: Public
// Description: Adds the indicated adjustment amount (which may be
// negative) to the priority for all transitions on the
// bottom arc, and for all arcs in the subgraph below.
// This can be used to force these nodes not to be
// overridden by a high-level state change above. If
// the priority would drop below zero, it is set to
// zero.
////////////////////////////////////////////////////////////////////
INLINE void NodePath::
adjust_all_priorities(int adjustment) {
nassertv(has_arcs());
nassertv(_head != (ArcComponent *)NULL);
r_adjust_all_priorities(_head->_arc, adjustment);
}
////////////////////////////////////////////////////////////////////
// Function: NodePath::show

View File

@ -2599,3 +2599,27 @@ r_list_transitions(ostream &out, int indent_level) const {
}
}
}
////////////////////////////////////////////////////////////////////
// Function: NodePath::r_adjust_all_priorities
// Access: Private
// Description: The recursive implementation of
// adjust_all_priorities(). This walks through the
// subgraph defined by the indicated arc and below.
////////////////////////////////////////////////////////////////////
void NodePath::
r_adjust_all_priorities(NodeRelation *arc, int adjustment) {
arc->adjust_all_priorities(adjustment);
Node *node = arc->get_child();
DownRelations::const_iterator dri;
dri = node->_children.find(_graph_type);
if (dri != node->_children.end()) {
const DownRelationPointers &drp = (*dri).second;
DownRelationPointers::const_iterator drpi;
for (drpi = drp.begin(); drpi != drp.end(); ++drpi) {
r_adjust_all_priorities(*drpi, adjustment);
}
}
}

View File

@ -413,6 +413,8 @@ PUBLISHED:
INLINE bool has_transparency() const;
bool get_transparency() const;
INLINE void adjust_all_priorities(int adjustment);
INLINE void show();
INLINE void hide();
INLINE void show_collision_solids();
@ -447,7 +449,7 @@ private:
void r_write_transitions(const ArcComponent *comp,
ostream &out, int indent_level) const;
void r_get_net_transitions(const ArcComponent *comp,
AllTransitionsWrapper &trans) const;
AllTransitionsWrapper &trans) const;
string format_node_name(Node *node) const;
void find_matches(NodePathCollection &result,
@ -465,6 +467,8 @@ private:
void r_list_descendants(ostream &out, int indent_level) const;
void r_list_transitions(ostream &out, int indent_level) const;
void r_adjust_all_priorities(NodeRelation *arc, int adjustment);
// It's important that there are no data members in this class. Put
// them in NodePathBase instead.

View File

@ -56,6 +56,20 @@ set_switch_time(float switch_time)
set_cycle_time(switch_time);
}
////////////////////////////////////////////////////////////////////
// Function: SequenceNode::make_copy
// Access: Public, Virtual
// Description: Returns a newly-allocated Node that is a shallow copy
// of this one. It will be a different Node pointer,
// but its internal data may or may not be shared with
// that of the original Node. No children will be
// copied.
////////////////////////////////////////////////////////////////////
Node *SequenceNode::
make_copy() const {
return new SequenceNode(*this);
}
////////////////////////////////////////////////////////////////////
// Function: SequenceNode::sub_render
// Access: Public, Virtual

View File

@ -30,6 +30,8 @@ PUBLISHED:
void set_switch_time(float switch_time);
public:
virtual Node *make_copy() const;
virtual bool sub_render(const AllAttributesWrapper &attrib,
AllTransitionsWrapper &trans,
RenderTraverser *trav);