Преглед на файлове

Add global on/off for motion trails.

aignacio_sf преди 18 години
родител
ревизия
922a414c95
променени са 2 файла, в които са добавени 44 реда и са изтрити 29 реда
  1. 39 28
      direct/src/motiontrail/MotionTrail.py
  2. 5 1
      direct/src/motiontrail/cMotionTrail.cxx

+ 39 - 28
direct/src/motiontrail/MotionTrail.py

@@ -47,6 +47,12 @@ class MotionTrail(NodePath, DirectObject):
     motion_trail_list = [ ]
     motion_trail_task_name = "motion_trail_task"
 
+    global_enable = True    
+
+    @classmethod
+    def setGlobalEnable (self, enable):
+        MotionTrail.global_enable = enable
+
     def __init__ (self,name,parent_node_path):
 
         DirectObject.__init__(self)
@@ -147,38 +153,43 @@ class MotionTrail(NodePath, DirectObject):
         index = 0
         while (index < total_motion_trails):
             motion_trail = MotionTrail.motion_trail_list [index]
-            if (motion_trail.use_python_version):
-                # Python version
-                if (motion_trail.active and motion_trail.check_for_update (current_time)):
-                    transform = None                
-                    if (motion_trail.root_node_path != None) and (motion_trail.root_node_path != render):
-                        motion_trail.root_node_path.update ( )
+                        
+            if (MotionTrail.global_enable):                       
+                if (motion_trail.use_python_version):
+                    # Python version
+                    if (motion_trail.active and motion_trail.check_for_update (current_time)):
+                        transform = None                
+                        if (motion_trail.root_node_path != None) and (motion_trail.root_node_path != render):
+                            motion_trail.root_node_path.update ( )
+
+                        if (motion_trail.root_node_path and (motion_trail.relative_to_render == False)):
+                            transform = motion_trail.getMat(motion_trail.root_node_path)
+                        else:
+                            transform = Mat4 (motion_trail.getNetTransform ( ).getMat ( ))
 
-                    if (motion_trail.root_node_path and (motion_trail.relative_to_render == False)):
-                        transform = motion_trail.getMat(motion_trail.root_node_path)
-                    else:
-                        transform = Mat4 (motion_trail.getNetTransform ( ).getMat ( ))
+                        if (transform != None):
+                            motion_trail.update_motion_trail (current_time, transform)
+                else:
+                    # C++ version
+                    if (motion_trail.active and motion_trail.cmotion_trail.checkForUpdate (current_time)):
+                        transform = None                
+                        if (motion_trail.root_node_path != None) and (motion_trail.root_node_path != render):
+                            motion_trail.root_node_path.update ( )
+
+                        if (motion_trail.root_node_path and (motion_trail.relative_to_render == False)):
+                            transform = motion_trail.getMat(motion_trail.root_node_path)
+                        else:
+                            transform = Mat4 (motion_trail.getNetTransform ( ).getMat ( ))
 
-                    if (transform != None):
-                        motion_trail.update_motion_trail (current_time, transform)
+                        if (transform != None):
+                            motion_trail.transferVertices ( )
+                            motion_trail.cmotion_trail.updateMotionTrail (current_time, transform)
 
-                index += 1
             else:
-                # C++ version
-                if (motion_trail.active and motion_trail.cmotion_trail.checkForUpdate (current_time)):
-                    transform = None                
-                    if (motion_trail.root_node_path != None) and (motion_trail.root_node_path != render):
-                        motion_trail.root_node_path.update ( )
-
-                    if (motion_trail.root_node_path and (motion_trail.relative_to_render == False)):
-                        transform = motion_trail.getMat(motion_trail.root_node_path)
-                    else:
-                        transform = Mat4 (motion_trail.getNetTransform ( ).getMat ( ))
-
-                    if (transform != None):
-                        motion_trail.transferVertices ( )
-                        motion_trail.cmotion_trail.updateMotionTrail (current_time, transform)
-                index += 1
+                motion_trail.reset_motion_trail()
+                motion_trail.reset_motion_trail_geometry()
+            
+            index += 1
                                              
         return Task.cont
 

+ 5 - 1
direct/src/motiontrail/cMotionTrail.cxx

@@ -580,7 +580,7 @@ update_motion_trail (float current_time, LMatrix4f *transform) {
           printf ("nurbs_start_t %f, nurbs_end_t %f \n", nurbs_start_t, nurbs_end_t);
         }
       }
-
+      
       // create quads from NurbsCurveResult                    
       float total_curve_segments;
       
@@ -709,6 +709,10 @@ update_motion_trail (float current_time, LMatrix4f *transform) {
         }
       }
 
+      for (index = 0; index < total_vertices; index++) {
+        nurbs_curve_result_array [index] = 0;
+      }
+      
       delete[] nurbs_curve_result_array;
     }
     else {