[1.187.209] raycasts detect planet when raycasting away from it over larger distances

LordTylus shared this bug 6 years ago
Outdated

Hello when playing around with the Mod and Ingame Programming API I tested a bit with the IMyCameraBlock.Raycast(double, float, float) Method.

I will demonstrate the issue with ingame Scripting (I know its experimental but its able to show it pretty easily).

I built a camera on my ship as well as a Programmable block and enabled the Raycasting function. And I looked in a random direction. (See Screenshot: 20180930154458_1.jpg)

When I perform a Raycast of 10km I get the information that Nothing was Detected as I expected. (See Screenshot: 20180930155338_1.jpg)

But if I do a raycast of 100km I get the information that I hit planet earth exactly 100km away from me. (See Screenshot: 20180930155440_1.jpg)

This is not what I was expecting since there is still nothing, so there should not be any planet detected. Especially not at a hit position far away from the planet itself.

However I assume this has something to do with performance, but It should be possible to determine if I am actually scanning towards a planet or away from it to reduce wrong data reports.

To verify this bug here is the test-script I created:

IMyCameraBlock camera = null;  
 
Program() { 
    init(); 
} 
 
void init() { 
     
    camera = GridTerminalSystem.GetBlockWithName("Camera") as IMyCameraBlock;     
      
    if(camera != null)  
        camera.EnableRaycast = true;  
} 
 
void Main(string argument) { 
 
    if(camera == null) 
        init(); 
 
    if(camera == null) { 
 
        Echo("Camera not found!");   
        	Me.CustomName = "GPS:Target:NA";     
 
        return; 
    } 
 
    float maxDistance = 10000f; 
 
    if(argument != null && argument.Length > 0) { 
 
        if(argument.Equals("update")) { 
            printScanRange(camera); 
            return; 
        } 
          
        if (!float.TryParse(argument, out maxDistance))    
            maxDistance = 10000f;    
    } 
 
    if(camera.CanScan(maxDistance)) { 
 
        MyDetectedEntityInfo info = camera.Raycast(maxDistance, 0,0);       
         
        MyDetectedEntityType type = info.Type;  
        if(type != MyDetectedEntityType.None) {  
 
            Vector3D offsetTarget = (Vector3D) info.HitPosition;  
 
            Echo("Target: "+VectorToString(offsetTarget, 4, ", ")); 
            Echo("Center: "+VectorToString(info.BoundingBox.Center, 4, ", ")); 
            Echo("Name: "+info.Name);             
            Echo("Relationship: "+info.Relationship); 
            Echo("Velocity: "+info.Velocity); 
  
            	Me.CustomName = "GPS:Target:"+VectorToString(offsetTarget, 4, ":")+":";     
 
            printScanRange(camera); 
 
        } else { 
             
            Echo("Nothing found!");  
            printScanRange(camera); 
            	Me.CustomName = "GPS:Target:NA";     
        } 
 
    } else { 
 
        Echo("Scan not Possible!"); 
        printScanRange(camera); 
        	Me.CustomName = "GPS:Target:NA";     
    } 
}  
 
void printScanRange(IMyCameraBlock camera) { 
    Echo("Scan range: "+camera.AvailableScanRange.ToString("N0")+" m");     
} 
 
string VectorToString(Vector3D vector, int decimals, string delimiter)      
{      
    return Math.Round(vector.GetDim(0), decimals) + delimiter + Math.Round(vector.GetDim(1), decimals) + delimiter + Math.Round(vector.GetDim(2), decimals);      
}

Replies (1)

photo
1

Hello, Engineer!


Thank you for your feedback! Your topic has been added between considered issues.


We will address all reported issues during future development and we will attempt to fix your issue as soon as possible. We are currently close to a Major release, which is under heavy development and this takes up a lot of our time.


Please keep voting for the issue as it will help us to identify the most serious bugs.


We really appreciate your patience.


Kind Regards


Keen Software House: QA Department

Leave a Comment
 
Attach a file