Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
6589c8c31f

+ 16 - 1
panda/src/graph/nodeRelation.I

@@ -136,6 +136,20 @@ change_parent(Node *parent) {
   attach();
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: NodeRelation::change_parent
+//       Access: Public
+//  Description: Changes the parent of the arc to a different node,
+//               simultaneously changing the sort index.
+////////////////////////////////////////////////////////////////////
+INLINE void NodeRelation::
+change_parent(Node *parent, int sort) {
+  PT(NodeRelation) hold_arc = detach();
+  _parent = parent;
+  _sort = sort;
+  attach();
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: NodeRelation::change_child
 //       Access: Public
@@ -337,11 +351,12 @@ get_last_update() const {
 //               the type is unknown.
 ////////////////////////////////////////////////////////////////////
 INLINE NodeRelation *NodeRelation::
-create_typed_arc(TypeHandle type, Node *parent, Node *child) {
+create_typed_arc(TypeHandle type, Node *parent, Node *child, int sort) {
   NodeRelation *arc = get_factory().make_instance(type);
   if (arc != (NodeRelation *)NULL) {
     arc->_parent = parent;
     arc->_child = child;
+    arc->_sort = sort;
     arc->attach();
   }
   return arc;

+ 2 - 1
panda/src/graph/nodeRelation.h

@@ -82,6 +82,7 @@ PUBLISHED:
   INLINE int get_sort() const;
 
   INLINE void change_parent(Node *parent);
+  INLINE void change_parent(Node *parent, int sort);
   INLINE void change_child(Node *child);
   INLINE void change_parent_and_child(Node *parent, Node *child);
   INLINE void set_sort(int sort);
@@ -115,7 +116,7 @@ public:
   // Factory stuff: to create a new NodeRelation based on its
   // TypeHandle.
   INLINE static NodeRelation *
-  create_typed_arc(TypeHandle type, Node *parent, Node *child);
+  create_typed_arc(TypeHandle type, Node *parent, Node *child, int sort = 0);
 
   // This is just to be called at initialization time; don't try to
   // call this directly.

+ 9 - 4
panda/src/parametrics/nurbsCurve.cxx

@@ -348,7 +348,9 @@ get_knot(int n) const {
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 void NurbsCurve::
-write(ostream &out) const {
+write(ostream &out, int indent_level) const {
+  indent(out, indent_level);
+
   switch (get_curve_type()) {
   case PCT_T:
     out << "Time-warping ";
@@ -369,14 +371,17 @@ write(ostream &out) const {
   out << "NurbsCurve, order " << _order << ", " << get_num_cvs()
       << " CV's.  t ranges from 0 to " << get_max_t() << ".\n";
 
-  out << "CV's:\n";
+  indent(out, indent_level)
+    << "CV's:\n";
   int i;
   for (i = 0; i < (int)_cvs.size(); i++) {
     LVecBase3f p = (const LVecBase3f &)_cvs[i]._p / _cvs[i]._p[3];
-    out << i << ") " << p << ", weight " << _cvs[i]._p[3] << "\n";
+    indent(out, indent_level)
+      << i << ") " << p << ", weight " << _cvs[i]._p[3] << "\n";
   }
 
-  out << "Knots: ";
+  indent(out, indent_level)
+    << "Knots: ";
   for (i = 0; i < (int)_cvs.size()+_order; i++) {
     out << " " << GetKnot(i);
   }

+ 1 - 1
panda/src/parametrics/nurbsCurve.h

@@ -87,7 +87,7 @@ PUBLISHED:
   bool set_knot(int n, double t);
   double get_knot(int n) const;
 
-  void write(ostream &out) const;
+  virtual void write(ostream &out, int indent_level = 0) const;
   void write_cv(ostream &out, int n) const;
 
   bool recompute();

+ 11 - 0
panda/src/putil/modifierButtons.I

@@ -90,6 +90,17 @@ add_event(const ButtonEvent &event) {
   }
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: ModifierButtons::all_buttons_up
+//       Access: Public
+//  Description: Marks all monitored buttons as being in the "up"
+//               state.
+////////////////////////////////////////////////////////////////////
+INLINE void ModifierButtons::
+all_buttons_up() {
+  _state = 0;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: ModifierButtons::is_down
 //       Access: Public

+ 1 - 0
panda/src/putil/modifierButtons.h

@@ -39,6 +39,7 @@ PUBLISHED:
   bool button_down(ButtonHandle button);
   bool button_up(ButtonHandle button);
   INLINE bool add_event(const ButtonEvent &event);
+  INLINE void all_buttons_up();
 
   bool is_down(ButtonHandle button) const;
   INLINE bool is_down(int index) const;

+ 2 - 2
panda/src/sgmanip/nodePath.I

@@ -430,11 +430,11 @@ find(const string &path) const {
 //               references it.
 ////////////////////////////////////////////////////////////////////
 INLINE NodePath NodePath::
-attach_new_node(const string &name) const {
+attach_new_node(const string &name, int sort) const {
   nassertr(verify_connectivity(), NodePath());
   nassertr(!is_empty(), NodePath(_graph_type));
 
-  return attach_new_node(new NamedNode(name));
+  return attach_new_node(new NamedNode(name), sort);
 }
 
 ////////////////////////////////////////////////////////////////////

+ 11 - 10
panda/src/sgmanip/nodePath.cxx

@@ -697,7 +697,7 @@ repair_connectivity(const NodePath &top) {
 //               the new path to the node.
 ////////////////////////////////////////////////////////////////////
 void NodePath::
-reparent_to(const NodePath &other) {
+reparent_to(const NodePath &other, int sort) {
   nassertv(other.verify_connectivity());
   nassertv(has_arcs());
   nassertv(_head != (ArcComponent *)NULL);
@@ -705,7 +705,7 @@ reparent_to(const NodePath &other) {
 
   NodeRelation *arc = _head->_arc;
 
-  arc->change_parent(other.get_bottom_node());
+  arc->change_parent(other.get_bottom_node(), sort);
 
   // Move our head pointer to the bottom of the new chain.  This will
   // update our own path, as well as all paths that share the same
@@ -723,7 +723,7 @@ reparent_to(const NodePath &other) {
 //               different coordinate system.
 ////////////////////////////////////////////////////////////////////
 void NodePath::
-wrt_reparent_to(const NodePath &other) {
+wrt_reparent_to(const NodePath &other, int sort) {
   nassertv(other.verify_connectivity());
   nassertv(has_arcs());
   nassertv(_head != (ArcComponent *)NULL);
@@ -732,7 +732,7 @@ wrt_reparent_to(const NodePath &other) {
   LMatrix4f mat = get_mat(other);
   set_mat(mat);
 
-  reparent_to(other);
+  reparent_to(other, sort);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -756,14 +756,15 @@ wrt_reparent_to(const NodePath &other) {
 //               node.
 ////////////////////////////////////////////////////////////////////
 NodePath NodePath::
-instance_to(const NodePath &other) const {
+instance_to(const NodePath &other, int sort) const {
   nassertr(verify_connectivity(), NodePath());
   nassertr(!is_empty(), NodePath());
   nassertr(!other.is_empty(), NodePath());
 
   Node *node = get_bottom_node();
   NodeRelation *arc = 
-    NodeRelation::create_typed_arc(_graph_type, other.get_bottom_node(), node);
+    NodeRelation::create_typed_arc(_graph_type, other.get_bottom_node(), 
+				   node, sort);
   nassertr(arc != (NodeRelation *)NULL, NodePath());
   nassertr(arc->is_exact_type(_graph_type), NodePath());
 
@@ -794,7 +795,7 @@ instance_to(const NodePath &other) const {
 //               NamedNode.
 ////////////////////////////////////////////////////////////////////
 NodePath NodePath::
-copy_to(const NodePath &other) const {
+copy_to(const NodePath &other, int sort) const {
   nassertr(verify_connectivity(), NodePath());
   nassertr(!is_empty(), NodePath());
   nassertr(!other.is_empty(), NodePath());
@@ -805,7 +806,7 @@ copy_to(const NodePath &other) const {
 
   NodeRelation *arc = 
     NodeRelation::create_typed_arc(_graph_type, other.get_bottom_node(), 
-				   copy_node);
+				   copy_node, sort);
   nassertr(arc != (NodeRelation *)NULL, NodePath());
   nassertr(arc->is_exact_type(_graph_type), NodePath());
 
@@ -834,13 +835,13 @@ copy_to(const NodePath &other) const {
 //               returned.
 ////////////////////////////////////////////////////////////////////
 NodePath NodePath::
-attach_new_node(Node *node) const {
+attach_new_node(Node *node, int sort) const {
   nassertr(verify_connectivity(), NodePath());
   nassertr(!is_empty(), NodePath(_graph_type));
   nassertr(node != (Node *)NULL, NodePath(_graph_type));
 
   NodePath path(node, _graph_type);
-  return path.instance_to(*this);
+  return path.instance_to(*this, sort);
 }
 
 ////////////////////////////////////////////////////////////////////

+ 11 - 8
panda/src/sgmanip/nodePath.h

@@ -176,14 +176,17 @@ PUBLISHED:
   find_all_matches(const string &path) const;
 
 
-  // Methods that actually move nodes around in the scene graph.
-
-  void reparent_to(const NodePath &other);
-  void wrt_reparent_to(const NodePath &other);
-  NodePath instance_to(const NodePath &other) const;
-  NodePath copy_to(const NodePath &other) const;
-  NodePath attach_new_node(Node *node) const;
-  INLINE NodePath attach_new_node(const string &name) const;
+  // Methods that actually move nodes around in the scene graph.  The
+  // optional "sort" parameter can be used to force a particular
+  // ordering between sibling nodes, useful when dealing with LOD's
+  // and similar switch nodes.  If the sort value is the same, bnodes
+  // will be arranged in the order they were added.
+  void reparent_to(const NodePath &other, int sort = 0);
+  void wrt_reparent_to(const NodePath &other, int sort = 0);
+  NodePath instance_to(const NodePath &other, int sort = 0) const;
+  NodePath copy_to(const NodePath &other, int sort = 0) const;
+  NodePath attach_new_node(Node *node, int sort = 0) const;
+  INLINE NodePath attach_new_node(const string &name, int sort = 0) const;
   void remove_node();
 
 

+ 25 - 5
panda/src/tform/dataValve.cxx

@@ -40,6 +40,28 @@ is_on(const DataValve &valve) const {
   return false;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: DataValve::Control::output
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void DataValve::Control::
+output(ostream &out) const {
+  switch (_state) {
+  case S_on:
+    out << "on";
+    break;
+
+  case S_off:
+    out << "off";
+    break;
+
+  case S_buttons:
+    out << _mods;
+    break;
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: DataValve::Constructor
 //       Access: Published
@@ -214,7 +236,7 @@ void DataValve::
 write(ostream &out, int indent_level) const {
   indent(out, indent_level)
     << "DataValve " << get_name() << ": (default control is "
-    << (_default_control->is_on(*this) ? "on" : "off") << ")\n";
+    << *_default_control << ")\n";
 
   size_t i;
   for (i = 0; i < _controls.size(); i++) {
@@ -226,7 +248,7 @@ write(ostream &out, int indent_level) const {
       if (child._control.is_null()) {
 	out << "(default)";
       } else {
-	out << (child._control->is_on(*this) ? "on" : "off");
+	out << *child._control;
       }
       out << "\n";
       
@@ -235,9 +257,7 @@ write(ostream &out, int indent_level) const {
 	   fci != child._fine_controls.end();
 	   ++fci) {
 	indent(out, indent_level + 4)
-	  << (*fci).first << " "
-	  << ((*fci).second->is_on(*this) ? "on" : "off")
-	  << "\n";
+	  << (*fci).first << " " << *(*fci).second;
       }
     }
   }

+ 7 - 0
panda/src/tform/dataValve.h

@@ -44,6 +44,8 @@ PUBLISHED:
 
     bool is_on(const DataValve &valve) const;
 
+    void output(ostream &out) const;
+
   private:
     enum State {
       S_on,
@@ -119,6 +121,11 @@ private:
   static TypeHandle _type_handle;
 };
 
+INLINE ostream &operator << (ostream &out, const DataValve::Control &control) {
+  control.output(out);
+  return out;
+}
+
 #include "dataValve.I"
 
 #endif