Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
CharacterCameraHandlerComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Character", description: "Scripted character camera handler (new)")]
3 {
4 }
5 
6 class SCR_CharacterCameraHandlerComponent : CameraHandlerComponent
7 {
8  [Attribute(category: "Camera Shake")]
9  protected ref SCR_RecoilCameraShakeParams m_pRecoilShakeParams;
10 
12  protected ref SCR_RecoilCameraShakeProgress m_pRecoilShake = new SCR_RecoilCameraShakeProgress();
13 
14  protected ref ScriptInvoker m_OnThirdPersonSwitch = new ScriptInvoker();
15  protected static float s_fOverlayCameraFOV;
16 
17  protected int m_iHipsBoneIndex = 0;
18 
19  protected bool m_bCameraActive;
20 
21  //------------------------------------------------------------------------------------------------
22  // constructor
26  void SCR_CharacterCameraHandlerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
27  {
28  #ifdef ENABLE_DIAG
29  DiagMenu.RegisterRange(SCR_DebugMenuID.DEBUGUI_CHARACTER_DEBUG_VIEW, "", "Cycle Debug View", "Character", "0, 8, 0, 1");
30  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_DRAW_CAMERA_COLLISION_SOLVER, "", "Draw Camera Collision Solver", "Character");
31  #endif
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  override void Init()
36  {
37  m_OwnerCharacter = SCR_ChimeraCharacter.Cast(GetOwner());
39  m_AnimationComponent = CharacterAnimationComponent.Cast(m_OwnerCharacter.FindComponent(CharacterAnimationComponent));
40  m_LoadoutStorage = EquipedLoadoutStorageComponent.Cast(m_OwnerCharacter.FindComponent(EquipedLoadoutStorageComponent));
41  m_InputManager = GetGame().GetInputManager();
42  m_IdentityComponent = CharacterIdentityComponent.Cast(m_OwnerCharacter.FindComponent(CharacterIdentityComponent));
43  m_CmdHandler = CharacterCommandHandlerComponent.Cast(m_OwnerCharacter.FindComponent(CharacterCommandHandlerComponent));
44 
45  m_iHeadBoneIndex = m_OwnerCharacter.GetAnimation().GetBoneIndex("Head");
46  m_iHipsBoneIndex = m_OwnerCharacter.GetAnimation().GetBoneIndex("Hips");
47  }
48 
49  //------------------------------------------------------------------------------------------------
50  override void OnCameraActivate()
51  {
53  m_bCameraActive = true;
54 
56  {
58  }
59 
61  if (playerController)
62  {
63  if (playerController.m_bRetain3PV)
64  SetThirdPerson(true);
65  playerController.m_bRetain3PV = false;
66  }
67 
69  {
70  OnAlphatestChange(m_OwnerCharacter.m_fFaceAlphaTest);
71  }
72  }
73 
74  //------------------------------------------------------------------------------------------------
76  void OnAlphatestChange(int a)
77  {
78  m_OwnerCharacter.m_fFaceAlphaTest = a;
79 
81  m_IdentityComponent.SetHeadAlpha(a);
82 
83  if (m_LoadoutStorage)
84  {
85  IEntity ent = m_LoadoutStorage.GetClothFromArea(LoadoutHeadCoverArea);
86  if (ent)
87  {
89  if (cloth)
90  cloth.SetAlpha(a);
91  }
92  }
93  }
94 
95  //------------------------------------------------------------------------------------------------
96  override void OnCameraDeactivate()
97  {
98  if (m_OwnerCharacter)
100 
101  m_fFocusTargetValue = 0.0;
102  m_fFocusValue = 0.0;
104 
105  m_bCameraActive = false;
106  }
107 
108  //------------------------------------------------------------------------------------------------
110  bool IsDebugView()
111  {
112  #ifdef ENABLE_DIAG
113  return DiagMenu.GetValue(SCR_DebugMenuID.DEBUGUI_CHARACTER_DEBUG_VIEW) != CharacterCameraSet.DEBUGVIEW_NONE;
114  #else
115  return false;
116  #endif
117  }
118 
119  private bool m_bWasVehicleADS;
120 
121  //------------------------------------------------------------------------------------------------
125  {
127  return m_bWasVehicleADS;
128  }
129 
130  //------------------------------------------------------------------------------------------------
134  bool CheckIsInTurret(out bool isInAds)
135  {
136  isInAds = false;
137  CompartmentAccessComponent compartmentAccess = m_OwnerCharacter.GetCompartmentAccessComponent();
138  // Fallback to default VehicleCamera behavior if getting out
139  if (compartmentAccess && compartmentAccess.IsInCompartment() && !compartmentAccess.IsGettingOut())
140  {
141  BaseCompartmentSlot compartment = compartmentAccess.GetCompartment();
142  if (compartment)
143  {
144  BaseControllerComponent controller = compartment.GetController();
145  if (controller)
146  {
147  TurretControllerComponent turretController = TurretControllerComponent.Cast(controller);
148  if(turretController && turretController.GetTurretComponent())
149  {
150  isInAds = turretController.IsWeaponADS();
151  return true;
152  }
153  }
154  }
155  }
156 
157  return false;
158  }
159 
160  //------------------------------------------------------------------------------------------------
161  override int CameraSelector()
162  {
163  m_AnimationComponent.GetMovementState(m_CharMovementState);
164 
165  #ifdef ENABLE_DIAG
166  if (IsDebugView())
167  {
168  return CharacterCameraSet.CHARACTERCAMERA_DEBUG;
169  }
170  #endif
171 
172  if (!IsInThirdPerson())
173  {
174  ECharacterLifeState lifeState = m_ControllerComponent.GetLifeState();
175  if (lifeState == ECharacterLifeState.DEAD)
176  return CharacterCameraSet.CHARACTERCAMERA_1ST_BONE_TRANSFORM;
177 
178  if (lifeState == ECharacterLifeState.INCAPACITATED)
179  return CharacterCameraSet.CHARACTERCAMERA_1ST_UNCONSCIOUS;
180  }
181  else
182  {
183  if (m_ControllerComponent.IsUnconscious())
184  return CharacterCameraSet.CHARACTERCAMERA_3RD_UNCONSCIOUS;
185  }
186 
187  if (m_ControllerComponent.IsSwimming())
188  {
189  if (IsInThirdPerson())
190  return CharacterCameraSet.CHARACTERCAMERA_3RD_FLOAT;
191  else
192  return CharacterCameraSet.CHARACTERCAMERA_1ST_FLOAT;
193  }
194 
195  if (SCR_BinocularsComponent.IsZoomedView())
196  return CharacterCameraSet.CHARACTERCAMERA_BINOCULARS;
197 
199  if (m_ControllerComponent.IsWeaponADS() || (m_ControllerComponent.GetInputContext().IsWeaponADS() && m_ControllerComponent.IsChangingStance()))
200  return CharacterCameraSet.CHARACTERCAMERA_ADS;
201 
202  if (m_ControllerComponent.IsGadgetRaisedModeWanted() && !m_OwnerCharacter.IsInVehicle())
203  return CharacterCameraSet.CHARACTERCAMERA_1ST;
204 
205  CompartmentAccessComponent compartmentAccess = m_OwnerCharacter.GetCompartmentAccessComponent();
206 
207  if (m_ControllerComponent.GetInspect() && !m_OwnerCharacter.IsInVehicle())
208  return CharacterCameraSet.CHARACTERCAMERA_1ST;
209 
210  bool isRolling = false;
211  if (m_ControllerComponent.IsRoll() && m_CmdHandler)
212  {
213  CharacterCommandMove moveCmd = m_CmdHandler.GetCommandMove();
215  if (moveCmd && !moveCmd.IsBlendingOutRoll())
216  isRolling = true;
217  }
218 
219  if (IsInThirdPerson())
220  {
221  if( m_OwnerCharacter.IsInVehicle() && compartmentAccess && !compartmentAccess.IsGettingOut() )
222  {
223  bool isTurretAds = false;
224  bool inTurret = CheckIsInTurret(isTurretAds);
225  if (inTurret)
226  {
227  if (isTurretAds)
228  return CharacterCameraSet.CHARACTERCAMERA_ADS_VEHICLE;
229 
230  return CharacterCameraSet.CHARACTERCAMERA_3RD_TURRET;
231  }
232 
233  if (m_ControllerComponent.GetInspect())
234  return CharacterCameraSet.CHARACTERCAMERA_1ST_VEHICLE;
235 
236  return CharacterCameraSet.CHARACTERCAMERA_3RD_VEHICLE;
237  }
238 
239  if (compartmentAccess && (compartmentAccess.IsGettingOut() || compartmentAccess.IsGettingIn()))
240  return CharacterCameraSet.CHARACTERCAMERA_3RD_ERC;
241 
242  if( m_CharMovementState.m_CommandTypeId == ECharacterCommandIDs.CLIMB )
243  return CharacterCameraSet.CHARACTERCAMERA_3RD_CLIMB;
244 
245  if (m_ControllerComponent.GetScrInputContext().m_iLoiteringType == 1)
246  {
247  SCR_CharacterCommandHandlerComponent scrCmdHandler = SCR_CharacterCommandHandlerComponent.Cast(m_CmdHandler);
248  if (scrCmdHandler && scrCmdHandler.IsLoitering())
249  return CharacterCameraSet.CHARACTERCAMERA_3RD_SITTING;
250  }
251 
252  if( m_CharMovementState.m_iStanceIdx == ECharacterStance.PRONE )
253  {
255  {
256  if (isRolling)
257  return CharacterCameraSet.CHARACTERCAMERA_1ST_BONE_TRANSFORM;
258 
259  return CharacterCameraSet.CHARACTERCAMERA_1ST;
260  }
261 
262  return CharacterCameraSet.CHARACTERCAMERA_3RD_PRO;
263  }
264  else if( m_CharMovementState.m_iStanceIdx == ECharacterStance.CROUCH )
265  {
267  return CharacterCameraSet.CHARACTERCAMERA_1ST;
268 
269  return CharacterCameraSet.CHARACTERCAMERA_3RD_CRO;
270  }
271 
273  return CharacterCameraSet.CHARACTERCAMERA_1ST;
274 
275  return CharacterCameraSet.CHARACTERCAMERA_3RD_ERC;
276  }
277  else if (compartmentAccess && (compartmentAccess.IsGettingIn() || compartmentAccess.IsGettingOut()))
278  {
279  return CharacterCameraSet.CHARACTERCAMERA_1ST_VEHICLE_TRANSITION;
280  }
281  else if( m_OwnerCharacter.IsInVehicle() )
282  {
283  bool isTurretAds = false;
284  bool inTurret = CheckIsInTurret(isTurretAds);
285  if (inTurret)
286  {
287  if (isTurretAds)
288  return CharacterCameraSet.CHARACTERCAMERA_ADS_VEHICLE;
289 
290  return CharacterCameraSet.CHARACTERCAMERA_1ST_TURRET;
291  }
292  else if( CheckVehicleADS() )
293  {
294  return CharacterCameraSet.CHARACTERCAMERA_ADS_VEHICLE;
295  }
296 
297  return CharacterCameraSet.CHARACTERCAMERA_1ST_VEHICLE;
298  }
301  else if (isRolling)
302  {
303  return CharacterCameraSet.CHARACTERCAMERA_1ST_BONE_TRANSFORM;
304  }
305 
306  return CharacterCameraSet.CHARACTERCAMERA_1ST;
307  }
308 
309  //------------------------------------------------------------------------------------------------
310  protected bool ShouldForceFirstPersonInThirdPerson(CharacterControllerComponent controller)
311  {
312  if (!m_ControllerComponent.GetWeaponADSInput())
313  return false;
314 
315  if (m_ControllerComponent.IsSprinting() || m_ControllerComponent.IsSwimming())
316  return false;
317 
318  return true;
319  }
320 
321  protected float m_fADSProgress;
322  protected float m_fADSTime;
323 
324  //------------------------------------------------------------------------------------------------
325  override float GetCameraTransitionTime(int pFrom, int pTo)
326  {
327  float transTime = 0.4;
328 
329  if (pFrom == CharacterCameraSet.CHARACTERCAMERA_3RD_ERC && pTo == CharacterCameraSet.CHARACTERCAMERA_3RD_PRO
330  || pFrom == CharacterCameraSet.CHARACTERCAMERA_3RD_PRO && pTo == CharacterCameraSet.CHARACTERCAMERA_3RD_ERC)
331  transTime = 1.4;
332  else if (pFrom == CharacterCameraSet.CHARACTERCAMERA_3RD_CRO && pTo == CharacterCameraSet.CHARACTERCAMERA_3RD_PRO
333  || pFrom == CharacterCameraSet.CHARACTERCAMERA_3RD_PRO && pTo == CharacterCameraSet.CHARACTERCAMERA_3RD_CRO)
334  transTime = 0.8;
335  else if (pTo == CharacterCameraSet.CHARACTERCAMERA_1ST_UNCONSCIOUS || pTo == CharacterCameraSet.CHARACTERCAMERA_3RD_UNCONSCIOUS)
336  transTime = 0.8;
337  else if (pFrom == CharacterCameraSet.CHARACTERCAMERA_DEBUG || pTo == CharacterCameraSet.CHARACTERCAMERA_DEBUG)
338  transTime = 0.0;
339  else if (pTo == CharacterCameraSet.CHARACTERCAMERA_ADS || pTo == CharacterCameraSet.CHARACTERCAMERA_1ST_READY)
340  {
342  {
343  m_fADSTime = m_ControllerComponent.GetADSTime();
344  if (m_fADSProgress > 0)
345  transTime = m_fADSTime * (1 - m_fADSProgress);
346  else
347  transTime = m_fADSTime;
348  }
349  }
350  else if (pFrom == CharacterCameraSet.CHARACTERCAMERA_ADS)
351  {
352  transTime = m_fADSTime * m_fADSProgress;
353  }
354  else if (pTo == CharacterCameraSet.CHARACTERCAMERA_ADS_VEHICLE)
355  {
356  CompartmentAccessComponent compAcc = m_OwnerCharacter.GetCompartmentAccessComponent();
357  if (compAcc && compAcc.IsInCompartment())
358  {
359  BaseCompartmentSlot compartment = compAcc.GetCompartment();
360  if (compartment)
361  {
362  BaseControllerComponent controller = compartment.GetController();
363  if (controller)
364  {
365  TurretControllerComponent turretController = TurretControllerComponent.Cast(controller);
366  if (turretController)
367  {
368  m_fADSTime = turretController.GetADSTime();
369  if (m_fADSProgress > 0)
370  transTime = m_fADSTime * (1 - m_fADSProgress);
371  else
372  transTime = m_fADSTime;
373  }
374  }
375  }
376  }
377  }
378  else if ((pFrom == CharacterCameraSet.CHARACTERCAMERA_ADS_VEHICLE/* || pFrom == CharacterCameraSet.CHARACTERCAMERA_1ST_TURRET*/) && pTo == CharacterCameraSet.CHARACTERCAMERA_1ST_READY)
379  {
380  transTime = 0.0;
381  }
382  else if ((pFrom == CharacterCameraSet.CHARACTERCAMERA_ADS_VEHICLE/* || pFrom == CharacterCameraSet.CHARACTERCAMERA_3RD_TURRET*/) && pTo == CharacterCameraSet.CHARACTERCAMERA_3RD_ERC)
383  {
384  transTime = 0.0;
385  }
386  else if (pFrom == CharacterCameraSet.CHARACTERCAMERA_1ST_VEHICLE_TRANSITION || pTo == CharacterCameraSet.CHARACTERCAMERA_1ST_VEHICLE_TRANSITION)
387  {
388  transTime = 0.8;
389  }
390  else
391  {
392  transTime = GetCameraSet().GetTransitionTime(pFrom, pTo);
393  }
394 
395  return transTime;
396  }
397 
398  //------------------------------------------------------------------------------------------------
399  override void OnThirdPersonSwitch(bool isInThirdPerson)
400  {
402  {
403  if (isInThirdPerson)
404  m_AnimationComponent.SetAnimationLayerTPP();
405  else
406  m_AnimationComponent.SetAnimationLayerFPP();
407  }
408 
409  m_OnThirdPersonSwitch.Invoke();
410  }
411 
412  //------------------------------------------------------------------------------------------------
415  {
416  return m_OnThirdPersonSwitch;
417  }
418 
419  // Empirical multiplier for focus deceleration
420  protected const float FOCUS_DECELERATION_RATIO = 4.5;
421  protected const float FOCUS_DEFAULT_ADS_TIME = 0.35;
422  protected const float FOCUS_ADS_TIME_RATIO = 0.75;
423 
424  [Attribute("0.5", UIWidgets.Slider, "Focus interpolation time", "0 10 0.05")]
425  protected float m_fFocusTime;
426 
427  [Attribute("0.9", UIWidgets.Slider, "Focus interpolation deceleration", "0 1 0.05")]
428  protected float m_fFocusDeceleration;
429 
430  protected bool m_bDoInterpolateFocus;
431  protected float m_fFocusTargetValue;
432  protected float m_fFocusValue;
433  protected float m_fAutoFocusProgress;
434 
435  //------------------------------------------------------------------------------------------------
436  override void OnBeforeCameraUpdate(float pDt, bool pIsKeyframe)
437  {
439 
441  float currDiff = Math.AbsFloat(m_fTargetSlide - m_fCameraSlideFilter);
442  if (currDiff <= sm_fDistanceEpsilon)
444 
445  m_InputManager.ActivateContext("PlayerCameraContext");
446 
447  bool isADSAllowed = m_CmdHandler && m_CmdHandler.IsWeaponADSAllowed(false);
448  bool isWeaponADS = isADSAllowed && m_ControllerComponent.GetWeaponADSInput() && !m_ControllerComponent.IsReloading();
449  if (!isWeaponADS)
450  CheckIsInTurret(isWeaponADS);
451 
453 
454  if (!isWeaponADS && playerController)
455  isWeaponADS = playerController.GetGadgetFocus();
456 
457  // Gadgets do not have ADS time defined
458  float adsTime = m_fADSTime;
459  if (adsTime <= 0)
460  adsTime = FOCUS_DEFAULT_ADS_TIME;
461 
462  float adsChange = pDt / adsTime;
463  float autoFocusChange = adsChange / FOCUS_ADS_TIME_RATIO;
464 
465  if (isWeaponADS)
466  {
467  if (m_fADSProgress < 1)
468  m_fADSProgress = Math.Min(1, m_fADSProgress + adsChange);
469 
470  if (m_fAutoFocusProgress < 1)
471  m_fAutoFocusProgress = Math.Min(1, m_fAutoFocusProgress + autoFocusChange);
472  }
473  else
474  {
475  if (m_fADSProgress > 0)
476  m_fADSProgress = Math.Max(0, m_fADSProgress - adsChange);
477 
478  if (m_fAutoFocusProgress > 0)
479  m_fAutoFocusProgress = Math.Max(0, m_fAutoFocusProgress - autoFocusChange);
480  }
481 
482  float cameraFocus;
483  if (playerController && !m_ControllerComponent.GetDisableViewControls())
484  cameraFocus = playerController.GetFocusValue(m_fAutoFocusProgress, pDt);
485 
486  if (!float.AlmostEqual(m_fFocusTargetValue, cameraFocus))
487  {
488  m_fFocusTargetValue = cameraFocus;
489  m_bDoInterpolateFocus = true;
490  }
491 
492  if (pIsKeyframe)
493  UpdateViewBob(pDt);
494 
495  // When ADS in third person, the fpv view is not necesarilly toggled, but oddly enforced,
496  // so the camera never activates/deactivates, thus bleeding values in
497  if (IsInThirdPerson() && m_ControllerComponent && m_ControllerComponent.GetInputContext().GetDie())
499 
501  return;
502 
503  float absDelta = 0;
504 
505  // Only care about transition if it takes time
506  if (m_fFocusTime > 0)
507  {
508  absDelta = Math.AbsFloat(m_fFocusTargetValue - m_fFocusValue);
509 
510  // Scale the focusChange by absDelta to smooth out the transition
511  float focusDeceleration = FOCUS_DECELERATION_RATIO * absDelta * m_fFocusDeceleration;
512 
513  // Linear component needs to be squared so that focus is 99% correct after m_fFocusTime
514  float focusSpeed = (1 - m_fFocusDeceleration) * (1 - m_fFocusDeceleration) + focusDeceleration;
515  float focusChange = pDt * focusSpeed / m_fFocusTime;
516 
518  m_fFocusValue += focusChange;
519  else
520  m_fFocusValue -= focusChange;
521 
522  m_fFocusValue = Math.Clamp(m_fFocusValue, 0, 1);
523  }
524 
525  if (float.AlmostEqual(absDelta, 0))
526  {
528  m_bDoInterpolateFocus = false;
529  }
530 
532  }
533 
534  //------------------------------------------------------------------------------------------------
535  override void OnAfterCameraUpdate(float pDt, bool pIsKeyframe, inout vector transformMS[4], inout vector transformWS[4])
536  {
537  UpdateHeadVisibility(transformWS[3]);
538 
539  if (m_ControllerComponent.IsDead())
540  return;
541 
543  if( pIsKeyframe )
544  UpdateAiming(transformMS);
545 
546  if (GetCurrentCamera())
547  GetCurrentCamera().OnAfterCameraUpdate(pDt, pIsKeyframe, transformMS);
548 
550  UpdateShake(pDt);
551  }
552 
553  //------------------------------------------------------------------------------------------------
554  void UpdateHeadVisibility(vector cameraPositionWS)
555  {
556  vector headBoneMat[4];
557  m_OwnerCharacter.GetAnimation().GetBoneMatrix(m_iHeadBoneIndex, headBoneMat);
558  vector charMat[4];
559  m_OwnerCharacter.GetWorldTransform(charMat);
560  Math3D.MatrixMultiply4(charMat, headBoneMat, headBoneMat);
561 
562  // Set alpha based on distance from camera
563  OnAlphatestChange(255 - Math.Clamp((vector.Distance(cameraPositionWS, headBoneMat[3]) - 0.2) / 0.15, 0.0, 1.0)*255);
564  }
565 
566  //------------------------------------------------------------------------------------------------
567  protected void UpdateShake(float pDt)
568  {
569  // Update and apply recoil based camera shake
570  if (m_pRecoilShake && !m_pRecoilShake.IsFinished())
571  m_pRecoilShake.Update(m_OwnerCharacter, pDt);
572  }
573 
574  //------------------------------------------------------------------------------------------------
578  void AddShakeToToTransform(inout vector transform[4], inout float fieldOfView)
579  {
580  bool applyRecoilShake = true;
581  #ifdef ENABLE_DIAG
582  applyRecoilShake = !DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_CHARACTER_RECOIL_CAMERASHAKE_DISABLE);
583  #endif
584 
585  // Apply recoil shake
586  if (applyRecoilShake && m_pRecoilShake)
587  m_pRecoilShake.Apply(transform, fieldOfView);
588 
589  // Apply generic shakes from shake manager to out transform
590  SCR_CameraShakeManagerComponent.ApplyCameraShake(transform, fieldOfView);
591  }
592 
593  //------------------------------------------------------------------------------------------------
595  {
596  bool current = IsInThirdPerson();
597  SetThirdPerson(!current);
598  }
599 
600  //------------------------------------------------------------------------------------------------
601  override void CollisionSolver(float pDt, inout ScriptedCameraItemResult pOutResult, inout vector resCamTM[4], bool isKeyframe)
602  {
603  // In case of changes, test:
604  // Freelook vs. collisions, heading vs. collisions
605  // Turrets - transitions between FPV, 3PV, ADS; collisions in ADS
606  // Jumping and collisions
607  // Collisions when close to a wall under a sharp angle, collisions when between two vehicles (<1m gap)
608  // Smoothness of transitions and slide/distance smoothing
609 
610  if (pOutResult.m_fDistance == 0.0)
611  {
613  ResetSlide();
614  }
615 
616  IEntity owner = pOutResult.m_pOwner;
617  vector ownerTransformWS[4];
618  if (owner)
619  owner.GetWorldTransform(ownerTransformWS);
620  else
621  Math3D.MatrixIdentity4(ownerTransformWS);
622 
623  vector resultWorldTransform[4]; // If pOutResult.m_CameraTM is in someone's model space, this transforms it back to world space.
624  if (pOutResult.m_pWSAttachmentReference)
625  pOutResult.m_pWSAttachmentReference.GetOwner().GetWorldTransform(resultWorldTransform);
626  else if (owner)
627  owner.GetWorldTransform(resultWorldTransform);
628  else
629  Math3D.MatrixIdentity4(resultWorldTransform);
630 
631  vector hipBoneWS[4];
632  m_OwnerCharacter.GetAnimation().GetBoneMatrix(m_iHipsBoneIndex, hipBoneWS);
633  Math3D.MatrixMultiply4(resultWorldTransform, hipBoneWS, hipBoneWS);
634 
635  #ifdef ENABLE_DIAG // These things are only useful for showing the debug spheres.
636  vector camPos = pOutResult.m_CameraTM[3];
637  vector inputCameraPosWS = camPos.Multiply4(resultWorldTransform);
638  #endif
639 
640  vector camTransformLS[4];
641  Math3D.MatrixCopy(pOutResult.m_CameraTM, camTransformLS);
642 
643  if (pOutResult.m_pWSAttachmentReference)
644  {
645  // If pOutResult.m_pWSAttachmentReference has value, the matrix was supplied in PointInfo space. Here we transform
646  // it to model's space (and can then use resultWorldTransform to translate into world space).
647  owner = pOutResult.m_pWSAttachmentReference.GetOwner();
648  vector wsAttachmentWorldTransform[4];
649  pOutResult.m_pWSAttachmentReference.GetModelTransform(wsAttachmentWorldTransform);
650  Math3D.MatrixMultiply4(wsAttachmentWorldTransform, camTransformLS, camTransformLS);
651  }
652 
653  vector basePos = camTransformLS[3]; // Camera position without heading applied.
654 
655  vector charRot[4]; // Matrix to transform from model space to heading space.
656  Math3D.MatrixIdentity4(charRot);
657 
658  if (pOutResult.m_fPositionModelSpace == 2.0) // 2.0 is world space.
659  {
660  camTransformLS[3] = camTransformLS[3] - resultWorldTransform[3];
661  }
662  else
663  {
664  if (pOutResult.m_fUseHeading > 0.0)
665  {
666  vector headingMat[4];
667  Math3D.AnglesToMatrix(Vector( Math.RAD2DEG * -pOutResult.m_fHeading, 0.0, 0.0), headingMat);
668 
669  if (pOutResult.m_pOwner)
670  pOutResult.m_pOwner.GetLocalTransform(charRot);
671 
672  charRot[3] = vector.Zero;
673 
674  Math3D.MatrixInvMultiply4(charRot, headingMat, charRot);
675  float charRotQ[4];
676  Math3D.MatrixToQuat(charRot, charRotQ);
677  float quatF[4] = {0.0, 0.0, 0.0, 1.0};
678  Math3D.QuatLerp(charRotQ, quatF, charRotQ, pOutResult.m_fUseHeading);
679  vector charRotQAngles = Math3D.QuatToAngles(charRotQ);
680  Math3D.AnglesToMatrix(charRotQAngles, charRot);
681 
682  Math3D.MatrixMultiply4(charRot, camTransformLS, camTransformLS);
683 
684  if (pOutResult.m_fDistance == 0.0)
685  camTransformLS[3] = basePos;
686  }
687 
688  if (pOutResult.m_fPositionModelSpace > 0.0)
689  {
690  // We are blending between heading (0.0) and local space (1.0) - for instance between turret ADS and 3PV.
691  vector msPos = camTransformLS[3];
692  vector lsPos = basePos;
693  camTransformLS[3] = vector.Lerp(lsPos, msPos, pOutResult.m_fPositionModelSpace);
694  }
695  }
696 
697  // Space and heading transformations are done. We transform them into WS to use with collision tracing.
698  vector camTransformWS[4];
699  if (pOutResult.m_fPositionModelSpace == 2.0)
700  Math3D.MatrixCopy(camTransformLS, camTransformWS);
701  else
702  Math3D.MatrixMultiply4(resultWorldTransform, camTransformLS, camTransformWS);
703 
704  if (pOutResult.m_bAllowCollisionSolver && !isKeyframe && pOutResult.m_fDistance > 0.0)
705  {
706  // We always make the traces a bit longer than they need to be and "anticipate" if it is going to collide.
707  // This way we can make the camera movement a bit smoother. This number says by how much they will be longer.
708  float SIDE_TRACE_MARGIN_MULTIPLIER = 2.0;
709  float BACK_TRACE_MARGIN_MULTIPLIER = 1.25;
710 
711  // Exclude all character-related entities from any tracing.
712  array<IEntity> excludeArray = {m_OwnerCharacter};
713  IEntity parent = m_OwnerCharacter.GetParent();
714  IEntity sibling = m_OwnerCharacter.GetSibling();
715  while (parent != null)
716  {
717  excludeArray.Insert(parent);
718  while (sibling != null)
719  {
720  excludeArray.Insert(sibling);
721  sibling = sibling.GetSibling();
722  }
723  sibling = parent.GetSibling();
724  parent = parent.GetParent();
725  }
726 
727  const float TRACE_RADIUS = 0.06;
728 
729  BaseWorld world = m_OwnerCharacter.GetWorld();
730  TraceSphere param = new TraceSphere();
731  param.Radius = TRACE_RADIUS;
732  param.ExcludeArray = excludeArray;
733  param.Flags = TraceFlags.WORLD | TraceFlags.ENTS;
734  param.LayerMask = TRACE_LAYER_CAMERA;
735 
736  // 1. Sideways collision (translating the camera to left/right from character).
737  vector sideTraceStart = Vector(hipBoneWS[3][0], camTransformWS[3][1], hipBoneWS[3][2]);
738  vector sideTraceEnd = camTransformWS[3];
739 
740  vector sideTraceDiff = sideTraceEnd - sideTraceStart;
741 
742  // Set up the side trace, we also limit the Y position of the trace end - otherwise, if the character jumps and
743  // the margin is high, the trace will point downwards.
744  param.Start = sideTraceStart;
745  param.End = sideTraceStart + SIDE_TRACE_MARGIN_MULTIPLIER * sideTraceDiff;
746  param.End[1] = sideTraceStart[1] + sideTraceDiff[1];
747 
748  float rightTrace = world.TraceMove(param, null);
749 
750  // The slide we apply is not divided by the margin multiplier, since we want slide to move
751  // in anticipation of hitting something. We still pass the multiplier here though,
752  // so that we can change the speed of the smoothing based on how close the tracing hit.
753  ApplySmoothedSlide(pDt, rightTrace, sideTraceStart, sideTraceDiff, SIDE_TRACE_MARGIN_MULTIPLIER, pOutResult.m_fShoulderDist, camTransformWS);
754  #ifdef ENABLE_DIAG
755  sideTraceEnd = vector.Lerp(param.Start, param.End, rightTrace);
756  #endif
757 
758  // Slide is applied to the camera matrix, but distance is not.
759  // So we apply it to the camTransformLS which we will be returning at the end.
760  Math3D.MatrixInvMultiply4(resultWorldTransform, camTransformWS, camTransformLS);
761 
762  // 2. Backwards collision. Vars are defined outside the scope because of the debug spheres.
763  vector backtraceDir = pOutResult.m_vBacktraceDir.Multiply3(charRot).Multiply3(resultWorldTransform);
764  backtraceDir = vector.Lerp(camTransformWS[2], backtraceDir, pOutResult.m_fUseBacktraceDir);
765 
766  float backTrace = 1;
767  vector backTraceStart = camTransformWS[3];
768  vector backTraceEnd = camTransformWS[3] - BACK_TRACE_MARGIN_MULTIPLIER * pOutResult.m_fDistance * backtraceDir;
769  // Trace N rays at a thickness of TRACE_RADIUS around the direction backTraceEnd - backTraceStart, approximating a sphere trace.
770  const int N = 4;
771  vector traceMat[N];
772  float rayBackTrace[N];
773  SCR_Math3D.LookAt(backTraceStart, backTraceEnd, {0, 1, 0}, traceMat); // Get a transform with Z axis facing the ray direction.
774  vector traceOffset[N] = {
775  TRACE_RADIUS * traceMat[0],
776  TRACE_RADIUS * traceMat[1],
777  TRACE_RADIUS * -traceMat[0],
778  TRACE_RADIUS * -traceMat[1]
779  };
780 
781  if (pOutResult.m_fPositionModelSpace <= 2.0 && pOutResult.m_fDistance > 0.001)
782  {
783  TraceParam rayParam();
784  rayParam.ExcludeArray = excludeArray;
785  rayParam.Flags = TraceFlags.WORLD | TraceFlags.ENTS;
786  rayParam.LayerMask = TRACE_LAYER_CAMERA;
787 
788  backTrace = 1;
789  for (int i = 0; i < N; ++i)
790  {
791  rayParam.Start = backTraceStart + traceOffset[i];
792  rayParam.End = backTraceEnd + traceOffset[i];
793  rayBackTrace[i] = world.TraceMove(rayParam, null);
794  backTrace = Math.Min(backTrace, rayBackTrace[i]);
795  }
796  if (backTrace < 1)
797  Math.Max(0, backTrace - TRACE_RADIUS); // Push the point inwards by TRACE_RADIUS amount, approximating a sphere trace.
798 
799  // Unlike with slide, distance will not move "in anticipation", so we can directly multiply this value and compare it to 1.
800  // We still want to have it a bit longer though, to cover the param.Radius margin.
801  backTrace = BACK_TRACE_MARGIN_MULTIPLIER * backTrace;
802 
803  float newDistance = pOutResult.m_fDistance * Math.Min(1.0, backTrace);
804 
805  if (newDistance < sm_fDistanceEpsilon)
806  newDistance = 0.0;
807 
808  if (Math.AbsFloat(m_fCameraDistanceFilter - newDistance) < sm_fDistanceEpsilon && m_fCameraDistanceFilterVel != 0.0)
810 
811  // Set distance smoothing.
812  m_fTargetDistance = newDistance;
813  if(IsCameraBlending() || newDistance < m_fCameraDistanceFilter)
814  m_fCameraDistanceFilter = newDistance;
815 
816  pOutResult.m_fDistance = m_fCameraDistanceFilter;
817  }
818 
819  #ifdef ENABLE_DIAG
820  if (DiagMenu.GetValue(SCR_DebugMenuID.DEBUGUI_DRAW_CAMERA_COLLISION_SOLVER))
821  {
822  int baseColor = ARGB(255, 0, 110, 255);
823  ShapeFlags shFlags = ShapeFlags.WIREFRAME|ShapeFlags.ONCE;
824 
825  Shape.CreateSphere(ARGB(255, 255, 255, 255), shFlags, inputCameraPosWS, param.Radius); // WHITE
826 
827  Shape.CreateSphere(ARGB(255, 0, 255, 0), shFlags, sideTraceStart, param.Radius); // GREEN
828  Shape.CreateSphere(ARGB(255, 255, 255 * rightTrace, 0), shFlags, sideTraceEnd, param.Radius); // YELLOW - RED
829 
830  for (int i = 0; i < N; ++i)
831  {
832  vector rayStart = backTraceStart + traceOffset[i];
833  vector rayEnd = backTraceEnd + traceOffset[i];
834 
835  Shape.CreateSphere(ARGB(255, 150, 0, 255), shFlags, rayStart, param.Radius * 0.2); // PURPLE
836  Shape.CreateSphere(ARGB(255, 0, 255, 255), shFlags, vector.Lerp(rayStart, rayEnd, Math.Lerp(0.05, 0.4, backTrace) * rayBackTrace[i]), param.Radius * 0.1);
837  // ^ TEAL
838  }
839 
840  if (backTrace < 1)
841  Shape.CreateSphere(ARGB(255, 255, 255 * backTrace, 0), shFlags, backTraceStart + (backTraceEnd - backTraceStart).Normalized() * (m_fCameraDistanceFilter - param.Radius), param.Radius * (1 - backTrace));
842  }
843  #endif
844  }
845 
846  // Return the camera position in local space with applied slide, distance is applied only if camera is in world space.
847  Math3D.MatrixCopy(camTransformLS, resCamTM);
848 
849  if (pOutResult.m_fPositionModelSpace < 2.0 && pOutResult.m_fDistance > 0.0)
850  {
851  vector camBoomDir = pOutResult.m_vBacktraceDir.Multiply3(charRot);
852  camBoomDir = vector.Lerp(resCamTM[2], camBoomDir, pOutResult.m_fUseBacktraceDir);
853 
854  resCamTM[3] = resCamTM[3] - pOutResult.m_fDistance * camBoomDir;
855  }
856  }
857 
858  //------------------------------------------------------------------------------------------------
859  private void UpdateViewBob(float pDt)
860  {
861  int stance = m_ControllerComponent.GetStance();
862 
863  // Adjust bob from freelook
864  float freeLookOffsetScale = 0;
865  if (m_ControllerComponent.IsFreeLookEnabled() || m_ControllerComponent.IsTrackIREnabled())
866  freeLookOffsetScale = 1;
867 
868  m_fBobFreelokFilter = Math.SmoothCD(m_fBobFreelokFilter, 1 - Math.Pow(1 - freeLookOffsetScale, 3), m_fBobFreelokFilterVel, 0.3, 1000, pDt);
869  freeLookOffsetScale = m_fBobFreelokFilter;
870 
871  // Add bobbing based on speed
872  m_fBob_ScaleFast = Math.Clamp(m_ControllerComponent.GetVelocity().Length() / Math.Max(m_AnimationComponent.GetTopSpeed(-1, false), 0.1), 0, 1);
874 
875  m_fBob_ScaleFast = Math.Pow(m_fBob_ScaleSlow, 3);
876  m_fBob_ScaleFast = Math.Clamp(m_fBob_ScaleFast + freeLookOffsetScale * m_fBob_ScaleFast, 0, 1);
877  if (m_fBob_ScaleFast < 0.01)
878  {
879  m_fBob_Up *= 1 - pDt;
880  m_fBob_Right *= 1 - pDt;
881  }
882  else
883  {
884  float stanceBobScale = 0.5;
885  if (stance == ECharacterStance.PRONE)
886  stanceBobScale = 0.25;
887  else if (stance == ECharacterStance.CROUCH)
888  stanceBobScale = 0.55;
889 
890  m_fBob_Up += Math.Clamp(pDt * 2 * stanceBobScale * m_fBob_ScaleFast, 0, 1);
891  if (m_fBob_Up >= 1)
892  m_fBob_Up -= 1;
893 
894  m_fBob_Right += Math.Clamp(pDt * 2.5 * stanceBobScale * m_fBob_ScaleFast, 0, 1);
895  if (m_fBob_Right >= 1)
896  m_fBob_Right -= 1;
897  }
898  }
899 
900  //------------------------------------------------------------------------------------------------
906  float AddViewBobToTransform(inout vector pOutTransform[4], float pBobScale, bool pAllowTranslation)
907  {
908  // Add bob
909  float bobMoveScale = (m_fBob_ScaleFast * 0.8 + 0.2) * pBobScale;
910  if( pAllowTranslation )
911  {
912  float freeLookOffsetScale = m_fBobFreelokFilter;
913  float bobFw = m_fBob_ScaleSlow * -0.5 * m_fBob_ScaleFast * (1 - freeLookOffsetScale);
914  float bobUp = Math.Sin(m_fBob_Up * 360 * Math.DEG2RAD) * 0.02 * bobMoveScale;
915  float bobRt = Math.Sin(m_fBob_Right * 360 * Math.DEG2RAD) * 0.015 * bobMoveScale;
916  bobRt += m_fBob_ScaleSlow * -0.2 * m_fBob_ScaleFast;
917  vector bobTranslation = pOutTransform[0] * bobRt + pOutTransform[3];
918  bobTranslation = pOutTransform[1] * bobUp + bobTranslation;
919  pOutTransform[3] = pOutTransform[2] * bobFw + bobTranslation;
920  }
921 
922  vector angBob = vector.Zero;
923  angBob[0] = Math.Sin(m_fBob_Up * 360 * Math.DEG2RAD) * 0.3 * bobMoveScale; // YAW < >
924  angBob[1] = Math.Sin(m_fBob_Right * 360 * Math.DEG2RAD) * 0.3 * bobMoveScale; // PITCH ^ v
925  // ROLL REMOVED, AS ITS ONLY PERCEIVABLE EFFECT WAS THAT IT CAUSES STRONG HEAD BOB WHEN LOOKING DIRECTLY AT GROUND
926  vector angBobMat[3], endBobmat[3];
927  Math3D.AnglesToMatrix(angBob * pBobScale, angBobMat);
928  Math3D.MatrixMultiply3(angBobMat, pOutTransform, endBobmat);
929  pOutTransform[0] = endBobmat[0];
930  pOutTransform[1] = endBobmat[1];
931  pOutTransform[2] = endBobmat[2];
932 
933  return m_fBob_ScaleFast;
934  }
935 
936  //------------------------------------------------------------------------------------------------
937  private void UpdateAiming(vector transformMS[4])
938  {
939  return;
940 
941 // vector characterMat[4];
942 // m_OwnerCharacter.GetWorldTransform(characterMat);
943 //
944 // if( Is3rdPersonView() )
945 // {
946 // vector dirLS = transformMS[2];
947 // vector dirWS = dirLS.Multiply3(characterMat);
948 // vector aimposLS = transformMS[3];
949 // vector aimposWS = aimposLS.Multiply4(characterMat);
950 //
951 // // Trace aiming for 3rd person
952 // autoptr TraceParam param = new TraceParam;
953 // param.Start = aimposWS + dirWS * 3;
954 // param.End = param.Start + dirWS * 100;
955 // param.Flags = TraceFlags.WORLD | TraceFlags.ENTS;
956 // param.Exclude = m_OwnerCharacter;
957 // param.LayerMask = TRACE_LAYER_CAMERA;
958 // vector aimpos = param.End;
959 //
960 // float traced = m_OwnerCharacter.GetWorld().TraceMove(param, null);
961 // if (traced < 1)
962 // aimpos = (param.End - param.Start) * traced + param.Start;
963 //
964 // m_ControllerComponent.SetLookAtPosition(aimpos);
965 // if (m_ControllerComponent.IsFreeLookEnabled() || m_ControllerComponent.IsWeaponObstructed())
966 // m_ControllerComponent.SetAimPosition(vector.Zero);
967 // else
968 // m_ControllerComponent.SetAimPosition(aimpos);
969 // }
970 // else
971 // {
972 // m_ControllerComponent.SetAimPosition(vector.Zero);
973 // m_ControllerComponent.SetLookAtPosition(vector.Zero);
974 // }
975  }
976 
977  //------------------------------------------------------------------------------------------------
980  {
981  return !IsDebugView() && IsInThirdPerson() && !(m_ControllerComponent && m_ControllerComponent.IsWeaponADS());
982  }
983 
984  private SCR_ChimeraCharacter m_OwnerCharacter;
986  private CharacterAnimationComponent m_AnimationComponent;
987  private InputManager m_InputManager;
988  private EquipedLoadoutStorageComponent m_LoadoutStorage;
989  private CharacterIdentityComponent m_IdentityComponent;
990  private CharacterCommandHandlerComponent m_CmdHandler;
991 
992  static private float sm_fDistanceEpsilon = 0.0001;
993 
994  private bool m_bApplySmoothedSlideThisFrame = true;
995  private float m_fTargetSlide = 1;
996  private float m_fSlideTime = 0.4;
997  private float m_fCameraSlideFilter = 0;
998  private float m_fCameraSlideFilterVelocity = 0;
999  private float m_fChangedTimer = 0;
1000  private float m_fSlideTimeout = 0.4;
1001  private float m_fBob_Up = 0;
1002  private float m_fBob_Right = 0;
1003  private float m_fBob_ScaleSlow = 0;
1004  private float m_fBob_ScaleFast = 0;
1005  private int m_iHeadBoneIndex = -1;
1006  private float m_fTargetDistance = 0.0;
1007  private float m_fCameraDistanceFilter;
1009  private float m_fBobFreelokFilter;
1010  private float m_fBobFreelokFilterVel;
1011  private bool m_bPrevSlideDirectionInside = false;
1012  private bool m_b3rdCollision_UseLeftShoulder = false;
1013 
1015 
1016  //------------------------------------------------------------------------------------------------
1017  private void ResetSlide()
1018  {
1020  m_fTargetSlide = 1;
1022  m_fChangedTimer = 0;
1023  }
1024 
1025  //------------------------------------------------------------------------------------------------
1026  private bool ApplySmoothedSlide(float pDt, float slide, vector sideTraceStart, vector sideTraceDiff, float sideTraceMarginMultiplier, float shoulderDist, inout vector inoutMat[4])
1027  {
1028  // Slide will only be enabled in one branch.
1030 
1031  bool slideInside = Math.AbsFloat(slide) < Math.AbsFloat(m_fCameraSlideFilter);
1032  // Apply timer only when direction of slide is changed
1033  if (m_bPrevSlideDirectionInside && !slideInside)
1035 
1036  m_bPrevSlideDirectionInside = slideInside;
1037 
1038  if (m_fChangedTimer > 0)
1039  {
1041  }
1042 
1043  // No smoothing while we are switching shoulders.
1044  if (Math.AbsFloat(shoulderDist) < 0.98 && m_fCameraSlideFilter > slide)
1045  {
1046  m_fCameraSlideFilter = slide;
1048  inoutMat[3] = sideTraceStart + sideTraceDiff * m_fCameraSlideFilter;
1049  return slideInside;
1050  }
1051 
1052  // Hard limit for the maximum slide to the side is the trace distance.
1053  if (slideInside && m_fCameraSlideFilter > slide * sideTraceMarginMultiplier)
1054  {
1055  m_fCameraSlideFilter = slide;
1057  }
1058  else
1059  {
1060  if (IsCameraBlending())
1061  m_fChangedTimer = 0;
1062 
1063  if (m_fChangedTimer <= 0 && m_fCameraSlideFilter != slide)
1064  {
1065  float slideTime = m_fSlideTimeout;
1066 
1067  // The aim of this is to increase the speed of adjusting to the target if current slide puts
1068  // the camera too close to the wall (so that we don't reach the above hard limit as easily).
1069  if (slideInside)
1070  {
1071  float slideT = sideTraceMarginMultiplier * ((m_fCameraSlideFilter)/Math.Max(0.01, slide * sideTraceMarginMultiplier) - (1/sideTraceMarginMultiplier));
1072  slideTime = Math.Lerp(0.1, m_fSlideTimeout, Math.Clamp(slideT, 0, 1));
1073  }
1074 
1075  // Set up data for slide smoothing for next frame.
1077  m_fTargetSlide = slide;
1078  m_fSlideTime = slideTime;
1079  }
1080  }
1081 
1082  inoutMat[3] = sideTraceStart + sideTraceDiff * m_fCameraSlideFilter;
1083  return slideInside;
1084  }
1085 
1086  //------------------------------------------------------------------------------------------------
1087  protected bool CanUseOverlayCameraFOV()
1088  {
1090  {
1091  EWeaponObstructedState obstructedState = m_ControllerComponent.GetWeaponObstructedState();
1092  if (obstructedState >= EWeaponObstructedState.SLIGHTLY_OBSTRUCTED_CAN_FIRE)
1093  return false;
1094  }
1095 
1096  return true;
1097  }
1098 
1099  //------------------------------------------------------------------------------------------------
1101  {
1102  if (!m_ControllerComponent)
1103  return 0.0;
1104 
1105  if (m_ControllerComponent.IsFreeLookEnabled())
1106  return 0.0;
1107 
1108  if (!CanUseOverlayCameraFOV())
1109  return 0.0;
1110 
1111  return m_fADSProgress;
1112  }
1113 
1114  //------------------------------------------------------------------------------------------------
1117  {
1118  return m_pRecoilShakeParams;
1119  }
1120 
1121  //------------------------------------------------------------------------------------------------
1123  static void SetOverlayCameraFOV(float fov)
1124  {
1125  s_fOverlayCameraFOV = fov;
1126  }
1127 
1128  //------------------------------------------------------------------------------------------------
1129  protected override event float CalculateFovScalar(notnull CameraBase mainCamera, CameraBase overlayCamera)
1130  {
1131  float fov = mainCamera.GetVerticalFOV();
1132  if (overlayCamera && s_fOverlayCameraFOV > 0)
1133  fov = Math.Lerp(fov, s_fOverlayCameraFOV, GetOverlayCameraFOVScalarWeight());
1134 
1135  return fov / 90;
1136  }
1137 
1138  //------------------------------------------------------------------------------------------------
1141  {
1142  return m_bCameraActive;
1143  }
1144 }
m_InputManager
private InputManager m_InputManager
Definition: CharacterCameraHandlerComponent.c:987
m_fCameraSlideFilter
private float m_fCameraSlideFilter
Definition: CharacterCameraHandlerComponent.c:997
m_bWasVehicleADS
private bool m_bWasVehicleADS
Definition: CharacterCameraHandlerComponent.c:119
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
ShouldForceFirstPersonInThirdPerson
protected bool ShouldForceFirstPersonInThirdPerson(CharacterControllerComponent controller)
Definition: CharacterCameraHandlerComponent.c:310
Attribute
SCR_CharacterCameraHandlerComponentClass CameraHandlerComponentClass Attribute(category:"Camera Shake")
Definition: CharacterCameraHandlerComponent.c:8
m_fCameraDistanceFilterVel
private float m_fCameraDistanceFilterVel
Definition: CharacterCameraHandlerComponent.c:1008
UpdateAiming
private void UpdateAiming(vector transformMS[4])
Definition: CharacterCameraHandlerComponent.c:937
CameraSelector
override int CameraSelector()
selects next camera
Definition: CharacterCameraHandlerComponent.c:161
SCR_PlayerController
Definition: SCR_PlayerController.c:31
SCR_RecoilCameraShakeProgress
Definition: SCR_RecoilCameraShakeProgress.c:4
m_fChangedTimer
private float m_fChangedTimer
Definition: CharacterCameraHandlerComponent.c:999
IsCameraBlending
proto external bool IsCameraBlending()
returns true if there's more than one processing camera
m_fTargetDistance
private float m_fTargetDistance
Definition: CharacterCameraHandlerComponent.c:1006
ECharacterLifeState
ECharacterLifeState
Definition: ECharacterLifeState.c:12
FOCUS_DEFAULT_ADS_TIME
const protected float FOCUS_DEFAULT_ADS_TIME
Definition: CharacterCameraHandlerComponent.c:421
AddViewBobToTransform
float AddViewBobToTransform(inout vector pOutTransform[4], float pBobScale, bool pAllowTranslation)
Definition: CharacterCameraHandlerComponent.c:906
CanUseOverlayCameraFOV
protected bool CanUseOverlayCameraFOV()
Definition: CharacterCameraHandlerComponent.c:1087
m_fFocusTime
protected float m_fFocusTime
Definition: CharacterCameraHandlerComponent.c:425
IsCameraActive
bool IsCameraActive()
Definition: CharacterCameraHandlerComponent.c:1140
m_AnimationComponent
private CharacterAnimationComponent m_AnimationComponent
Definition: CharacterCameraHandlerComponent.c:986
UpdateHeadVisibility
void UpdateHeadVisibility(vector cameraPositionWS)
Definition: CharacterCameraHandlerComponent.c:554
m_fSlideTimeout
private float m_fSlideTimeout
Definition: CharacterCameraHandlerComponent.c:1000
ECharacterStance
ECharacterStance
Definition: ECharacterStance.c:12
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GetCameraTransitionTime
override float GetCameraTransitionTime(int pFrom, int pTo)
get how long should transition between given cameras be
Definition: CharacterCameraHandlerComponent.c:325
m_fBobFreelokFilterVel
private float m_fBobFreelokFilterVel
Definition: CharacterCameraHandlerComponent.c:1010
CheckVehicleADS
bool CheckVehicleADS()
Definition: CharacterCameraHandlerComponent.c:124
UpdateShake
protected void UpdateShake(float pDt)
Definition: CharacterCameraHandlerComponent.c:567
IsInThirdPerson
proto external bool IsInThirdPerson()
Returns true if the camera is in third person mode.
IsDebugView
bool IsDebugView()
Definition: CharacterCameraHandlerComponent.c:110
CharacterMovementState
Definition: CharacterMovementState.c:15
OnCameraSwitchPressed
void OnCameraSwitchPressed()
Definition: CharacterCameraHandlerComponent.c:594
m_CmdHandler
private CharacterCommandHandlerComponent m_CmdHandler
Definition: CharacterCameraHandlerComponent.c:990
ApplySmoothedSlide
private bool ApplySmoothedSlide(float pDt, float slide, vector sideTraceStart, vector sideTraceDiff, float sideTraceMarginMultiplier, float shoulderDist, inout vector inoutMat[4])
Definition: CharacterCameraHandlerComponent.c:1026
m_fBobFreelokFilter
private float m_fBobFreelokFilter
Definition: CharacterCameraHandlerComponent.c:1009
FOCUS_DECELERATION_RATIO
const protected float FOCUS_DECELERATION_RATIO
Definition: CharacterCameraHandlerComponent.c:420
m_iHeadBoneIndex
private int m_iHeadBoneIndex
Definition: CharacterCameraHandlerComponent.c:1005
SCR_CharacterControllerComponent
Definition: SCR_CharacterControllerComponent.c:35
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
m_fFocusValue
protected float m_fFocusValue
Definition: CharacterCameraHandlerComponent.c:432
AddShakeToToTransform
void AddShakeToToTransform(inout vector transform[4], inout float fieldOfView)
Definition: CharacterCameraHandlerComponent.c:578
m_fAutoFocusProgress
protected float m_fAutoFocusProgress
Definition: CharacterCameraHandlerComponent.c:433
SCR_Math3D
Contains various scripted 3D math functions.
Definition: SCR_Math3D.c:2
LoadoutHeadCoverArea
Definition: LoadoutHeadCoverArea.c:12
m_fFocusDeceleration
protected float m_fFocusDeceleration
Definition: CharacterCameraHandlerComponent.c:428
m_fCameraSlideFilterVelocity
private float m_fCameraSlideFilterVelocity
Definition: CharacterCameraHandlerComponent.c:998
m_bApplySmoothedSlideThisFrame
private bool m_bApplySmoothedSlideThisFrame
Definition: CharacterCameraHandlerComponent.c:994
m_b3rdCollision_UseLeftShoulder
private bool m_b3rdCollision_UseLeftShoulder
Definition: CharacterCameraHandlerComponent.c:1012
CalculateFovScalar
protected override event float CalculateFovScalar(notnull CameraBase mainCamera, CameraBase overlayCamera)
Definition: CharacterCameraHandlerComponent.c:1129
CharacterCameraSet
Definition: CharacterCameraSet.c:1
SetThirdPerson
proto external void SetThirdPerson(bool val)
Set the current third person camera state.
OnCameraActivate
override void OnCameraActivate()
activation
Definition: CharacterCameraHandlerComponent.c:50
m_fBob_ScaleFast
private float m_fBob_ScaleFast
Definition: CharacterCameraHandlerComponent.c:1004
ResetSlide
private void ResetSlide()
Definition: CharacterCameraHandlerComponent.c:1017
m_fTargetSlide
private float m_fTargetSlide
Definition: CharacterCameraHandlerComponent.c:995
TRACE_LAYER_CAMERA
const int TRACE_LAYER_CAMERA
Definition: Constants.c:14
OnThirdPersonSwitch
override void OnThirdPersonSwitch(bool isInThirdPerson)
when we switch between FPP and TPP
Definition: CharacterCameraHandlerComponent.c:399
GetRecoilShakeParams
SCR_RecoilCameraShakeParams GetRecoilShakeParams()
Definition: CharacterCameraHandlerComponent.c:1116
Is3rdPersonView
bool Is3rdPersonView()
Definition: CharacterCameraHandlerComponent.c:979
SCR_CharacterCameraHandlerComponentClass
Definition: CharacterCameraHandlerComponent.c:2
Init
override void Init()
initialization
Definition: CharacterCameraHandlerComponent.c:35
m_OwnerCharacter
private SCR_ChimeraCharacter m_OwnerCharacter
Definition: CharacterCameraHandlerComponent.c:984
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
m_fSlideTime
private float m_fSlideTime
Definition: CharacterCameraHandlerComponent.c:996
GetCurrentCamera
proto external ScriptedCameraItem GetCurrentCamera()
returns current active camera
OnBeforeCameraUpdate
override void OnBeforeCameraUpdate(float pDt, bool pIsKeyframe)
before camera update
Definition: CharacterCameraHandlerComponent.c:436
m_IdentityComponent
private CharacterIdentityComponent m_IdentityComponent
Definition: CharacterCameraHandlerComponent.c:989
CharacterCommandMove
CharacterCommandMove.
Definition: CharacterCommandMove.c:13
OnAfterCameraUpdate
override void OnAfterCameraUpdate(float pDt, bool pIsKeyframe, inout vector transformMS[4], inout vector transformWS[4])
after camera update
Definition: CharacterCameraHandlerComponent.c:535
m_LoadoutStorage
private EquipedLoadoutStorageComponent m_LoadoutStorage
Definition: CharacterCameraHandlerComponent.c:988
m_fBob_Up
private float m_fBob_Up
Definition: CharacterCameraHandlerComponent.c:1001
CheckIsInTurret
bool CheckIsInTurret(out bool isInAds)
Definition: CharacterCameraHandlerComponent.c:134
SetFocusMode
proto external void SetFocusMode(float focusMode)
Set the current value of the focus mode.
TurretControllerComponent
Definition: TurretControllerComponent.c:12
m_fADSTime
protected float m_fADSTime
Definition: CharacterCameraHandlerComponent.c:322
OnCameraDeactivate
override void OnCameraDeactivate()
deactivation
Definition: CharacterCameraHandlerComponent.c:96
m_fBob_ScaleSlow
private float m_fBob_ScaleSlow
Definition: CharacterCameraHandlerComponent.c:1003
OnAlphatestChange
void OnAlphatestChange(int a)
Definition: CharacterCameraHandlerComponent.c:76
BaseLoadoutClothComponent
Definition: BaseLoadoutClothComponent.c:12
m_ControllerComponent
private SCR_CharacterControllerComponent m_ControllerComponent
Definition: CharacterCameraHandlerComponent.c:985
SCR_RecoilCameraShakeParams
Definition: SCR_RecoilCameraShakeParams.c:5
GetThirdPersonSwitchInvoker
ScriptInvoker GetThirdPersonSwitchInvoker()
Definition: CharacterCameraHandlerComponent.c:414
m_fCameraDistanceFilter
private float m_fCameraDistanceFilter
Definition: CharacterCameraHandlerComponent.c:1007
m_CharMovementState
private ref CharacterMovementState m_CharMovementState
Definition: CharacterCameraHandlerComponent.c:1014
EWeaponObstructedState
EWeaponObstructedState
Definition: EWeaponObstructedState.c:12
m_fADSProgress
protected float m_fADSProgress
Definition: CharacterCameraHandlerComponent.c:321
UpdateViewBob
private void UpdateViewBob(float pDt)
Definition: CharacterCameraHandlerComponent.c:859
GetOverlayCameraFOVScalarWeight
override float GetOverlayCameraFOVScalarWeight()
Definition: CharacterCameraHandlerComponent.c:1100
GetCameraSet
CameraHandlerComponentClass ScriptComponentClass GetCameraSet()
m_fBob_Right
private float m_fBob_Right
Definition: CharacterCameraHandlerComponent.c:1002
CollisionSolver
override void CollisionSolver(float pDt, inout ScriptedCameraItemResult pOutResult, inout vector resCamTM[4], bool isKeyframe)
collision solver
Definition: CharacterCameraHandlerComponent.c:601
m_bDoInterpolateFocus
protected bool m_bDoInterpolateFocus
Definition: CharacterCameraHandlerComponent.c:430
m_fFocusTargetValue
protected float m_fFocusTargetValue
Definition: CharacterCameraHandlerComponent.c:431
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3
FOCUS_ADS_TIME_RATIO
const protected float FOCUS_ADS_TIME_RATIO
Definition: CharacterCameraHandlerComponent.c:422
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
CameraHandlerComponentClass
Definition: CameraHandlerComponent.c:12
m_bPrevSlideDirectionInside
private bool m_bPrevSlideDirectionInside
Definition: CharacterCameraHandlerComponent.c:1011