Speed of CreatePivot and FreeEntity

Blitz3D Forums/Blitz3D Programming/Speed of CreatePivot and FreeEntity

KuRiX(Posted 2005) [#1]
Hello again Friends.

I am using Pivots a lot of times in my game. In every function i need i create a pivote, i use it, and then i free it. I can say i create and destroy over 50 pivots every frame (50 frames per second in my game).

Can this become a slowdown problem or can i continue using it without worry?

thanks a lot. Cheers.


RGR(Posted 2005) [#2]
Hello KuRiX.
Put this into your code and count each time you call the Function
If its relevant you could add PositionEntity... and things you are doing in your code to make it a bit more specific and then translate your website...
time=time+CreateAndKill(200)

Type piv
	Field pivot
End Type

Function CreateAndKill(Num=200)
	m=MilliSecs()
	For i=1 To Num
		p.piv=New piv
		p\pivot=CreatePivot()
	Next
	
	For p.piv=Each piv
		FreeEntity p\pivot
	Next
	Delete Each piv
	Return MilliSecs()-m
End Function

Result here: 14 Million Pivots cost 10 seconds and my framerate dropped from 283 down to 280 FPS
CreateAndKill 1000 Pivots each Frame lets the Rate drop down to 168.
Means: 50 to 100 Pivots each frame is not measurable with Millisecs() because its always 0


KuRiX(Posted 2005) [#3]
Well thanks!. Of course in each function i rotate the pivot, position it in different places, etc...

My question was if it is worthy to make a Global Pivot, then use it where i need, instead of creating and deleting in every function.

For what you say creating and kill 1000 pivots could be a problem. I will count how much pivots i create every time. Thanks Again!


Ricky Smith(Posted 2005) [#4]
A global pivot is a much better idea !


RGR(Posted 2005) [#5]
Can this become a slowdown problem or can i continue using it without worry?

This was your question and not that one:

My question was if it is worthy to make a Global Pivot

Some of you people are really funny...
Your posting gives the impression to me you MUST use at least 50 pivots or am I the only one who cannot read? :-P
Btw: As Smiff stated
A global pivot is a much better idea !

No further comment needed ... ;-)


Danny(Posted 2005) [#6]
he might only need one or two at a time...


KuRiX(Posted 2005) [#7]
Well, i have changed all my code to ONE global pivot. I have needed to change lot of things, cause i used pivots in lof of functions.

But i must say i have gained 50ms of execution per second.

So, we all know now the answer!

P.D: RagR, i don't understand your last post.


RGR(Posted 2005) [#8]
But i must say i have gained 50ms of execution per second.
That's better than 50ms per Frame as long as you don't gain Framerates lower than 1.0... ;-)
So, we all know now the answer!
NOW? We all knew the obvious answer before... nobody else had the idea to Create and Free 1000s of Pivots each second...
P.D: RagR, i don't understand your last post.
One day you will die and still not understand this very important last post... because this is not the place for a German to explain a Spaniard his exegesis of the english language... LOL


KuRiX(Posted 2005) [#9]
How funny is for you insulting me instead of helping me?

It is not so obvious.

For example, with Global Pivot:

positionentity globalpivot,x,y,z
moventity globalpivot,0,1,0
Functionthatusesthepivot()
positionentity globalpivot,x,y,z
moventity globalpivot,0,1,0
Functionthatusesthepivotsecondversion()

Without global pivot:

localpivot = createpivot()
positionentity localpivot ,x,y,z
moventity localpivot ,0,1,0
Functionthatusesthepivot()
Functionthatusesthepivotsecondversion()
freeentity localpivot

In the second case you don't need to care about the uses of the functionthatusespivots makes with the pivot, because it will use its own pivot.

Cheers!


RGR(Posted 2005) [#10]
I'd say since you can only use one of the functions at a time you do not need a local pivot in a second function at all.
Because each time you call one of those functions the pivot (jumps) gets positioned at his new place anyway and as long as your Function does not refer to the global Pivot used in other Functions and the global Pivot gets not parented to anything there's only one needed.
But I exclude that because you were speaking of 50 Pivots and Functions. In that case I wonder how you would be able to track that all and keep the proper grasp if they were additionally referring each other ...

And KuRiX... I never had in mind to insult you at all (that's what the emoticons should express ;-)
Actually I only bite when I feel I got bitten...
And I only write when I am sure its a help or if the posting is too dumb and my bad mood makes me to react (as several others here with loveliness react on my writings :-D
But you're right - I found it funny indeed that you thought you had made completely clear in your first posting what you meant while I still think the opposite is true ... LOL

Its all a matter of interpretation:
and then translate your website...
of my first answer above could be read as rude...
but also ...
"there was someone interested in my website but unfortunately didn't understand the language"
I let it open to you what you read in it...