mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
"using new ShipFloorCollide for avatars on a ship"
This commit is contained in:
parent
de7e08b8ee
commit
d9dcbfc429
@ -93,6 +93,9 @@ class ControlManager:
|
|||||||
controls.setCollisionsActive(0)
|
controls.setCollisionsActive(0)
|
||||||
self.controls[name] = controls
|
self.controls[name] = controls
|
||||||
|
|
||||||
|
def get(self, name):
|
||||||
|
return self.controls.get(name)
|
||||||
|
|
||||||
def remove(self, name):
|
def remove(self, name):
|
||||||
"""
|
"""
|
||||||
name is any key that was used to refer to the
|
name is any key that was used to refer to the
|
||||||
@ -245,3 +248,4 @@ class ControlManager:
|
|||||||
onScreenDebug.add("InputState slideLeft", "%d"%(inputState.isSet("slideLeft")))
|
onScreenDebug.add("InputState slideLeft", "%d"%(inputState.isSet("slideLeft")))
|
||||||
onScreenDebug.add("InputState slideRight", "%d"%(inputState.isSet("slideRight")))
|
onScreenDebug.add("InputState slideRight", "%d"%(inputState.isSet("slideRight")))
|
||||||
return Task.cont
|
return Task.cont
|
||||||
|
|
||||||
|
@ -280,6 +280,13 @@ class GravityWalker(DirectObject.DirectObject):
|
|||||||
def setFloorBitMask(self, bitMask):
|
def setFloorBitMask(self, bitMask):
|
||||||
self.floorBitmask = bitMask
|
self.floorBitmask = bitMask
|
||||||
|
|
||||||
|
def swapFloorBitMask(self, oldMask, newMask):
|
||||||
|
self.floorBitmask = self.floorBitmask &~ oldMask
|
||||||
|
self.floorBitmask |= newMask
|
||||||
|
|
||||||
|
if self.cRayNodePath and not self.cRayNodePath.isEmpty():
|
||||||
|
self.cRayNodePath.node().setFromCollideMask(self.floorBitmask)
|
||||||
|
|
||||||
def initializeCollisions(self, collisionTraverser, avatarNodePath,
|
def initializeCollisions(self, collisionTraverser, avatarNodePath,
|
||||||
avatarRadius = 1.4, floorOffset = 1.0, reach = 1.0):
|
avatarRadius = 1.4, floorOffset = 1.0, reach = 1.0):
|
||||||
"""
|
"""
|
||||||
|
@ -64,6 +64,13 @@ class NonPhysicsWalker(DirectObject.DirectObject):
|
|||||||
def setFloorBitMask(self, bitMask):
|
def setFloorBitMask(self, bitMask):
|
||||||
self.cRayBitMask = bitMask
|
self.cRayBitMask = bitMask
|
||||||
|
|
||||||
|
def swapFloorBitMask(self, oldMask, newMask):
|
||||||
|
self.cRayBitMask = self.cRayBitMask &~ oldMask
|
||||||
|
self.cRayBitMask |= newMask
|
||||||
|
|
||||||
|
if self.cRayNodePath and not self.cRayNodePath.isEmpty():
|
||||||
|
self.cRayNodePath.node().setFromCollideMask(self.cRayBitMask)
|
||||||
|
|
||||||
def initializeCollisions(self, collisionTraverser, avatarNodePath,
|
def initializeCollisions(self, collisionTraverser, avatarNodePath,
|
||||||
avatarRadius = 1.4, floorOffset = 1.0, reach = 1.0):
|
avatarRadius = 1.4, floorOffset = 1.0, reach = 1.0):
|
||||||
"""
|
"""
|
||||||
|
@ -56,6 +56,13 @@ class ShipPilot(PhysicsWalker):
|
|||||||
def setWallBitMask(self, bitMask):
|
def setWallBitMask(self, bitMask):
|
||||||
self.wallBitmask = bitMask
|
self.wallBitmask = bitMask
|
||||||
|
|
||||||
|
def swapWallBitMask(self, oldMask, newMask):
|
||||||
|
self.wallBitmask = self.wallBitmask &~ oldMask
|
||||||
|
self.wallBitmask |= newMask
|
||||||
|
|
||||||
|
if self.cSphereNodePath and not self.cSphereNodePath.isEmpty():
|
||||||
|
self.cSphereNodePath.node().setFromCollideMask(self.wallBitmask)
|
||||||
|
|
||||||
def setFloorBitMask(self, bitMask):
|
def setFloorBitMask(self, bitMask):
|
||||||
self.floorBitmask = bitMask
|
self.floorBitmask = bitMask
|
||||||
|
|
||||||
@ -102,33 +109,40 @@ class ShipPilot(PhysicsWalker):
|
|||||||
self.pusher = PhysicsCollisionHandler()
|
self.pusher = PhysicsCollisionHandler()
|
||||||
self.pusher.setInPattern("enter%in")
|
self.pusher.setInPattern("enter%in")
|
||||||
self.pusher.setOutPattern("exit%in")
|
self.pusher.setOutPattern("exit%in")
|
||||||
|
|
||||||
|
cSphereNode = CollisionNode('SP.cSphereNode')
|
||||||
|
|
||||||
# Front sphere:
|
# Front sphere:
|
||||||
sRadius = abs((self.portPos - self.starboardPos)[0] / 2.0)
|
sRadius = abs((self.portPos - self.starboardPos)[0] / 2.0)
|
||||||
cBowSphere = CollisionSphere(
|
cBowSphere = CollisionSphere(
|
||||||
0.0, self.bowPos[1]+sRadius, 0.0, sRadius)
|
0.0, self.bowPos[1]+sRadius, 0.0, sRadius)
|
||||||
cBowSphereNode = CollisionNode('SP.cBowSphereNode')
|
cSphereNode.addSolid(cBowSphere)
|
||||||
cBowSphereNode.addSolid(cBowSphere)
|
# cBowSphereNode = CollisionNode('SP.cBowSphereNode')
|
||||||
self.cBowSphereNodePath = self.ship.getInteractCollisionRoot().attachNewNode(
|
# cBowSphereNode.addSolid(cBowSphere)
|
||||||
cBowSphereNode)
|
# self.cBowSphereNodePath = self.ship.getInteractCollisionRoot().attachNewNode(
|
||||||
# self.cBowSphereNodePath.show()
|
# cBowSphereNode)
|
||||||
|
|
||||||
self.pusher.addCollider(
|
# self.pusher.addCollider(
|
||||||
self.cBowSphereNodePath, self.shipNodePath)
|
# self.cBowSphereNodePath, self.shipNodePath)
|
||||||
self.pusher.setHorizontal(True)
|
|
||||||
|
|
||||||
# Back sphere:
|
# Back sphere:
|
||||||
cSternSphere = CollisionSphere(
|
cSternSphere = CollisionSphere(
|
||||||
0.0, self.sternPos[1]-sRadius, 0.0, sRadius)
|
0.0, self.sternPos[1]-sRadius, 0.0, sRadius)
|
||||||
cSternSphereNode = CollisionNode('SP.cSternSphereNode')
|
cSternSphereNode = CollisionNode('SP.cSternSphereNode')
|
||||||
cSternSphereNode.addSolid(cSternSphere)
|
cSphereNode.addSolid(cSternSphere)
|
||||||
self.cSternSphereNodePath = self.ship.getInteractCollisionRoot().attachNewNode(
|
# cSternSphereNode.addSolid(cSternSphere)
|
||||||
cSternSphereNode)
|
# self.cSternSphereNodePath = self.ship.getInteractCollisionRoot().attachNewNode(
|
||||||
# self.cSternSphereNodePath.show()
|
# cSternSphereNode)
|
||||||
|
|
||||||
|
# self.pusher.addCollider(
|
||||||
|
# self.cSternSphereNodePath, self.shipNodePath)
|
||||||
|
|
||||||
self.pusher.addCollider(
|
|
||||||
self.cSternSphereNodePath, self.shipNodePath)
|
|
||||||
|
|
||||||
|
self.cSphereNodePath = self.ship.getInteractCollisionRoot().attachNewNode(
|
||||||
|
cSphereNode)
|
||||||
|
self.pusher.addCollider(
|
||||||
|
self.cSphereNodePath, self.shipNodePath)
|
||||||
|
self.pusher.setHorizontal(True)
|
||||||
# hide other things on my ship that these spheres might collide
|
# hide other things on my ship that these spheres might collide
|
||||||
# with and which I dont need anyways...
|
# with and which I dont need anyways...
|
||||||
shipCollWall = self.shipNodePath.find("**/collision_hull")
|
shipCollWall = self.shipNodePath.find("**/collision_hull")
|
||||||
@ -144,26 +158,38 @@ class ShipPilot(PhysicsWalker):
|
|||||||
self.collisionsActive = active
|
self.collisionsActive = active
|
||||||
shipCollWall = self.shipNodePath.find("**/collision_hull;+s")
|
shipCollWall = self.shipNodePath.find("**/collision_hull;+s")
|
||||||
if active:
|
if active:
|
||||||
self.cBowSphereNodePath.node().setFromCollideMask(self.wallBitmask | self.floorBitmask)
|
# self.cBowSphereNodePath.node().setFromCollideMask(self.wallBitmask | self.floorBitmask)
|
||||||
self.cBowSphereNodePath.node().setIntoCollideMask(BitMask32.allOff())
|
# self.cBowSphereNodePath.node().setIntoCollideMask(BitMask32.allOff())
|
||||||
self.cSternSphereNodePath.node().setFromCollideMask(self.wallBitmask | self.floorBitmask)
|
# self.cSternSphereNodePath.node().setFromCollideMask(self.wallBitmask | self.floorBitmask)
|
||||||
self.cSternSphereNodePath.node().setIntoCollideMask(BitMask32.allOff())
|
# self.cSternSphereNodePath.node().setIntoCollideMask(BitMask32.allOff())
|
||||||
self.cTrav.addCollider(self.cBowSphereNodePath, self.pusher)
|
self.cSphereNodePath.node().setFromCollideMask(self.wallBitmask | self.floorBitmask)
|
||||||
self.cTrav.addCollider(self.cSternSphereNodePath, self.pusher)
|
self.cSphereNodePath.node().setIntoCollideMask(BitMask32.allOff())
|
||||||
|
# self.cTrav.addCollider(self.cBowSphereNodePath, self.pusher)
|
||||||
|
# self.cTrav.addCollider(self.cSternSphereNodePath, self.pusher)
|
||||||
|
self.cTrav.addCollider(self.cSphereNodePath, self.pusher)
|
||||||
shipCollWall.stash()
|
shipCollWall.stash()
|
||||||
else:
|
else:
|
||||||
self.cTrav.removeCollider(self.cBowSphereNodePath)
|
# self.cTrav.removeCollider(self.cBowSphereNodePath)
|
||||||
self.cTrav.removeCollider(self.cSternSphereNodePath)
|
# self.cTrav.removeCollider(self.cSternSphereNodePath)
|
||||||
|
self.cTrav.removeCollider(self.cSphereNodePath)
|
||||||
shipCollWall.unstash()
|
shipCollWall.unstash()
|
||||||
# Now that we have disabled collisions, make one more pass
|
# Now that we have disabled collisions, make one more pass
|
||||||
# right now to ensure we aren't standing in a wall.
|
# right now to ensure we aren't standing in a wall.
|
||||||
self.oneTimeCollide()
|
self.oneTimeCollide()
|
||||||
|
|
||||||
def deleteCollisions(self):
|
def deleteCollisions(self):
|
||||||
import pdb;pdb.set_trace()
|
|
||||||
assert self.debugPrint("deleteCollisions()")
|
assert self.debugPrint("deleteCollisions()")
|
||||||
del self.cTrav
|
del self.cTrav
|
||||||
|
|
||||||
|
"""
|
||||||
|
if hasattr(self, "cBowSphereNodePath"):
|
||||||
|
self.cBowSphereNodePath.removeNode()
|
||||||
|
del self.cBowSphereNodePath
|
||||||
|
|
||||||
|
if hasattr(self, "cSternSphereNodePath"):
|
||||||
|
self.cSternSphereNodePath.removeNode()
|
||||||
|
del self.cSternSphereNodePath
|
||||||
|
"""
|
||||||
if hasattr(self, "cSphereNodePath"):
|
if hasattr(self, "cSphereNodePath"):
|
||||||
self.cSphereNodePath.removeNode()
|
self.cSphereNodePath.removeNode()
|
||||||
del self.cSphereNodePath
|
del self.cSphereNodePath
|
||||||
@ -186,8 +212,9 @@ class ShipPilot(PhysicsWalker):
|
|||||||
assert self.debugPrint("takedownPhysics()")
|
assert self.debugPrint("takedownPhysics()")
|
||||||
|
|
||||||
def setTag(self, key, value):
|
def setTag(self, key, value):
|
||||||
self.cSternSphereNodePath.setTag(key, value)
|
# self.cSternSphereNodePath.setTag(key, value)
|
||||||
self.cBowSphereNodePath.setTag(key, value)
|
# self.cBowSphereNodePath.setTag(key, value)
|
||||||
|
self.cSphereNodePath.setTag(key, value)
|
||||||
|
|
||||||
def setAvatarPhysicsIndicator(self, indicator):
|
def setAvatarPhysicsIndicator(self, indicator):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user