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

Blender 2.80 compatibility #18

Closed
samipfjo opened this issue Dec 11, 2018 · 28 comments
Closed

Blender 2.80 compatibility #18

samipfjo opened this issue Dec 11, 2018 · 28 comments

Comments

@samipfjo
Copy link
Contributor

samipfjo commented Dec 11, 2018

The way that classes are registered has changed. Additionally, properties use type annotations now.

The class registration should be easy, and type annotations shouldn't be too bad, either. There will inevitably be other things that break.

Let's keep track of progress here.

@samipfjo
Copy link
Contributor Author

I think it would be wise to wait to port to 2.8 until it's out of beta. Unrelated errors present in the beta may make the port far more work than it would be with the stable release.

@arpu
Copy link

arpu commented Mar 21, 2019

what i read since the beta release, there would be no api changes

@arpu
Copy link

arpu commented Mar 21, 2019

@samipfjo
Copy link
Contributor Author

samipfjo commented Mar 21, 2019 via email

@friggog
Copy link
Owner

friggog commented Mar 23, 2019

I'd certainly encourage someone to work on 2.8 compatibility if they are keen as it will be needed in the long run, but totally agree that working on third party stuff for beta software is often a bit of a waste of time. This might a good thing for someone new to the project to work on as it requires less intimate knowledge of the plugin itself and more general blender API experience.|

The time I can contribute will probably be focussed on #20 as I think this is more important for artists to be able to use the plugin effectively and I'm best placed to do it. The features @luketimothyjones is working on are also more important and a better use of his time than 2.8 compatibility at the minute in my view.

@friggog
Copy link
Owner

friggog commented May 24, 2019

Pretty detailed info on conversion available here: https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API

Should be relatively straightforward as the complex code is pretty well decoupled from Blender and just uses the curve drawing stuff which doesn't seem to have changed. The main effort is in updating the UI to fit with new interface of 2.8 (may not be much to do?) and some of the utilities which do object selection/work with meshes.

@Oxervision
Copy link
Contributor

Hi, Blender 2.80 is near to realease, are there news about updating the addon to 2.80?
Thanks in advance!!

@friggog
Copy link
Owner

friggog commented Jul 4, 2019

Yeah I think it's probably a reasonable time to look at 2.8 compatibility, the built in sapling add-on might provide a basis as to how the UI should work with the redesigned interface. There is probably some significant refactoring required to achieve this, along with the other standard changes from 2.79 to 2.8.

I don't have time to work on this now - any contributors welcome!

@Oxervision
Copy link
Contributor

Oxervision commented Jul 5, 2019

Hi again,
I got that the addon to appear in UI (with all options visible) and that the addon mades the tree object but I obtain some errors and the complete tree is not finished, it stops in the process, these are the errors in console:

** Generating Tree **

Using seed: 3420778

Making Stems
-> 0 stems made
Traceback (most recent call last):
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/gui.py", line 230, in _construct
    parametric.gen.construct(params, scene.seed_input, scene.generate_leaves_input)
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/parametric/gen.py", line 1245, in construct
    t.make()
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/parametric/gen.py", line 180, in make
    self.create_branches()
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/parametric/gen.py", line 257, in create_branches
    self.make_stem(turtle, Stem(0, trunk))
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/parametric/gen.py", line 524, in make_stem
    stem.curve.bezier_points.add()
TypeError: SplineBezierPoints.add(): required parameter "count" not specified

Tree generation failed

I do not know the Python code, I did an Internet search to change some lines in the addon files, mainly in the 2.80 API changes, but at this point I'm lost, maybe you have a little time to solve these problems.

TreeGen 2 80

Here TreeGen modified to 2.80

ch_trees 2.80.zip

@samipfjo
Copy link
Contributor Author

samipfjo commented Jul 5, 2019 via email

@friggog
Copy link
Owner

friggog commented Jul 5, 2019

Yeah awesome work on getting the plugin working as much as you have @Oxervision! The normal workflow would be for you to fork this repo and create a branch for your changes which you can then submit as a PR to a branch in the main repo. This also makes it easier for other to comment on your code as it will be visible to everyone (others can also commit directly to your PR to fix things).

I've just created a branch to hold the 2.8 version (I think it's worth retaining the 2.7 version in master for now). If you can do PR to this with your changes that would be amazing!

@Oxervision
Copy link
Contributor

Oxervision commented Jul 5, 2019

Excuse for my ignorance (I'm new in Python and the process in the GitHub)
What is PR? Can you give me a little explanation about the process to update the addon in GitHub with my changes?

I made some new changes to the addon and the creation of trees work now!!
In some trees like Willow, the creation process is very slow or sometimes Blender crash perhaps it's to the memory of my computer (iMac mid 2011).

Issues to fix:

1. UV Textures Leafs

Making Leaves
-> 4500 leaves made, 0 blossoms made
Traceback (most recent call last):
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/gui.py", line 230, in _construct
    parametric.gen.construct(params, scene.seed_input, scene.generate_leaves_input)
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/parametric/gen.py", line 1245, in construct
    t.make()
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/parametric/gen.py", line 184, in make
    self.create_leaf_mesh()
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/parametric/gen.py", line 324, in create_leaf_mesh
    leaves.uv_textures.new("leavesUV")
AttributeError: 'Mesh' object has no attribute 'uv_textures'

2. Render Tree
If the camera name in the scene is different to camera, in my case "Cámara" (I'm a spanish user), and you press Render Tree button, it appers this error:

Rendering Scene
Could not find camera to capture with

If you change the camera name to "Camera" and press Render Tree button, it appears this error:

Rendering Scene
Traceback (most recent call last):
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/gui.py", line 293, in execute
    utilities.render_tree(context.scene.render_output_path_input)
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/utilities.py", line 300, in render_tree
    vec_rot = vec * inv  # vec aligned to local axis
TypeError: Element-wise multiplication: not supported between 'Vector' and 'Matrix' types

3. Creation LOD

Creating LODs. Blender will appear to crash; be patient.

Traceback (most recent call last):
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/gui.py", line 343, in execute
    utilities.generate_lods(context, 3)
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/utilities.py", line 151, in generate_lods
    temp_mesh = new_curve.to_mesh(bpy.context.view_layer, settings='RENDER', apply_modifiers=False)
TypeError: Object.to_mesh(): takes at most 2 arguments, got 3

LOD creation failed

4. Convert to Mesh:

Converting tree to mesh. Blender will appear to crash; be patient.

Traceback (most recent call last):
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/gui.py", line 315, in execute
    utilities.convert_to_mesh(context)
  File "/Users/Oxer/Library/Application Support/Blender/2.80/scripts/addons/ch_trees/utilities.py", line 87, in convert_to_mesh
    old_branch_mesh = old_branches.to_mesh(scene, False, 'RENDER')
TypeError: Object.to_mesh(): takes at most 2 arguments, got 3

Conversion to mesh failed

I'll continue testing the settings to see posibble issues.

Trees in 2 80

Addon modified to 2.80 with Tree creation working:
ch_trees.zip

@samipfjo
Copy link
Contributor Author

samipfjo commented Jul 5, 2019 via email

@Oxervision
Copy link
Contributor

Ok, I'm in this point:
1. I installed GitHub Desktop Mac.
2. I forked tree-gen repo.

Repo Forked

3. I cloned the repo to my computer.
4. I changed the files with the new API

Files changed

What's the the next step?
Or I did something wrong

@samipfjo
Copy link
Contributor Author

samipfjo commented Jul 5, 2019 via email

@samipfjo
Copy link
Contributor Author

samipfjo commented Jul 5, 2019

Whoops, hold on, there's an existing pull request

@Oxervision
Copy link
Contributor

Ok, Thanks for the info!!
I'll do it and I'll inform you in a moment

@Oxervision
Copy link
Contributor

Oxervision commented Jul 5, 2019

I did the pull request, should not I have done it?

@samipfjo
Copy link
Contributor Author

samipfjo commented Jul 5, 2019

Alright, in your GitHub app press "Push" on the right-hand side at the top. That will upload your changes to GitHub. I left out a vital step (setting the target branch) but we'll deal with that later.

@Oxervision
Copy link
Contributor

Done, the files were updated in my forked Oxervision/tree-generator repo.
Thanks you very much for your help!!

@samipfjo
Copy link
Contributor Author

samipfjo commented Jul 5, 2019

Don't worry about it, my fault. A classic example that I should never use Git before my morning coffee.

Wonderful! I'll review your changes and will get started fixing the more vital bugs sometime today.

@Oxervision
Copy link
Contributor

:) I don't like the coffee, I usually drink cocoa with milk in my breasfast, but here in Spain It's snack time, 19:26 PM.

@samipfjo
Copy link
Contributor Author

samipfjo commented Jul 5, 2019

Ah, cocoa with milk sounds like a lovely way to start the day!

I am a hopeless caffeine addict unfortunately, so I am pretty groggy until I have had my coffee. With that said, over here in America we are (generally speaking) fairly uncreative when it comes to morning beverages. Coffee, orange juice, milk, and/or tea are what the majority of Americans drink in the morning.

@friggog
Copy link
Owner

friggog commented Jul 16, 2019

Enjoyed the wholesome exchange above ;)

Have merged #33 with the initial work from @Oxervision (thanks!), it sounds as though there is still a significant number of fixes that need to be made as a result of the blender API changes relating to mesh and curve operations.

Are you planning to work on this @luketimothyjones? I think it should be fairly easy and am happy to take a look, though it will probably be a while before I can find the time too.

Issues:

  • Leaf uv textures API change
  • Render tree operation failure due to camera ref issue
  • Convert to mesh failure due to mesh API change
  • LOD creation failure due to mesh API change
  • Possible mesh memory leaks
  • Select tree properly after generation
  • Segfault when generating tree, not every time, usually within 2 or 3 runs

@samipfjo
Copy link
Contributor Author

I would very much like to do so, but have recently returned to college (uni) to finish my degree, so my time has yet again become a scarce commodity. This unfortunately means that I'm in a similar situation as you; I would love to, but it will be a while before I can. I might be able to sneak some work in here and there, but that's a generous use of "might" in the immediate future.

@friggog
Copy link
Owner

friggog commented Jul 17, 2019

Ok no worries, good luck with uni! I’ll hopefully have some spare time in a few weeks - if you do do anything make sure to do a PR (even if incomplete) so I can easily work on top of your changes

@friggog
Copy link
Owner

friggog commented Jul 18, 2019

Had an hour train ride this morning so started fixing things: da3e18f.
Rendering and convert to mesh nominally work, though there is possibly a leak with the mesh conversion. LOD creation still fails but should be mostly fixed.

Some of these changes should be propagated to the 2.79 version (e.g. correct camera selection and the way objects are accessed possibly).

One big issue I'm having is a fairly regular segfault when generating trees - can't see any obvious reason and debugging isn't as straightforward as most of the other issues.

Also when generating a tree the operators should work straight away, at the minute you need to manually select the tree. We just need to make sure the generated tree is selected properly at the end of generation.

@friggog
Copy link
Owner

friggog commented Jul 31, 2019

ebda1d6 should fix the utilities (I think). I was having some weird bug hiding the LODs which I think might just be because I had an out of date build - currently downloading the release version to test (taking ages because the blender site is wrecked).

Still getting segfaults (will see what happens on the release build)

@friggog friggog mentioned this issue Jul 31, 2019
3 tasks
@friggog friggog closed this as completed Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants