public void PrepareData(BaseLog log) { if (log == null) { throw new ArgumentNullException("log"); } Log = log; Cache.Clear(); Geometry = new Geometry { Transform = true }; //List<ADT> adtList = new List<ADT>(); bool hasHandle = false; try { try { hasHandle = _mutex.WaitOne(Timeout.Infinite, false); if (hasHandle == false) { throw new TimeoutException("Timeout waiting for exclusive access"); } } catch (AbandonedMutexException) { // The mutex was abandoned in another process, it will still get aquired hasHandle = true; } // Do the work which require this mutex locking (useless with CACS) //{ ADT main = GetAdt(World, X, Y); Geometry.AddAdt(main); InsertAllGameobjectGeometry(X, Y, MapId); // Geometry.CreateDemoDump("X:\\Meshes\\" + MapId + "_" + X + "_" + Y + ".obj"); //} if (Geometry.Vertices.Count == 0 && Geometry.Triangles.Count == 0) { throw new InvalidOperationException("Can't build tile with empty geometry"); } // again, we load everything - wasteful but who cares for (int ty = Y - 1; ty <= Y + 1; ty++) { for (int tx = X - 1; tx <= X + 1; tx++) { // don't load main tile again if (tx == X && ty == Y) { continue; } ADT adt = GetAdt(World, tx, ty); if (adt.HasObjectData) { //Console.WriteLine("-> " + World + "_" + tx + "_" + ty); Geometry.AddAdt(adt); InsertAllGameobjectGeometry(tx, ty, MapId); } else { string parentMap = PhaseHelper.GetParentMap(World); if (parentMap != string.Empty) { ADT adtParent = GetAdt(parentMap, tx, ty); if (adtParent.HasObjectData) { Console.WriteLine("-> " + parentMap + "_" + tx + "_" + ty); Geometry.AddAdt(adtParent); InsertAllGameobjectGeometry(tx, ty, PhaseHelper.GetMapIdByName(parentMap)); } } } } } } finally { if (hasHandle) { _mutex.ReleaseMutex(); } } Context = new RecastContext(); Context.SetContextHandler(Log); }