Exemple #1
0
        public void ExtrapolatePath(ISightTarget target, float secondsForward, out SightTargetSampleData[] extrapolationData)
        {
            var samples = _samplesQueue[target];

            if (_extrapolatedData.ContainsKey(target) == false)
            {
                _extrapolatedData.Add(target, new SightTargetSampleData[_config.extrapolateSampleCount]);
            }

            var extrapolationSamples = _extrapolatedData[target];

            var firstSample  = samples.First();
            var secondSample = samples.ElementAt(1);
            var dir          = secondSample.position - firstSample.position;

            for (int i = 0; i < samples.count; i++)
            {
                extrapolationSamples[i] = new SightTargetSampleData()
                {
                    position = target.transform.position + dir * i,
                    time     = LosUtility.time + (i * _config.updateInterval)
                };
            }

            extrapolationData = extrapolationSamples;
//            Debug.Log("Extrapolated path", target.gameObject);
        }
        public void ExtrapolatePath(ISightTarget target, float secondsForward, out SightTargetSampleData[] extrapolationData)
        {
            var samples = _samplesQueue[target];

            if (_extrapolatedData.ContainsKey(target) == false)
            {
                _extrapolatedData.Add(target, new SightTargetSampleData[samples.maxCount]);
            }

            var extrapolationSamples = _extrapolatedData[target];

            int counter     = 0;
            var firstSample = samples.FirstOrDefault();

            foreach (var currentSample in samples)
            {
                extrapolationSamples[counter] = new SightTargetSampleData()
                {
                    position = target.transform.position + (currentSample.position - firstSample.position),
                    rotation = target.transform.rotation * (Quaternion.Inverse(currentSample.rotation) * firstSample.rotation), // * by inverse gives dif.
                    time     = LosUtility.time + (currentSample.time - firstSample.time)
                };

                counter++;
            }

            extrapolationData = extrapolationSamples;
        }
Exemple #3
0
 private void GetCurrentPositionSample(SightTargetInfo sightInfo, out SightTargetSampleData?sample)
 {
     sample = new SightTargetSampleData()
     {
         position = sightInfo.target.transform.position,
         rotation = sightInfo.target.transform.rotation,
         time     = LosUtility.time
     };
 }