why many pivots takes time to render ?

Blitz3D Forums/Blitz3D Beginners Area/why many pivots takes time to render ?

RemiD(Posted 2016) [#1]
hello,

to me, a pivot is just a 3d point in 3d space with a position, an orientation, a scale. (and sometimes a parent or/and childs)

i can understand that if there are many parents or/and childs, it can take more time to render because the childs will be oriented positionned scaled according to their parents.

however if there is no such thing, then why many pivots takes time to render ?
(in my example, it takes only 1.28ms to browse a 63000 list of 3dpoints (with their positions, orientations, stored in dim arrays), and without pivots the render time is fast, only 0.12ms, but if i create a pivot for each point (so in total 63000pivots), the render time takes a lot of time, more than 37ms)


Bobysait(Posted 2016) [#2]
Pivots are not "juste a 3d point in 3d space" it's an entity.
Creating a single pivot takes time to update the hierarchy (even without parent, it needs to be attached to something internally -> to a root list or to a single global Parent)
It uses several extra data such as matrix, quaternions and vectors but also contains its own children list (empty or not) and several bunch of states (hide/show etc ...)
Then on render time :
A simple type containing a position vector is not computed at all (it's not part of the Blitz runtime, it's just user data) while a pivot is an entity that Renderworld needs to decide if it has to be rendered or not.
So it makes a lot of tests for nothing.

If you really just need 3d points, then use 3d points, not pivot, they are not really done for this kind of purpopse.

* have a look on the memory if you can :
-> create a simple code like
Graphics3d 800,600,0,2
WaitMouse()

FlushMouse()
For n = 1 To 1000000
CreatePivot()
Next
WaitMouse()
End

(take care, it should use about 800 Mo of ram ^^)

-> launch the program, it will wait for a mouse event "on the blitz window"
-> open the task manager and find the process
-> have a look on the initial memory used.
-> go back to the "waiting window" and hit any mouse button (the program will wait again)
-> go back again to the task manager and see how many memory usage 1000 pivot takes (divide by 1000000 and you'll understand the tons of stuff a simple pivot can be holding, it should be something around 800 octets per pivot ... for just a 3d point which should not take more than 1handle (an integer adress for the variable that holds the vector = 4 bytes) 4 bytes per float * 3 components -> 16 bytes)


RemiD(Posted 2016) [#3]
ok, thanks for these precisions...
i will continue to use pīvots, but with moderation...
for example i will store the 3dpoints positions orientations in dim arrays and then use only one pivot that i will position here and there when needed. noted.


Bobysait(Posted 2016) [#4]
Depending on the usage, position/move/translate/rotate/etc... can take lot of time. If it's just to get some data, skip the using of entity if possible
Sometimes, just using simple maths is enough.
Else, you can use the big maths library I posted on the code archive, everything an entity does is doable with this library.
I'll update it to simulate entity transformations, so there won't need "temporary" entities for simple stuff ;)

[edit]
Have a look on the code archive, I've added the stuff for replacing pivots by transform objects.
It can be faster, or slower ... depending on the requirements.
Hope the sample is clear enough, I'm not very critic for what I do ... it always seems clear to me (as I coded it -_-)