lag in camerapick()

Blitz3D Forums/Blitz3D Programming/lag in camerapick()

I think the CreateSphere line is what's slowing it down. Try this...

Graphics3D(640,480,0,2)
SetBuffer(BackBuffer())

c = CreateCamera()
PositionEntity(c, 0,0,-2)
CameraRange(c, .1,5)

s = CreateSphere(64)
EntityPickMode(s, 2)

s1 = CreateSphere(2)
EntityColor(s1, 255,0,0)
ScaleEntity(s1, .1,.1,.1)
s2 = CreateSphere(2)
EntityColor(s2, 0,255,0)
ScaleEntity(s2, .1,.1,.1)

While Not KeyHit(1)
	t = MilliSecs()
	CameraPick(c, MouseX(), MouseY())
	PositionEntity(s1, PickedX(), PickedY(), PickedZ())

	PositionEntity(s2, (MouseX() - 320)/640.0 * 2, -(MouseY() - 240)/480.0 * 2, -1)

	If MouseHit(1)
		DebugLog "***********************************"
		DebugLog "before creation " + (MilliSecs()-t)
		FreeEntity(n)
		n = CopyEntity (s)
		DebugLog "after creation " + (MilliSecs()-t)
		EntityPickMode(n, 2)
	EndIf

	RenderWorld()
	DebugLog "after renderworld " + (MilliSecs()-t)
	Flip()
Wend
End


I'm not certain if a CopyEntity command retains the pickmode, but I am assuming it doesn't.