help with "erratic" collision error...

Blitz3D Forums/Blitz3D Programming/help with "erratic" collision error...

Damien Sturdy(Posted 2004) [#1]
hey peeps...

now, out of debug mode, this all works, and the game runs... BUT, put it in debug mode and i instantly get an error.

Theres too much extra code to post it all, but heres the failing chunk:

	For ent.ODE_Object = Each ODE_Object
			em=ent\mesh
			If ent\colmesh<>0 Then ent\mesh=ent\colmesh
			cm=ent\mesh
		
			;check whether this object is a sphere
			If (ent\obtype = 2 Or ent\obtype=1) And (ent\collisioncheck=1)

				;it IS a sphere so handle the mesh collision
				If EntityCollided(cm,COLTYPE_poly)  ;And CountCollisions(ent\mesh)>0    <<interesting bit
					;how many collisions for this object?
					cc=CountCollisions(ent\mesh)
					
					If cc>2 Then cc=2
					For c=1 To cc

						;update the global collision array data which will get passed to the DLL
						If Globalcolcount<colsalowed Then	GLOBALCOLCOUNT = GLOBALCOLCOUNT + 1
						c2 = GLOBALCOLCOUNT
						yc#=0:If ent\mesh=ent\colmesh Then yc=-1
						
						cx#=CollisionX(ent\mesh,c)     ;MARKED LINE!!!
						cy#=CollisionY(ent\mesh,c)
						cz#=CollisionZ(ent\mesh,c)
.......



Okay, so what im getting is at the marked line, an error saying "collision index out of bounds"..... i can't for the life of me figure it out? I am in no way altering the value of C... it appears to be coming right from the for loop. Is it possible for something to alter the value of C?

what can cause this? any advice towards fixing is greatly apreciated!

Lemme know what else you need.. (more code?)


MadJack(Posted 2004) [#2]
Damien

I've been having an intermittent 'collision index out of range' error crop up as well when countcollisions gives a value greater than 1 (although I don't know if this latest Blitz version has an effect).

Possible fix is to loop for 1 to c-1 (when c > 1), but that means not all multiple collisions will be looked at.


Damien Sturdy(Posted 2004) [#3]
the problem is, even when i manually check for the Out Of Bounds issue, and dont do the check when it is, the program stops working....


Im using Blitz 1.88.. Is this a bug then you think?


MadJack(Posted 2004) [#4]
Damien

Yeah, I can't see how it can be anything but - when you have a current collisioncount value, then check each index number directly after the countcollision command and it bombs out, it has to be a bug(?).

As an stopgap I'm just using the first collision and have put the issue on the list of things to look at later.


Damien Sturdy(Posted 2004) [#5]
Im not gona post it over to the bugs forum yet, il keep playing... but this is kind of worrying, because to only check one collision will no doubt end up with my entities dropping through floors (which happened earlier)...


Cheers for your help

Email/msn me (same address) if you want to experiment with this lil fecker...


big10p(Posted 2004) [#6]
Have you seen this?
http://www.blitzbasic.com/Community/posts.php?topic=27508


Damien Sturdy(Posted 2004) [#7]
For now, my code seems to be working..

a ";" had become a ":" further down the code... which was a commented "resetentity".. hehe...

big10p.. thanks for that, its worth noting...


Damien Sturdy(Posted 2004) [#8]
Some screenies this is being used in....

http://www.blitzbasic.com/Community/posts.php?topic=40455