X_COLLISIONRAY crash

Previous topic - Next topic

FutureCow

My program will crash when it hits the X_COLLISIONRAY line in the following section of code - but only when debug is disabled

Code (glbasic) Select

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 :
Code (glbasic) Select
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

MrTAToad

Is it crashing inside the IF/ELSE block or the actual command ?

FutureCow

No, the command crashes.

mentalthink

HI a few days I used this command and don´t crash, perhaps it´s Xgetface, I´m not used, in the code containing X_raycollision..

FutureCow

#4
It is definitely the line containing X_COLLISIONRAY that crashes the program as I ran the following test and the program still crashes when not in debug mode.

Code (glbasic) Select
IF X_COLLISIONRAY(M_Hill, 0, x, y, z, x2-x, y2-y, z2-z)<>0
                END
ELSE
                END
ENDIF


Hemlos


hmm interesting codesnip...is this a "test" to see who can see what you see? lol

if then end, else end...

its ending the program not crashing.
Bing ChatGpt is pretty smart :O

FutureCow

As noted on the initial post
QuoteBy 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.
I posted the actual code described by that code in response to metalthinks questioning whether it was one of the commands in the IF statement.

The result was definitely a crash with a "do you want to report the problem to Microsoft" query.

Hemlos

Does the sample in the help file crash too?

More dumb questions(my forte):
Is your collisionray before or after all the x_make3d?
Have you already created/loaded the object before testing the command?
Bing ChatGpt is pretty smart :O

mentalthink

Hi Future, I do this code... it´s based in your code.

The Code it´s attached, don´t care too much to read in these Lines.
Code (glbasic) Select
// --------------------------------- //
// Project: xcollision
// Start: Thursday, June 14, 2012
// IDE Version: 10.283


// SETCURRENTDIR("Media") // go to media files

GLOBAL M_Hill = 100
GLOBAL Face[]
//X_LOADOBJ "Media/objX_ship_Interior_01.ddd", M_Hill

X_LOADOBJ "Media/Box001.ddd", M_Hill

GLOBAL MouseX,MouseY
GLOBAL b1,b2
WHILE TRUE
MOUSESTATE MouseX,MouseY,b1,b2

render()
//STATIC x,y,z, x2,y2,z2
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

STATIC MouseCollisionFace
IF X_COLLISIONRAY(M_Hill, 0, x, y, z, x2-x, y2-y, z2-z)<>0
LOCAL color = RGB(255,0,0)
X_LINE x, y, z, x2-x, y2-y, z2-z, 2,color
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"

message_Screen()
ELSE
MouseCollisionFace=-1
ENDIF


SHOWSCREEN
WEND

FUNCTION render:

STATIC phi
X_MAKE3D 1,1000,45
X_CAMERA 0,0,40 , _
0,0, 0


IF phi<360
INC phi
ELSE
phi=0
ENDIF

X_MOVEMENT 0+(COS(phi)*100),0,-300
X_ROTATION phi,1,1,1
X_DRAWOBJ M_Hill,0
ENDFUNCTION

FUNCTION message_Screen:
X_MAKE2D
PRINT "Now Have collision" , 0 , 0
ENDFUNCTION


Have a little "more complex" collision becuase the object it´s moving... for me your code works fine, in Debug mode too, I only think in the local variables, I put in static , but I turn again to put in Local and works equal...

I think, but this it´s only a speculaton, perhaps the problem it´s the model, I don´t know if it´s a model from a 3D suite or it´s a runtime model... perhaps can be too the extension... I always use .ddd, and never have troubles...

You have attached the complete Code:

PS: Future only a think try to put in your code, when decalare the array for get the faces, try to put global and not in Local... and we see what´s happend


[attachment deleted by admin]

Kitty Hello

or send in the working example that crashes.

FutureCow

Damn! I can't get it to crash now I've added a bit to my program! I'll keep trying and if I can reproduce it I'll upload the example code.
Sorry, I should've thought to do that when I posted the bug report.