TheGameCreators / GameGuruRepo

The GameGuru Repository For Community Collaboration
http://www.game-guru.com
137 stars 56 forks source link

Add support for convex hull for faster form of Polygon collision #5038

Open boltactiongaming opened 1 year ago

boltactiongaming commented 1 year ago

Having been debugging and optimizing some old work, I found that there were significant performance bottlenecks which could be isolated to one region and one region alone: the use of the polygon collisionmode.
This is easily duplicable.

Take an empty level. Go to mega pack 3 scenery --> "Office & Industrial props" (CASE MATTERS). This version of the water cooler uses a box-type collision mesh with full transparencies, PBR, etc.

Now use any other version of that water cooler you like. FPSC classic set, for instance. This uses old shaders, low quality graphics, and .. the polygon collision mode. Bump into the object while monitoring physics performance via tab screen.

You will go from very low 3-5% values on the high quality box-type one, to very high values (80%) and framerate drops on the low quality one.

I've been able to duplicate this with around thirty different models. The fix EACH TIME is to convert them to box type. However, not all models are suitable for this.

boltactiongaming commented 1 year ago

https://github.com/TheGameCreators/GameGuruRepo/issues/1140 possibly related

MonkeyFrogStudio commented 1 year ago

Polygon collision is the slowest, most intensive form of collision detection and should rarely, if ever, be used. It forces the engine to consider every single polygonal face for collision purposes. If it's not possible for a player to collide with, say, a small crevice or dent on an object, then there's no need at all for the engine to have to calculate collision for the polygonal faces there.

If none of the other collision methods are suitable (cylinder, sphere, box, etc.) for the shape of the object then the best option is to create your own custom collision mesh that has as few polygonal faces as possible while still approximating the shape of your object.

davetgc commented 1 year ago

As @MonkeyFrogStudio said, poly collision should really be avoided, as it will cause some massive slowdowns. It has it's place, but isn't recommended for general use. As you say, converting models to BOX collision or even no collision if the player or NPC isn't going to interact with it is the best bet.

boltactiongaming commented 1 year ago

Poly collision is the only option for models that are based on segment or building components, however, such as the asylum pieces. That said, it feels worse than previous versions.

Obviously poly is going to be the lowest performance but we're talking a difference of practically no frame loss to a total drag down to 30 FPS with just a few models.

I don't recall it ever being that substantial or big of a drag. Performance improvements should be sought as this is clearly low hanging fruit and I'd argue that it's behavior is totally out of line even if SOME performance drain is expected. If the engine is supposed to have a nearly 1000-10000% increase in processing from cube to poly maps per object, then why even have it in the engine, you know?

MonkeyFrogStudio commented 1 year ago

Poly collision should not be the only options for models that are based on segments or building components. You could use Hull Decomp or Convex Hull, depending on the model. Of course, once again, the best solution is a custom collision mesh. As stated previously, polygon collision should rarely, if ever, be used.

boltactiongaming commented 1 year ago

Except what I'm saying is that I've tested the alternative solutions of different collision modes - they do not work, full stop. You cannot walk through the area. So those are non-starters as far as a resolution is concerned.

Kitakazi commented 1 year ago

Unless it was added at a later date I don't think Classic even has Hull Decomp. Boltactiongaming you should try Max man... I think you would be quite pleased. (sorry not trying to turn your bug report into a discussion just kinda shocked you're still using classic)

MonkeyFrogStudio commented 1 year ago

@Kitakazi Yeah, I didn't realize, when I'd posted, that this was about Classic. My bad.

boltactiongaming commented 1 year ago

Agreed, @Kitakazi I should, but I have reasons for my madness :) That said, this is 100% a classic issue, not sure about max.