def IsResultWithinWarpDistance(result):
    ballpark = sm.GetService('michelle').GetBallpark()
    egoBall = ballpark.GetBall(ballpark.ego)
    egoPos = geo2.Vector(egoBall.x, egoBall.y, egoBall.z)
    resultPos = geo2.Vector(*result.data)
    distanceSquared = geo2.Vec3LengthSq(egoPos - resultPos)
    return distanceSquared > MIN_WARP_DISTANCE_SQUARED
Exemple #2
0
 def UpdateProbePosition(self, probeID, position):
     probeData = self.probeData[probeID]
     distSq = geo2.Vec3LengthSq(position)
     if distSq > probescanning.const.MAX_PROBE_DIST_FROM_SUN_SQUARED:
         scale = probescanning.const.MAX_PROBE_DIST_FROM_SUN_SQUARED / distSq
         position = geo2.Vec3Scale(position, scale)
     probeData.pos = probeData.destination = position
     return position
Exemple #3
0
 def Update(self, controller):
     if hasattr(controller.entityRef, 'aiming'):
         debugBoneName = 'fj_eyeballLeft'
         gazeAtEntityID = self.aimingClient.GetTargetEntityID(controller.entityRef, const.aiming.AIMING_VALID_TARGET_GAZE_ID)
         if gazeAtEntityID:
             gazeAtEntity = self.entityService.FindEntityByID(gazeAtEntityID)
             if gazeAtEntity:
                 sensorPos = geo2.Vector(*controller.entityRef.position.position)
                 sensorPos = sensorPos + self.perceptionClient.GetSensorOffset(controller.entityRef)
                 focusPos = geo2.Vector(*gazeAtEntity.position.position)
                 focusPos = focusPos + self.perceptionClient.GetSensorOffset(gazeAtEntity)
                 headTransform = controller.animationNetwork.GetBoneTransform(debugBoneName)
                 if headTransform is None:
                     return
                 headTranslation, headRotation = headTransform
                 useBlendToHeadBone = False
                 if useBlendToHeadBone:
                     workPos = geo2.Vec3Subtract(focusPos, controller.entPos)
                     entRotInvQuat = geo2.QuaternionInverse(controller.entRot)
                     entRotInvQuat = geo2.QuaternionNormalize(entRotInvQuat)
                     workPos = geo2.QuaternionTransformVector(entRotInvQuat, workPos)
                     workPos = geo2.Vec3Subtract(workPos, headTranslation)
                     headRotInvQuat = geo2.QuaternionInverse(headRotation)
                     headRotInvQuat = geo2.QuaternionNormalize(headRotInvQuat)
                     workPos = geo2.QuaternionTransformVector(headRotInvQuat, workPos)
                     relativeLookAtYaw = mathCommon.GetYawAngleFromDirectionVector(workPos)
                     relativeLookAtPitch = mathCommon.GetPitchAngleFromDirectionVector(workPos)
                 else:
                     sensorToFocusVec = geo2.Vec3Subtract(focusPos, sensorPos)
                     yawToFocus = mathCommon.GetYawAngleFromDirectionVector(sensorToFocusVec)
                     pitchToFocus = mathCommon.GetPitchAngleFromDirectionVector(sensorToFocusVec)
                     entityYaw, trash, trash = geo2.QuaternionRotationGetYawPitchRoll(controller.entRot)
                     relativeLookAtYaw = yawToFocus - entityYaw
                     relativeLookAtPitch = pitchToFocus
                 relativeLookAtYaw = math.fmod(relativeLookAtYaw, 2 * math.pi)
                 relativeLookAtPitch = math.fmod(relativeLookAtPitch, 2 * math.pi)
                 if relativeLookAtYaw < 0:
                     relativeLookAtYaw = relativeLookAtYaw + 2 * math.pi
                 if relativeLookAtPitch < 0:
                     relativeLookAtPitch = relativeLookAtPitch + 2 * math.pi
                 if relativeLookAtYaw > math.pi:
                     relativeLookAtYaw = relativeLookAtYaw - 2 * math.pi
                 if relativeLookAtPitch > math.pi:
                     relativeLookAtPitch = relativeLookAtPitch - 2 * math.pi
                 if geo2.Vec3LengthSq(controller.entityRef.movement.physics.velocity) > 0.0:
                     maxYaw = MAXIMUM_HEAD_LOOK_ANGLE_YAW_MOVING
                     maxPitch = MAXIMUM_HEAD_LOOK_ANGLE_PITCH_MOVING
                 else:
                     maxYaw = MAXIMUM_HEAD_LOOK_ANGLE_YAW
                     maxPitch = MAXIMUM_HEAD_LOOK_ANGLE_PITCH
                 if abs(relativeLookAtYaw) < maxYaw and abs(relativeLookAtPitch) < maxPitch:
                     controller.SetControlParameter('Aim_X', -relativeLookAtYaw)
                     controller.SetControlParameter('Aim_Y', -relativeLookAtPitch)
                     controller.SetControlParameter('HeadLookWeight', 1)
                     aimingManager = self.aimingClient.GetAimingManager(controller.entityRef.scene.sceneID)
                     if aimingManager.IsDebugRendering():
                         self.aimingClient.GetAimingManager(controller.entityRef.scene.sceneID).SetDebugUsedParams(controller.entityRef.entityID, relativeLookAtYaw, -relativeLookAtPitch, maxYaw, maxPitch, headTranslation, headRotation)
                     return
         controller.SetControlParameter('HeadLookWeight', 0)
         aimingManager = self.aimingClient.GetAimingManager(controller.entityRef.scene.sceneID)
         if aimingManager.IsDebugRendering():
             translation, orientation = controller.entityRef.animation.updater.network.GetBoneTransform(debugBoneName)
             self.aimingClient.GetAimingManager(controller.entityRef.scene.sceneID).SetDebugUsedParams(controller.entityRef.entityID, -99, -99, MAXIMUM_HEAD_LOOK_ANGLE_YAW, MAXIMUM_HEAD_LOOK_ANGLE_PITCH, translation, orientation)
Exemple #4
0
 def DistSqFromCenter(v):
     return geo2.Vec3LengthSq(
         geo2.Vec3Subtract(v, translationCenterPoint))