Open MinnieTheMoocher opened 10 years ago
Blender doesn't have such a feature, other than duplicating objects, afaik. Materials behave like this though, and should already be handled in such a fashion.
/cc @rioforce You know how this could work.
I think the feature exists and is called "Linked Duplicate" http://wiki.blender.org/index.php/Doc:2.4/Manual/Modeling/Objects/Duplication
This script seems to use it: https://sites.google.com/site/impiaaa/blenderldrawimporter
A linked duplicate is not necessarily a good option, supposing a user wants to directly modify or simulate parts of his/her model. It would be good for things like studs, but the linking would be restricted to per-part.
It is definitely possible in code, you'd just have to change the LDraw file parser to detect if a brick was imported by the name of the model, duplicate it (either Ctrl+D, which doesn't link, or Alt+D, which does link) and move it the the proper location. The problem is, you'd have to read the LDraw file to determine the location of the brick without having it import it again. This would save loading times and also make the script expandable.
We actually have two issues here: an option to reuse mesh and an option to link alike mesh. The former should happen and would speed everything up, but the latter would come later. As Tribex accurately said, this would be a part-by-part bases. Only alike bricks would be linked. A 2x2 brick would not be linked to,say, a 4x6 plate.
Here's the Blender 2.6 (instead of 2.4) documentation. http://wiki.blender.org/index.php/Doc:2.6/Manual/Modeling/Objects/Duplication
Moved to milestone v1.3, as linked mesh has been requested before.
i was just talking about not having multiple meshes of 2x4 bricks. instead, the 2x4 brick mesh should be present only once, and then the other instances of it in the model should refer to that mesh.
and i was not talking of the manual editing process later, but of the importing step.
there, each brick file should only be read once, and its mesh be established only once, and all other copies of it re-use that 1 mesh.
the implementation would be very simple as well: when importing a model, every part should be put in a dictionary. when you later encounter it again, you check if it is already in the dictionary. if yes, re-use that mesh. if no, load the mesh and put it into the dictionary. a simple, quite straightforward implementation, which will dramatically reduce scene complexity, importing time and memory usage.
I wasn't saying afterwards, I was saying while it imports.
yep, exactly
Just adding a method that may work:
No, that's IMHO a weird workaround implementation, and its implementation is as expensive (if not: more expensive) than the really desired one.
The desired one is very, very, very, very simple, as described in my post above 14 months ago.
Linking #71 as it contains info that can be used here.
Improvement suggestion:
As far as I can see, currently each and every single LDRAW file gets imported into a Blender scene without creating references.
For example, if a primitive 1-4cyli.dat is used, it is repeated in each and every instance as a separate mesh.
I think that Blender supports re-use of objects. I cannot really imagine that it does not.
My suggestion is to search for that feature and modify the loading script to not repeat and repeat and repeat each mesh, but instead only load it once, and then in all places where it is used, make a reference to that one instance, just applying transformation matrix, i.e., rotation and translation and coloring.
This should dramatically reduce the resulting blender scene size, rendering time, importing time etc.
I cannot really imagine that Blender does not have such a feature...
Also: the already loaded files should be cached inside the importing script. Currently it seems to me that a file like 1-4cyli.dat gets repeatedly parsed each time it is used. That's not necessary. It should get read just once, and its parsed contents saved in some python object. When the next occurrence of it is met, and it is already parsed, then the parsed version will be used. This should save a LOT of loading time.