forward movement normalized

This commit is contained in:
Dave Schuyler 2005-10-11 21:42:57 +00:00
parent c9c13dc10f
commit d6d1877329

View File

@ -515,32 +515,29 @@ class GravityWalker(DirectObject.DirectObject):
self.vel=Vec3(Vec3.forward() * distance + self.vel=Vec3(Vec3.forward() * distance +
Vec3.right() * slideDistance) Vec3.right() * slideDistance)
if self.vel != Vec3.zero() or self.priorParent != Vec3.zero(): if self.vel != Vec3.zero() or self.priorParent != Vec3.zero():
if 0: # rotMat is the rotation matrix corresponding to
# rotMat is the rotation matrix corresponding to # our previous heading.
# our previous heading. rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up()) contact = self.lifter.getContactNormal()
right = Vec3(rotMat.xform(Vec3.right())) forward = contact.cross(Vec3.right())
up = Vec3(rotMat.xform(self.lifter.getContactNormal())) forward = Vec3(rotMat.xform(forward))
forward = up.cross(right) # Consider commenting out this normalize. If you do so
self.vel=Vec3(forward * distance + # then going up and down slops is a touch slower and
right * slideDistance) # steeper terrain can cut the movement in half. Without
step=self.vel + (self.priorParent * dt) # the normalize the movement is slowed by the cosine of
self.avatarNodePath.setFluidPos(Point3( # the slope (i.e. it is multiplied by the sign as a
self.avatarNodePath.getPos()+step)) # side effect of the cross product above).
if 1: forward.normalize()
# rotMat is the rotation matrix corresponding to self.vel=Vec3(forward * distance)
# our previous heading. if slideDistance:
rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up()) right = forward.cross(contact)
forward = self.lifter.getContactNormal().cross(Vec3.right()) right = Vec3(rotMat.xform(Vec3.right()))
forward = Vec3(rotMat.xform(forward)) # See note above for forward.normalize()
self.vel=Vec3(forward * distance) right.normalize()
if slideDistance: self.vel=Vec3(self.vel + right * slideDistance)
right = forward.cross(self.lifter.getContactNormal()) step=self.vel + (self.priorParent * dt)
right = Vec3(rotMat.xform(Vec3.right())) self.avatarNodePath.setFluidPos(Point3(
self.vel=Vec3(self.vel + right * slideDistance) self.avatarNodePath.getPos()+step))
step=self.vel + (self.priorParent * dt)
self.avatarNodePath.setFluidPos(Point3(
self.avatarNodePath.getPos()+step))
self.avatarNodePath.setH(self.avatarNodePath.getH()+rotation) self.avatarNodePath.setH(self.avatarNodePath.getH()+rotation)
else: else:
self.vel.set(0.0, 0.0, 0.0) self.vel.set(0.0, 0.0, 0.0)