Browse Source

*** empty log message ***

Mike Goslin 25 years ago
parent
commit
d30b3b43ac
2 changed files with 14 additions and 2 deletions
  1. 3 0
      direct/src/particles/Forces.py
  2. 11 2
      direct/src/showbase/ShowBase.py

+ 3 - 0
direct/src/particles/Forces.py

@@ -22,6 +22,9 @@ class Forces(DirectObject):
 
     def addForce(self, force):
 	"""addForce(self, force)"""
+	if (force.isLinear() == 0):
+	    # Physics manager will need an angular integrator
+	    base.addAngularIntegrator()
 	self.node.addForce(force)
 
     def removeForce(self, force):

+ 11 - 2
direct/src/showbase/ShowBase.py

@@ -13,6 +13,7 @@ import EventManager
 import math
 import sys
 import LinearEulerIntegrator
+import AngularEulerIntegrator
 import ClockObject
 
 globalClock = ClockObject.ClockObject.getGlobalClock()
@@ -117,9 +118,10 @@ class ShowBase:
 
 	# Physics manager
 	self.physicsMgr = physicsMgr
-	self.integrator = LinearEulerIntegrator.LinearEulerIntegrator()
-	self.physicsMgr.attachLinearIntegrator(self.integrator)
+	integrator = LinearEulerIntegrator.LinearEulerIntegrator()
+	self.physicsMgr.attachLinearIntegrator(integrator)
 	self.physicsMgrEnabled = 0
+	self.physicsMgrAngular = 0
 
         self.createAudioManager()
         self.createRootPanel()
@@ -127,6 +129,13 @@ class ShowBase:
 
         self.restart()
 
+    def addAngularIntegrator(self):
+	"""addAngularIntegrator(self)"""
+	if (self.physicsMgrAngular == 0):
+	    self.physicsMgrAngular = 1
+	    integrator = AngularEulerIntegrator.AngularEulerIntegrator()
+	    self.physicsMgr.attachAngularIntegrator(integrator)
+
     def enableParticles(self):
 	"""enableParticles(self)"""
 	self.particleMgrEnabled = 1