Closed Cobertos closed 2 weeks ago
An even hacky-er solution that I've started to do is just putting the KV props right in the entity name. This way they traverse the whole import pipeline but I can deserialize them on the other end.
(unfortunately a name of 64 characters will crash hammer++ so I have to be careful)
I quickly did the Rust side of this in this branch, so only the Python import code would need to be edited to import this information. So if you want to experiment with how to get the properties to Blender using the Python API, you can clone this branch and edit the file unknown_entity.py, where the properties would be accessible by calling the properties() function returning a dict in the UnknownEntity class.
You would need to build the Rust code to get the new function there, but there are instructions for that in the readme.
This is only for unknown point entities imported by the "import unknown entities" option though.
Wow thanks! I will try this and report back
I was able to get it built and working, the additional code in unknown_entities.py
was very simple. I will push up a commit to a fork.
The instructions you provided in the README were very helpful. Thank you for that. I am much less familiar with Rust so I needed that.
Pushed up a commit to https://github.com/Cobertos/Plumber/tree/feature/unknown-entity-properties , I can make a PR if desired?
Only open questions I thought of while working on this:
Ah, I realized this does not work for brush entities, but it looks like BuiltBrushEntity inherits from BaseEntity so it should be possible to do the same thing for those. oh no it doesnt Im dumb
This is further complicated by brush entities not mapping to a single object datablock, as the solids are unpacked.
Thanks, looks good! A PR would be great!
Could you check if this works in Blender 2.90? It is still supported according to the readme, but I think the minimum supported version can be raised if needed.
I think if we want to add the entity class to all objects, might as well add all the properties for them in the same way as for unknown entities. It should be fairly easy to do this the same way as for the unknown entities. But yeah, we would need a flag for that to avoid the clutter, and it could also make the import slower. This could be also further extended to also include the properties in vmt files for materials, for example, if it's possible to add custom properties for materials.
I don't think it makes sense to ignore any properties as it would complicate the code without that much benefits.
For the brush entities, if the merge solids option is enabled, there is one object for one brush entity so the properties could be added there in that case. If the solids are separated, the same properties could be imported for all solids of the brush entity, or not imported at all, not sure which one would make more sense. But even with just this I think a flag for whether to import the properties or not should be added.
PR - Okay, I will get the PR in later today. Test with Blender 2.90 - Sure, I can test 2.90, it will take me a bit longer to get to that as I really want to finish up this mod first. Entity class - Okay, I dont have an immediate need for this, having it in the name was enough for me. Dunno if that's worth the extra work for either of us rn. Ignore properties - Sounds good to me Brush entities - I know no Rust but I was able to hack this in. I will push up a separate branch for this in a bit too. For non-merged, it adds it to all brushes. For my uses, all my entities are a single brush anyway so it works for me
Sounds good! I can also test it with 2.90 at some point, but not sure when I would have time for that.
Good to hear you got the brush entity support in, from what I checked looked like it would require edits to plumber_core as well, were you able to do those or did you find some other workaround?
Got another PR for this actually, so this is now implemented in the latest release.
The properties are not currently added for brushes though, so I'm open to accept PRs for that as well.
Describe the solution you'd like For unknown entities (brush or point) current the only extended data you can get from it is the name of the entity as the object name prefix, it would be nice to have the option to import the entity type and associated properties to Blender's custom KV props that are stored under the object datablock.
As an alternative, just plain strings or even more influence on the import name would even be enough to hack with.
Additional context This is useful for example to convert something from Hammer -> Blender -> Game Engine where an importer on the engine side would be able to read the entities and act on the data. Unity's asset importer has a method to hook into for converting/doing stuff based on these properties.