Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

don't repeat meshes - use Linked Duplicates instead #43

Open
MinnieTheMoocher opened this issue Dec 28, 2013 · 12 comments
Open

don't repeat meshes - use Linked Duplicates instead #43

MinnieTheMoocher opened this issue Dec 28, 2013 · 12 comments

Comments

@MinnieTheMoocher
Copy link

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.

@JoshTheDerf
Copy link
Collaborator

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.

@le717
Copy link
Owner

le717 commented Dec 28, 2013

/cc @rioforce You know how this could work.

@MinnieTheMoocher
Copy link
Author

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

@JoshTheDerf
Copy link
Collaborator

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.

@rioforce
Copy link
Collaborator

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.

@le717 le717 mentioned this issue Dec 28, 2013
6 tasks
@le717
Copy link
Owner

le717 commented Dec 28, 2013

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.

@MinnieTheMoocher
Copy link
Author

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.

@rioforce
Copy link
Collaborator

I wasn't saying afterwards, I was saying while it imports.

  1. Script imports 2x4
  2. Script sees another 2x4 needs importing
  3. Script finds name of original imported 2x4 and selects 2x4 model
  4. Script Duplicates (or duplicates linked, depending on what it is told to do) 2x4
  5. Script moves 2x4 to proper location.

@MinnieTheMoocher
Copy link
Author

yep, exactly

This was referenced May 5, 2014
@le717 le717 modified the milestones: 1.2.5, 1.2.0 Jul 4, 2014
@le717 le717 mentioned this issue Jul 4, 2014
9 tasks
@rioforce
Copy link
Collaborator

Just adding a method that may work:

  1. Read entire file
  2. Find how many 2x4s need importing
  3. Import x number of 2x4s in proper locations

@MinnieTheMoocher
Copy link
Author

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.

@le717 le717 removed this from the 1.3.0 milestone Aug 7, 2015
@le717
Copy link
Owner

le717 commented Feb 29, 2016

Linking #71 as it contains info that can be used here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants