UPBGE / upbge

UPBGE, the best integrated game engine in Blender
https://upbge.org
Other
1.45k stars 180 forks source link

Performances issue with add object when there are many animations 0.3 #1252

Open youle31 opened 4 years ago

youle31 commented 4 years ago

Stephen ndungu showed us on discord that when there are many animations in the file, even if actions are not be played, there's a big performance cost in this file when we add object:

https://drive.google.com/file/d/1a7h7FPQacPlAJ9M9sKI7SHOTqlBI8TwP/view?usp=sharing

video: https://cdn.discordapp.com/attachments/716421809406476320/732656425360162906/2020-07-14_18-47-52.mp4

Capture

Note: The lag happens only if add object actuator on "BulletEmpty" is triggered.

Petermhen commented 2 years ago

It appears that this may be the cause of the lag I'm experiencing as well.

I have a .blend with a 3rd person shooter setup. Shooting creates a bullet shell object and decal plane at the hit position using two Add Object actuators. The scene is lagging really badly.

I'll run some tests to confirm that this is the problem.

Petermhen commented 2 years ago

The low fps I was experiencing seemed to be due to how UPBGE 0.3 applies the animations, per https://blenderartists.org/t/upbge-0-3-armature-animation-deform-problem/1365616/3

Switched everything back to UPBGE 0.2.5 and the framerate is fine now.

Perhaps 0.3 shouldn't be listed as stable & shown as the primary download on the Upbge website if there are serious issues such as this. Would save users spending lots of time on it only to have to revert to 0.2.5 to get things working.

BluePrintRandom commented 2 years ago

@Petermhen set up a object pool and reuse the agents (or in your case bullets)

this is a common design pattern https://en.wikipedia.org/wiki/Object_pool_pattern

2.5x has about 1/15th the power of 3.x + (we have geonodes, bpy, openXR, and much more in game**)

we can do amazing things in both 2.5x and 3x is still growing****

BluePrintRandom commented 2 years ago

https://www.youtube.com/watch?v=uBzqbKEl9zI

Petermhen commented 2 years ago

@BluePrintRandom Thank you for the response and the information. Turns out the speed issues wasn't down to the Add Object actuator, but rather just having the armature parented to an object with the object's physics set to "Dynamic". That resulted in a halving of the framerate. From looking through the Blender Artists forum I saw a couple more threads reporting a similar issue. Works fine in UPBGE 0.2.5

I haven't gotten a chance to look through the bug reports to see if this has already been reported.

Thread I made about it. https://blenderartists.org/t/framerate-issue-when-armature-has-parent-with-dynamic-collision-enabled-in-upbge-0-3/1367755