-
Notifications
You must be signed in to change notification settings - Fork 14
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
Refactoring mvr.py #203
Refactoring mvr.py #203
Conversation
I have also tested the speed, with the capture demo file. The current mvr import takes: INFO MVR scene loaded in 314.9368 sec. And loads 78 fixtures. The refactor takes: INFO MVR scene loaded in 372.4841 sec. But actually loads only 28 fixtures. So if all fixtures were loaded, it will be even a bit slower (This is fine). Testing file attached: Capture_MVR.zip |
I have been testing further: first import works (with the changes i mentioned in the comments). Then, if you re-import the same file again, what happens is that some geometries get duplicated, which should not happen. For that, i use the scene_objects.mvr from the pymvr repo, it loads fast and has good features for testing. |
I see, this indeed should not happen and I catched that issue in my test setup, I will try to fix this. |
@vanous I tried a plenty of methods to check for existing objects. It is no problem for all regular geometries but for symbols it is not easy because it can be the same object with a different transformation, I have no idea how to identify the object if it has the same filename and symdef but is linked to another scene object because the aux data has to be loaded first to have them available if symbols got imported |
Thank you. I would have to have a look how it was done before and dive deeper into the mvr code. I remember that for the Geometry3D i generate a hash to be unique based on name and transform here, so could we perhaps do something similar in this case? |
New method simply checks if mesh is already in current collection. Could be so easy
@nrgsille76 thank you for all the work! Ready to merge? |
existing_fixture.build( | ||
unique_name, | ||
f"{fixture.name} {layer_index}-{fixture_index}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we need to use the unique name, otherwise subsequent import of the same file will fail. This is because in BlenderDMX, the collection name is the fixture name, which is not ideal. In the future, fixture name will be independent of collection name.
dmx.addFixture( | ||
unique_name, | ||
f"{fixture.name} {layer_index}-{fixture_index}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - we need to use the unique name, otherwise subsequent import of the same file will fail. This is because in BlenderDMX, the collection name is the fixture name, which is not ideal. In the future, fixture name will be independent of collection name.
if len(layer_collection.all_objects) == 0: | ||
bpy.context.scene.collection.children.unlink(layer_collection) | ||
|
||
load_mvr(self, file_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to add the import configuration here in the future, this will make also testing much easier - import only fixtures, or import only some objects.
folder_path, extracted, layer_collection, fixture_group) | ||
|
||
if len(layer_collection.all_objects) == 0: | ||
layer_collect.children.unlink(layer_collection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to handle if the collection exists:, this works:
if len(layer_collection.all_objects) == 0:
if layer_collection.name in layer_collect.children:
layer_collect.children.unlink(layer_collection)
Thank you! |
Complete refactor of mvr.py including: