private void ScanVoxelMap(int id, IMyVoxelBase voxelMap, IMyCubeBlock turret, BoundingSphereD sphere, bool lastcountisfull, ref Dictionary oreList, bool PriorScan = false) { LogMessageOnThread("Thread start"); ... ... ... for (var it = new Vector3I_RangeIterator(ref cacheMinI, ref cacheMaxI); it.IsValid(); it.MoveNext()) // iterace jen v intervalu [cachemin .. cachemax] { ... ... ... // test cut_sphere if (! VoxelOperations.SecureSphereIsEmpty(vpos,spawnignoreentityid, 2f)) { calcnumvoxelsnonsecure++; continue; } // nelze pouzit castray - nesmi byt v threadu (kolize s jinym castray) // Game version >= 188 use CatRayParallel //------------------------------------------------------------------------- var dirmeter = vpos - sphere.Center; dirmeter.Normalize(); var frompos = sphere.Center+dirmeter; var hitinfos = new List(); bool hit = false; // test if Ray hit grid (grid is before voxel) LogMessageOnThread(" Thread before call CastRayParallel..."); MyAPIGateway.Physics.CastRayParallel(ref frompos, ref vpos, hitinfos, 0, // without filters delegate(List hitinf) { hit = false; LogMessageOnThread(string.Format(" CastRayParallel hitinfos.count: {0}, hitinf.count: {1}", hitinfos.Count, hitinf.Count)); foreach (var hitinfo in hitinf) { if ( hitinfo.HitEntity is IMyVoxelBase) { // LogMessageOnThread(string.Format(" Voxelhit(first) at pos: {0}", hitinfo.Position)); break; // voxelhit is first -> end and ignore } if ( hitinfo.HitEntity is IMyCubeGrid ) { if ( hitinfo.HitEntity.EntityId != spawnignoreentityid ) { // gridhit is first -> end and respect (blocked way) LogMessageOnThread(string.Format(" Gridhit(first) at pos: {0}", hitinfo.Position)); hit = true; break; } } else LogMessageOnThread(string.Format(" Other hit at pos: {0}, Entity {1}", hitinfo.Position, hitinfo.HitEntity)); } } ); // eof call castrayparallel LogMessageOnThread(" Thread after call CastRayParallel..."); if (hitinfos.Count >0) LogMessageOnThread(string.Format(" CastRayParallel hits.Count {0} to pos: {1}", hitinfos.Count, vpos)); if (hit) // I need result HERE { LogMessageOnThread(string.Format(" CastRayParallel to pos: {0} gridhit", vpos)); calcnumvoxelsblocked++; continue; // ignore, nonuseable } //--------------------------------------------------------------------- // accept, useable ... ... ... } ... ... ... LogMessageOnThread("Thread scanning end"); ... ... ... LogMessageOnThread("Thread finish\n"); }