You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had an idea to use Linq to improve the FindBlock() function in world.cs:
public List<Location> FindBlock(Location from, Material block, int radiusx, int radiusy, int radiusz)
{
Location minPoint = new Location(from.X - radiusx, from.Y - radiusy, from.Z - radiusz);
Location maxPoint = new Location(from.X + radiusx, from.Y + radiusy, from.Z + radiusz);
List<int> xRange = Enumerable.Range(Convert.ToInt32(Math.Floor(minPoint.X)), Convert.ToInt32(Math.Floor(maxPoint.X - minPoint.X)) + 1).ToList();
List<int> yRange = Enumerable.Range(Convert.ToInt32(Math.Floor(minPoint.Y)), Convert.ToInt32(Math.Floor(maxPoint.Y - minPoint.Y)) + 1).ToList();
List<int> zRange = Enumerable.Range(Convert.ToInt32(Math.Floor(minPoint.Z)), Convert.ToInt32(Math.Floor(maxPoint.Z - minPoint.Z)) + 1).ToList();
List<Location> listOfBlocks = xRange.SelectMany(x => yRange.SelectMany(y => zRange.Select(z => new Location(x, y, z)))).ToList();
return listOfBlocks.Where(loc => GetWorld().GetBlock(loc).Type == block).ToList();
}
I benchmarked it against the default function and found out that the larger the radius is, the better it performes against the current implementation. Unfortunately cases, where you would actually notice a difference are never reached, due to the limited render distance. Although this implementation provides a small improvement (< 1 sec.), the user will not actually notice a real difference.
I did not want this idea to die unheared. Therefore I posted it here, maybe you have some thoughts about it?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I had an idea to use Linq to improve the FindBlock() function in
world.cs:I benchmarked it against the default function and found out that the larger the radius is, the better it performes against the current implementation. Unfortunately cases, where you would actually notice a difference are never reached, due to the limited render distance. Although this implementation provides a small improvement (< 1 sec.), the user will not actually notice a real difference.
I did not want this idea to die unheared. Therefore I posted it here, maybe you have some thoughts about it?
Beta Was this translation helpful? Give feedback.
All reactions