Browse Source

*** empty log message ***

Mark Mine 24 years ago
parent
commit
92558bca76

+ 34 - 25
direct/src/directtools/DirectCameraControl.py

@@ -30,6 +30,7 @@ class DirectCameraControl(PandaObject):
             ['h', self.homeCam],
             ['h', self.homeCam],
             ['i', self.toggleMarkerVis],
             ['i', self.toggleMarkerVis],
             ['m', self.moveToFit],
             ['m', self.moveToFit],
+            ['n', self.pickNextCOA],
             ['u', self.orbitUprightCam],
             ['u', self.orbitUprightCam],
             ['U', self.uprightCam],
             ['U', self.uprightCam],
             [`1`, self.spawnMoveToView, 1],
             [`1`, self.spawnMoveToView, 1],
@@ -69,31 +70,7 @@ class DirectCameraControl(PandaObject):
             # And then spawn task to determine mouse mode
             # And then spawn task to determine mouse mode
             node, hitPt, hitPtDist = direct.iRay.pickGeom(
             node, hitPt, hitPtDist = direct.iRay.pickGeom(
                 fIntersectUnpickable = 1)
                 fIntersectUnpickable = 1)
-            coa = Point3(0)
-            if self.fUpdateCOA and node:
-                # Set center of action
-                coa.assign(hitPt)
-                coaDist = hitPtDist
-                # Handle case of bad coa point (too close or too far)
-                if ((coaDist < (1.1 * direct.dr.near)) or
-                    (coaDist > direct.dr.far)):
-                    # Just use existing point
-                    coa.assign(self.coaMarker.getPos(direct.camera))
-                    coaDist = Vec3(coa - ZERO_POINT).length()
-                    if coaDist < (1.1 * direct.dr.near):
-                        coa.set(0,100,0)
-                        coaDist = 100
-            else:
-                # If no intersection point or COA is locked:
-                # Use existing point
-                coa.assign(self.coaMarker.getPos(direct.camera))
-                coaDist = Vec3(coa - ZERO_POINT).length()
-                # Check again its not to close 
-                if coaDist < (1.1 * direct.dr.near):
-                    coa.set(0,100,0)
-                    coaDist = 100
-            # Update coa and marker
-            self.updateCoa(coa, coaDist)
+            self.computeCOA(node, hitPt, hitPtDist)
             # Start manipulation
             # Start manipulation
             self.spawnXZTranslateOrHPanYZoom()
             self.spawnXZTranslateOrHPanYZoom()
             # END MOUSE IN CENTRAL REGION
             # END MOUSE IN CENTRAL REGION
@@ -278,6 +255,38 @@ class DirectCameraControl(PandaObject):
     def toggleCOALock(self):
     def toggleCOALock(self):
         self.fUpdateCOA = 1 - self.fUpdateCOA
         self.fUpdateCOA = 1 - self.fUpdateCOA
 
 
+    def pickNextCOA(self):
+        """ Cycle through collision handler entries """
+        node, hitPt, hitPtDist = direct.iRay.pickNext()
+        self.computeCOA(node, hitPt, hitPtDist)
+
+    def computeCOA(self, node, hitPt, hitPtDist):
+        coa = Point3(0)
+        if self.fUpdateCOA and node:
+            # Set center of action
+            coa.assign(hitPt)
+            coaDist = hitPtDist
+            # Handle case of bad coa point (too close or too far)
+            if ((coaDist < (1.1 * direct.dr.near)) or
+                (coaDist > direct.dr.far)):
+                # Just use existing point
+                coa.assign(self.coaMarker.getPos(direct.camera))
+                coaDist = Vec3(coa - ZERO_POINT).length()
+                if coaDist < (1.1 * direct.dr.near):
+                    coa.set(0,100,0)
+                    coaDist = 100
+        else:
+            # If no intersection point or COA is locked:
+            # Use existing point
+            coa.assign(self.coaMarker.getPos(direct.camera))
+            coaDist = Vec3(coa - ZERO_POINT).length()
+            # Check again its not to close 
+            if coaDist < (1.1 * direct.dr.near):
+                coa.set(0,100,0)
+                coaDist = 100
+        # Update coa and marker
+        self.updateCoa(coa, coaDist)
+
     def updateCoa(self, cam2point, coaDist = None):
     def updateCoa(self, cam2point, coaDist = None):
         self.coa.set(cam2point[0], cam2point[1], cam2point[2])
         self.coa.set(cam2point[0], cam2point[1], cam2point[2])
         if coaDist:
         if coaDist:

+ 37 - 22
direct/src/directtools/DirectSelection.py

@@ -395,7 +395,10 @@ class SelectionRay:
         self.rayCollisionNode.addSolid( self.ray )
         self.rayCollisionNode.addSolid( self.ray )
         # Create a queue to hold the collision results
         # Create a queue to hold the collision results
         self.cq = CollisionHandlerQueue()
         self.cq = CollisionHandlerQueue()
+        # Number of entries in CollisionHandlerQueue
         self.numEntries = 0
         self.numEntries = 0
+        # Current entry in collision queue
+        self.cqIndex = 0
         # And a traverser to do the actual collision tests
         # And a traverser to do the actual collision tests
         self.ct = CollisionTraverser( RenderRelation.getClassType() )
         self.ct = CollisionTraverser( RenderRelation.getClassType() )
         # Let the traverser know about the queue and the collision node
         # Let the traverser know about the queue and the collision node
@@ -413,13 +416,13 @@ class SelectionRay:
 
 
     def pickGeom(self, targetNodePath = render, fIntersectUnpickable = 0):
     def pickGeom(self, targetNodePath = render, fIntersectUnpickable = 0):
         self.collideWithGeom()
         self.collideWithGeom()
-        numEntries = self.pick(targetNodePath,
-                               direct.dr.mouseX,
-                               direct.dr.mouseY)
-        # Init index
-        index = -1
+        self.pick(targetNodePath,
+                  direct.dr.mouseX,
+                  direct.dr.mouseY)
+        # Init self.cqIndex
+        self.cqIndex = -1
         # Pick out the closest object that isn't a widget
         # Pick out the closest object that isn't a widget
-        for i in range(0,numEntries):
+        for i in range(0,self.numEntries):
             entry = self.cq.getEntry(i)
             entry = self.cq.getEntry(i)
             node = entry.getIntoNode()
             node = entry.getIntoNode()
             # Don't pick hidden nodes
             # Don't pick hidden nodes
@@ -427,7 +430,7 @@ class SelectionRay:
                 pass
                 pass
             # Can pick unpickable, use the first visible node
             # Can pick unpickable, use the first visible node
             elif fIntersectUnpickable:
             elif fIntersectUnpickable:
-                index = i
+                self.cqIndex = i
                 break
                 break
             # Is it a named node?, If so, see if it has a name
             # Is it a named node?, If so, see if it has a name
             elif issubclass(node.__class__, NamedNode):
             elif issubclass(node.__class__, NamedNode):
@@ -435,17 +438,17 @@ class SelectionRay:
                 if name in self.unpickable:
                 if name in self.unpickable:
                     pass
                     pass
                 else:
                 else:
-                    index = i
+                    self.cqIndex = i
                     break
                     break
             # Not hidden and not one of the widgets, use it
             # Not hidden and not one of the widgets, use it
             else:
             else:
-                index = i
+                self.cqIndex = i
                 break
                 break
         # Did we hit an object?
         # Did we hit an object?
-        if(index >= 0):
+        if(self.cqIndex >= 0):
             # Yes!
             # Yes!
             # Find hit point in parent's space
             # Find hit point in parent's space
-            hitPt = self.parentToHitPt(index)
+            hitPt = self.parentToHitPt(self.cqIndex)
             hitPtDist = Vec3(hitPt - ZERO_POINT).length()
             hitPtDist = Vec3(hitPt - ZERO_POINT).length()
             return (node, hitPt, hitPtDist)
             return (node, hitPt, hitPtDist)
         else:
         else:
@@ -453,11 +456,11 @@ class SelectionRay:
 
 
     def pickWidget(self, targetNodePath = render):
     def pickWidget(self, targetNodePath = render):
         self.collideWithWidget()
         self.collideWithWidget()
-        numEntries = self.pick(targetNodePath,
-                               direct.dr.mouseX,
-                               direct.dr.mouseY)
+        self.pick(targetNodePath,
+                  direct.dr.mouseX,
+                  direct.dr.mouseY)
         # Did we hit a widget?
         # Did we hit a widget?
-        if numEntries:
+        if self.numEntries:
             # Yes!
             # Yes!
             # Entry 0 is the closest hit point if multiple hits
             # Entry 0 is the closest hit point if multiple hits
             minPt = 0
             minPt = 0
@@ -482,12 +485,24 @@ class SelectionRay:
         self.cq.sortEntries()
         self.cq.sortEntries()
         return self.numEntries
         return self.numEntries
 
 
+    def pickNext(self):
+        if self.cqIndex >= 0:
+            self.cqIndex = (self.cqIndex + 1) % self.numEntries
+            entry = self.cq.getEntry(self.cqIndex)
+            node = entry.getIntoNode()
+            # Find hit point in parent's space
+            hitPt = self.parentToHitPt(self.cqIndex)
+            hitPtDist = Vec3(hitPt - ZERO_POINT).length()
+            return (node, hitPt, hitPtDist)
+        else:
+            return (None, ZERO_POINT, 0)
+
     def pickGeom3D(self, targetNodePath = render, origin = Point3(0),
     def pickGeom3D(self, targetNodePath = render, origin = Point3(0),
                    dir = Vec3(0,0,-1), fIntersectUnpickable = 0):
                    dir = Vec3(0,0,-1), fIntersectUnpickable = 0):
         self.collideWithGeom()
         self.collideWithGeom()
         numEntries = self.pick3D(targetNodePath, origin, dir)
         numEntries = self.pick3D(targetNodePath, origin, dir)
-        # Init index
-        index = -1
+        # Init self.cqIndex
+        self.cqIndex = -1
         # Pick out the closest object that isn't a widget
         # Pick out the closest object that isn't a widget
         for i in range(0,numEntries):
         for i in range(0,numEntries):
             entry = self.cq.getEntry(i)
             entry = self.cq.getEntry(i)
@@ -497,7 +512,7 @@ class SelectionRay:
                 pass
                 pass
             # Can pick unpickable, use the first visible node
             # Can pick unpickable, use the first visible node
             elif fIntersectUnpickable:
             elif fIntersectUnpickable:
-                index = i
+                self.cqIndex = i
                 break
                 break
             # Is it a named node?, If so, see if it has a name
             # Is it a named node?, If so, see if it has a name
             elif issubclass(node.__class__, NamedNode):
             elif issubclass(node.__class__, NamedNode):
@@ -505,17 +520,17 @@ class SelectionRay:
                 if name in self.unpickable:
                 if name in self.unpickable:
                     pass
                     pass
                 else:
                 else:
-                    index = i
+                    self.cqIndex = i
                     break
                     break
             # Not hidden and not one of the widgets, use it
             # Not hidden and not one of the widgets, use it
             else:
             else:
-                index = i
+                self.cqIndex = i
                 break
                 break
         # Did we hit an object?
         # Did we hit an object?
-        if(index >= 0):
+        if(self.cqIndex >= 0):
             # Yes!
             # Yes!
             # Find hit point in parent's space
             # Find hit point in parent's space
-            hitPt = self.parentToHitPt(index)
+            hitPt = self.parentToHitPt(self.cqIndex)
             hitPtDist = Vec3(hitPt - ZERO_POINT).length()
             hitPtDist = Vec3(hitPt - ZERO_POINT).length()
             return (node, hitPt, hitPtDist)
             return (node, hitPt, hitPtDist)
         else:
         else:

+ 7 - 9
direct/src/interval/LerpInterval.py

@@ -252,17 +252,15 @@ class LerpFunctionInterval(Interval):
         if (t >= self.duration):
         if (t >= self.duration):
             # Set to end value
             # Set to end value
 	    apply(self.function, [self.toData] + self.extraArgs)
 	    apply(self.function, [self.toData] + self.extraArgs)
+        elif self.duration == 0.0:
+            # Zero duration, just use endpoint
+            apply(self.function, [self.toData] + self.extraArgs)
         else:
         else:
             # In the middle of the lerp, compute appropriate blended value
             # In the middle of the lerp, compute appropriate blended value
-            try:
-                bt = self.blendType(t/self.duration)
-                data = (self.fromData * (1 - bt)) + (self.toData * bt)
-                # Evaluate function
-                apply(self.function, [data] + self.extraArgs)
-            except ZeroDivisionError:
-                # Zero duration, just use endpoint
-                apply(self.function, [self.toData] + self.extraArgs)
-
+            bt = self.blendType(t/self.duration)
+            data = (self.fromData * (1 - bt)) + (self.toData * bt)
+            # Evaluate function
+            apply(self.function, [data] + self.extraArgs)
     def getBlend(self, blendType):
     def getBlend(self, blendType):
         """__getBlend(self, string)
         """__getBlend(self, string)
         Return the C++ blend class corresponding to blendType string
         Return the C++ blend class corresponding to blendType string

+ 3 - 4
direct/src/interval/MultiTrack.py

@@ -45,12 +45,11 @@ class MultiTrack(Interval):
 	    Go to time t
 	    Go to time t
 	"""
 	"""
 	for track in self.tlist:
 	for track in self.tlist:
-            tEnd = track.getDuration()
             # Compare time with track's end times
             # Compare time with track's end times
-            if (t > tEnd):
-                # If t > tEnd, only call if just crossing over
+            if (t > track.duration):
+                # If t > track.duration, only call if just crossing over
                 # or this is an IVAL_INIT event
                 # or this is an IVAL_INIT event
-                if (self.prev_t < tEnd) or (event == IVAL_INIT):
+                if (self.prev_t < track.duration) or (event == IVAL_INIT):
                     track.setT(t, event)
                     track.setT(t, event)
             else:
             else:
                 # Update track
                 # Update track

+ 1 - 1
direct/src/tkpanels/Inspector.py

@@ -382,7 +382,7 @@ class InspectorWindow:
         frame.pack()
         frame.pack()
         text = Label(
         text = Label(
             frame, justify = LEFT,
             frame, justify = LEFT,
-            text = "ListBox shows selected object's attributes\nDouble click or use right arrow on an instance variable to dive down.\nDouble click self or use left arrow to pop back up.\nUse up and down arrow keys to move from item to item in the current level.\n\nnResult box (upper right) shows current value of selected item\n\nCommand box (lower right) is used to evaluate python commands\nLocal variables 'object' and 'this' are defined as the current object being inspected\nand the current attribute selected."
+            text = "ListBox shows selected object's attributes\nDouble click or use right arrow on an instance variable to dive down.\nDouble click self or use left arrow to pop back up.\nUse up and down arrow keys to move from item to item in the current level.\n\nValue box (upper right) shows current value of selected item\n\nCommand box (lower right) is used to evaluate python commands\nLocal variables 'object' and 'this' are defined as the current object being inspected\nand the current attribute selected."
             )
             )
         text.pack()
         text.pack()