Linepick/camerapick

Blitz3D Forums/Blitz3D Programming/Linepick/camerapick

Makepool(Posted 2006) [#1]
I’m not sure if this is a bug which is why I’ve not posted in the bug section, yet at least. I’ve been doing some experiments and I’ve noticed that camerapick is much slower than a linepick even though it is over the same distance. I just wondered why this was the case as it’s surely very similar code within Blitz3D.


Ross C(Posted 2006) [#2]
Remember that camerapick will go as far as the camera range is. Linepick has a distance parameter. Do you mean, if you send a linepick from the cameras co-ords and a camera pick and hit the same object, the camera pick is slower?


jfk EO-11110(Posted 2006) [#3]
I also thought they are about the same in speed. Ross is correct, as soon as you pick "nothing" then it'll be the camera range, that may be a very long range. I usually put an invisible, meshflipped big cube around the camera, so camerapick will hit it instead of scanning until it reaches the horizon.

But if Camerapick is really slower for some reason, that would be strange.


Makepool(Posted 2006) [#4]
I should have been more specific but I was in a rush. I know there's no range on a camerapick but I am picking things and at the same range so why the diffference?


Ross C(Posted 2006) [#5]
I know this might sound daft, put have you set a pickmode for the item your picking? The reason i say, is you might think your picking something, but actually going straight through it.


Ross C(Posted 2006) [#6]
Hmmmm, verrrrrrrrrry strange. lol. Basically, Linepick is extremely slow, compared to camerapick... odd or what?

Graphics3D 800,600
SetBuffer BackBuffer()


Global camera = CreateCamera()
PositionEntity camera,0,0,-20


Global cube = CreateCube()
EntityPickMode cube,2

Global cube1 = CreateCube()
EntityPickMode cube1,2
PositionEntity cube1,2,0,-5



While Not KeyHit(1)

	Cls


	If MouseHit(1) Then
		CameraPick(camera,MouseX(),MouseY())
		If PickedEntity() <> 0 Then
			flag$="picked with camera pick!, time of = "+PickedTime()+" entity = "+PickedEntity()
			EntityColor PickedEntity(),Rnd(0,255),Rnd(0,255),Rnd(0,255)
		Else
			flag$="nothing picked..."
		End If
	ElseIf MouseHit(2) Then
		LinePick(0,0,-20,0,0,20)
		If PickedEntity() <> 0 Then
			flag$="picked with line pick!, time of = "+PickedTime()+" entity = "+PickedEntity()
			EntityColor PickedEntity(),Rnd(0,255),Rnd(0,255),Rnd(0,255)
		Else
			flag$="nothing picked..."
		End If
	End If
	
	UpdateWorld
	RenderWorld
	Text 0,0,flag
	Flip
Wend
End



Ross C(Posted 2006) [#7]
I've done some more tests. The further you move the camera away, doesn't seem to affect the time much... It seems most of the extra time in linepick, is spent doing something other than picking... very strange...


jfk EO-11110(Posted 2006) [#8]
indeed. is this the same with older versions of blitz too?


RGR(Posted 2006) [#9]
.

Last edited 2012


Stevie G(Posted 2006) [#10]
I asked about pickedtime() in the past and while the documentation states that it's the execution time I'm sure someone told me that it actually returns the time (0...1) based on interpolation between the pick starting and end points. e.g. If the entity was picked half way between the start and end point it would return .5.

I may be wrong though but worth considering.

Stevie


Ross C(Posted 2006) [#11]
Interesting thought Stevie. And no RaGR, your input is very much welcome. Just personal insults aren't ;o) It was just a quick test as i had to rush out. You have a good point stevie. A similar problem arises with AnimTime(). It doesn't return the actual Animation Time, rather the current frame i believe.

[EDIT]
Ok, i've done some more testing. Looks like your stevie and RaGR. Thanks for that :o)


big10p(Posted 2006) [#12]
Yep, Stevie is correct about PickedTime() - it has nothing to do with the actual time the pick took to execute.


Ross C(Posted 2006) [#13]
What a stupid error, and command name to use...


big10p(Posted 2006) [#14]
Yeah, I remember PickedTime had me scratching my head when I first tried using it. It's clear that whoever wrote the docs for the command didn't understand how it works, either. :/

Actually, I think I've only ever used the command once. You can (I think) use it to calculate the distance from the start of the pick to the picked point with PickedTime() * pick_length.