performance of openb3d/minib3d, loads slower after each entity is copied?

Started by William, September 18, 2023, 15:27:40

Previous topic - Next topic

William

Creating over 50 Tplayer instances becomes really slow.. i do not know if it copies methods and functions for every instance.

my best guess is that loading copyentity of 100 animated model entities it slows per after entity is created.

after the application finishes loading and i can play (and i havent tested moving them and animations) the performance is normal.


why is it slower after each entity? ideally i would have thousands of entities maybe 500 visible/not hidden. i would like maybe 500 player entities per session.. maybe not feasible all in one scene though.

time to use a different library?
im still interested in oldschool app/gamedev

Midimaster

For a test I would switch off the GNET-Object-Generation. I guess this is responsible for the slowdown.

 I guess the creating of 50 mesh-copies does not stress the computer.
...back from Egypt

William

negative @Midimaster , debug says the functions ran of new tplayer are copyentity and createpivot. copyentity is causing the slowdown. i understand it is singlethreaded, i do not know if this particular function(s) like moving and animating entities may be threaded. it is not explained why it is slower each time an entity model is copied, @markcwm .i will need to conceptualize scaling the scope of the project game. i would like to have a discussion about that, too.

though cpu usage of all 8 of my cores one is 100% during loading and the rest were at 20%. 2.8ghz.
im still interested in oldschool app/gamedev

markcwm

Hi William,

yes CopyEntity is slow because it creates a "deep" copy of the mesh, including children and bones. So what you do in Openb3d is use RepeatMesh instead (this is not something available in Minib3d) which creates an "instance" of the mesh sharing everything else with the parent, like rotations, etc. It is like CopyEntity in Blitz3d, but Minib3d changed CopyEntity so Openb3d kept this change and added RepeatMesh instead.

To clarify CopyEntity is like CopyMesh in Blitz3d and RepeatMesh is like CopyEntity in Blitz3d, and CopyMesh is it's own new thing which doesn't copy any children nor animations, it's like CopyEntityLight.

Angros wrote a good docs which you should refer to:
https://sourceforge.net/projects/minib3d/files/OpenB3D.pdf/download


markcwm

Yes, I wrote an example of loading meshes with threads, I think it was faster, test it out.

https://github.com/markcwm/openb3d.docs/blob/master/standard/loadmesh_threads.bmx

Go to the LoadOrk function and replace CopyEntity with RepeatMesh.

William

@markcwm ty was that you whom i shared a project with all them years ago? i met a player whom shared coding with me.
but my real question/post is that bones may be necessary for wielding items ingame (though i do not know exact mechanics of methods for that purpose.)

im still interested in oldschool app/gamedev

Midimaster

Yes you are right... I tested it the CopyMesh() slows down the startup of the app

Workaround:

Does really every Player need it's Mesh from the very beginning? Even when he is not visible for the local player?

If you start with 500 players and you do not copy the meshes imediately, the startup needs 26msec. Now you need an algorithm that checks which TPlayer's coordinates are really closed to the camera and in front of the camera. Only those will receive an Entity to be visible.

Or this idea: Instead of the mesh every TPlayer gets an TSprite first. The TSprite shows an image of a mesh. Also this needs only 100msec for 500 Players. Now you need the algorithm that checks which TPlayer's coordinates are really closed to the camera and in front of the camera. Only those will change the TSprite with the Mesh.
...back from Egypt

William

@gwron @markcwm or somebody it's great it can be threaded but what is the cause the bottleneck that each time an entity is copied it loads the next copy slower?
im still interested in oldschool app/gamedev

markcwm

Assuming you are rendering all the entities at the same time like in the threaded demo, that is the bottleneck, the more rendering work then the slower it is to load an entity. If it's not that then it would be memory.

Derron

As said earlier already (other thread/chat): 
Provide a simple base example exposing the issue. The code must be self contained (except for an asset you might provide). 

This will make it easier for us to see WHAT you do, HOW you do it and then identify why it is slow.


bye
Ron

funkheld

Hi good afternoon. I'm new here at 74 years old from Germany. 

This openb3d.pdf is also intended for minib3d? are the commands of openb3d and minib3d the same? 

Thanks. greeting

Midimaster

Quote from: funkheld on September 23, 2023, 12:11:56... This openb3d.pdf is also intended for minib3d? are the commands of openb3d and minib3d the same?
More or less...

The amount of commands is much bigger than the aviable commands in MiniB3D.

MiniB3D is very similar to old school Blitz3D. So if you find an old Blitz3D download anywhere..it's HELP has a very good command reference and an alphabetic reference with hundered of examples. This may help more for Minib3D use.

And as I know you are from Germany... the german forum has a real good Blitz3D reference too:
https://www.blitzforum.de/help/?cat=2
...back from Egypt


William

may there be a way to pause rendering until all entity copies have finished would that load faster? later i may try threading it however bones are required for animation of child entities of bones like sword attack.
im still interested in oldschool app/gamedev