Example #1
0
 public void CountingForRangeIntersectionCalculator(RangeIntersectionCalculator rangeIntersectionCalculator)
 {
     if (rangeIntersectionCalculator.GetAssociatedRangeObjectType() == RangeType.SPHERE)
     {
         this.totalSphereTypeIntersection += 1;
     }
 }
Example #2
0
        public bool ForRangeInteresectionCalculator(RangeIntersectionCalculator rangeIntersectionCalculator, ObstacleOcclusionCalculationManagerV2 ObstacleOcclusionCalculationManagerV2,
                                                    out IsOccludedByObstacleJobData IsOccludedByObstacleJobData)
        {
            int ObstacleFrustumPointsPositionsBeginIndex = currentObstacleFrustumPointsCounter;
            var associatedObstacleListener = rangeIntersectionCalculator.GetAssociatedObstacleListener();

            if (associatedObstacleListener != null)
            {
                //obstacle listener may never have triggered calculation
                ObstacleOcclusionCalculationManagerV2.TryGetCalculatedOcclusionFrustumsForObstacleListener(associatedObstacleListener, out Dictionary <int, List <FrustumPointsPositions> > calculatedFrustumPositions);
                if (calculatedFrustumPositions != null)
                {
                    foreach (var calculatedObstacleFrustumList in calculatedFrustumPositions.Values)
                    {
                        foreach (var calculatedObstacleFrustum in calculatedObstacleFrustumList)
                        {
                            this.AssociatedObstacleFrustumPointsPositions[currentObstacleFrustumPointsCounter] = calculatedObstacleFrustum;
                            currentObstacleFrustumPointsCounter += 1;
                        }
                    }
                }

                IsOccludedByObstacleJobData = new IsOccludedByObstacleJobData
                {
                    TestedBoxCollider = new BoxDefinition(rangeIntersectionCalculator.TrackedInteractiveObject.InteractiveGameObject.GetLogicColliderAsBox()),
                    ObstacleFrustumPointsPositionsBeginIndex = ObstacleFrustumPointsPositionsBeginIndex,
                    ObstacleFrustumPointsPositionsEndIndex   = currentObstacleFrustumPointsCounter
                };
                return(true);
            }

            IsOccludedByObstacleJobData = default;
            return(false);
        }
Example #3
0
 public void CountingForRangeIntersectionCalculator(RangeIntersectionCalculator rangeIntersectionCalculator)
 {
     if (rangeIntersectionCalculator.GetAssociatedRangeObjectType() == RangeType.ROUNDED_FRUSTUM)
     {
         this.totalRoundedFrustumTypeIntersection += 1;
     }
 }
Example #4
0
        /// <summary>
        /// Build the <see cref="VisibilityProbeIntersectionJobData"/> and feed the <see cref="VisibilityProbeLocalPoints"/> based on targetted interactive object probe.
        /// </summary>
        private VisibilityProbeIntersectionJobData CalculatingVisibilityProbeJobData(RangeIntersectionCalculator RangeIntersectionCalculatorV2, ref int currentVisibilityProbeLocalPointsCounter)
        {
            var visibilityProbes = RangeIntersectionCalculatorV2.TrackedInteractiveObject.InteractiveGameObject.VisibilityProbe;
            VisibilityProbeIntersectionJobData visibilityProbeIntersectionJobData = default;

            if (visibilityProbes.LocalPoints != null && visibilityProbes.LocalPoints.Length > 0)
            {
                int startIndex = currentVisibilityProbeLocalPointsCounter;
                int endIndex   = startIndex;
                for (int i = 0; i < visibilityProbes.LocalPoints.Length; i++)
                {
                    this.VisibilityProbeLocalPoints[currentVisibilityProbeLocalPointsCounter] = visibilityProbes[i];
                    endIndex = currentVisibilityProbeLocalPointsCounter;
                    currentVisibilityProbeLocalPointsCounter += 1;
                }

                visibilityProbeIntersectionJobData = new VisibilityProbeIntersectionJobData()
                {
                    VisibilityProbeLocalToWorld = RangeIntersectionCalculatorV2.TrackedInteractiveObject.InteractiveGameObject.LogicCollider.transform.localToWorldMatrix,
                    VisibilityProbePositionsBeginIndexIncluded = startIndex,
                    VisibilityProbePositionsEndIndexIncluded   = endIndex
                };
            }

            return(visibilityProbeIntersectionJobData);
        }
Example #5
0
 protected override void OnJustNotIntersected(RangeIntersectionCalculator intersectionCalculator)
 {
     if (OnJustNotIntersectedAction != null)
     {
         OnJustNotIntersectedAction.Invoke(intersectionCalculator.TrackedInteractiveObject);
     }
 }
Example #6
0
 protected override void OnInterestedNothing(RangeIntersectionCalculator intersectionCalculator)
 {
     if (OnInterestedNothingAction != null)
     {
         OnInterestedNothingAction.Invoke(intersectionCalculator.TrackedInteractiveObject);
     }
 }
Example #7
0
 public int OnRangeIntersectionCalculatorV2ManagerCreation(RangeIntersectionCalculator rangeIntersectionCalculator)
 {
     this.AllRangeIntersectionCalculatorV2.Add(rangeIntersectionCalculator);
     this.CurrentRangeIntersectionCalculatorV2ManagerCounter += 1;
     rangeIntersectionCalculator.GetAssociatedRangeObject().RegisterOnRangeObjectDestroyedEventListener(this.OnRangeObjectDestroyed);
     rangeIntersectionCalculator.TrackedInteractiveObject.RegisterInteractiveObjectDestroyedEventListener(this.OnTrackedInteractiveObjectDestroyed);
     return(this.CurrentRangeIntersectionCalculatorV2ManagerCounter);
 }
Example #8
0
 private void SingleJustExited(RangeIntersectionCalculator justTriggerExitedRangeIntersectionCalculator)
 {
     //Debug.Log("JustTriggeredExit : " + justTriggerExitedCalculatorIndex + " " + this.justTriggerExitedCalculators.Count);
     OnJustNotIntersected(justTriggerExitedRangeIntersectionCalculator);
     justTriggerExitedRangeIntersectionCalculator.OnDestroy();
     justTriggerExitedCalculatorsIndexedByTrackedInteractiveObject.Remove(justTriggerExitedRangeIntersectionCalculator.TrackedInteractiveObject);
     justTriggerExitedCalculators.Remove(justTriggerExitedRangeIntersectionCalculator);
 }
Example #9
0
        public sealed override void OnTriggerEnter(RangeObjectPhysicsTriggerInfo PhysicsTriggerInfo)
        {
            var rangeIntersectionCalculator = new RangeIntersectionCalculator(associatedRangeObject, PhysicsTriggerInfo.OtherInteractiveObject);

            intersectionCalculators.Add(rangeIntersectionCalculator);
            intersectionCalculatorsIndexedByTrackedInteractiveObject[PhysicsTriggerInfo.OtherInteractiveObject] = rangeIntersectionCalculator;
            OnTriggerEnterSuccess(PhysicsTriggerInfo);
        }
Example #10
0
        public sealed override void OnTriggerEnter(InteractiveObjectPhysicsTriggerInfo PhysicsTriggerInfo)
        {
            PhysicsTriggerInfo.OtherInteractiveObject.RegisterInteractiveObjectDestroyedEventListener(this.OnInteractiveObjectDestroyed);
            var rangeIntersectionCalculator = new RangeIntersectionCalculator(associatedRangeObject, PhysicsTriggerInfo.OtherInteractiveObject);

            intersectionCalculators.Add(rangeIntersectionCalculator);
            intersectionCalculatorsIndexedByTrackedInteractiveObject[PhysicsTriggerInfo.OtherInteractiveObject] = rangeIntersectionCalculator;
            OnTriggerEnterSuccess(PhysicsTriggerInfo);
        }
Example #11
0
        private void SingleCalculation(RangeIntersectionCalculator intersectionCalculator)
        {
            var intersectionOperation = intersectionCalculator.Tick();

            if (intersectionOperation == InterserctionOperationType.JustInteresected)
            {
                OnJustIntersected(intersectionCalculator);
            }
            else if (intersectionOperation == InterserctionOperationType.JustNotInteresected)
            {
                OnJustNotIntersected(intersectionCalculator);
            }
            else if (intersectionOperation == InterserctionOperationType.IntersectedNothing)
            {
                OnInterestedNothing(intersectionCalculator);
            }
        }
Example #12
0
 public void CalculationDataSetupForRangeIntersectionCalculator(RangeIntersectionCalculator rangeIntersectionCalculator,
                                                                IsOccludedByObstacleJobData IsOccludedByObstacleJobData, int currentObstacleIntersectionCalculatorCounter)
 {
     if (rangeIntersectionCalculator.GetAssociatedRangeObjectType() == RangeType.SPHERE)
     {
         var SphereRangeObject         = (SphereRangeObjectV2)rangeIntersectionCalculator.GetAssociatedRangeObject();
         var SphereIntersectionJobData = new SphereIntersectionJobData
         {
             RangeIntersectionCalculatorV2UniqueID = rangeIntersectionCalculator.RangeIntersectionCalculatorV2UniqueID,
             RangeTransform = SphereRangeObject.GetTransform(),
             IsOccludedByObstacleJobData  = IsOccludedByObstacleJobData,
             ComparedCollider             = rangeIntersectionCalculator.TrackedInteractiveObject.InteractiveGameObject.GetLogicColliderBoxDefinition(),
             ObstacleCalculationDataIndex = SphereRangeObject.GetObstacleListener() == null ? -1 : (currentObstacleIntersectionCalculatorCounter - 1),
             SphereRadius = SphereRangeObject.SphereBoundingCollider.radius
         };
         this.SphereIntersectionJobData[this.currentSphereIntersectionJobdataCounter] = SphereIntersectionJobData;
         this.currentSphereIntersectionJobdataCounter += 1;
     }
 }
Example #13
0
 public void CalculationDataSetupForRangeIntersectionCalculator(RangeIntersectionCalculator rangeIntersectionCalculator,
                                                                IsOccludedByObstacleJobData IsOccludedByObstacleJobData, int currentObstacleIntersectionCalculatorCounter)
 {
     if (rangeIntersectionCalculator.GetAssociatedRangeObjectType() == RangeType.ROUNDED_FRUSTUM)
     {
         var RoundedFrustumRangeObject         = (RoundedFrustumRangeObjectV2)rangeIntersectionCalculator.GetAssociatedRangeObject();
         var RoundedFrustumIntersectionJobData = new RoundedFrustumIntersectionJobData
         {
             RangeIntersectionCalculatorV2UniqueID = rangeIntersectionCalculator.RangeIntersectionCalculatorV2UniqueID,
             FrustumRadius  = RoundedFrustumRangeObject.GetFrustum().GetFrustumFaceRadius(),
             RangeTransform = RoundedFrustumRangeObject.GetTransform(),
             IsOccludedByObstacleJobData  = IsOccludedByObstacleJobData,
             RoundedFrustumPositions      = RoundedFrustumRangeObject.GetFrustumWorldPositions(),
             ComparedCollider             = rangeIntersectionCalculator.TrackedInteractiveObject.InteractiveGameObject.GetLogicColliderBoxDefinition(),
             ObstacleCalculationDataIndex = RoundedFrustumRangeObject.GetObstacleListener() == null ? -1 : (currentObstacleIntersectionCalculatorCounter - 1)
         };
         this.RoundedFrustumIntersectionJobData[currentRoundedFrustumIntersectionJobDataCounter] = RoundedFrustumIntersectionJobData;
         currentRoundedFrustumIntersectionJobDataCounter += 1;
     }
 }
Example #14
0
        // Try to get all occlusion frustums fro mthe obstacle listener and push them in the AssociatedObstacleFrustumPointsPositions.
        // Returns the index range of insertion of AssociatedObstacleFrustumPointsPositions.
        public bool ForRangeInteresectionCalculator(RangeIntersectionCalculator rangeIntersectionCalculator, ObstacleOcclusionCalculationManagerV2 ObstacleOcclusionCalculationManagerV2,
                                                    out IsOccludedByObstacleJobData IsOccludedByObstacleJobData)
        {
            int ObstacleFrustumPointsPositionsBeginIndex = currentObstacleFrustumPointsCounter;
            var associatedObstacleListener = rangeIntersectionCalculator.GetAssociatedObstacleListener();

            if (associatedObstacleListener != null)
            {
                //obstacle listener may never have triggered calculation
                ObstacleOcclusionCalculationManagerV2.TryGetCalculatedOcclusionFrustumsForObstacleListener(associatedObstacleListener, out Dictionary <int, List <FrustumPointsPositions> > calculatedFrustumPositions);
                if (calculatedFrustumPositions != null)
                {
                    var calculatedFrustumPositionsEnumerator = calculatedFrustumPositions.Values.GetEnumerator();
                    while (calculatedFrustumPositionsEnumerator.MoveNext())
                    {
                        var calculatedObstacleFrustumList = calculatedFrustumPositionsEnumerator.Current;

                        for (int calculatedObstacleFrustumIndex = 0; calculatedObstacleFrustumIndex < calculatedObstacleFrustumList.Count; calculatedObstacleFrustumIndex++)
                        {
                            this.AssociatedObstacleFrustumPointsPositions[currentObstacleFrustumPointsCounter] = calculatedObstacleFrustumList[calculatedObstacleFrustumIndex];
                            currentObstacleFrustumPointsCounter += 1;
                        }
                    }
                }

                IsOccludedByObstacleJobData = new IsOccludedByObstacleJobData
                {
                    ObstacleFrustumPointsPositionsBeginIndex = ObstacleFrustumPointsPositionsBeginIndex,
                    ObstacleFrustumPointsPositionsEndIndex   = currentObstacleFrustumPointsCounter
                };
                return(true);
            }

            IsOccludedByObstacleJobData = default;
            return(false);
        }
Example #15
0
 public void TryGetRangeintersectionResult(RangeIntersectionCalculator rangeIntersectionCalculator, out bool result)
 {
     GetRangeIntersectionResult().TryGetValue(rangeIntersectionCalculator.RangeIntersectionCalculatorV2UniqueID, out result);
 }
Example #16
0
 public bool GetRangeIntersectionResult(RangeIntersectionCalculator rangeIntersectionCalculator)
 {
     return(GetRangeIntersectionResult()[rangeIntersectionCalculator.RangeIntersectionCalculatorV2UniqueID]);
 }
Example #17
0
 public void OnRangeIntersectionCalculatorV2ManagerDestroyed(RangeIntersectionCalculator rangeIntersectionCalculator)
 {
     this.AllRangeIntersectionCalculatorV2.Remove(rangeIntersectionCalculator);
 }
Example #18
0
 protected virtual void OnJustNotIntersected(RangeIntersectionCalculator intersectionCalculator)
 {
 }
Example #19
0
 public int OnRangeIntersectionCalculatorV2ManagerCreation(RangeIntersectionCalculator rangeIntersectionCalculator)
 {
     this.AllRangeIntersectionCalculatorV2.Add(rangeIntersectionCalculator);
     this.CurrentRangeIntersectionCalculatorV2ManagerCounter += 1;
     return(this.CurrentRangeIntersectionCalculatorV2ManagerCounter);
 }
Example #20
0
 protected virtual void OnInterestedNothing(RangeIntersectionCalculator intersectionCalculator)
 {
 }