Ejemplo n.º 1
0
        public List<TraceResult> Trace(string destination)
        {
            var l = new List<TraceResult>();

            var tr = new TraceResult(id: _thisId);
            tr.Name = _thisName;
            tr.MachineName = System.Environment.MachineName;
            tr.Identity = System.Environment.UserDomainName;

            l.Add(tr);

            if (!string.IsNullOrEmpty(destination) && destination.ToLowerInvariant() !=  _thisName.ToLowerInvariant())
            {
                var mws = new MyWebService1.WebService1SoapClient();
                var res = mws.Trace(destination);
                foreach(var re in res)
                {
                    l.Add(new TraceResult() {
                        Id = re.Id
                        , FinishedAt = re.FinishedAt
                        , Identity = re.Identity
                        , MachineName = re.MachineName
                        , Name = re.Name
                        , Payload = re.Payload
                        , StartedAt = re.StartedAt });
                }
            }

            tr.Finish(string.Format("Pong [{0}]", destination));

            return l;
        }
        public List<TraceResult> Trace(string destination)
        {
            var l = new List<TraceResult>();

            var tr = new TraceResult(id: _thisId);
            tr.Name = _thisName;
            tr.MachineName = System.Environment.MachineName;
            tr.Identity = System.Environment.UserDomainName;

            l.Add(tr);

            switch(destination.ToLowerInvariant())
            {
                case "database1":
                    l.Add(_repo.RunTrace(destination));
                    break;
            }

            tr.Finish(string.Format("Pong [{0}]", destination));

            return l;
        }
Ejemplo n.º 3
0
 public FileWriter(TraceResult traceResult, string fileName)
 {
     result   = traceResult;
     FileName = fileName;
 }
Ejemplo n.º 4
0
        public override void OnPlayerControlTick(TankPlayer player, bool allowDebug)
        {
            float throttle  = Input.Forward;
            float steering  = Input.Left * (throttle >= 0 ? 1 : -1) * TurnSpeed;
            var   moveDelta = Rotation.Forward * throttle * MoveSpeed;

            // Corner world position
            var frontLeft  = moveDelta + Position + Rotation * (extents * new Vector3(1, 1, 0.5f));
            var frontRight = moveDelta + Position + Rotation * (extents * new Vector3(1, -1, 0.5f));
            var backLeft   = moveDelta + Position + Rotation * (extents * new Vector3(-1, 1, 0.5f));
            var backRight  = moveDelta + Position + Rotation * extents * new Vector3(-1, -1, 0.5f);
            var center     = moveDelta + Position + extents * new Vector3(0, 0, 0.5f);

            // Base world directions
            var frontDir      = Rotation.Forward;
            var leftDir       = Rotation.Left;
            var backDir       = Rotation.Backward;
            var rightDir      = Rotation.Right;
            var frontLeftDir  = (frontDir + leftDir).Normal;
            var frontRightDir = (frontDir + rightDir).Normal;
            var backLeftDir   = (backDir + leftDir).Normal;
            var backRightDir  = (backDir + rightDir).Normal;

            float testDistance = 2 * MoveSpeed;

            if (allowDebug)
            {
                /*DebugOverlay.Axis(frontLeft, Rotation);
                *  DebugOverlay.Axis(frontRight, Rotation);
                *  DebugOverlay.Axis(backLeft, Rotation);
                *  DebugOverlay.Axis(backRight, Rotation);*/
                DebugOverlay.Sphere(frontLeft, testDistance, Color.Red);
                DebugOverlay.Sphere(frontRight, testDistance, Color.Red);
                DebugOverlay.Sphere(backLeft, testDistance, Color.Red);
                DebugOverlay.Sphere(backRight, testDistance, Color.Red);
            }

            var cornerResults = new TraceResult[12];

            cornerResults[0]  = Trace.Ray(frontLeft, frontLeft + frontDir * testDistance).Run();           // Forward
            cornerResults[1]  = Trace.Ray(frontLeft, frontLeft + leftDir * testDistance).Run();            // Side
            cornerResults[2]  = Trace.Ray(frontLeft, frontLeft + frontRightDir * testDistance).Run();      // Diagonal inward
            cornerResults[3]  = Trace.Ray(frontRight, frontRight + frontDir * testDistance).Run();
            cornerResults[4]  = Trace.Ray(frontRight, frontRight + rightDir * testDistance).Run();
            cornerResults[5]  = Trace.Ray(frontRight, frontRight + frontLeftDir * testDistance).Run();
            cornerResults[6]  = Trace.Ray(backLeft, backLeft + backDir * testDistance).Run();
            cornerResults[7]  = Trace.Ray(backLeft, backLeft + leftDir * testDistance).Run();
            cornerResults[8]  = Trace.Ray(backLeft, backLeft + backRightDir * testDistance).Run();
            cornerResults[9]  = Trace.Ray(backRight, backRight + backDir * testDistance).Run();
            cornerResults[10] = Trace.Ray(backRight, backRight + rightDir * testDistance).Run();
            cornerResults[11] = Trace.Ray(backRight, backRight + backLeftDir * testDistance).Run();

            // Turn off movement and don't collide if both front or back corners are colliding (but only if pushing against an axis-aligned wall)
            bool  noMove = (cornerResults[0].Hit && cornerResults[3].Hit) || (cornerResults[6].Hit && cornerResults[9].Hit);
            float yaw    = Rotation.Yaw();

            noMove &= yaw.SnapToGrid(90).AlmostEqual(yaw, 2);
            if (noMove)
            {
                moveDelta = 0;
            }

            for (int i = 0; i < cornerResults.Length; i++)
            {
                var result = cornerResults[i];
                if (!result.Hit)
                {
                    if (allowDebug)
                    {
                        DebugOverlay.Line(result.StartPos, result.StartPos + result.Direction * testDistance * 8, Color.Green, 0, false);
                    }
                    continue;
                }
                if (i % 3 != 0 && cornerResults[i - (i % 3)].Hit)                   // Skip the side and diagonal tests if the primary one already hit
                {
                    if (allowDebug)
                    {
                        DebugOverlay.Line(result.StartPos, result.StartPos + result.Direction * testDistance * 8, Color.Yellow, 0, false);
                    }
                    continue;
                }
                if (i % 3 == 0 && noMove)
                {
                    continue;
                }
                if (allowDebug)
                {
                    DebugOverlay.Line(result.StartPos, result.StartPos + result.Direction * testDistance * 8, Color.Red, 0, false);
                }

                Position += result.Normal * (testDistance - result.Distance);
                float torque = Vector3.Cross(result.StartPos - center, result.Normal).z *Time.Delta;
                Rotation *= Rotation.FromYaw(torque);
                if (allowDebug)
                {
                    DebugOverlay.Line(result.EndPos, result.EndPos + result.Normal * MathF.Abs(torque) * 50, Color.Blue, 0, false);
                }
            }

            var edgeResults = new TraceResult[8];

            edgeResults[0] = Trace.Ray(frontLeft, frontRight).Run();
            edgeResults[2] = Trace.Ray(backLeft, backRight).Run();
            edgeResults[4] = Trace.Ray(frontLeft, backLeft).Run();
            edgeResults[6] = Trace.Ray(frontRight, backRight).Run();

            for (int i = 0; i < edgeResults.Length; i += 2)
            {
                var result = edgeResults[i];
                if (result.Hit)                   // Only run the partner trace if the first one on that edge hits
                {
                    if (i == 0)
                    {
                        edgeResults[i + 1] = Trace.Ray(frontRight, frontLeft).Run();
                    }
                    else if (i == 2)
                    {
                        edgeResults[i + 1] = Trace.Ray(backRight, backLeft).Run();
                    }
                    else if (i == 4)
                    {
                        edgeResults[i + 1] = Trace.Ray(backLeft, frontLeft).Run();
                    }
                    else if (i == 6)
                    {
                        edgeResults[i + 1] = Trace.Ray(backRight, frontRight).Run();
                    }
                }
                else
                {
                    continue;
                }

                if (allowDebug)
                {
                    DebugOverlay.Line(result.StartPos, result.EndPos, 0, false);
                }
                Vector3 correctionDir = Vector3.Zero;
                if (i == 0)
                {
                    correctionDir = frontDir;
                }
                else if (i == 2)
                {
                    correctionDir = backDir;
                }
                else if (i == 4)
                {
                    correctionDir = leftDir;
                }
                else if (i == 6)
                {
                    correctionDir = rightDir;
                }

                float distance = Vector3.DistanceBetween(result.EndPos, edgeResults[i + 1].EndPos);
                float angle    = Vector3.GetAngle(result.EndPos - result.StartPos, result.Normal) - 90;

                float correction = distance * 0.5f * MathF.Sin(2 * angle.DegreeToRadian());                 // How much to push out of the corner, finds the altitude of a right triangle
                Position -= correctionDir * correction;

                var   avgPos = (result.EndPos + edgeResults[i + 1].EndPos) * 0.5f;
                float torque = Vector3.Cross(avgPos - center, -correctionDir).z *Time.Delta;
                Rotation *= Rotation.FromYaw(torque);

                if (allowDebug)
                {
                    DebugOverlay.Line(avgPos, avgPos - correctionDir * MathF.Abs(torque) * 50, Color.Cyan, 0, false);
                    DebugOverlay.Line(result.EndPos, edgeResults[i + 1].EndPos, Color.Red, 0, false);
                    DebugOverlay.Line(result.EndPos, result.EndPos + correctionDir * correction * 10, Color.Green, 0, false);
                    DebugOverlay.Line(edgeResults[i + 1].EndPos, edgeResults[i + 1].EndPos + correctionDir * correction * 10, Color.Green, 0, false);
                }
            }

            moveDelta = moveDelta.WithZ(0);
            Position += moveDelta;
            Rotation *= Rotation.FromYaw(steering);
        }
Ejemplo n.º 5
0
 public string serialize(TraceResult result)
 {
     //optional
     //return JsonConvert.SerializeObject(result);
     return(JsonConvert.SerializeObject(result, Formatting.Indented));
 }
Ejemplo n.º 6
0
        public static void Output(ISerialization serializer, TraceResult result)
        {
            string text = serializer.Serialize <TraceResult>(result);

            Console.WriteLine(text);
        }
Ejemplo n.º 7
0
 public string Serialize(TraceResult obj)
 {
     return(JsonConvert.SerializeObject(obj, JsonSettings));
 }
Ejemplo n.º 8
0
 public string FormatTraceResult(TraceResult traceResult)
 {
     return(JsonConvert.SerializeObject(traceResult, Formatting.Indented));
 }
Ejemplo n.º 9
0
        public unsafe int TraceMonsterHull(Entity pEdict, Vec3 v1, Vec3 v2, int fNoMonsters, Entity pentToSkip, out TraceResult ptr)
        {
            float[] fvec1 = v1.GetArray();
            float[] fvec2 = v2.GetArray();

            fixed(float *pvec1 = fvec1, pvec2 = fvec2)
            {
                void *resTrace = null;
                int   res      = ef.TraceMonsterHull(pEdict.UPointer, pvec1, pvec2, fNoMonsters, pentToSkip.UPointer, (TraceResult *)resTrace);

                ptr = (TraceResult)Marshal.PtrToStructure(new IntPtr(resTrace), typeof(TraceResult));
                return(res);
            }
        }
Ejemplo n.º 10
0
        public bool Rotation(out TraceResult result, Vector3 start, idRotation rotation, idClipModel model, Matrix traceModelAxis, ContentFlags contentMask, idEntity passEntity)
        {
            idConsole.Warning("TODO: idClip.Rotation");

            /*idTraceModel traceModel = TraceModelForClipModel(model);
             * idBounds traceBounds = new idBounds();
             * TraceResult traceResult;
             *
             * if((passEntity == null) || (passEntity.Index != idR.EntityIndexWorld))
             * {
             *      // test world
             *      _rotationCount++;
             *
             *      // TODO: NEED ENGINE SOURCE idR.CollisionModelManager.Rotation(out result, start, rotation, traceModel, traceModelAxis, contentMask, 0, Vector3.Zero, Matrix.Identity);
             *      result.ContactInformation.EntityIndex = (result.Fraction != 1.0f) ? idR.EntityIndexWorld : idR.EntityIndexNone;
             *
             *      if(result.Fraction == 0.0f)
             *      {
             *              return true; // blocked immediately by the world
             *      }
             * }
             * else
             * {
             *      result = new TraceResult();
             *      result.Fraction = 1.0f;
             *      result.EndPosition = start;
             *      result.EndAxis = traceModelAxis * rotation.ToMatrix();
             * }
             *
             * if(traceModel == null)
             * {
             *      traceBounds = idBounds.FromPointRotation(start, rotation);
             * }
             * else
             * {
             *      traceBounds = idBounds.FromBoundsRotation(traceModel.Bounds, start, traceModelAxis, rotation);
             * }
             *
             * idClipModel[] clipModelList = GetTraceClipModels(traceBounds, contentMask, passEntity);
             *
             * foreach(idClipModel touch in clipModelList)
             * {
             *      if(touch == null)
             *      {
             *              continue;
             *      }
             *
             *      if(touch.RenderModelHandle != -1)
             *      {
             *              continue;
             *      }
             *
             *      _rotationCount++;
             *      // TODO: traceResult = idR.CollisionModelManager.Rotation(start, rotation, traceModel, traceModelAxis, contentMask, touch.Handle, touch.Origin, touch.Axis);
             *
             *      if(traceResult.Fraction < result.Fraction)
             *      {
             *              result = traceResult;
             *              result.ContactInformation.EntityIndex = touch.Entity.Index;
             *              result.ContactInformation.ID = touch.ID;
             *
             *              if(result.Fraction == 0.0f)
             *              {
             *                      break;
             *              }
             *      }
             * }
             *
             * return (result.Fraction < 1.0f);*/
            result = new TraceResult();
            return(false);
        }
Ejemplo n.º 11
0
        public bool Translation(out TraceResult result, Vector3 start, Vector3 end, idClipModel model, Matrix traceModelAxis, ContentFlags contentMask, idEntity passEntity)
        {
            idConsole.Warning("TODO: idClip.Translation");
            // TODO

            /*if(TestHugeTranslation(result, model, start, end, traceModelAxis) == true)
             * {
             *      return true;
             * }*/

            // TODO

            /*idTraceModel traceModel = TraceModelForClipModel(model);
             * idBounds traceBounds = new idBounds();
             * TraceResult traceResult;
             * float radius = 0;
             *
             * if((passEntity == null) || (passEntity.Index != idR.EntityIndexWorld))
             * {
             *      // test world
             *      _translationCount++;
             *
             *      // TODO: idR.CollisionModelManager.Translation(out result, start, end, traceModel, traceModelAxis, contentMask, 0, Vector3.Zero, Matrix.Identity);
             *      result.ContactInformation.EntityIndex = (result.Fraction != 1.0f) ? idR.EntityIndexWorld : idR.EntityIndexNone;
             *
             *      if(result.Fraction == 0.0f)
             *      {
             *              return true; // blocked immediately by the world
             *      }
             * }
             * else
             * {
             *      result = new TraceResult();
             *      result.Fraction = 1.0f;
             *      result.EndPosition = end;
             *      result.EndAxis = traceModelAxis;
             * }
             *
             * if(traceModel == null)
             * {
             *      traceBounds = idBounds.FromPointTranslation(start, result.EndPosition - start);
             *      radius = 0.0f;
             * }
             * else
             * {
             *      traceBounds = idBounds.FromBoundsTranslation(traceModel.Bounds, start, traceModelAxis, result.EndPosition - start);
             *      radius = traceModel.Bounds.GetRadius();
             * }
             *
             * idClipModel[] clipModelList = GetTraceClipModels(traceBounds, contentMask, passEntity);
             *
             * foreach(idClipModel touch in clipModelList)
             * {
             *      if(touch == null)
             *      {
             *              continue;
             *      }
             *
             *      if(touch.RenderModelHandle != -1)
             *      {
             *              _renderModelTraceCount++;
             *              traceResult = TraceRenderModel(start, end, radius, traceModelAxis, touch);
             *      }
             *      else
             *      {
             *              _translationCount++;
             *              // TODO: traceResult = idR.CollisionModelManager.Translation(start, end, traceModel, traceModelAxis, contentMask, touch.Handle, touch.Origin, touch.Axis);
             *      }
             *
             *      if(traceResult.Fraction < result.Fraction)
             *      {
             *              result = traceResult;
             *              result.ContactInformation.EntityIndex = touch.Entity.Index;
             *              result.ContactInformation.ID = touch.ID;
             *
             *              if(result.Fraction == 0.0f)
             *              {
             *                      break;
             *              }
             *      }
             * }
             *
             * return (result.Fraction < 1.0f);*/
            result = new TraceResult();
            return(false);
        }
Ejemplo n.º 12
0
 public string Serialize(TraceResult value)
 {
     return(JsonConvert.SerializeObject(TraceResultHelper.GetReadyToSerializeVersion(value), Formatting.Indented));
 }
        public void DeepClone_Object_CloneOfObject()
        {
            Object _testobject = new object();

            Assert.AreNotSame(TraceResult.DeepClone(_testobject), _testobject);
        }
Ejemplo n.º 14
0
 private Tracer()
 {
     _threads = new Dictionary <int, Stack <Stopwatch> >();
     _result  = new TraceResult();
 }
Ejemplo n.º 15
0
 public void Write(TraceResult tr)
 {
     Console.WriteLine(Serializer.Serialize(tr));
 }
Ejemplo n.º 16
0
        public void NestedMultiThreadTest()
        {
            tracer = new Tracer.Tracer();

            var  threads      = new List <Thread>();
            long expectedTime = 0;

            Thread newThread;

            for (int i = 0; i < threadsCount; i++)
            {
                newThread = new Thread(MultiThreadedMethod);
                threads.Add(newThread);
                newThread.Start();
                expectedTime += waitTime * (threadsCount + 1);
            }

            foreach (Thread thread in threads)
            {
                thread.Join();
            }

            long        actualTime = 0;
            TraceResult result     = tracer.GetTraceResult();

            foreach (ThreadTracingResult threadResult in result.ThreadTracingResults)
            {
                actualTime += threadResult.ExecutionTime;
            }

            TestExecutionTime(actualTime, expectedTime);

            // Тестирование количества общего числа потоков

            Assert.AreEqual(threadsCount * threadsCount + threadsCount, result.ThreadTracingResults.Count);
            int multiThreadedMethodCounter = 0, singleThreadedMethodCounter = 0;

            MethodTracingResult methodResult;

            foreach (ThreadTracingResult threadResult in result.ThreadTracingResults)
            {
                // Тестирование количества методов в потоках
                Assert.AreEqual(threadResult.ThreadMethods.Count, 1);
                methodResult = threadResult.ThreadMethods[0];

                // Тестирование количества вложенных методов
                Assert.AreEqual(0, methodResult.InnerMethods.Count);

                // Тестирование имени класса
                Assert.AreEqual(nameof(UnitTests), methodResult.ClassName);

                // Тестирование времени выполнения
                TestExecutionTime(methodResult.ExecutionTime, waitTime);

                if (methodResult.MethodName == nameof(MultiThreadedMethod))
                {
                    multiThreadedMethodCounter++;
                }
                if (methodResult.MethodName == nameof(SingleThreadedMethod))
                {
                    singleThreadedMethodCounter++;
                }
            }

            // Тестирование количества многопоточных и однопоточных методов
            Assert.AreEqual(threadsCount, multiThreadedMethodCounter);
            Assert.AreEqual(threadsCount * threadsCount, singleThreadedMethodCounter);
        }
Ejemplo n.º 17
0
 public void Write(ISerializer serializer, TraceResult traceResult)
 {
     _currentInterface.Write(serializer, traceResult);
 }
Ejemplo n.º 18
0
 public string Serialize(TraceResult value)
 {
     return(JsonConvert.SerializeObject(value, Formatting.Indented));
 }
Ejemplo n.º 19
0
 public abstract void SaveTraceResult(TextWriter textWriter, TraceResult traceResult);
Ejemplo n.º 20
0
        private async void StartTrace()
        {
            DisplayStatusMessage = false;
            IsTraceRunning       = true;

            // Measure the time
            StartTime = DateTime.Now;
            stopwatch.Start();
            dispatcherTimer.Tick    += DispatcherTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
            dispatcherTimer.Start();
            EndTime = null;

            TraceResult.Clear();
            Hops = 0;

            // Change the tab title (not nice, but it works)
            Window window = Application.Current.Windows.OfType <Window>().FirstOrDefault(x => x.IsActive);

            if (window != null)
            {
                foreach (TabablzControl tabablzControl in VisualTreeHelper.FindVisualChildren <TabablzControl>(window))
                {
                    tabablzControl.Items.OfType <DragablzTabItem>().First(x => x.ID == _tabId).Header = Host;
                }
            }

            cancellationTokenSource = new CancellationTokenSource();

            // Try to parse the string into an IP-Address
            IPAddress.TryParse(Host, out IPAddress ipAddress);

            try
            {
                // Try to resolve the hostname
                if (ipAddress == null)
                {
                    IPHostEntry ipHostEntrys = await Dns.GetHostEntryAsync(Host);

                    foreach (IPAddress ip in ipHostEntrys.AddressList)
                    {
                        if (ip.AddressFamily == AddressFamily.InterNetwork && SettingsManager.Current.Traceroute_ResolveHostnamePreferIPv4)
                        {
                            ipAddress = ip;
                            continue;
                        }
                        else if (ip.AddressFamily == AddressFamily.InterNetworkV6 && !SettingsManager.Current.Traceroute_ResolveHostnamePreferIPv4)
                        {
                            ipAddress = ip;
                            continue;
                        }
                    }

                    // Fallback --> If we could not resolve our prefered ip protocol
                    if (ipAddress == null)
                    {
                        foreach (IPAddress ip in ipHostEntrys.AddressList)
                        {
                            ipAddress = ip;
                            continue;
                        }
                    }
                }

                TracerouteOptions tracerouteOptions = new TracerouteOptions
                {
                    Timeout         = SettingsManager.Current.Traceroute_Timeout,
                    Buffer          = SettingsManager.Current.Traceroute_Buffer,
                    MaximumHops     = SettingsManager.Current.Traceroute_MaximumHops,
                    DontFragement   = true,
                    ResolveHostname = SettingsManager.Current.Traceroute_ResolveHostname
                };

                Traceroute traceroute = new Traceroute();

                traceroute.HopReceived        += Traceroute_HopReceived;
                traceroute.TraceComplete      += Traceroute_TraceComplete;
                traceroute.MaximumHopsReached += Traceroute_MaximumHopsReached;
                traceroute.UserHasCanceled    += Traceroute_UserHasCanceled;

                traceroute.TraceAsync(ipAddress, tracerouteOptions, cancellationTokenSource.Token);

                // Add the host to history
                AddHostToHistory(Host);
            }
            catch (SocketException) // This will catch DNS resolve errors
            {
                TracerouteFinished();

                StatusMessage        = string.Format(LocalizationManager.GetStringByKey("String_CouldNotResolveHostnameFor"), Host);
                DisplayStatusMessage = true;
            }
            catch (Exception ex) // This will catch any exception
            {
                TracerouteFinished();

                StatusMessage        = ex.Message;
                DisplayStatusMessage = true;
            }
        }
Ejemplo n.º 21
0
 public ConsoleWriter(TraceResult traceResult)
 {
     result = traceResult;
 }
Ejemplo n.º 22
0
		public bool Translation(out TraceResult result, Vector3 start, Vector3 end, idClipModel model, Matrix traceModelAxis, ContentFlags contentMask, idEntity passEntity)
		{
			idConsole.Warning("TODO: idClip.Translation");
			// TODO
			/*if(TestHugeTranslation(result, model, start, end, traceModelAxis) == true)
			{
				return true;
			}*/

			// TODO
			/*idTraceModel traceModel = TraceModelForClipModel(model);
			idBounds traceBounds = new idBounds();
			TraceResult traceResult;
			float radius = 0;

			if((passEntity == null) || (passEntity.Index != idR.EntityIndexWorld))
			{
				// test world
				_translationCount++;

				// TODO: idR.CollisionModelManager.Translation(out result, start, end, traceModel, traceModelAxis, contentMask, 0, Vector3.Zero, Matrix.Identity);
				result.ContactInformation.EntityIndex = (result.Fraction != 1.0f) ? idR.EntityIndexWorld : idR.EntityIndexNone;

				if(result.Fraction == 0.0f)
				{
					return true; // blocked immediately by the world
				}
			}
			else
			{
				result = new TraceResult();
				result.Fraction = 1.0f;
				result.EndPosition = end;
				result.EndAxis = traceModelAxis;
			}

			if(traceModel == null)
			{
				traceBounds = idBounds.FromPointTranslation(start, result.EndPosition - start);
				radius = 0.0f;
			}
			else
			{
				traceBounds = idBounds.FromBoundsTranslation(traceModel.Bounds, start, traceModelAxis, result.EndPosition - start);
				radius = traceModel.Bounds.GetRadius();
			}

			idClipModel[] clipModelList = GetTraceClipModels(traceBounds, contentMask, passEntity);

			foreach(idClipModel touch in clipModelList)
			{
				if(touch == null)
				{
					continue;
				}

				if(touch.RenderModelHandle != -1)
				{
					_renderModelTraceCount++;
					traceResult = TraceRenderModel(start, end, radius, traceModelAxis, touch);
				}
				else
				{
					_translationCount++;
					// TODO: traceResult = idR.CollisionModelManager.Translation(start, end, traceModel, traceModelAxis, contentMask, touch.Handle, touch.Origin, touch.Axis);
				}

				if(traceResult.Fraction < result.Fraction)
				{
					result = traceResult;
					result.ContactInformation.EntityIndex = touch.Entity.Index;
					result.ContactInformation.ID = touch.ID;

					if(result.Fraction == 0.0f)
					{
						break;
					}
				}
			}

			return (result.Fraction < 1.0f);*/
			result = new TraceResult();
			return false;
		}
Ejemplo n.º 23
0
        public string Serialize(TraceResult result)
        {
            string output = JsonConvert.SerializeObject(result.TraceThreads, Formatting.Indented);

            return(output);
        }
Ejemplo n.º 24
0
		public bool Rotation(out TraceResult result, Vector3 start, idRotation rotation, idClipModel model, Matrix traceModelAxis, ContentFlags contentMask, idEntity passEntity)
		{
			idConsole.Warning("TODO: idClip.Rotation");
			/*idTraceModel traceModel = TraceModelForClipModel(model);
			idBounds traceBounds = new idBounds();
			TraceResult traceResult;

			if((passEntity == null) || (passEntity.Index != idR.EntityIndexWorld))
			{
				// test world
				_rotationCount++;

				// TODO: NEED ENGINE SOURCE idR.CollisionModelManager.Rotation(out result, start, rotation, traceModel, traceModelAxis, contentMask, 0, Vector3.Zero, Matrix.Identity);
				result.ContactInformation.EntityIndex = (result.Fraction != 1.0f) ? idR.EntityIndexWorld : idR.EntityIndexNone;

				if(result.Fraction == 0.0f)
				{
					return true; // blocked immediately by the world
				}
			}
			else
			{
				result = new TraceResult();
				result.Fraction = 1.0f;
				result.EndPosition = start;
				result.EndAxis = traceModelAxis * rotation.ToMatrix();
			}

			if(traceModel == null)
			{
				traceBounds = idBounds.FromPointRotation(start, rotation);
			}
			else
			{
				traceBounds = idBounds.FromBoundsRotation(traceModel.Bounds, start, traceModelAxis, rotation);
			}

			idClipModel[] clipModelList = GetTraceClipModels(traceBounds, contentMask, passEntity);

			foreach(idClipModel touch in clipModelList)
			{
				if(touch == null)
				{
					continue;
				}

				if(touch.RenderModelHandle != -1)
				{
					continue;
				}

				_rotationCount++;
				// TODO: traceResult = idR.CollisionModelManager.Rotation(start, rotation, traceModel, traceModelAxis, contentMask, touch.Handle, touch.Origin, touch.Axis);

				if(traceResult.Fraction < result.Fraction)
				{
					result = traceResult;
					result.ContactInformation.EntityIndex = touch.Entity.Index;
					result.ContactInformation.ID = touch.ID;

					if(result.Fraction == 0.0f)
					{
						break;
					}
				}
			}

			return (result.Fraction < 1.0f);*/
			result = new TraceResult();
			return false;
		}
Ejemplo n.º 25
0
 /// <summary>
 /// Serializes the given TraceResult
 /// </summary>
 /// <param name="tr">TraceResult</param>
 /// <returns>JSON serialization result as a byte array</returns>
 public byte[] Serialize(TraceResult tr)
 {
     return(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(tr, Formatting.Indented)));
 }
Ejemplo n.º 26
0
 public void WriteTraceResult(TraceResult traceResult)
 {
     WriteString(_formatter.FormatTraceResult(traceResult));
 }
Ejemplo n.º 27
0
        public string Serialize(TraceResult traceResult)
        {
            var serializer = XSerializer.JsonSerializer.Create(traceResult.GetType());

            return(serializer.Serialize(traceResult));
        }
Ejemplo n.º 28
0
 public void Write(TraceResult traceResult)
 {
     File.WriteAllText(_filePath, _serializer.Serialize(traceResult));
 }
Ejemplo n.º 29
0
 public void Write(ISerializer serializer, TraceResult traceResult)
 {
     Console.WriteLine(serializer.Serialize(traceResult));
 }
Ejemplo n.º 30
0
 public void Write(TraceResult traceResult)
 {
     Console.Write(_serializer.Serialize(traceResult));
 }
Ejemplo n.º 31
0
 protected virtual bool IsTraceValid(TraceResult tr) => tr.Hit;
Ejemplo n.º 32
0
 public void addInternalResult(TraceResult result)
 {
     internalResults.Add(result);
 }
Ejemplo n.º 33
0
        private async void StartTrace()
        {
            DisplayStatusMessage = false;
            IsTraceRunning       = true;

            // Measure the time
            StartTime = DateTime.Now;
            stopwatch.Start();
            dispatcherTimer.Tick    += DispatcherTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
            dispatcherTimer.Start();
            EndTime = null;

            TraceResult.Clear();
            Hops = 0;

            cancellationTokenSource = new CancellationTokenSource();

            // Try to parse the string into an IP-Address
            IPAddress.TryParse(Host, out IPAddress ipAddress);

            try
            {
                // Try to resolve the hostname
                if (ipAddress == null)
                {
                    IPHostEntry ipHostEntrys = await Dns.GetHostEntryAsync(Host);

                    foreach (IPAddress ip in ipHostEntrys.AddressList)
                    {
                        if (ip.AddressFamily == AddressFamily.InterNetwork && SettingsManager.Current.Traceroute_ResolveHostnamePreferIPv4)
                        {
                            ipAddress = ip;
                            continue;
                        }
                        else if (ip.AddressFamily == AddressFamily.InterNetworkV6 && !SettingsManager.Current.Traceroute_ResolveHostnamePreferIPv4)
                        {
                            ipAddress = ip;
                            continue;
                        }
                    }

                    // Fallback --> If we could not resolve our prefered ip protocol
                    if (ipAddress == null)
                    {
                        foreach (IPAddress ip in ipHostEntrys.AddressList)
                        {
                            ipAddress = ip;
                            continue;
                        }
                    }
                }

                TracerouteOptions tracerouteOptions = new TracerouteOptions
                {
                    Timeout         = SettingsManager.Current.Traceroute_Timeout,
                    Buffer          = SettingsManager.Current.Traceroute_Buffer,
                    MaximumHops     = SettingsManager.Current.Traceroute_MaximumHops,
                    DontFragement   = true,
                    ResolveHostname = SettingsManager.Current.Traceroute_ResolveHostname
                };

                Traceroute traceroute = new Traceroute();

                traceroute.HopReceived        += Traceroute_HopReceived;
                traceroute.TraceComplete      += Traceroute_TraceComplete;
                traceroute.MaximumHopsReached += Traceroute_MaximumHopsReached;
                traceroute.UserHasCanceled    += Traceroute_UserHasCanceled;

                traceroute.TraceAsync(ipAddress, tracerouteOptions, cancellationTokenSource.Token);

                // Add the host to history
                AddHostToHistory(Host);
            }
            catch (SocketException) // This will catch DNS resolve errors
            {
                TracerouteFinished();

                StatusMessage        = string.Format(Application.Current.Resources["String_CouldNotResolveHostnameFor"] as string, Host);
                DisplayStatusMessage = true;
            }
            catch (Exception ex) // This will catch any exception
            {
                TracerouteFinished();

                StatusMessage        = ex.Message;
                DisplayStatusMessage = true;
            }
        }
Ejemplo n.º 34
0
 protected virtual void OnPostCategorizePosition(bool stayOnGround, TraceResult trace)
 {
 }