View Issue Details

IDProjectCategoryView StatusLast Update
0005601Multi Theft Auto : San AndreasScriptingpublic2010-11-09 11:08
ReportereAi Assigned ToKayl  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Target Version1.1Fixed in Version1.1 
Summary0005601: processLineOfSight should return the normal of the face hit

It's odd that pLoS doesn't return the normal of the face the ray hit, as I'm pretty sure we know what this is internally, so this should be easy to add.

TagsNo tags attached.


child of 0003344 closed New Feature Requests Requested features tracker 



2010-11-09 01:36

developer   ~~0012134

Attached a potential patch which adds:

  • normal
  • material
  • lighting intensity (of hit surface)
  • piece type (for ped body part and vehicle parts)

Here is the clientside code to test it:

function string.split(str, delim)
local startPos = 1
local endPos = string.find(str, delim, 1, true)
local result = {}
while endPos do
table.insert(result, string.sub(str, startPos, endPos-1))
startPos = endPos + 1
endPos = string.find(str, delim, startPos, true)
table.insert(result, string.sub(str, startPos))
return result

function _FDL(sx, sy, sz, ex, ey, ez, color)
local realColor = color or tocolor(255, 0, 0, 255)
local ssx, ssy = getScreenFromWorldPosition(sx, sy, sz)
local esx, esy = getScreenFromWorldPosition(ex, ey, ez)
if ssx and ssy and esx and esy then
dxDrawLine(ssx, ssy, esx, esy, realColor, 2)

addEventHandler("onClientRender", getRootElement(),
local cx, cy, cz, tx, ty, tz = getCameraMatrix()

local hit, hx, hy, hz, hElement, nx, ny, nz, mat, light, piece = processLineOfSight ( cx, cy, cz, tx, ty, tz )
local text = ""
if not hit then
    text = "No hit"
    text = string.format("hit: %f %f %f\nelement: %s\nnormal: %f %f %f\nmaterial %s light %s piece %s", 
                    hx, hy, hz, 
                    tostring(hElement and isElement(hElement) and getElementType(hElement)),
                    nx, ny, nz,
                    tostring(mat), tostring(light),
                    tostring(piece), tostring(pb))
    _FDL(hx, hy, hz, hx+nx, hy+ny, hz+nz)

local width, height = guiGetScreenSize()
local nbLines = #(text:split("\n"))
dxDrawRectangle(0, 0, width, 10+nbLines*dxGetFontHeight(1.5,  "clear"), tocolor(0, 0, 0, 128))
dxDrawText(text, 0, 0, width, height, tocolor(255, 255, 255, 255), 1.5,  "clear", "center", "top")


Issue History

Date Modified Username Field Change