Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown Entity General KV Property Support #181

Open
Cobertos opened this issue Feb 20, 2024 · 9 comments
Open

Unknown Entity General KV Property Support #181

Cobertos opened this issue Feb 20, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@Cobertos
Copy link

Cobertos commented Feb 20, 2024

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.

image

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.

@Cobertos Cobertos added the enhancement New feature or request label Feb 20, 2024
@Cobertos Cobertos changed the title Unknown Brush/Solid Entity Support Unknown Entity General KV Property Support Feb 23, 2024
@Cobertos
Copy link
Author

Cobertos commented Feb 24, 2024

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.

image

(unfortunately a name of 64 characters will crash hammer++ so I have to be careful)

@lasa01
Copy link
Owner

lasa01 commented Feb 24, 2024

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.

@Cobertos
Copy link
Author

Wow thanks! I will try this and report back

@Cobertos
Copy link
Author

image

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.

@Cobertos
Copy link
Author

Cobertos commented Feb 25, 2024

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:

  • Should entity class be added as a custom property for all objects? Most likely would want to be behind a flag because that's a lot of extra stuff
  • Should "origin", "angles" and other custom properties that are already handled elsewhere be ignored for adding as properties to unknown entities

@Cobertos
Copy link
Author

Cobertos commented Feb 25, 2024

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.

@lasa01
Copy link
Owner

lasa01 commented Feb 25, 2024

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.

@Cobertos
Copy link
Author

Cobertos commented Feb 25, 2024

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

@lasa01
Copy link
Owner

lasa01 commented Mar 2, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants