2021년 4학년 1학기 기업연계프로젝트2 컴퓨터소프트웨어공학과 <원광투어팀> 팀장 : 송유진 팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.6 KiB

5 years ago
  1. //========= Copyright 2016-2020, HTC Corporation. All rights reserved. ===========
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. namespace HTC.UnityPlugin.Pointer3D
  6. {
  7. public class PhysicsRaycastMethod : BaseRaycastMethod
  8. {
  9. public enum MaskTypeEnum
  10. {
  11. Inclusive,
  12. Exclusive,
  13. }
  14. private static readonly RaycastHit[] hits = new RaycastHit[64];
  15. public MaskTypeEnum maskType;
  16. public LayerMask mask;
  17. public int RaycastMask { get { return maskType == MaskTypeEnum.Inclusive ? (int)mask : ~mask; } }
  18. #if UNITY_EDITOR
  19. protected virtual void Reset()
  20. {
  21. maskType = MaskTypeEnum.Exclusive;
  22. mask = LayerMask.GetMask("Ignore Raycast");
  23. }
  24. #endif
  25. public override void Raycast(Ray ray, float distance, List<RaycastResult> raycastResults)
  26. {
  27. var hitCount = Physics.RaycastNonAlloc(ray, hits, distance, RaycastMask);
  28. for (int i = 0; i < hitCount; ++i)
  29. {
  30. raycastResults.Add(new RaycastResult
  31. {
  32. gameObject = hits[i].collider.gameObject,
  33. module = raycaster,
  34. distance = hits[i].distance,
  35. worldPosition = hits[i].point,
  36. worldNormal = hits[i].normal,
  37. screenPosition = Pointer3DInputModule.ScreenCenterPoint,
  38. index = raycastResults.Count,
  39. sortingLayer = 0,
  40. sortingOrder = 0
  41. });
  42. }
  43. }
  44. }
  45. }