Browse Source

better handling for non-blending case

David Rose 17 years ago
parent
commit
0a0bf8e38f
2 changed files with 35 additions and 17 deletions
  1. 18 9
      panda/src/chan/movingPartMatrix.cxx
  2. 17 8
      panda/src/chan/movingPartScalar.cxx

+ 18 - 9
panda/src/chan/movingPartMatrix.cxx

@@ -77,23 +77,32 @@ get_blend_value(const PartBundle *root) {
       _value = _initial_value;
       _value = _initial_value;
     }
     }
 
 
-  } else if (cdata->_blend.size() == 1 && !cdata->_frame_blend_flag) {
+  } else if ((cdata->_blend.size() == 1 || !cdata->_anim_blend_flag) && 
+             !cdata->_frame_blend_flag) {
     // A single value, the normal case.
     // A single value, the normal case.
-    AnimControl *control = (*cdata->_blend.begin()).first;
-
-    ChannelType *channel = NULL;
-    int channel_index = control->get_channel_index();
-    if (channel_index >= 0 && channel_index < (int)_channels.size()) {
-      channel = DCAST(ChannelType, _channels[channel_index]);
+    AnimControl *bound_control = NULL;
+    ChannelType *bound_channel = NULL;
+
+    PartBundle::ChannelBlend::const_iterator cbi;
+    for (cbi = cdata->_blend.begin(); 
+         cbi != cdata->_blend.end() && bound_channel == (ChannelType *)NULL; 
+         ++cbi) {
+      AnimControl *control = (*cbi).first;
+      int channel_index = control->get_channel_index();
+      if (channel_index >= 0 && channel_index < (int)_channels.size()) {
+        bound_control = control;
+        bound_channel = DCAST(ChannelType, _channels[channel_index]);
+      }
     }
     }
-    if (channel == (ChannelType *)NULL) {
+
+    if (bound_channel == (ChannelType *)NULL) {
       // Nothing is actually bound here.
       // Nothing is actually bound here.
       if (restore_initial_pose) {
       if (restore_initial_pose) {
         _value = _initial_value;
         _value = _initial_value;
       }
       }
 
 
     } else {
     } else {
-      channel->get_value(control->get_frame(), _value);
+      bound_channel->get_value(bound_control->get_frame(), _value);
     }
     }
 
 
   } else {
   } else {

+ 17 - 8
panda/src/chan/movingPartScalar.cxx

@@ -62,23 +62,32 @@ get_blend_value(const PartBundle *root) {
       _value = _initial_value;
       _value = _initial_value;
     }
     }
 
 
-  } else if (cdata->_blend.size() == 1 && !cdata->_frame_blend_flag) {
+  } else if ((cdata->_blend.size() == 1 || !cdata->_anim_blend_flag) && 
+             !cdata->_frame_blend_flag) {
     // A single value, the normal case.
     // A single value, the normal case.
-    AnimControl *control = (*cdata->_blend.begin()).first;
+    AnimControl *bound_control = NULL;
+    ChannelType *bound_channel = NULL;
 
 
-    ChannelType *channel = NULL;
-    int channel_index = control->get_channel_index();
-    if (channel_index >= 0 && channel_index < (int)_channels.size()) {
-      channel = DCAST(ChannelType, _channels[channel_index]);
+    PartBundle::ChannelBlend::const_iterator cbi;
+    for (cbi = cdata->_blend.begin(); 
+         cbi != cdata->_blend.end() && bound_channel == (ChannelType *)NULL; 
+         ++cbi) {
+      AnimControl *control = (*cbi).first;
+      int channel_index = control->get_channel_index();
+      if (channel_index >= 0 && channel_index < (int)_channels.size()) {
+        bound_control = control;
+        bound_channel = DCAST(ChannelType, _channels[channel_index]);
+      }
     }
     }
-    if (channel == NULL) {
+
+    if (bound_channel == NULL) {
       // Nothing is actually bound here.
       // Nothing is actually bound here.
       if (restore_initial_pose) {
       if (restore_initial_pose) {
         _value = _initial_value;
         _value = _initial_value;
       }
       }
 
 
     } else {
     } else {
-      channel->get_value(control->get_frame(), _value);
+      bound_channel->get_value(bound_control->get_frame(), _value);
     }
     }
 
 
   } else {
   } else {