Pivot picking bug

BlitzMax Forums/MiniB3D Module/Pivot picking bug

Difference(Posted 2008) [#1]
Using the lastest version, 0.51 - 10/05/08
In class tPick

in function
Function Pick:TEntity(ax:Float,ay:Float,az:Float,bx:Float,by:Float,bz:Float,radius:Float=0.0)

the line
pick=C_Pick(c_col_info,c_line,radius,c_col,c_tform,tree,ent.pick_mode)

crashes with a "Unhandled Exeption:Unhandled memory Exeption Error", when the picked entity is an Pivot.

Pickmode is set with EntityPickMode(2) on an entity that contains one pivot( parent), and one mesh (child).


Difference(Posted 2009) [#2]
Bump

Here is code reproduce in ver 0.531
Pick where the box used to be, to see it crash.

A quick fix in tPick:

If ent.pick_mode=0 Or ent.Hidden()=True Or piv.class$="Pivot" Then Continue

But then pivots are unpickable





Difference(Posted 2009) [#3]
Btw: Pickmode 3, does not have this problem.


SLotman(Posted 2009) [#4]
On TPick.bmx where you see:

	
pick=C_Pick(c_col_info,c_line,radius,c_col,c_tform,tree,ent.pick_mode)
			
If pick
	picked_ent=ent
EndIf


make it:
		
If tree<>Null Then
   pick=C_Pick(c_col_info,c_line,radius,c_col,c_tform,tree,ent.pick_mode)		
   If pick 
      picked_ent=ent
   EndIf
End If


It should work. Don't know if pivots are picked or not, but at least your sample doesn't crash anymore here...


Difference(Posted 2009) [#5]
Thanks Slottman for finding the reason.
Looking into it, I now suggest a slightly different fix.

In tPick.bmx, Function Pick()

change If TMesh(ent)<>Null section slightly, by adding an elseif


This will allow pivot box picking and fix the crash:

			If TMesh(ent)<>Null
				TMesh(ent).col_tree.TreeCheck(TMesh(ent)) ' create collision tree for mesh if necessary
				tree=TMesh(ent).col_tree.c_col_tree
			ElseIf ent.pick_mode = 2	' skip pivots with pickmode 2
				Continue
			EndIf