Linepick/camerapick

Blitz3D Forums/Blitz3D Programming/Linepick/camerapick

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

An incomplete Documentation and an incomplete test program may cause wrong conclusions...

What is 0.014 vs 0.019? hours? seconds as I believe you think? or millisecs?!
The docs don't tell...

So put
m=MilliSecs()

before the If Mousehit(1) line

and after
Endif
m2=millisecs()-m

plus
Text 0,15,m
Text 0,30,m2

before Flip

I have m2=0 ! Always. What means its less than 1 millisec
So what is it therefore: 0.014 is 14 microsecs ? In this case: Not a big reason to worry about, right?!
And no bug at all! And not extremely slow either.

So try this (1000 Picks and 3000 Rnds each loop!):
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

cursor=CreateImage(20,20)
CameraClsColor camera,60,55,55
While Not KeyHit(1)

	m=MilliSecs()
	MFlag=0
	If MouseHit(1) Then
		For i=1 To 1000
			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
		Next
		MFlag=1
	ElseIf MouseHit(2) Then
		For i=1 To 1000
			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
		Next
		MFlag=1
	End If
	m2=MilliSecs()-m
	If MFlag<>0
		lastm2=m2
	EndIf
	
	UpdateWorld
	RenderWorld
	Color 255,255,255
	Text 0,0,flag
	Text 0,15,m
	Text 0,30,m2
	Text 0,45,lastm2
	DrawBlock cursor,MouseX(),MouseY()
	Flip
Wend
End

In other words: If I didn't make a mistake, it picks 100s of entities without you being able to measure it with the millisecs() function...


Oh boy, I dared to do it again... bash me as usual
.