Slow Down unknown

Blitz3D Forums/Blitz3D Programming/Slow Down unknown

Baystep Productions(Posted 2006) [#1]
Const FPS=65
Global framePeriod=1000/FPS
Global frameTime=MilliSecs()-framePeriod
While Not KeyHit(1)
		Repeat
			frameElapsed=MilliSecs()-frameTime
		Until frameElapsed
		frameTicks=frameElapsed/framePeriod
		frameTween#=Float(frameElapsed Mod frameperiod/Float(frameperiod))
		For frameLimit=1 To frameTicks
			If frameLimit=frameTicks Then CaptureWorld
			frameTime=frameTime+framePeriod
			UpdateWorld()
			If curmode%=0
				UpdateSpaceMenu()
			Else
				UpdateGame()
			EndIf
			
		Next
	RenderWorld frameTween	
	If curmode%=0
		UpdateSpaceMenu_HUD()
	Else
		UpdateGame_HUD()
	EndIf
	Flip
Wend
End

Function UpdateSpaceMenu()
	mx=MouseX()
	my=MouseY()
	TurnEntity planet1,0,.05,0
	pick%=CameraPick(cam,MouseX(),MouseY())  ;<--- This is the main source of it!
	;If pick=planet1
	;	EntityColor planet1,255,0,0
	;	EntityAlpha planet1,.8
	;Else If pick=0
	;	If oldpick=planet1
	;		EntityColor planet1,127,127,127
	;		EntityAlpha planet1,1
	;	EndIf
	;EndIf
	oldpick=pick
End Function

Function UpdateSpaceMenu_HUD()
	DrawImage(cur2,mx,my)
End Function


Why is the fps dropping so low? I've tried in both debug and not. The scene is only 2900 tris. Its just a planet in space . Any ideas by looking at it?

|Notice the comment on the camerapick line in UpdateSpaceMenu!|


WolRon(Posted 2006) [#2]
CameraPicks are slow.
CameraPicks with long CameraRanges (if I'm not mistaken) are even slower if the CameraPick didn't collide with anything.
2D commands (DrawImage) with some graphics cards can be extremely slow.


lo-tekk(Posted 2006) [#3]
I am using camerapick quite often without a considerably loss of framerate. But i run the pick only every 100 ms or so. Then i call MouseX() only once per gameloop and store these values globally, thus whenever i need mousecoords i have them handy. Then you should avoid using 2d image commands. Get yourself one of the 3D-Font/Sprite/HUD engines.

-------------------------
www.moonworx.de


Ross C(Posted 2006) [#4]
Yep, long picks, whether it be camera pick or linepick, are slow. If need be, scale everything down for shorter pick lengths, and create an invisible quad, that fills the camera view and parent it. This will act as the furthest away thing, so your pick doesn't go on forever, as it will always hit that quad.


Baystep Productions(Posted 2006) [#5]
well I tried the quad Idea, and the back quad is only 20 units forward, and it's still slow. (yes I set the pickmode)

Any alternatives?


Baystep Productions(Posted 2006) [#6]
Okay, heres something. The framelimiting part is causeing most of it with the CameraPick. Any Ideas why?


Scherererer(Posted 2006) [#7]
pick%=CameraPick(cam,MouseX(),MouseY())


why are you converting the picked object's pointer to an integer? that might have something to do with it, maybe the blitz compiler doesn't know what to do with it so it just slows down to process it every time.


Baystep Productions(Posted 2006) [#8]
no actualy, it woks now.
And the integers do work, thats what the memory adress is.

MODERATOR: Delete this thread.


Ross C(Posted 2006) [#9]
What solved the problem?


LineOf7s(Posted 2006) [#10]
Why delete threads that are likely helpful to others?

And letting us know what the problem was will help a great deal. Thankyou.


Baystep Productions(Posted 2006) [#11]
Hmmm.. okay fixing the problem I had to:

- Mouse positions used variables mx and my.
- A quad "mesh" was used instead of a sprite behind the scene.
- Pick modes where changed for planets from poly to sphere.

A quad mesh file was used because for some reason Blitz does not support poly picking on sprites and I couldn't figure out how to set up the box.


WolRon(Posted 2006) [#12]
- Pick modes where changed for planets from poly to sphere.
Yeah, that would help considerably.

MODERATOR: Delete this thread.
If everyone did that once they figured out their problems, there wouldn't be any threads...