Example #1
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 #2
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);
        }