10
My program will crash when it hits the X_COLLISIONRAY line in the following section of code - but only when debug is disabled
LOCAL x,y,z, x2,y2,z2
X_SCREEN2WORLD MouseX, MouseY, 0, x, y, z
X_SCREEN2WORLD MouseX, MouseY, -1, x2,y2,z2
// DEBUG M_Hill+","+x+","+y+","+z+","+x2+","+y2+","+z2
// END
IF X_COLLISIONRAY(M_Hill, 0, x, y, z, x2-x, y2-y, z2-z)<>0
MouseCollisionFace=X_GETCOLLISIONFACE() // div by 3 for x_getcollisionface bug, then divide by 2 to get the right triangle
X_GETFACE M_Hill, 0, MouseCollisionFace, Face[]
DEBUG "Collision = "+MouseCollisionFace+",X="+Face[0][0]+",Y="+Face[0][1]+",Z="+Face[0][2]+",nx="+Face[0][6]+",ny="+Face[0][7]+",nz="+Face[0][8]+"\n"
ELSE
MouseCollisionFace=-1
ENDIF
If I turn debug on, there's no crash. By uncommenting the two commented lines I can see I have valid variables to pass to the command :
Injection started
7,-6.900289536,1.999999642,3.900290012,-6.900289536,1.999999642,3.900290012
By putting "END" commands straight after the "IF" and "ELSE" lines, I can prove it's the X_COLLISIONRAY on the first execution of the code that crashes the program.
My setup is Windows XP, GLBasic 10.283