User Tools

Site Tools


4rpl:commands:getterrainlos

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
4rpl:commands:getterrainlos [2021/01/08 11:01] – external edit 127.0.0.14rpl:commands:getterrainlos [2024/04/13 14:27] (current) – [Description] durikkan
Line 3: Line 3:
  
 ====== GetTerrainLOS ====== ====== GetTerrainLOS ======
-GetTerrainLOS(<-start <-end <-checkLastCell) ->hit+GetTerrainLOS(<-startPos <-endPos <-checkLastCell) ->hitPos
  
 ===== Description ===== ===== Description =====
-Checks a line running from start to end and returns the terrain cell (if any) that the line first intersects. +Checks a line running from startPos to endPos and returns the world position (if any) where the line first ever intersects terrain geometry.\\ 
-The 'start', 'end' and 'hit' vars are all vectors. +This routine is useful for checking the exact terrain Line Of Sight (LOS) between two points and where the LOS was blocked. If a unit wants to fire from any location in 3d space to any location in 3d space, this routine can check if there is any terrain in the way and where
-This routine is useful for checking the exact terrain line of sight. If a unit wants to fire from any location in 3d space to any location in 3d space, + 
-this routine can check if there is any terrain in the way. +-The 'startPos ', 'endPos', and 'hitPos' vars are all vectors ([[V3]]as floats.\\ 
-The return value is the vector position in 3d space (floatsof the location where the collision took place.  If there is no collision, then the returned hit locations are negative.+-Returns the world space location of where the collision took place. If no hit occurs then the returned vector is the minimum value [-3.402823E+38, -3.402823E+38, -3.402823E+38]. 
 + 
 +-CheckLastCell is a Boolean that will have the API extend its calculations past the endPos until it exits the cell the end position is within or a hit is encountered. A cell is a 1x1 square and any location within this square is within that cell (no matter the Y position). For reference, the center location of cell 10,15 is (10.5,15.5)((Any position with an X position between (10.000-11.000] and Z position between (15.000-16.000] would be within this cell.\\ 
 +Example positions in cell 10,15: (10.000001,16), (10.2,15.000001), (10.6,15.3).\\ 
 +Please note the bounds. An X position of 15.00000 is NOT within ANY cell located at (15,Z). 15.00000 is located within cell (14,Z) instead.)). Be mindful with this when there is a very large difference in Y-axis / "height" between the two points as the calculation can only exit the cell laterally, not vertically. Should CheckLastCell be true and the line between startPos and endPos be mostly vertical, the calculated line will be noticeably extended past endPos. 
 + 
 +:NOTE:\\ 
 +Void (height of 0) acts as proper terrain (even outside the map). Should you use this API and it calculates a line that crosses through void terrain, it will detect the hit as expected (like (-50 0 -10)). 
 + 
 +:WARNING:\\ 
 +This API becomes unreliable when startPos and endPos are significantly off map and will consistently fail to detect a hit although the line does intersect the void terrain. 
 + 
 +:NOTE:\\ 
 +This API has its limits. It can not detect a hit at extreme angles(([Tested] Such as from (-852 500 30) to (171 3 32). End position is behind a wall and a hit is detected should the starting X pos be greater than -851 but fails otherwise (no other changes than starting X).)). 
  
 ===== Examples ===== ===== Examples =====
4rpl/commands/getterrainlos.txt · Last modified: 2024/04/13 14:27 by durikkan