From b79e18da3eab4dc3fba8c573ed1e31a5cc46c8b3 Mon Sep 17 00:00:00 2001 From: Dave Schuyler Date: Fri, 20 Aug 2004 03:35:07 +0000 Subject: [PATCH] added takedown physics --- direct/src/controls/ShipPilot.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/direct/src/controls/ShipPilot.py b/direct/src/controls/ShipPilot.py index 8831b309cd..f2f874f47d 100755 --- a/direct/src/controls/ShipPilot.py +++ b/direct/src/controls/ShipPilot.py @@ -76,7 +76,9 @@ class ShipPilot(PhysicsWalker.PhysicsWalker): def setAvatar(self, ship): self.ship = ship - if ship is not None: + if ship is None: + self.takedownPhysics() + else: #self.setupShip() self.setupPhysics(ship) @@ -180,12 +182,23 @@ class ShipPilot(PhysicsWalker.PhysicsWalker): self.pusher.addCollider(self.cSphereNodePath, self.avatarNodePath) + def takedownPhysics(self): + assert(self.debugPrint("takedownPhysics()")) + if hasattr(self, "phys"): + del self.phys + for i in self.nodes: + i.removeNode() + def setupPhysics(self, avatarNodePath): assert(self.debugPrint("setupPhysics()")) if avatarNodePath is None: return assert not avatarNodePath.isEmpty() + self.takedownPhysics() + self.nodes = [] + self.phys=PhysicsManager.PhysicsManager() + if 0: # Connect to Physics Manager: self.actorNode=ActorNode("ship-physicsActor") @@ -204,14 +217,6 @@ class ShipPilot(PhysicsWalker.PhysicsWalker): self.actorNode = physicsActor.node() self.actorNode.getPhysicsObject().setOriented(1) self.actorNode.getPhysical(0).setViscosity(0.1) - - if hasattr(self, "phys"): - del self.phys - for i in self.nodes: - i.removeNode() - - self.nodes = [] - self.phys=PhysicsManager.PhysicsManager() fn=ForceNode("ship gravity") fnp=NodePath(fn) @@ -480,6 +485,7 @@ class ShipPilot(PhysicsWalker.PhysicsWalker): # self.phys.debugOutput()) onScreenDebug.add("orientation", self.actorNode.getPhysicsObject().getOrientation().pPrintValues()) + #print "ship orientation:", self.actorNode.getPhysicsObject().getOrientation().pPrintValues() momentumForce = self.momentumForce.getLocalVector() onScreenDebug.add("w momentumForce vec",