Open midspace opened 8 years ago
Is this faster than the previously used method or just API changes?
It should be faster, from what I've heard. What is in question is the accuracy. It really needs testing, in terms of range, variety of entities and entity edges.
I've been researching this CastRay, and it's not practical. The raycast occurs in the Havok engine, against all objects between the two points. And it only returns the closest object. It does not have the capability of filtering by object type. ie, ignore asteroids and floating objects to only return the closest ship. It also does not detect planets.
What we really need is access to:
public static void CastRay(Vector3D from, Vector3D to, List<HitInfo> toList, int raycastFilterLayer = 0)
As this returns a list of hit objects. This would allows us to filter the results.
Update calls to RayCastBlocks to use MyAPIGateway.Physics.CastRay.
https://github.com/midspace/Space-Engineers-Admin-script-mod/blob/master/midspace%20admin%20helper/Data/Scripts/midspace.adminscripts/Support.cs#L105