public void SetOrgin(Vector3 orgin) { _toRemove.Clear(); orgin = new Vector3((int)orgin.x, (int)orgin.y, (int)orgin.z); if (!CompareUtility.IsApproximatelyEqual(WorldOrigin.Origin, orgin, 1f)) { var shiftSceneObject = 0f; var shiftDefaultGoChilds = 0f; var shiftStreamingChilds = 0f; var diff = WorldOrigin.Origin - orgin; WorldOrigin.Origin = orgin; try { _profile.BeginProfile(); shiftSceneObject = ShiftSceneObject(diff); shiftDefaultGoChilds = ShiftDefaultGoChilds(diff); shiftStreamingChilds = ShiftStreamingChilds(diff); // TerrainCommonData.leftMinPos = // SingletonManager.Get<MapConfigManager>().SceneParameters.OriginPosition - orgin; } finally { var t = _profile.EndProfile(); _logger.InfoFormat("Move World From {0} to {1} with scene:{2} default:{3} stream:{4} in {5}ms", WorldOrigin.Origin + diff, WorldOrigin.Origin, shiftSceneObject, shiftDefaultGoChilds, shiftStreamingChilds, t); } } }
public virtual bool IsApproximatelyEqual(object right) { var rightObj = right as AbstractStateComponent; if (rightObj != null) { return(CompareUtility.IsApproximatelyEqual(PostureStateId, rightObj.PostureStateId) && CompareUtility.IsApproximatelyEqual(PostureStateProgress, rightObj.PostureStateProgress) && CompareUtility.IsApproximatelyEqual(PostureTransitionId, rightObj.PostureTransitionId) && CompareUtility.IsApproximatelyEqual(PostureTransitionProgress, rightObj.PostureTransitionProgress) && CompareUtility.IsApproximatelyEqual(LeanStateId, rightObj.LeanStateId) && CompareUtility.IsApproximatelyEqual(LeanStateProgress, rightObj.LeanStateProgress) && CompareUtility.IsApproximatelyEqual(LeanTransitionId, rightObj.LeanTransitionId) && CompareUtility.IsApproximatelyEqual(LeanTransitionProgress, rightObj.LeanTransitionProgress) && CompareUtility.IsApproximatelyEqual(MovementStateId, rightObj.MovementStateId) && CompareUtility.IsApproximatelyEqual(MovementStateProgress, rightObj.MovementStateProgress) && CompareUtility.IsApproximatelyEqual(MovementTransitionId, rightObj.MovementTransitionId) && CompareUtility.IsApproximatelyEqual(MovementTransitionProgress, rightObj.MovementTransitionProgress) && CompareUtility.IsApproximatelyEqual(ActionStateId, rightObj.ActionStateId) && CompareUtility.IsApproximatelyEqual(ActionStateProgress, rightObj.ActionStateProgress) && CompareUtility.IsApproximatelyEqual(ActionTransitionId, rightObj.ActionTransitionId) && CompareUtility.IsApproximatelyEqual(ActionTransitionProgress, rightObj.ActionTransitionProgress) && CompareUtility.IsApproximatelyEqual(KeepStateId, rightObj.KeepStateId) && CompareUtility.IsApproximatelyEqual(KeepStateProgress, rightObj.KeepStateProgress) && CompareUtility.IsApproximatelyEqual(KeepTransitionId, rightObj.KeepTransitionId) && CompareUtility.IsApproximatelyEqual(KeepTransitionProgress, rightObj.KeepTransitionProgress) ); } return(false); }
private float CalcDiveXAngle(float vertical, float horizontal, float updown) { float retVertical = 0.0f; float retUpDown = 0.0f; // process vertical if (vertical < 0) { retVertical = Mathf.Lerp(DiveCharacterController.DiveBack, 0, vertical + 1); } else { retVertical = Mathf.Lerp(0, DiveCharacterController.DiveFowrard, vertical); } if (updown < 0) { retUpDown = Mathf.Lerp(DiveCharacterController.DiveDown, 0, updown + 1); } else { retUpDown = Mathf.Lerp(0, DiveCharacterController.DiveUp, updown); } float absVertical = Mathf.Abs(vertical); float absUpdown = Mathf.Abs(updown); float total = absVertical + absUpdown; if (CompareUtility.IsApproximatelyEqual(total, 0)) { return(retVertical); } return(retVertical * absVertical / total + retUpDown * absUpdown / total); }
/// <summary> /// 计算地面坡度 /// </summary> /// <param name="player"></param> private static void CalcGroundSteep(PlayerEntity player) { var syncTransform = player.RootGo().transform; //坡度计算 bool exceedSteepLimit = false; // 在宏观尺度, Move的距离为实际距离, 在微观尺度, Move的距离为水平距离 var actualMovement = (syncTransform.position - player.position.Value); var horizontalComponent = Mathf.Sqrt(actualMovement.x * actualMovement.x + actualMovement.z * actualMovement.z); var steep = CompareUtility.IsApproximatelyEqual(horizontalComponent, 0.0f) ? 0 : actualMovement.y / horizontalComponent; //+ (1 - ratio) * lastSteep; float aveSteep = steep * SteepAverRatio + (1 - SteepAverRatio) * player.playerMove.SteepAverage; player.playerMove.SteepAverage = aveSteep; player.playerMove.Steep = steep; if (horizontalComponent > 0) { exceedSteepLimit = (aveSteep >= SteepLimitBegin) || ((aveSteep > SteepLimitStop) && player.stateInterface.State.IsSlowDown()); } player.stateInterface.State.SetSteepSlope(exceedSteepLimit); }
public override void SetCharacterPosition(Vector3 targetPos) { if (!CompareUtility.IsApproximatelyEqual(_motor.TransientPosition, targetPos, EPS)) { _motor.SetFlyPosition(targetPos); } }
public virtual void SetCharacterRotation(Vector3 euler) { if (!CompareUtility.IsApproximatelyEqual(YawPitchUtility.Normalize(_motor.TransientRotation.eulerAngles), euler, EPS)) { _motor.SetRotation(Quaternion.Euler(euler)); } }
private void AlignLocatorRotation(SightStatusParam param, Vector3 dir, Matrix4x4 alignedMatrix) { var dir1 = _sightLocationP1.position - _cameraLocatorP1.position; var dir2 = Vector3.Normalize(dir1 + dir); dir1 = dir1.normalized; var axis = Vector3.Cross(dir1, dir2).normalized; if (CompareUtility.IsApproximatelyEqual(axis, Vector3.zero) || CompareUtility.IsApproximatelyEqual(Vector3.Dot(dir1, dir2), 1, 0)) { return; } var angle = Mathf.Acos(Vector3.Dot(dir1, dir2)) * Mathf.Rad2Deg; if (float.IsNaN(angle)) { return; } if (param.IsFire || _updateBone) { return; } _sightLocationP1.Rotate(axis, -angle); AlignCoordinateSystems(_sightLocationP1, Vector3.Lerp(_sightLocationP1.position, alignedMatrix.ExtractPosition(), Mathf.Clamp01(param.SightProgress)), Quaternion.Slerp(_sightLocationP1.rotation, alignedMatrix.ExtractRotation(), Mathf.Clamp01(param.SightProgress)), _directionLocatorP1); }
// 第一人称腰射时手/枪的随动 private void SetFirstPersonShift(FirstPersonOffsetParam param) { if (!FirstPersonIncluded || !param.IsFirstPerson || param.IsSight) { return; } if (!CompareUtility.IsApproximatelyEqual(param.HorizontalShift, 0) || !CompareUtility.IsApproximatelyEqual(param.VerticalShift, 0)) { if (!CompareUtility.IsApproximatelyEqual(param.HorizontalShift, 0)) { var modifiedRotation = Quaternion.AngleAxis(param.HorizontalShift, _cameraLocatorP1.TransformDirection(Vector3.up)) * _leftHandP1.rotation; AlignCoordinateSystems(_leftHandP1, _leftHandP1.position, modifiedRotation, _directionLocatorP1); } if (!CompareUtility.IsApproximatelyEqual(param.VerticalShift, 0)) { var modifiedRotation = Quaternion.AngleAxis(param.VerticalShift, _cameraLocatorP1.TransformDirection(Vector3.right)) * _rightHandP1.rotation; AlignCoordinateSystems(_rightHandP1, _rightHandP1.position, modifiedRotation, _directionLocatorP1); } } // 一人称腰射状态下人物偏移(枪,分辨率相关) _directionLocatorP1.localPosition += param.FirstPersonPositionOffset; _directionLocatorP1.localEulerAngles += param.FirstPersonRotationOffset; }
public bool IsApproximatelyEqual(object right) { var remote = right as WeaponRuntimeDataComponent; return(PunchDecayLeftInterval == remote.PunchDecayLeftInterval && PunchYawLeftSide == remote.PunchYawLeftSide && CompareUtility.IsApproximatelyEqual(PunchYawSpeed, remote.PunchYawSpeed, 3) && CompareUtility.IsApproximatelyEqual(TargetPunchPitchDelta, remote.TargetPunchPitchDelta, 3) && Math.Abs(Accuracy - remote.Accuracy) < 0.01f && LastRenderTimestamp == remote.LastRenderTimestamp && NextAttackTimestamp == remote.NextAttackTimestamp && LastAttackTimestamp == remote.LastAttackTimestamp && ContinuesShootCount == remote.ContinuesShootCount && NeedAutoBurstShoot == remote.NeedAutoBurstShoot && NeedAutoReload == remote.NeedAutoReload && ContinuesShootReduceTimestamp == remote.ContinuesShootReduceTimestamp && BurstShootCount == remote.BurstShootCount && CameraRotationInterval == remote.CameraRotationInterval // && CompareUtility.IsApproximatelyEqual(LastBulletDir ,remote.LastBulletDir) && Math.Abs(LastSpreadX - remote.LastSpreadX) < 0.0001f && Math.Abs(LastSpreadY - remote.LastSpreadY) < 0.0001f && ContinueAttackEndStamp == remote.ContinueAttackEndStamp && ContinueAttackStartStamp == remote.ContinueAttackStartStamp && NextAttackPeriodStamp == remote.NextAttackPeriodStamp && MeleeAttacking == remote.MeleeAttacking && IsPrevCmdFire == remote.IsPrevCmdFire && PullBoltInterrupt == remote.PullBoltInterrupt); }
private void PitchP1(float pitch) { if (FirstPersonIncluded && !CompareUtility.IsApproximatelyEqual(pitch, 0)) { _viewPointP1.localRotation = Quaternion.AngleAxis(pitch, Vector3.right) * _viewPointP1.localRotation; } }
private static Vector3 CheckRatio(float ratio) { var offset = new Vector3(); try { foreach (var item in _ratioDatas) { foreach (var ratioIndex in item.Value) { if (ratioIndex > 0 && CompareUtility.IsApproximatelyEqual(FirstPersonOffsetConfig.ScreenRatios[ratioIndex], ratio)) { var offsetData = _offsetDatas[item.Key]; offset.Set(offsetData[0], offsetData[1], offsetData[2]); return(offset); } } } var index = RatioNearEqual(ratio); if (index >= 0 && index < _offsetDatas.Count) { var data = _offsetDatas[index]; offset.Set(data[0], data[1], data[2]); } } catch { Logger.Error("FirstPersonOffset config xml offset Error !"); } return(offset); }
/// <summary> /// warning, 一直返回true,计算以客户端为主,原因, replayPose是不能完全恢复现场, /// 其1:在过渡状态, 有exitTime, normalizeTime会把整数部分截掉,比如5.88->0.88 /// 其2:在过渡状态,没有exitTime /// </summary> /// <param name="right"></param> /// <returns></returns> public bool IsApproximatelyEqual(object right) { bool ret = true; var rightObj = right as NetworkAnimatorComponent; if (rightObj != null) { // for (int i = 0; i < AnimatorLayers.Count; i++) // { // var equal = AnimatorLayers[i].IsApproximatelyEqual(rightObj.AnimatorLayers[i]); // if (!equal) // { // _logger.Info(AnimatorLayers[i].ToString()); // _logger.Info(rightObj.AnimatorLayers[i].ToString()); // } // ret = ret && equal; // } for (int i = 0; i < AnimatorParameters.Count; i++) { var equal = AnimatorParameters[i].IsApproximatelyEqual(rightObj.AnimatorParameters[i]); if (!equal) { _logger.Info(AnimatorParameters[i].ToString()); _logger.Info(rightObj.AnimatorParameters[i].ToString()); } ret = ret && equal; } ret = ret && CompareUtility.IsApproximatelyEqual(BaseClientTime, rightObj.BaseClientTime); } return(ret); }
public virtual void SetCharacterPosition(Vector3 targetPos) { if (!CompareUtility.IsApproximatelyEqual(_motor.TransientPosition, targetPos, EPS)) { _motor.SetPosition(targetPos); } //Logger.InfoFormat("set target pos:{0}", targetPos); }
public virtual void SetCharacterRotation(Quaternion rot) { //这边是需要传进来旋转之前的状态,现在是由相机输入的,已经加过新的旋转了 if (!CompareUtility.IsApproximatelyEqual(_motor.TransientRotation.eulerAngles, rot.eulerAngles, EPS)) { _motor.SetRotation(rot); } }
protected void SetLatestWardrobeValue(Wardrobe type, int value) { var index = (int)type; _rewindFlag = (_latestWardrobeRewindFlag[index] = _latestWardrobeRewindFlag[index] || !CompareUtility.IsApproximatelyEqual(_latestWardrobeValue[index], value)) || _rewindFlag; _latestWardrobeValue[index] = value; }
public override void SetCharacterPosition(Vector3 targetPos) { if (!CompareUtility.IsApproximatelyEqual(_motor.TransientPosition, targetPos, EPS)) { //Logger.InfoFormat("rewind Pos from:{0} to:{1}",_motor.Transform.position ,targetPos); _motor.SetFlyPosition(targetPos); } }
private static bool IsVault(float kind) { var ret = CompareUtility.IsApproximatelyEqual(kind, AnimatorParametersHash.Instance.Vault50CmValue) || CompareUtility.IsApproximatelyEqual(kind, AnimatorParametersHash.Instance.Vault1MValue) || CompareUtility.IsApproximatelyEqual(kind, AnimatorParametersHash.Instance.Vault150CmValue) || CompareUtility.IsApproximatelyEqual(kind, AnimatorParametersHash.Instance.Vault2MValue); return(ret); }
protected void SetClientWeaponValue(ClientWeaponStateIndex type, int value) { var index = (int)type; _rewindFlag = (_clientWeaponRewindFlag[index] = _clientWeaponRewindFlag[index] || !CompareUtility.IsApproximatelyEqual(_clientWeaponValue[index], value) ) || _rewindFlag; _clientWeaponValue[index] = value; }
public bool IsApproximatelyEqual(object right) { var r = (right as PositionComponent); if (r.AlwaysEqual || AlwaysEqual) { return(true); } return(CompareUtility.IsApproximatelyEqual(FixedVector3.WorldVector3(), r.FixedVector3.WorldVector3())); }
public bool IsApproximatelyEqual(object right) { var r = ((CameraFinalOutputNewComponent)right); return(CompareUtility.IsApproximatelyEqual(Position, r.Position) && CompareUtility.IsApproximatelyEqual(EulerAngle, r.EulerAngle) && CompareUtility.IsApproximatelyEqual(Fov, r.Fov) && CompareUtility.IsApproximatelyEqual(Far, r.Far) && CompareUtility.IsApproximatelyEqual(Near, r.Near)); }
public virtual bool IsApproximatelyEqual(object right) { var rightObj = right as AbstractStateInterVar; return (CompareUtility.IsApproximatelyEqual(VerticalValue, rightObj.VerticalValue) && CompareUtility.IsApproximatelyEqual(HorizontalValue, rightObj.HorizontalValue) && CompareUtility.IsApproximatelyEqual(UpDownValue, rightObj.UpDownValue) ); }
public bool IsApproximatelyEqual(object right) { var r = (right as PositionComponent); if (r.AlwaysEqual || AlwaysEqual) { return(true); } return(CompareUtility.IsApproximatelyEqual(Value, r.Value)); }
public bool IsApproximatelyEqual(object right) { var rightObj = right as OxygenEnergyComponent; if (rightObj != null) { return(CompareUtility.IsApproximatelyEqual(CurrentOxygen, rightObj.CurrentOxygen)); } return(false); }
/// 有动作,从旧装备上画新装备 private void DoDrawArmWeaponWithActionFromOtherWeapon(WeaponScanStruct destWeapon, int lastWeaponId, WeaponDrawAppearanceStruct appearanceStruct) { RelatedCharState.SwitchWeapon(() => { WeaponToHand(destWeapon.ConfigId, lastWeaponId, appearanceStruct.targetSlot, CompareUtility.IsApproximatelyEqual(appearanceStruct.drawParam, AnimatorParametersHash.Instance.DrawLeftValue)); onWeaponSwitchEvt(this, destWeapon.ConfigId, EInOrOff.Off); }, () => OnDrawWeaponCallback(destWeapon, appearanceStruct.targetSlot), appearanceStruct.switchParam); }
public bool IsApproximatelyEqual(object right) { if (ServerAuthoritive) { var r = right as ShipRudderDynamicData; const float delta = 0.000001f; return(CompareUtility.IsApproximatelyEqual(Angle, r.Angle, delta)); } return(true); }
public override bool IsApproximatelyEqual(object right) { var rig = right as StateInterVar; return(AnimationCallbackCommands.Equals(rig.AnimationCallbackCommands) && StateInterCommands.Equals(rig.StateInterCommands) && FirstPersonAnimationEventCallBack.Equals(rig.FirstPersonAnimationEventCallBack) && ThirdPersonAnimationEventCallBack.Equals(rig.ThirdPersonAnimationEventCallBack) && base.IsApproximatelyEqual(right) && CompareUtility.IsApproximatelyEqual(IsJumpForSync, rig.IsJumpForSync) ); }
private bool IsApproximatelyEqual(NetworkAnimatorParameter right, float floatEpsilon) { if (right == null) { return(false); } return((ParamType == right.ParamType) && CompareUtility.IsApproximatelyEqual(IntValue, right.IntValue) && CompareUtility.IsApproximatelyEqual(FloatValue, right.FloatValue, floatEpsilon) && CompareUtility.IsApproximatelyEqual(BoolValue, right.BoolValue) && CompareUtility.IsApproximatelyEqual(NameHash, right.NameHash)); }
public bool IsApproximatelyEqual(object right) { var rightObj = (PredictedAppearanceComponent)right; if (rightObj != null) { return(CompareUtility.IsApproximatelyEqual(WeaponInHand, rightObj.WeaponInHand) && CompareUtility.IsApproximatelyEqual(OverrideControllerState, rightObj.OverrideControllerState)); } return(false); }
public bool IsApproximatelyEqual(object right) { if (ServerAuthorative) { var r = right as CarRewindWheelComponent; const float delta = 0.000001f; return(CompareUtility.IsApproximatelyEqual(SteerAngle, r.SteerAngle, delta) && CompareUtility.IsApproximatelyEqual(ColliderSteerAngle, r.ColliderSteerAngle, delta)); } return(true); }
public void Write(NetworkAnimatorLayer right, MyBinaryWriter writer) { BitArrayWrapper bitArray = BitArrayWrapper.Allocate(7, false); if (right == null) { bitArray.SetAll(true); } else { bitArray[0] = !CompareUtility.IsApproximatelyEqual(LayerIndex, right.LayerIndex); bitArray[1] = Weight != right.Weight; bitArray[2] = !CompareUtility.IsApproximatelyEqual(CurrentStateHash, right.CurrentStateHash); bitArray[3] = NormalizedTime != right.NormalizedTime; bitArray[4] = StateDuration != right.StateDuration; bitArray[5] = TransitionNormalizedTime != right.TransitionNormalizedTime; bitArray[6] = TransitionDuration != right.TransitionDuration; } writer.Write(bitArray); if (bitArray[0]) { writer.Write(LayerIndex); } if (bitArray[1]) { writer.Write(Weight); } if (bitArray[2]) { writer.Write(CurrentStateHash); } if (bitArray[3]) { writer.Write(NormalizedTime); } if (bitArray[4]) { writer.Write(StateDuration); } if (bitArray[5]) { writer.Write(TransitionNormalizedTime); } if (bitArray[6]) { writer.Write(TransitionDuration); } bitArray.ReleaseReference(); }