codecat / godot-tbloader

TrenchBroom Loader for Godot 4. (Alternative to Qodot)
MIT License
232 stars 29 forks source link

brush-entities are ignoring the "origin" property #94

Open Skaruts opened 7 months ago

Skaruts commented 7 months ago

Brush-entities ignore the origin property and always end up positioned at the center of their geometry, making it impossible to make rotating entities with TBLoader (doors, levers, fans, etc).

It would be nice if one could define the point of rotation, by defining the origin property in TB.

(TB doesn't currently have a good way to edit origins, but one can use a dummy point-entity, and copy-paste the origin value to the brush-entity.)


I tackled this in my fork and I found a possible fix. I found that libmap itself seems to create brush geometry relative to the entity's center or something, so fixing this at a core level might be tricky. Also because changing that code will also affect world geometry.

So the way I fixed it is perhaps a little hacky, but seems to work fine. Basically it's just two steps:

(Ignore the switch-case changes at the bottom of that commit, as they're irrelevant to the issue. That was just my OCD being triggered by unindented cases.)