Browse Source

disallow negative indices for SwitchNode

David Rose 14 years ago
parent
commit
4603b5f652

+ 1 - 0
panda/src/pgraphnodes/selectiveChildNode.I

@@ -46,5 +46,6 @@ SelectiveChildNode(const SelectiveChildNode &copy) :
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void SelectiveChildNode::
 INLINE void SelectiveChildNode::
 select_child(int n) {
 select_child(int n) {
+  nassertv(n >= 0);
   _selected_child = n;
   _selected_child = n;
 }
 }

+ 1 - 0
panda/src/pgraphnodes/switchNode.I

@@ -54,6 +54,7 @@ SwitchNode(const string &name) :
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void SwitchNode::
 INLINE void SwitchNode::
 set_visible_child(int index) {
 set_visible_child(int index) {
+  nassertv(index >= 0);
   CDWriter cdata(_cycler);
   CDWriter cdata(_cycler);
   cdata->_visible_child = index;
   cdata->_visible_child = index;
 }
 }