static object PerformMemberwiseClone(ref object o) { var ins = new Unity.Profiling.ProfilerMarker(); ins = (Unity.Profiling.ProfilerMarker)o; return(ins); }
static Profiling() { k_Markers = new Unity.Profiling.ProfilerMarker[(int)MarkerId.MarkerCount]; k_Recorders = new UnityEngine.Profiling.Recorder[(int)MarkerId.MarkerCount]; for (int i = 0; i != (int)MarkerId.MarkerCount; ++i) { k_Markers[i] = new Unity.Profiling.ProfilerMarker(k_MarkerNames[i]); k_Recorders[i] = UnityEngine.Profiling.Recorder.Get(k_MarkerNames[i]); } }
static void WriteBackInstance(CSHotFix.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref Unity.Profiling.ProfilerMarker instance_of_this_method) { ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.Object: { __mStack[ptr_of_this_method->Value] = instance_of_this_method; } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { var t = __domain.GetType(___obj.GetType()) as CLRType; t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method); } } break; case ObjectTypes.StaticFieldReference: { var t = __domain.GetType(ptr_of_this_method->Value); if (t is ILType) { ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as Unity.Profiling.ProfilerMarker[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; } break; } }
static StackObject *Begin_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); Unity.Profiling.ProfilerMarker instance_of_this_method = (Unity.Profiling.ProfilerMarker) typeof(Unity.Profiling.ProfilerMarker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); instance_of_this_method.Begin(); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); __intp.Free(ptr_of_this_method); return(__ret); }
[Explicit("Test for specific fail case which I don't want to deal with atm, so keeping it around here, but will have fix for it at some point?")] // TODO: Make this pass public void FailingAddTrianglePoints() { //var randomSeed = (uint)Mathf.Max(1, System.DateTime.Now.Millisecond); var randomSeed = (uint)886; try { using var d = new Unity.Profiling.ProfilerMarker("AddTrianglePoints").Auto(); var points = new List <Vector2>(); var randomPoints = new Unity.Mathematics.Random(randomSeed); for (int i = 0; i < 500; i++) { points.Add(randomPoints.NextFloat2()); } var desiredSpline = new BMCurves.CurveBuilder(DistanceBetweenPoints, CurveSplitError); var optimizedSpline = new OPCurves.CurveBuilder(DistanceBetweenPoints, CurveSplitError); for (int i = 0; i < points.Count; i++) { var desiredRes = desiredSpline.AddPoint(points[i]); var optimizedRes = optimizedSpline.AddPoint(points[i]); Assert.IsTrue(desiredRes.FirstChangedIndex == optimizedRes.FirstChangedIndex); } for (int i = 0; i < desiredSpline.Curves.Count; i++) { try { Assert.IsTrue(Equals(desiredSpline.Curves[i], optimizedSpline.Curves[i])); } catch (Exception e) { throw e; } } } catch (Exception e) { Debug.LogError($"Seed: {randomSeed}"); throw e; } }
static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.String @name = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = new Unity.Profiling.ProfilerMarker(@name); if (!isNewObj) { __ret--; WriteBackInstance(__domain, __ret, __mStack, ref result_of_this_method); return(__ret); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public Path Run <TMod>(LogLevel pathfindingLogLevel, Vector3 fromPoint, Vector3 toPoint, Constraint constraint, Graph graph, TMod pathModifier, int threadIndex = 0, bool burstEnabled = true, bool cacheEnabled = false) where TMod : struct, IPathModifier { var path = new Path(); var pathResult = new PathInternal(); var navMeshGraph = (NavMeshGraph)graph; var areas = -1; if (constraint.checkArea == true) { areas = (int)constraint.areaMask; } System.Diagnostics.Stopwatch swPath = null; if ((pathfindingLogLevel & LogLevel.Path) != 0) { swPath = System.Diagnostics.Stopwatch.StartNew(); } var statLength = 0; var statVisited = 0; var query = new UnityEngine.Experimental.AI.NavMeshQuery(UnityEngine.Experimental.AI.NavMeshWorld.GetDefaultWorld(), Unity.Collections.Allocator.TempJob, PathfindingNavMeshProcessor.POOL_SIZE); if (burstEnabled == true) { var results = new Unity.Collections.NativeArray <UnityEngine.Experimental.AI.NavMeshLocation>(PathfindingNavMeshProcessor.MAX_PATH_SIZE, Unity.Collections.Allocator.TempJob); var pathResults = new Unity.Collections.NativeArray <int>(2, Unity.Collections.Allocator.TempJob); var job = new BuildPathJob() { query = query, fromPoint = fromPoint, toPoint = toPoint, agentTypeId = navMeshGraph.agentTypeId, areas = areas, pathResults = pathResults, results = results, }; job.Schedule().Complete(); var pathStatus = (UnityEngine.Experimental.AI.PathQueryStatus)pathResults[0]; var cornerCount = pathResults[1]; pathResults.Dispose(); if ((pathStatus & UnityEngine.Experimental.AI.PathQueryStatus.Success) != 0) { if (cornerCount >= 2) { path.navMeshPoints = PoolListCopyable <Vector3> .Spawn(cornerCount); for (var i = 0; i < cornerCount; ++i) { path.navMeshPoints.Add(results[i].position); } if ((pathfindingLogLevel & LogLevel.Path) != 0) { var hash = 0; for (var i = 0; i < cornerCount; ++i) { hash ^= (int)(results[i].position.x * 1000000f); } UnityEngine.Debug.Log("Path hash X: " + hash); hash = 0; for (var i = 0; i < cornerCount; ++i) { hash ^= (int)(results[i].position.y * 1000000f); } UnityEngine.Debug.Log("Path hash Y: " + hash); hash = 0; for (var i = 0; i < cornerCount; ++i) { hash ^= (int)(results[i].position.z * 1000000f); } UnityEngine.Debug.Log("Path hash Z: " + hash); } if ((pathStatus & UnityEngine.Experimental.AI.PathQueryStatus.PartialResult) != 0) { path.result = PathCompleteState.CompletePartial; } else { path.result = PathCompleteState.Complete; } } else { path.result = PathCompleteState.NotExist; } } results.Dispose(); query.Dispose(); return(path); } UnityEngine.AI.NavMesh.SamplePosition(fromPoint, out var hitFrom, 1000f, new UnityEngine.AI.NavMeshQueryFilter() { agentTypeID = navMeshGraph.agentTypeId, areaMask = areas, }); fromPoint = hitFrom.position; var from = query.MapLocation(fromPoint, Vector3.one * 10f, navMeshGraph.agentTypeId, areas); if (from.polygon.IsNull() == true) { return(path); } UnityEngine.AI.NavMesh.SamplePosition(toPoint, out var hitTo, 1000f, new UnityEngine.AI.NavMeshQueryFilter() { agentTypeID = navMeshGraph.agentTypeId, areaMask = areas, }); toPoint = hitTo.position; var to = query.MapLocation(toPoint, Vector3.one * 10f, navMeshGraph.agentTypeId, areas); if (to.polygon.IsNull() == true) { return(path); } var marker = new Unity.Profiling.ProfilerMarker("PathfindingNavMeshProcessor::Query::BuildPath"); marker.Begin(); query.BeginFindPath(from, to, areas); query.UpdateFindPath(PathfindingNavMeshProcessor.MAX_ITERATIONS, out var performed); marker.End(); statVisited = performed; var result = query.EndFindPath(out var pathSize); if ((result & UnityEngine.Experimental.AI.PathQueryStatus.Success) != 0) { var pathInternal = new Unity.Collections.NativeArray <UnityEngine.Experimental.AI.PolygonId>(pathSize, Unity.Collections.Allocator.Persistent); query.GetPathResult(pathInternal); var markerFindStraight = new Unity.Profiling.ProfilerMarker("PathfindingNavMeshProcessor::Query::FindStraightPath"); markerFindStraight.Begin(); var straightPathFlags = new Unity.Collections.NativeArray <StraightPathFlags>(PathfindingNavMeshProcessor.MAX_PATH_SIZE, Unity.Collections.Allocator.Persistent); var vertexSide = new Unity.Collections.NativeArray <float>(PathfindingNavMeshProcessor.MAX_PATH_SIZE, Unity.Collections.Allocator.Persistent); var results = new Unity.Collections.NativeArray <UnityEngine.Experimental.AI.NavMeshLocation>(PathfindingNavMeshProcessor.MAX_PATH_SIZE, Unity.Collections.Allocator.Persistent); var resultStatus = new Unity.Collections.NativeArray <int>(2, Unity.Collections.Allocator.TempJob); var job = new FindStraightPathJob() { query = query, from = from, to = to, pathInternal = pathInternal, pathSize = pathSize, results = results, straightPathFlags = straightPathFlags, vertexSide = vertexSide, resultStatus = resultStatus, }; job.Schedule().Complete(); var pathStatus = (UnityEngine.Experimental.AI.PathQueryStatus)job.resultStatus[0]; var cornerCount = job.resultStatus[1]; resultStatus.Dispose(); statLength = cornerCount; markerFindStraight.End(); if (pathStatus == UnityEngine.Experimental.AI.PathQueryStatus.Success) { /*for (int i = 1; i < cornerCount; ++i) { * * Gizmos.color = Color.green; * Gizmos.DrawLine(results[i].position, results[i - 1].position); * * }*/ pathResult.pathStatus = pathStatus; pathResult.results = results; pathResult.corners = cornerCount; if (cornerCount >= 2) { path.navMeshPoints = PoolListCopyable <Vector3> .Spawn(cornerCount); for (var i = 0; i < cornerCount; ++i) { path.navMeshPoints.Add(results[i].position); } if ((pathfindingLogLevel & LogLevel.Path) != 0) { var hash = 0; for (var i = 0; i < cornerCount; ++i) { hash ^= (int)(results[i].position.x * 1000000f); } UnityEngine.Debug.Log("Path hash X: " + hash); hash = 0; for (var i = 0; i < cornerCount; ++i) { hash ^= (int)(results[i].position.y * 1000000f); } UnityEngine.Debug.Log("Path hash Y: " + hash); hash = 0; for (var i = 0; i < cornerCount; ++i) { hash ^= (int)(results[i].position.z * 1000000f); } UnityEngine.Debug.Log("Path hash Z: " + hash); } path.result = PathCompleteState.Complete; } else { path.result = PathCompleteState.NotExist; } pathResult.Dispose(); } else { path.result = PathCompleteState.NotExist; results.Dispose(); } vertexSide.Dispose(); straightPathFlags.Dispose(); pathInternal.Dispose(); } else { path.result = PathCompleteState.NotExist; //Debug.LogWarning("Path result: " + result + ", performed: " + performed); } System.Diagnostics.Stopwatch swModifier = null; if ((pathfindingLogLevel & LogLevel.PathMods) != 0) { swModifier = System.Diagnostics.Stopwatch.StartNew(); } if ((path.result & PathCompleteState.Complete) != 0) { path = pathModifier.Run(path, constraint); } if ((pathfindingLogLevel & LogLevel.Path) != 0) { Logger.Log( $"Path result {path.result}, built in {(swPath.ElapsedTicks / (double)System.TimeSpan.TicksPerMillisecond).ToString("0.##")}ms. Path length: {statLength} (Visited: {statVisited})\nThread Index: {threadIndex}"); } if ((pathfindingLogLevel & LogLevel.PathMods) != 0) { Logger.Log($"Path Mods: {swModifier.ElapsedMilliseconds}ms"); } query.Dispose(); return(path); }