fIsItOnLine proc lpVLine1:dword,lpVLine2:dword,lpVTested:dword
LOCAL VNormals:VERTEX
LOCAL vDelta:VERTEX
LOCAL VNormals2:VERTEX
LOCAL vDelta2:VERTEX
LOCAL TLen:real4
LOCAL vScaled:VERTEX
; lpVLine1/2 is the Line position using Vertex as coordinate (X,Y,Z)
; First lets have the Normals first
invoke Vec_Sub,addr vDelta,lpVLine2,lpVLine1
invoke Vec_Normalize,addr VNormals,addr vDelta
; Lets have the normals and the delta of the tested vertex
invoke Vec_Sub,addr vDelta2,lpVTested,lpVLine1
invoke Vec_Normalize,addr VNormals2,addr vDelta2
invoke Vec_DotProduct,addr vDelta,addr vDelta
fsqrt
fstp TLen
invoke Vec_Copy,addr vScaled,addr VNormals2
invoke Vec_Scale,addr vScaled,TLen
invoke Vec_Sub,addr vDelta,addr vScaled,lpVTested
invoke Vec_DotProduct,addr vDelta,addr vDelta
push eax
fistp dword ptr[esp]
pop eax
; if it is zero, it mean the dot is colliding the line, if it was not, then it was not zero.
.if eax==0
mov eax,TRUE
.else
mov eas,FALSE
.endif
ret
fIsItOnLine endp
This is the fastest and shortest I can do right now. I'll try to improve it.
Right now I only able to check wheter a dot is colliding with a line. my target is triangle with triangle collision detect.