jitspoe / godot_bsp_importer

An importer addon to import Quake BSP files.
MIT License
97 stars 9 forks source link

Feature Request: Add Support for Brush-Based Collisions (wrbrushes) #21

Closed daniel-abbott closed 1 week ago

daniel-abbott commented 4 weeks ago

ericw-tools qbsp tool supports compiling maps with a list of brushes for brush-based collisions, which might be useful for faster and more accurate generation of StaticBody3D collision geometry over the current two approaches.

Further, this opens the door to per-body physics materials - example: take all the brushes with a "stone" texture and put all of those collision bodies under a single static body, which can then receive a "stone" physics material.

https://ericw-tools.readthedocs.io/en/latest/qbsp.html#cmdoption-qbsp-wrbrushes

jitspoe commented 4 weeks ago

Using the brushes would definitely be more optimal. Not sure how significant it would be, considering physics collision calculations are typically O(log n). The Quake2 format also stores the brush data. I'd like to get both of these in at some point, but I don't know when it'll happen. Feel free to make a PR if it's something you need sooner rather than later! I think @Yagich was planning to look at Q2 BSP support. Quake 3 support might also be nice.

I think getting the texture info might be possible even without the brush data. The challenge there is, if a brush has multiple textures, what would you use for the physics material? Ex: Something might have grass on the top and rock on the side. I guess something is better than nothing!

daniel-abbott commented 4 weeks ago

Fair point about the multi-textured brushes, Q1 maps don't support surface flags - I believe both the Q2 and the Half-Life BSP format does, I can't remember if Q3 does but I think so...

Maybe we should just create a new BSP format, with hookers and blackjack

jitspoe commented 4 weeks ago

Yeah, I've definitely considered extending ericw-tools with a special format that simply does the CSG stuff for the meshes and doesn't do any BSP splitting. Not sure how involved that would be.

jitspoe commented 2 weeks ago

Made some progress on this today. The additional brush info does not contain anything about textures, though. It only has the bounds of the brush for collision. Hopefully this will help with some of the physics performance issues I've been running into with more complex maps.

jitspoe commented 1 week ago

Implmented in ce338f2ccd17b61c6b9f3ee08b2394249026d7e8

daniel-abbott commented 1 week ago

Thanks! I guess I was too optimistic about directly tying the visual geometry to the collision geometry, the possibility for improved physics performance though is still exciting, I'll give this some testing myself.

jitspoe commented 1 week ago

In order to do that, we'd have to go through all the textured polygons and attempt to find a matching plane in the collision. It could be done, but would probably slow down the import quite a bit (and there's also the issue of multiple textures per brush to deal with).