mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 08:15:18 -04:00
physics: Fix GlobalForceGroup
This commit is contained in:
parent
f1a171bfd8
commit
a6580f5dd3
@ -1,4 +1,6 @@
|
|||||||
from . import ForceGroup
|
from . import ForceGroup
|
||||||
|
from direct.showbase.PhysicsManagerGlobal import physicsMgr
|
||||||
|
|
||||||
|
|
||||||
class GlobalForceGroup(ForceGroup.ForceGroup):
|
class GlobalForceGroup(ForceGroup.ForceGroup):
|
||||||
|
|
||||||
@ -6,7 +8,7 @@ class GlobalForceGroup(ForceGroup.ForceGroup):
|
|||||||
ForceGroup.ForceGroup.__init__(self, name)
|
ForceGroup.ForceGroup.__init__(self, name)
|
||||||
|
|
||||||
def addForce(self, force):
|
def addForce(self, force):
|
||||||
ForceGroup.ForceGroup.addForce(force)
|
ForceGroup.ForceGroup.addForce(self, force)
|
||||||
if (force.isLinear() == 0):
|
if (force.isLinear() == 0):
|
||||||
# Physics manager will need an angular integrator
|
# Physics manager will need an angular integrator
|
||||||
base.addAngularIntegrator()
|
base.addAngularIntegrator()
|
||||||
@ -16,7 +18,7 @@ class GlobalForceGroup(ForceGroup.ForceGroup):
|
|||||||
physicsMgr.addAngularForce(force)
|
physicsMgr.addAngularForce(force)
|
||||||
|
|
||||||
def removeForce(self, force):
|
def removeForce(self, force):
|
||||||
ForceGroup.ForceGroup.removeForce(force)
|
ForceGroup.ForceGroup.removeForce(self, force)
|
||||||
if (force.isLinear() == 1):
|
if (force.isLinear() == 1):
|
||||||
physicsMgr.removeLinearForce(force)
|
physicsMgr.removeLinearForce(force)
|
||||||
else:
|
else:
|
||||||
|
19
tests/physics/test_GlobalForceGroup.py
Normal file
19
tests/physics/test_GlobalForceGroup.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from direct.particles.GlobalForceGroup import GlobalForceGroup
|
||||||
|
from panda3d import physics
|
||||||
|
|
||||||
|
|
||||||
|
def test_GlobalForceGroup():
|
||||||
|
gfg = GlobalForceGroup()
|
||||||
|
|
||||||
|
force1 = physics.LinearVectorForce((1, 0, 0))
|
||||||
|
force2 = physics.LinearVectorForce((0, 1, 0))
|
||||||
|
gfg.addForce(force1)
|
||||||
|
assert tuple(gfg) == (force1,)
|
||||||
|
gfg.addForce(force2)
|
||||||
|
assert tuple(gfg) == (force1, force2)
|
||||||
|
gfg.removeForce(force1)
|
||||||
|
assert tuple(gfg) == (force2,)
|
||||||
|
gfg.removeForce(force1)
|
||||||
|
assert tuple(gfg) == (force2,)
|
||||||
|
gfg.removeForce(force2)
|
||||||
|
assert tuple(gfg) == ()
|
Loading…
x
Reference in New Issue
Block a user